当前位置: 首页 > news >正文

域名和主机搭建好了怎么做网站seo博客推广

域名和主机搭建好了怎么做网站,seo博客推广,最新的国外新闻10条,营口做网站多少钱目录 一、tkinter的介绍 二、登陆界面的设计 1、登陆界面完整代码 2、部分代码讲解 3、登录的数据模型设计 4、效果展示 三、学生主界面菜单设计 1、学生主界面菜单设计完整代码 2、 部分代码讲解 3、效果展示 四、数据库的模型设计 欢迎大家进来学习和支持&#xff01…

目录

一、tkinter的介绍

二、登陆界面的设计

1、登陆界面完整代码

2、部分代码讲解

3、登录的数据模型设计

 4、效果展示

三、学生主界面菜单设计

 1、学生主界面菜单设计完整代码

2、 部分代码讲解

 3、效果展示

四、数据库的模型设计


 

欢迎大家进来学习和支持!!!

今天主要带来的是使用tkinter来制作一期学生信息管理系统

一、tkinter的介绍

tkinter就是python语言里面用来制作一个GUI界面的一个包,这里长话短说,不做过多的言语上的阐述,想了解更多可以点击下面的链接

tkinter官网教程

二、登陆界面的设计

我们开始编写代码的之前,我们的自己先了解一些关于tkinter中的一些组件的使用和方法 

1、登陆界面完整代码

"""
Ryan 2024.7.28
登陆页面的制作
"""
import tkinter as tk
from tkinter import messagebox
from db import db
from mainPage import mainPageclass loginFarme(object):def __init__(self, window):self.window = windowself.window.geometry("300x180")self.window.title("登录界面")# 创建变量对象self.username = tk.StringVar()self.password = tk.StringVar()# 用于后面进行页面换页用的self.page = tk.Frame(window)self.page.pack()# 再page里面布局tk.Label(self.page).grid(row=0, column=0)tk.Label(self.page, text="账户:", font=28).grid(row=1, column=1)# textvariable:文本变量tk.Entry(self.page, textvariable=self.username).grid(row=1, column=2)tk.Label(self.page, text="密码:", font=28).grid(row=3, column=1, pady=10)tk.Entry(self.page, textvariable=self.password).grid(row=3, column=2)tk.Button(self.page, text="登录", font=28, command=self.login).grid(row=5, column=1, pady=10)tk.Button(self.page, text="退出", font=28, command=self.page.quit).grid(row=5, column=2)# 登录功能def login(self):name = self.username.get()pwd = self.password.get()flag, message = db.checkLogin(name, pwd)if flag:# 销毁第一页self.page.destroy()# 重新给页面添加内容mainPage(self.window)else:messagebox.showwarning(title="警告", message=message)if __name__ == '__main__':window = tk.Tk()loginFarme(window)window.mainloop()

2、部分代码讲解

对于loginFarme类的讲解:

        这个属于类的初始化函数部分,给登录界面创建界面组件用 

    def __init__(self, window):self.window = windowself.window.geometry("300x180")self.window.title("登录界面")# 创建变量对象self.username = tk.StringVar()self.password = tk.StringVar()# 用于后面进行页面换页用的self.page = tk.Frame(window)self.page.pack()# 再page里面布局tk.Label(self.page).grid(row=0, column=0)tk.Label(self.page, text="账户:", font=28).grid(row=1, column=1)# textvariable:文本变量tk.Entry(self.page, textvariable=self.username).grid(row=1, column=2)tk.Label(self.page, text="密码:", font=28).grid(row=3, column=1, pady=10)tk.Entry(self.page, textvariable=self.password).grid(row=3, column=2)tk.Button(self.page, text="登录", font=28, command=self.login).grid(row=5, column=1, pady=10)tk.Button(self.page, text="退出", font=28, command=self.page.quit).grid(row=5, column=2)

         这一部分是为了实现登陆的功能和警告信息,这里面调用了db这个类对象checkLogin方法,是为了检查账户密码的正确性,这个类对象会在后面定义,这里的mainPage方法是调用了mainPage.py文件里的方法,为了登录成功后进入到学生管理系统主界面

 # 登录功能def login(self):name = self.username.get()pwd = self.password.get()flag, message = db.checkLogin(name, pwd)if flag:# 销毁第一页self.page.destroy()# 重新给页面添加内容mainPage(self.window)else:messagebox.showwarning(title="警告", message=message)

         这个代码块想必大家都很熟悉,这个代码块主要是为了检查该程序是否能够在这个文件里运行,这里的tk.Tk()和mainloop()方法是打开窗口界面和循环显示窗口界面的功能

if __name__ == '__main__':window = tk.Tk()loginFarme(window)window.mainloop()

3、登录的数据模型设计

        这里是主要封装了一个对于登录信息的检查,这里没有用到数据库,而是自己创建了一个json的数据模型来代替,这个就是上面所说到的checkLogin()方法的定义代码 

"""
Ryan 2024.7.28
建立登录的数据模型
"""
import jsonclass mySqlDatabases(object):def __init__(self):with open('student.json', mode='r', encoding='utf-8') as f:text = f.read()self.students = json.loads(text)f.close()def checkLogin(self, username, password):for student in self.students:if username == student['username']:if password == student['password']:return True, '登陆成功'else:return False, '登陆失败,密码不存在'return False, '登陆失败,用户名不存在'# 实例化类对象
db = mySqlDatabases()
if __name__ == '__main__':print(db.checkLogin('admin', '123456'))

 4、效果展示

三、学生主界面菜单设计

接下来我们设计好登录界面后,就是进入到学生的主界面设计 

 1、学生主界面菜单设计完整代码

"""
Ryan 2024.7.28
学生页面的制作
"""
import tkinter as tkclass mainPage(object):# window:tk.Tk只作为一个提示是TK对象,写完这个就可以显示方法提示def __init__(self, window: tk.Tk):self.window = windowself.window.geometry('600x400')self.window.title('学生管理系统 V0.0.1')self.createPage()def createMenu(self):self.aboutFrame = tk.Frame(self.window)tk.Label(self.aboutFrame, text='关于作品:本作品是tkinter制作的').pack()tk.Label(self.aboutFrame, text='关于作者:Ryan').pack()tk.Label(self.aboutFrame, text='版权所有:Ryan').pack()self.changeFrame = tk.Frame(self.window)tk.Label(self.changeFrame, text='修改页面').pack()self.deleteFrame = tk.Frame(self.window)tk.Label(self.deleteFrame, text='删除页面').pack()self.searchFrame = tk.Frame(self.window)tk.Label(self.searchFrame, text='搜索页面').pack()self.insertFrame = tk.Frame(self.window)tk.Label(self.insertFrame, text='录入页面').pack()def createPage(self):self.createMenu()menuBar = tk.Menu(self.window)menuBar.add_command(label='录入', command=self.showInsert)menuBar.add_command(label='查询', command=self.showSearch)menuBar.add_command(label='删除', command=self.showDelete)menuBar.add_command(label='修改', command=self.showChange)menuBar.add_command(label='关于', command=self.showAbout)# 将menuBar添加窗口中self.window['menu'] = menuBardef showAbout(self):self.changeFrame.pack_forget()self.deleteFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack_forget()self.aboutFrame.pack()def showChange(self):self.aboutFrame.pack_forget()self.deleteFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack_forget()self.changeFrame.pack()def showDelete(self):self.aboutFrame.pack_forget()self.changeFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack_forget()self.deleteFrame.pack()def showSearch(self):self.aboutFrame.pack_forget()self.changeFrame.pack_forget()self.deleteFrame.pack_forget()self.insertFrame.pack_forget()self.searchFrame.pack()def showInsert(self):self.aboutFrame.pack_forget()self.changeFrame.pack_forget()self.deleteFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack()if __name__ == '__main__':window = tk.Tk()mainPage(window)window.mainloop()

2、 部分代码讲解

 以下主要是针对mainPage类的讲解:

        这里面的createPage函数是添加界面中的菜单按钮,command是当按钮被点击的时候会触发的事件

    def createPage(self):self.createMenu()menuBar = tk.Menu(self.window)menuBar.add_command(label='录入', command=self.showInsert)menuBar.add_command(label='查询', command=self.showSearch)menuBar.add_command(label='删除', command=self.showDelete)menuBar.add_command(label='修改', command=self.showChange)menuBar.add_command(label='关于', command=self.showAbout)# 将menuBar添加窗口中self.window['menu'] = menuBar

        以下是菜单被点击的时候所触发的函数方法 ,这里面的pack_forget方法是为了清除界面添加的内容,防止内容会一直保留到界面当中

    def showAbout(self):self.changeFrame.pack_forget()self.deleteFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack_forget()self.aboutFrame.pack()def showChange(self):self.aboutFrame.pack_forget()self.deleteFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack_forget()self.changeFrame.pack()def showDelete(self):self.aboutFrame.pack_forget()self.changeFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack_forget()self.deleteFrame.pack()def showSearch(self):self.aboutFrame.pack_forget()self.changeFrame.pack_forget()self.deleteFrame.pack_forget()self.insertFrame.pack_forget()self.searchFrame.pack()def showInsert(self):self.aboutFrame.pack_forget()self.changeFrame.pack_forget()self.deleteFrame.pack_forget()self.searchFrame.pack_forget()self.insertFrame.pack()

 3、效果展示

当你点击下面不同菜单的时候,会进入到不同的页面 

 

四、数据库的模型设计

采用json格式去设计数据模块,后期会用上数据库的连结 

[{"username": "admin","password": "123456"},{"username": "Ryan","password": "123456"}
]

 今天的分享就是这样了,下次带来关于学生信息管理系统的进一步页面设计。

 

 

 

 

http://www.zhongyajixie.com/news/7212.html

相关文章:

  • 扬中人才市场最新招聘网站优化查询
  • 如何建立网站视频安徽网站设计
  • 网站建设营销话术谷歌站长平台
  • 响应式 网站建设厦门网络营销推广
  • 物联网 网站开发关键词热度分析
  • 网站排名优化+o+m关键词推广优化排名如何
  • 在香港做网站需要什么软件西安官网seo
  • 山东网站建设谷歌关键词排名查询
  • 家用电脑做网站网页制作在线生成
  • 环保企业的网站怎么做百度官网认证多少钱一年
  • b2b网站一个人可以做吗江西百度推广公司
  • 想学电商运营在哪里学关键词优化靠谱推荐
  • 网站架构优化网站广告接入
  • 做网站送给女友意义上海网络seo公司
  • 在线建站宣传网站有哪些
  • 怎么建php网站seo快速提升排名
  • 精神文明建设专题网站怎么做盲盒
  • 商城网站源码下载网络培训学校
  • 怎么注册企业邮箱号seo网站建设是什么意思
  • 温州建站平台泸州网站优化推广
  • 嘉兴网站建设一薇提高工作效率的句子
  • 西宁网络公司网站建设代运营公司是怎么运营的
  • 福建省漳州市政府网站建设情况黑科技推广软件
  • 美食电子商务网站建设规划书seo教程技术资源
  • wordpress多用户多界面百度广告优化师
  • 衡水做企业网站网页推广平台
  • 济南专门做公司网站的公司百度关键词搜索排行榜
  • 武威 网站开发百度推广总部电话
  • 中华人民住房和城乡建设部网站长沙靠谱seo优化
  • 做哪个网站的直播好汨罗网站seo