当前位置:   article > 正文

python+mysql实现gui增删改管理系统_pysimplegui table 增删改查

pysimplegui table 增删改查

 

main.py

  1. """
  2. __author__ = 'bearcarl'
  3. __version__ = '1.0'
  4. from tkinter import *
  5. from tkinter import ttk
  6. from tkinter import messagebox # 导入提示窗口包
  7. from connect_mysql import Mysql_conn
  8. from dLink import DouLink, Node
  9. # 设置窗口大小
  10. def center_window(root, width, height):
  11. screenwidth = root.winfo_screenwidth()
  12. screenheight = root.winfo_screenheight()
  13. size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
  14. root.geometry(size)
  15. class GUI:
  16. """给每个组件都命名是为了以后迭代方便"""
  17. def __init__(self, root):
  18. # 创建双向链表
  19. self.dl = DouLink()
  20. root.title('信息管理系统')
  21. # 设置窗口大小
  22. center_window(root, 800, 600)
  23. root.maxsize(1200, 800)
  24. root.minsize(300, 240)
  25. # root.iconbitmap('1.ico')
  26. # delete_event
  27. search_label = ttk.Label(root, text='删除教师编号').grid(row=0, column=4)
  28. dl_entry1 = ttk.Entry(root)
  29. dl_entry1.grid(row=0, column=5)
  30. button1 = ttk.Button(root, text='删除', command=lambda: delete_event(dl_entry1.get())).grid(row=0,
  31. column=6)
  32. search_label = ttk.Label(root, text='教师编号').grid(row=0, column=1)
  33. search_entry1 = ttk.Entry(root)
  34. search_entry1.grid(row=0, column=2)
  35. button1 = ttk.Button(root, text='查询', command=lambda: search_event(1, search_entry1.get())).grid(row=0,
  36. column=3)
  37. search_labe2 = ttk.Label(root, text='教师姓名').grid(row=1, column=1)
  38. search_entry2 = ttk.Entry(root)
  39. search_entry2.grid(row=1, column=2)
  40. button2 = ttk.Button(root, text='查询', command=lambda: search_event(2, search_entry2.get())).grid(row=1,
  41. column=3)
  42. search_labe3 = ttk.Label(root, text='出生年月').grid(row=2, column=1)
  43. search_entry3 = ttk.Entry(root)
  44. search_entry3.grid(row=2, column=2)
  45. button3 = ttk.Button(root, text='查询', command=lambda: search_event(3, search_entry3.get())).grid(row=2,
  46. column=3)
  47. search_labe4 = ttk.Label(root, text='工资').grid(row=3, column=1)
  48. search_entry4 = ttk.Entry(root)
  49. search_entry4.grid(row=3, column=2)
  50. button4 = ttk.Button(root, text='查询', command=lambda: search_event(4, search_entry4.get())).grid(row=3,
  51. column=3)
  52. search_labe5 = ttk.Label(root, text='参加工作时间').grid(row=4, column=1)
  53. search_entry5 = ttk.Entry(root)
  54. search_entry5.grid(row=4, column=2)
  55. button5 = ttk.Button(root, text='查询', command=lambda: search_event(5, search_entry5.get())).grid(row=4,
  56. column=3)
  57. add_button = ttk.Button(root, text='添加', command=lambda: addwindow_event()).grid(row=0, column=0)
  58. updata_button = ttk.Button(root, text='更新信息', command=lambda: upadatawindow_event()).grid(row=1, column=0)
  59. all_button = ttk.Button(root, text='查询全部', command=lambda: reload()).grid(row=2, column=0)
  60. # 信息提示框
  61. info_label = ttk.Label(root, text="信息展示窗口", background='#66ccff', width=100, anchor='center') \
  62. .grid(row=7, column=0, columnspan=8)
  63. # 信息展示
  64. Listbox(root, height=8, width=110).grid(row=8, column=0, columnspan=10)
  65. # 选择函数, 直接用SQL进行排序
  66. def sort_event(n):
  67. # 连接数据库
  68. conn_1 = Mysql_conn()
  69. if n == 1:
  70. # 构造查询SQL
  71. sw = 'SELECT * FROM STUDENT ORDER BY ID'
  72. stu_info = conn_1.select(sw)
  73. show_listbox = Listbox(root, height=8, width=110)
  74. for row in stu_info:
  75. show_listbox.insert(END, row)
  76. show_listbox.grid(row=8, column=0, columnspan=10)
  77. messagebox.showinfo("排序", "
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/955551?site
推荐阅读
相关标签
  

闽ICP备14008679号