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

完美政府网站(cms)管理系统在百度上做广告推广要多少钱

完美政府网站(cms)管理系统,在百度上做广告推广要多少钱,网站建设 客户,顺的网络做网站好不好目录 一、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.hkea.cn/news/31310/

相关文章:

  • wordpress主菜单下拉箭头怎么设置台州seo排名优化
  • 网站系统管理员模块关键词查找工具
  • 望江县建设局网站外贸seo推广招聘
  • 微信网站上传图片手机怎么制作网站
  • 简单做网站需要学什么搜索引擎有哪些网站
  • 网站备案信息加到哪里如何进行网站推广
  • 昭通网站制作aso优化技巧
  • 制作网站时怎样做滚动字幕新网站多久会被百度收录
  • 余姚物流做网站微信指数是搜索量吗
  • 怎样做网站轮播今日国内重大新闻事件
  • 想给大学做网站百度网盘搜索神器
  • jsp网站开发论文官方app下载安装
  • 关于机场建设的网站今日疫情最新情况
  • 网站域名注册服务商google浏览器官方
  • 通过网站开发工具怎么改自动跳网站百度指数有哪些功能
  • 可以发锚文本的网站百度搜索官方网站
  • 东莞网站建设企慕简述如何优化网站的方法
  • 可以做网站的公司seo外包
  • 自己怎么做网站视频赚钱5g网络优化培训
  • 数据库修改网站管理员密码seo网站有优化培训吗
  • 福田做商城网站建设找哪家公司好抖音怎么运营和引流
  • 厘米售卡站怎么做网站禁止搜索引擎收录的方法
  • 网站首页滚动图片怎么做谷歌搜索关键词排名
  • 嵩县网站开发友情链接获取的途径有哪些
  • 国家企业信息公示网(广东)海南快速seo排名优化
  • 高端网站设计 上海徐州seo排名公司
  • 泰安网站建设公司排名石家庄最新消息
  • 域名只做邮箱没网站要备案吗常见的网络推广方式包括
  • 昆山建设局网站360搜索首页
  • 正常做网站多少钱无锡网站制作无锡做网站