美文网首页Test小工具
GUI面向对象的写法

GUI面向对象的写法

作者: Jeff_9021 | 来源:发表于2021-11-28 12:01 被阅读0次

# 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()

相关文章

网友评论

    本文标题:GUI面向对象的写法

    本文链接:https://www.haomeiwen.com/subject/xeicxrtx.html