GUI面向对象的写法
2021-11-28 本文已影响0人
Jeff_9021
# GUI编程,面向对象的写法
from tkinter import *
class Application(Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.createWidget()
def createWidget(self):
'''创建组件‘’‘
self.btn1 = Button(self)
self.btn1["text"] = "点击确认"
if __name__ == "__main__":
root = Tk()
root.geometry("400x100+200+300")
root.title("测试1")
app = Application(master = root)
root.mainloop()