|
楼主 |
发表于 2020-7-31 15:54:21
|
显示全部楼层
from tkinter import *
#主界面
class Indexpage():
def __init__(self,master):
self.master = master
self.master.config()
self.master.geometry("1000x500")
Menubar(self.master)
#主菜单
class Menubar():
def __init__(self,master):
self.master = master
menubar = Menu(self.master)
menubar.add_command(label = "测试1",command = self.cheshi1)
menubar.add_command(label = "测试",command = self.cheshi)
menubar.add_command(label = "退出",command = root.quit)
self.frame1 = Frame(self.master)
self.frame1.grid(row = 0,column = 0)
Label(self.frame1, text="测试内容").grid(row = 0,column = 0)
self.master.config(menu = menubar)
def cheshi1(self):
self.frame1.destroy()
self.frame1 = Frame(self.master)
self.frame1.grid(row = 0,column = 0)
Button(self.frame1,text = "提交").grid(row = 0,column =0)
Label(self.frame1,text = "进度:").grid(row = 1,column = 0,sticky = W)
canvas = Canvas(self.frame1,width = 350,height = 20,bg= "white").grid(row = 2,column = 0)
#这里的canvas 没有create方法
canvas.create
#测试界面
def cheshi(self):
self.frame1.destroy()
self.frame1 = Frame(self.master)
self.frame1.grid(row = 0,column = 0)
Label(self.frame1,text = "测试:").grid(row = 0,column = 0,sticky = W)
if __name__ == "__main__":
root = Tk()
Indexpage(root)
mainloop()
|
|