天下程序员首页cx06.com
管理 |  登录 |  注册
组件的面向对象,class类编程(有利于复杂组件)
更新于:2024-07-30

组件的面向对象在有利于复杂组件的组合

下面是固定格式:

from tkinter import *

class App(Frame):
     # 固定写法====master相当于Tk()==
    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.pack()

        self.createWidget()

    # 组件集合=====
    def createWidget(self):
       Button(self,text="重复插入文本")
     
    # 组件相关函数=====

root=Tk()
root.title("第一个tk程序")
root.geometry("600x500+100+200")
app=App(root)
root.mainloop()
天下程序员 www.cx06.com 程序员的网上家园!
作者微信:13126507001