本文共 1023 字,大约阅读时间需要 3 分钟。
from tkinter import *root = Tk()w = Label(root, text="Hello, world!")w.pack()root.mainloop()
_tkinter
是一个二进制扩展模块,包含低级的TK接口。不会直接被应用程序员所使用。from tkinter import *class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button( frame, text="QUIT", fg="red", command=frame.quit ) self.button.pack(side=LEFT) self.hi_there = Button(frame, text="Hello", command=self.say_hi) self.hi_there.pack(side=LEFT) def say_hi(self): print ("hi there, everyone!")root = Tk()app = App(root)root.mainloop()root.destroy() # optional; see description below
Frame可以包含其他的Widget.
转载地址:http://kzbtb.baihongyu.com/