Tkinter的基本用法
1:导入和新建
from tkinter import *
root = Tk()
root.mainloop()
![这里写图片描述](https://img-blog.csdn.net/20170107101131777?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTElfd2lsbA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
2:设置标题和大小以及窗口位置
from tkinter import *
root = Tk()
root.title("TkinterSimple")
#窗口大小
width ,height= 600, 600
#窗口居中显示
root.geometry('%dx%d+%d+%d' % (width,height,(root.winfo_screenwidth() - width ) / 2, (root.winfo_screenheight() - height) / 2))
#窗口最大值
root.maxsize(600,600)
#窗口最小值
root.minsize(600,600)
root.mainloop()
![这里写图片描述](https://img-blog.csdn.net/20170107101950473?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTElfd2lsbA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
3:常用的控件
from tkinter import *
root = Tk()
root.title("TkinterSimple")
width ,height= 600, 600
root.geometry('%dx%d+%d+%d' % (width,height,(root.winfo_screenwidth() - width ) / 2, (root.winfo_screenheight() - height) / 2))
root.maxsize(600,600)
root.minsize(600,600)
def prints():
print("button")
button = Button(root, text="Button", command=prints)
button.pack()
label = Label(root, text="Label")
label.pack()
entry = Entry(root)
entry.pack()
checkbutton = Checkbutton(root, text="CheckButton")
checkbutton.pack()
radioButton = Radiobutton(root, text="RadioButton")
radioButton.pack()
root.mainloop()
![这里写图片描述](https://img-blog.csdn.net/20170107102824787?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTElfd2lsbA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)