from tkinter import *
class mywin:
def __init__(self,name,len,wid,gox,goy):
self.mytk = Tk()#Tk是一个类,tk()构造函数
self.mytk.title(name)#调用类的行为
self.len=len
self.wid=wid
self.gox=gox
self.goy=goy
lastter="%dx%d+%d+%d"%(self.len ,self.wid,self.gox,self.goy)
self.mytk.geometry(lastter)
def print(self):
self.mytk.mainloop()#运行起来
win1=mywin("hello 1",500,500,0,0)
win1.print()
win2=mywin("hello 2",600,600,0,0)
win2.print()
win3=mywin("hello 3",700,700,0,0)
win3.print()
类的实际用途
最新推荐文章于 2022-09-02 22:04:41 发布