鱼C论坛

 找回密码
 立即注册
查看: 1280|回复: 4

[已解决]tkinter的一个问题

[复制链接]
发表于 2020-9-5 18:06:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
这是一个学生管理系统的小程序。目前还未完成,碰壁了。。。
  1. from tkinter import *
  2. from tkinter import Tk,messagebox,Toplevel
  3. from tkinter.ttk import Combobox
  4. import openpyxl


  5. root= Tk()
  6. root.title('登录界面')
  7. root.geometry('300x200')
  8. root.resizable(width=False,height=False)
  9. #账号输入框
  10. user_name = Label(root,text='账号>>>',font=('Heiti',12))
  11. user_name.place(x=8, y=30)
  12. user_name_text = StringVar()
  13. user_name_entry = Entry(root,textvariable=user_name_text,font=('Heiti',12),width=20)
  14. user_name_entry.place(x=60,y=30)
  15. # 密码输入框
  16. user_pwd = Label(root,text='密码>>>',font=('Heiti',12))
  17. user_pwd.place(x=8,y=60)
  18. user_pwd_text =  StringVar()
  19. user_pwd_entry = Entry(root,textvariable=user_pwd_text,font=('Heiti',12),width=20)
  20. user_pwd_entry.place(x=60,y=60)

  21. def data():
  22.     with open('./data.txt','r',encoding='utf-8') as f:
  23.         user_list = f.readlines()
  24.         user_dict = {}
  25.         for each_user in user_list:
  26.             user = each_user.strip().split(':')[0]
  27.             pwd = each_user.strip().split(':')[1]
  28.             user_dict[user]=pwd
  29.         return user_dict

  30. def get_input():
  31.     user_input = user_name_text.get()
  32.     pwd_input = user_pwd_text.get()
  33.     user_dict = data()
  34.     if user_input != '' and pwd_input != '':
  35.         if user_input in user_dict.keys():
  36.             if pwd_input == user_dict[user_input]:
  37.                 messagebox.showinfo(title='ok',message='欢迎回来  ' + user_input)
  38.                 root.destroy()
  39.             else:
  40.                 messagebox.showwarning(title='error',message='密码错误')
  41.         else:
  42.             messagebox.showerror(title='error',message='空用户,不存在')
  43.     else:
  44.         messagebox.showerror(title='error',message='账号,密码不能为空')
  45.         # print('不能为空')

  46. def pop_win():
  47.     top = Toplevel()
  48.     top.title('注册')
  49.     top.geometry('300x200')
  50.     top.resizable(width=False,height=False)

  51.     Label(top,text='账号>>>').grid(row=1, column=2)
  52.     new_name = StringVar()
  53.     Entry(top,text=new_name).grid(row=1,column=4)

  54.     Label(top,text='密码>>>').grid(row=3,column=2)
  55.     new_pwd = StringVar()
  56.     Entry(top,text=new_pwd).grid(row=3,column=4)

  57.     Label(top, text='确认密码>>>').grid(row=5, column=2)
  58.     new_check = StringVar()
  59.     Entry(top, text=new_check).grid(row=5, column=4)

  60.     def check_pwd():
  61.         use_1 = new_name.get()
  62.         pwd_1 = new_pwd.get()
  63.         pwd_2 = new_check.get()
  64.         if use_1 == '' or pwd_1 == '' or pwd_2 == '' :
  65.             messagebox.showerror(title='error', message='Not null')
  66.         else:
  67.             if pwd_1 == pwd_2:
  68.                 with open('./data.txt','a',encoding='utf-8') as fp:
  69.                     fp.writelines('\n' + use_1 +':'+ pwd_1)
  70.                     fp.flush()
  71.                 messagebox.showinfo(title='ok', message='注册成功')
  72.                 top.destroy()
  73.             else:
  74.                 messagebox.showerror(title='error',message='两次密码不一致')

  75.     button_3 = Button(top,text='提交',width=15,command=check_pwd).grid(row=9,column=4)

  76. def save_stu():
  77.     wb = openpyxl.Workbook()
  78.     sheet = wb.active
  79.     sheet['A1'] = '姓名'
  80.     sheet['B1'] = '电话'
  81.     sheet['C1'] = '性别'
  82.     sheet['D1'] = '省份'
  83.     sheet['E1'] = '爱好1'
  84.     sheet['F1'] = '爱好2'

  85.     wb.save('./学生信息.xlsx')

  86. def add_sutdent():
  87.     new_root = Tk()
  88.     new_root.title('学生注册')
  89.     new_root.geometry('300x300')

  90.     new_stu = Label(new_root, text='姓名>>>', font=('Heiti', 12)).grid(row=1, column=1)
  91.     stu = StringVar()
  92.     new_stu_entry = Entry(new_root, textvariable=stu, width=20).grid(row=1, column=2)

  93.     new_pho = Label(new_root, text='电话>>>', font=('Heiti', 12)).grid(row=2, column=1)
  94.     pho = StringVar()
  95.     new_pho_entry = Entry(new_root, textvariable=pho, font=('Heiti', 12), width=20).grid(row=2, column=2)

  96.     new_sex_choice = Label(new_root, text='性别>>>', font=('Heiti', 12)).grid(row=3, column=1)
  97.     sex = StringVar()
  98.     Radiobutton(new_root, text='male', variable=sex, value='male').grid(row=3, column=2, sticky='w')
  99.     Radiobutton(new_root, text='female', variable=sex, value='female').grid(row=3, column=2, sticky='e')

  100.     new_hob_choice = Label(new_root, text='爱好>>>', font=('Heiti', 12)).grid(row=4, column=1)
  101.     hob_1 = IntVar()
  102.     hob_2 = IntVar()
  103.     Checkbutton(new_root, text='唱', variable=hob_1, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='w')
  104.     Checkbutton(new_root, text='跳', variable=hob_2, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='e')

  105.     new_pov_choice = Label(new_root, text='省份>>>', font=('Heiti', 12)).grid(row=5, column=1)
  106.     pros = ['北京', '上海', '广州', '深圳']
  107.     pro = StringVar()
  108.     pro_choice = Combobox(new_root, textvariable=pro, width=15, values=pros, state='readonly').grid(row=5, column=2)

  109.     def get_stu_info():
  110.         stu_name = stu.get()
  111.         stu_pho = pho.get()
  112.         stu_sex = sex.get()
  113.         stu_pro = pro.get()
  114.         stu_like1 = hob_1.get()
  115.         stu_like2 = hob_2.get()
  116.         print(stu_name, stu_pho, stu_sex, stu_pro, stu_like1, stu_like2)

  117.     button_4 = Button(new_root, text='提交', width=12, command=get_stu_info).grid(row=6, columnspan=3, pady=20)

  118. #菜单栏
  119. menu_bar = Menu(root)
  120. stu_men = Menu(menu_bar)
  121. #添加选项
  122. stu_men.add_command(label='注册',command=add_sutdent)
  123. stu_men.add_command(label='查询',command='')
  124. #将菜单添加到菜单栏中
  125. menu_bar.add_cascade(label='学生',menu=stu_men)
  126. # 配置菜单栏
  127. root.config(menu=menu_bar)

  128. score_menu = Menu(menu_bar)
  129. score_menu.add_command(label='添加',command='')
  130. score_menu.add_command(label='查询',command='')
  131. menu_bar.add_cascade(label='成绩',menu=score_menu)
  132. root.config(menu=menu_bar)

  133. button_1 = Button(root,text='Login in',font=('Heiti',12),width=8,command=get_input).place(x=40,y=100)

  134. button_2 = Button(root,text='注册',font=('Heiti',12),width=8,command=pop_win).place(x=160,y=100)

  135. root.mainloop()
  136. # new_root.mainloop()
复制代码


问题出在这个函数
  1. def add_sutdent():
  2.     new_root = Tk()
  3.     new_root.title('学生注册')
  4.     new_root.geometry('300x300')

  5.     new_stu = Label(new_root, text='姓名>>>', font=('Heiti', 12)).grid(row=1, column=1)
  6.     stu = StringVar()
  7.     new_stu_entry = Entry(new_root, textvariable=stu, width=20).grid(row=1, column=2)

  8.     new_pho = Label(new_root, text='电话>>>', font=('Heiti', 12)).grid(row=2, column=1)
  9.     pho = StringVar()
  10.     new_pho_entry = Entry(new_root, textvariable=pho, font=('Heiti', 12), width=20).grid(row=2, column=2)

  11.     new_sex_choice = Label(new_root, text='性别>>>', font=('Heiti', 12)).grid(row=3, column=1)
  12.     sex = StringVar()
  13.     Radiobutton(new_root, text='male', variable=sex, value='male').grid(row=3, column=2, sticky='w')
  14.     Radiobutton(new_root, text='female', variable=sex, value='female').grid(row=3, column=2, sticky='e')

  15.     new_hob_choice = Label(new_root, text='爱好>>>', font=('Heiti', 12)).grid(row=4, column=1)
  16.     hob_1 = IntVar()
  17.     hob_2 = IntVar()
  18.     Checkbutton(new_root, text='唱', variable=hob_1, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='w')
  19.     Checkbutton(new_root, text='跳', variable=hob_2, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='e')

  20.     new_pov_choice = Label(new_root, text='省份>>>', font=('Heiti', 12)).grid(row=5, column=1)
  21.     pros = ['北京', '上海', '广州', '深圳']
  22.     pro = StringVar()
  23.     pro_choice = Combobox(new_root, textvariable=pro, width=15, values=pros, state='readonly').grid(row=5, column=2)

  24.     def get_stu_info():
  25.         stu_name = stu.get()
  26.         stu_pho = pho.get()
  27.         stu_sex = sex.get()
  28.         stu_pro = pro.get()
  29.         stu_like1 = hob_1.get()
  30.         stu_like2 = hob_2.get()
  31.         print(stu_name, stu_pho, stu_sex, stu_pro, stu_like1, stu_like2)

  32.     button_4 = Button(new_root, text='提交', width=12, command=get_stu_info).grid(row=6, columnspan=3, pady=20)
复制代码


在项目里返回的总是两个0,但是把这个函数单独拿出来就有正常的返回值了,这是为什么呢?
最佳答案
2020-9-6 22:52:36

这样试试看:

  1. from tkinter import *
  2. from tkinter import Tk,messagebox,Toplevel
  3. from tkinter.ttk import Combobox
  4. import openpyxl


  5. root= Tk()
  6. root.title('登录界面')
  7. root.geometry('300x200')
  8. root.resizable(width=False,height=False)
  9. #账号输入框
  10. user_name = Label(root,text='账号>>>',font=('Heiti',12))
  11. user_name.place(x=8, y=30)
  12. user_name_text = StringVar()
  13. user_name_entry = Entry(root,textvariable=user_name_text,font=('Heiti',12),width=20)
  14. user_name_entry.place(x=60,y=30)
  15. # 密码输入框
  16. user_pwd = Label(root,text='密码>>>',font=('Heiti',12))
  17. user_pwd.place(x=8,y=60)
  18. user_pwd_text =  StringVar()
  19. user_pwd_entry = Entry(root,textvariable=user_pwd_text,font=('Heiti',12),width=20)
  20. user_pwd_entry.place(x=60,y=60)

  21. def data():
  22.     with open('./data.txt','r',encoding='utf-8') as f:
  23.         user_list = f.readlines()
  24.         user_dict = {}
  25.         for each_user in user_list:
  26.             user = each_user.strip().split(':')[0]
  27.             pwd = each_user.strip().split(':')[1]
  28.             user_dict[user]=pwd
  29.         return user_dict

  30. def get_input():
  31.     user_input = user_name_text.get()
  32.     pwd_input = user_pwd_text.get()
  33.     user_dict = data()
  34.     if user_input != '' and pwd_input != '':
  35.         if user_input in user_dict.keys():
  36.             if pwd_input == user_dict[user_input]:
  37.                 messagebox.showinfo(title='ok',message='欢迎回来  ' + user_input)
  38.                 root.destroy()
  39.             else:
  40.                 messagebox.showwarning(title='error',message='密码错误')
  41.         else:
  42.             messagebox.showerror(title='error',message='空用户,不存在')
  43.     else:
  44.         messagebox.showerror(title='error',message='账号,密码不能为空')
  45.         # print('不能为空')

  46. def pop_win():
  47.     top = Toplevel()
  48.     top.title('注册')
  49.     top.geometry('300x200')
  50.     top.resizable(width=False,height=False)

  51.     Label(top,text='账号>>>').grid(row=1, column=2)
  52.     new_name = StringVar()
  53.     Entry(top,text=new_name).grid(row=1,column=4)

  54.     Label(top,text='密码>>>').grid(row=3,column=2)
  55.     new_pwd = StringVar()
  56.     Entry(top,text=new_pwd).grid(row=3,column=4)

  57.     Label(top, text='确认密码>>>').grid(row=5, column=2)
  58.     new_check = StringVar()
  59.     Entry(top, text=new_check).grid(row=5, column=4)

  60.     def check_pwd():
  61.         use_1 = new_name.get()
  62.         pwd_1 = new_pwd.get()
  63.         pwd_2 = new_check.get()
  64.         if use_1 == '' or pwd_1 == '' or pwd_2 == '' :
  65.             messagebox.showerror(title='error', message='Not null')
  66.         else:
  67.             if pwd_1 == pwd_2:
  68.                 with open('./data.txt','a',encoding='utf-8') as fp:
  69.                     fp.writelines('\n' + use_1 +':'+ pwd_1)
  70.                     fp.flush()
  71.                 messagebox.showinfo(title='ok', message='注册成功')
  72.                 top.destroy()
  73.             else:
  74.                 messagebox.showerror(title='error',message='两次密码不一致')

  75.     button_3 = Button(top,text='提交',width=15,command=check_pwd).grid(row=9,column=4)

  76. def save_stu():
  77.     wb = openpyxl.Workbook()
  78.     sheet = wb.active
  79.     sheet['A1'] = '姓名'
  80.     sheet['B1'] = '电话'
  81.     sheet['C1'] = '性别'
  82.     sheet['D1'] = '省份'
  83.     sheet['E1'] = '爱好1'
  84.     sheet['F1'] = '爱好2'

  85.     wb.save('./学生信息.xlsx')

  86. def add_sutdent():
  87.     new_root = Toplevel()
  88.     new_root.title('学生注册')
  89.     new_root.geometry('300x300')

  90.     new_stu = Label(new_root, text='姓名>>>', font=('Heiti', 12)).grid(row=1, column=1)
  91.     stu = StringVar()
  92.     new_stu_entry = Entry(new_root, textvariable=stu, width=20).grid(row=1, column=2)

  93.     new_pho = Label(new_root, text='电话>>>', font=('Heiti', 12)).grid(row=2, column=1)
  94.     pho = StringVar()
  95.     new_pho_entry = Entry(new_root, textvariable=pho, font=('Heiti', 12), width=20).grid(row=2, column=2)

  96.     new_sex_choice = Label(new_root, text='性别>>>', font=('Heiti', 12)).grid(row=3, column=1)
  97.     sex = StringVar()
  98.     Radiobutton(new_root, text='male', variable=sex, value='male').grid(row=3, column=2, sticky='w')
  99.     Radiobutton(new_root, text='female', variable=sex, value='female').grid(row=3, column=2, sticky='e')

  100.     new_hob_choice = Label(new_root, text='爱好>>>', font=('Heiti', 12)).grid(row=4, column=1)
  101.     hob_1 = IntVar()
  102.     hob_2 = IntVar()
  103.     Checkbutton(new_root, text='唱', variable=hob_1, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='w')
  104.     Checkbutton(new_root, text='跳', variable=hob_2, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='e')

  105.     new_pov_choice = Label(new_root, text='省份>>>', font=('Heiti', 12)).grid(row=5, column=1)
  106.     pros = ['北京', '上海', '广州', '深圳']
  107.     pro = StringVar()
  108.     pro_choice = Combobox(new_root, textvariable=pro, width=15, values=pros, state='readonly').grid(row=5, column=2)

  109.     def get_stu_info():
  110.         stu_name = stu.get()
  111.         stu_pho = pho.get()
  112.         stu_sex = sex.get()
  113.         stu_pro = pro.get()
  114.         stu_like1 = hob_1.get()
  115.         stu_like2 = hob_2.get()
  116.         print(stu_name, stu_pho, stu_sex, stu_pro, stu_like1, stu_like2)

  117.     button_4 = Button(new_root, text='提交', width=12, command=get_stu_info).grid(row=6, columnspan=3, pady=20)

  118. #菜单栏
  119. menu_bar = Menu(root)
  120. stu_men = Menu(menu_bar)
  121. #添加选项
  122. stu_men.add_command(label='注册',command=add_sutdent)
  123. stu_men.add_command(label='查询',command='')
  124. #将菜单添加到菜单栏中
  125. menu_bar.add_cascade(label='学生',menu=stu_men)
  126. # 配置菜单栏
  127. root.config(menu=menu_bar)

  128. score_menu = Menu(menu_bar)
  129. score_menu.add_command(label='添加',command='')
  130. score_menu.add_command(label='查询',command='')
  131. menu_bar.add_cascade(label='成绩',menu=score_menu)
  132. root.config(menu=menu_bar)

  133. button_1 = Button(root,text='Login in',font=('Heiti',12),width=8,command=get_input).place(x=40,y=100)

  134. button_2 = Button(root,text='注册',font=('Heiti',12),width=8,command=pop_win).place(x=160,y=100)

  135. root.mainloop()
  136. # new_root.mainloop()
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-9-6 22:17:35 | 显示全部楼层
new_root = Toplevel()
还有个小问题,把'\n'放后面fp.writelines( use_1 +':'+ pwd_1 + '\n' )
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-9-6 22:52:36 | 显示全部楼层    本楼为最佳答案   

这样试试看:

  1. from tkinter import *
  2. from tkinter import Tk,messagebox,Toplevel
  3. from tkinter.ttk import Combobox
  4. import openpyxl


  5. root= Tk()
  6. root.title('登录界面')
  7. root.geometry('300x200')
  8. root.resizable(width=False,height=False)
  9. #账号输入框
  10. user_name = Label(root,text='账号>>>',font=('Heiti',12))
  11. user_name.place(x=8, y=30)
  12. user_name_text = StringVar()
  13. user_name_entry = Entry(root,textvariable=user_name_text,font=('Heiti',12),width=20)
  14. user_name_entry.place(x=60,y=30)
  15. # 密码输入框
  16. user_pwd = Label(root,text='密码>>>',font=('Heiti',12))
  17. user_pwd.place(x=8,y=60)
  18. user_pwd_text =  StringVar()
  19. user_pwd_entry = Entry(root,textvariable=user_pwd_text,font=('Heiti',12),width=20)
  20. user_pwd_entry.place(x=60,y=60)

  21. def data():
  22.     with open('./data.txt','r',encoding='utf-8') as f:
  23.         user_list = f.readlines()
  24.         user_dict = {}
  25.         for each_user in user_list:
  26.             user = each_user.strip().split(':')[0]
  27.             pwd = each_user.strip().split(':')[1]
  28.             user_dict[user]=pwd
  29.         return user_dict

  30. def get_input():
  31.     user_input = user_name_text.get()
  32.     pwd_input = user_pwd_text.get()
  33.     user_dict = data()
  34.     if user_input != '' and pwd_input != '':
  35.         if user_input in user_dict.keys():
  36.             if pwd_input == user_dict[user_input]:
  37.                 messagebox.showinfo(title='ok',message='欢迎回来  ' + user_input)
  38.                 root.destroy()
  39.             else:
  40.                 messagebox.showwarning(title='error',message='密码错误')
  41.         else:
  42.             messagebox.showerror(title='error',message='空用户,不存在')
  43.     else:
  44.         messagebox.showerror(title='error',message='账号,密码不能为空')
  45.         # print('不能为空')

  46. def pop_win():
  47.     top = Toplevel()
  48.     top.title('注册')
  49.     top.geometry('300x200')
  50.     top.resizable(width=False,height=False)

  51.     Label(top,text='账号>>>').grid(row=1, column=2)
  52.     new_name = StringVar()
  53.     Entry(top,text=new_name).grid(row=1,column=4)

  54.     Label(top,text='密码>>>').grid(row=3,column=2)
  55.     new_pwd = StringVar()
  56.     Entry(top,text=new_pwd).grid(row=3,column=4)

  57.     Label(top, text='确认密码>>>').grid(row=5, column=2)
  58.     new_check = StringVar()
  59.     Entry(top, text=new_check).grid(row=5, column=4)

  60.     def check_pwd():
  61.         use_1 = new_name.get()
  62.         pwd_1 = new_pwd.get()
  63.         pwd_2 = new_check.get()
  64.         if use_1 == '' or pwd_1 == '' or pwd_2 == '' :
  65.             messagebox.showerror(title='error', message='Not null')
  66.         else:
  67.             if pwd_1 == pwd_2:
  68.                 with open('./data.txt','a',encoding='utf-8') as fp:
  69.                     fp.writelines('\n' + use_1 +':'+ pwd_1)
  70.                     fp.flush()
  71.                 messagebox.showinfo(title='ok', message='注册成功')
  72.                 top.destroy()
  73.             else:
  74.                 messagebox.showerror(title='error',message='两次密码不一致')

  75.     button_3 = Button(top,text='提交',width=15,command=check_pwd).grid(row=9,column=4)

  76. def save_stu():
  77.     wb = openpyxl.Workbook()
  78.     sheet = wb.active
  79.     sheet['A1'] = '姓名'
  80.     sheet['B1'] = '电话'
  81.     sheet['C1'] = '性别'
  82.     sheet['D1'] = '省份'
  83.     sheet['E1'] = '爱好1'
  84.     sheet['F1'] = '爱好2'

  85.     wb.save('./学生信息.xlsx')

  86. def add_sutdent():
  87.     new_root = Toplevel()
  88.     new_root.title('学生注册')
  89.     new_root.geometry('300x300')

  90.     new_stu = Label(new_root, text='姓名>>>', font=('Heiti', 12)).grid(row=1, column=1)
  91.     stu = StringVar()
  92.     new_stu_entry = Entry(new_root, textvariable=stu, width=20).grid(row=1, column=2)

  93.     new_pho = Label(new_root, text='电话>>>', font=('Heiti', 12)).grid(row=2, column=1)
  94.     pho = StringVar()
  95.     new_pho_entry = Entry(new_root, textvariable=pho, font=('Heiti', 12), width=20).grid(row=2, column=2)

  96.     new_sex_choice = Label(new_root, text='性别>>>', font=('Heiti', 12)).grid(row=3, column=1)
  97.     sex = StringVar()
  98.     Radiobutton(new_root, text='male', variable=sex, value='male').grid(row=3, column=2, sticky='w')
  99.     Radiobutton(new_root, text='female', variable=sex, value='female').grid(row=3, column=2, sticky='e')

  100.     new_hob_choice = Label(new_root, text='爱好>>>', font=('Heiti', 12)).grid(row=4, column=1)
  101.     hob_1 = IntVar()
  102.     hob_2 = IntVar()
  103.     Checkbutton(new_root, text='唱', variable=hob_1, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='w')
  104.     Checkbutton(new_root, text='跳', variable=hob_2, onvalue=1, offvalue=0).grid(row=4, column=2, sticky='e')

  105.     new_pov_choice = Label(new_root, text='省份>>>', font=('Heiti', 12)).grid(row=5, column=1)
  106.     pros = ['北京', '上海', '广州', '深圳']
  107.     pro = StringVar()
  108.     pro_choice = Combobox(new_root, textvariable=pro, width=15, values=pros, state='readonly').grid(row=5, column=2)

  109.     def get_stu_info():
  110.         stu_name = stu.get()
  111.         stu_pho = pho.get()
  112.         stu_sex = sex.get()
  113.         stu_pro = pro.get()
  114.         stu_like1 = hob_1.get()
  115.         stu_like2 = hob_2.get()
  116.         print(stu_name, stu_pho, stu_sex, stu_pro, stu_like1, stu_like2)

  117.     button_4 = Button(new_root, text='提交', width=12, command=get_stu_info).grid(row=6, columnspan=3, pady=20)

  118. #菜单栏
  119. menu_bar = Menu(root)
  120. stu_men = Menu(menu_bar)
  121. #添加选项
  122. stu_men.add_command(label='注册',command=add_sutdent)
  123. stu_men.add_command(label='查询',command='')
  124. #将菜单添加到菜单栏中
  125. menu_bar.add_cascade(label='学生',menu=stu_men)
  126. # 配置菜单栏
  127. root.config(menu=menu_bar)

  128. score_menu = Menu(menu_bar)
  129. score_menu.add_command(label='添加',command='')
  130. score_menu.add_command(label='查询',command='')
  131. menu_bar.add_cascade(label='成绩',menu=score_menu)
  132. root.config(menu=menu_bar)

  133. button_1 = Button(root,text='Login in',font=('Heiti',12),width=8,command=get_input).place(x=40,y=100)

  134. button_2 = Button(root,text='注册',font=('Heiti',12),width=8,command=pop_win).place(x=160,y=100)

  135. root.mainloop()
  136. # new_root.mainloop()
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-9-13 08:09:11 | 显示全部楼层

不好意思,最近忙学校的事,没有及时回复,请问一下是哪里出问题了呢
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-9-13 08:16:08 | 显示全部楼层

已经搞明白啦,谢谢各位啦
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-27 03:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表