用户:wrmdcxy查看:108 回复:8 评论:108 创建时间:2020-05-08T15:19:49
最近大家都不怎么活跃呢。。。。。是不是因为要开学了?
写了个gui
import tkinter
class GUI:
def __init__(self,width=300,height=300,title="Window"):
self.t = tkinter.Tk()
self.t.geometry(f"{width}x{height}")
self.t.title(title)
def run(self):
self.t.mainloop()
def text(self,text="",x=None,y=None,color="black"):
if x and y:
tkinter.Label(master=self.t,text=text,fg=color).place(x=x,y=y)
if not (x or y):
tkinter.Label(master=self.t,text=text,fg=color).pack()
def button(self,command,width=20,height=20,text="",x=None,y=None):
if x and y:
tkinter.Button(master=self.t,text=text,command=command,width=width,height=height).place(x=x,y=y)
if not (x or y):
tkinter.Button(master=self.t, text=text, command=command).pack()
def msgbox(text,title="",button_text="OK"):
a = tkinter.Tk()
a.title(title)
a.geometry("300x100")
tkinter.Label(a,text=text).pack()
tkinter.Button(a,text=button_text,command=a.destroy).pack()
a.mainloop()
点赞0
评论