from tkinter import *
from tkinter import colorchooser root = Tk() def show(): colorchooser.askcolor() Button(root,text='选择颜色',command=show).pack() mainloop()
from tkinter import *
from tkinter import messagebox root = Tk() def show(): messagebox.askyesno('山丘','确认注册?') def create(): #top.attributes('-alpha',0.5)
top = Toplevel(root) top.title('山丘') top.geometry('400x250') Label(top,text='用户名:').place(x=20,y=50) Label(top,text='密码:').place(x=20,y=120) Entry(top).place(x=110,y=50) Entry(top,show='*').place(x=110,y=120) Button(top,text='确认注册',width=10,command=show).place(x=170,y=190) root.title('山丘') root.geometry('450x400') Label(root,text='用户名:').place(x=100,y=170) Label(root,text='密码:').place(x=100,y=230) photo = PhotoImage(file='welcome.gif') Label(root,image=photo).place(x=0,y=0) Entry(root).place(x=190,y=170) Entry(root,show='*').place(x=190,y=230) Button(root,text='注册',width=10,command=create).place(x=100,y=300) Button(root,text='提交',width=10).place(x=300,y=300) mainloop()