1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
import tkinter master=tkinter.Tk() master.title("这是一个窗口") master.geometry("300x120") master.mainloop()
from tkinter import* import tkinter.messagebox master=Tk() master.title("这就是个窗口") master.geometry("500x280") def button_clicked(): tkinter.messagebox.showinfo("Message","Holle World!!!") btn1=Button(master,text="hello",command=button_clicked) btn1.pack() master.mainloop()
from tkinter import * root=Tk();root.title("登录")
f1=Frame(root);f1.pack() f2=Frame(root);f2.pack() f3=Frame(root);f3.pack() Label(f1,text="用户名").pack(side=LEFT) Entry(f1).pack(side=LEFT)
Label(f2,text="密码").pack(side=LEFT) Entry(f2,show="*").pack(side=LEFT)
Button(f3,text="登录").pack(side=RIGHT) Button(f3,text="取消").pack(side=RIGHT) root.mainloop()
from tkinter import * master=Tk();master.title("登录")
Label(master,text="用户名").grid(row=0,column=0) Entry(master).grid(row=0,column=1,columnspan=2)
Label(master,text="密码").grid(row=1,column=0) Entry(master,show="*").grid(row=1,column=1,columnspan=2)
Button(master,text="登录").grid(row=3,column=1,sticky=E) Button(master,text="取消").grid(row=3,column=2,sticky=W) master.mainloop()
from tkinter import* root=Tk();root.title("登录")
root['width']=200;root['height']=80
Label(root,text="用户名",width=6).place(x=1,y=1) Entry(root,width=20).place(x=45,y=1)
Label(root,text="密码",width=6).place(x=1,y=20) Entry(root,width=20,show="* ").place(x=45,y=20)
Button(text="登录",width=8).place(x=40,y=40) Button(text="取消",width=8).place(x=110,y=40) root.mainloop()
|