import tkinter from tkinter import * def callback(): print("你点一下按钮") def turn_on(): #开启按钮 button1.config(state="disabled") button2.config(state="active") def turn_off(): #关闭按钮 button1.config(state="active") button2.config(state="disabled") root = Tk() root.title("杨焱") #窗口名称 root.iconbitmap("bitbug_favicon.ico") #ico图标 root.geometry("300x300") #窗体长宽 root.config(bg="blue") #背景颜色 lab = Label(root, text="Hello, Tkinter!") lab.pack() # lab = Label(root, text="Hello!", font=("黑体", 20)) #字体为黑体,大小20;顺序不能颠倒 # lab = Label(root, text="Hello!", font=20) #只设置大小20 # lab = Label(root, text="Hello!", font="黑体") #只设置字体为黑体 # Label(root, text="杨焱", font=("黑体", 20, "bold")).pack() #Label(root, text="谭媛", font=("黑体", 20, "italic")).pack() #Label(root, text="王兴维", font=("黑体", 20, "underline")).pack() #Label(root, text="删除线", font=("黑体", 20, "overstrike")).pack() #Label(root, text="叠加使用", font=("黑体", 20, "bold", "italic", "underline", "overstrike")).pack() #root.resizable(False, False) #mainloop() # #cursorList = ['arrow', 'xterm', 'watch', 'hand2', 'question_arrow', 'sb_h_double_arrow', 'sb_v_double_arrow', 'fleur', # 'crosshair', 'based_arrow_down', 'based_arrow_up', 'boat', 'bogosity', 'top_left_corner', # 'top_right_corner', 'bottom_left_corner', 'bottom_right_corner', 'top_side', 'bottom_side', 'top_tee', # 'bottom_tee', 'box_spiral', 'center_ptr', 'circle', 'clock', 'coffee_mug', 'cross', 'cross_reverse', # 'diamond_cross', 'dot', 'dotbox', 'double_arrow', 'top_left_arrow', 'draft_small', 'draft_large', # 'left_ptr', 'right_ptr', 'draped_box', 'exchange', 'gobbler', 'gumby', 'hand1', 'heart', 'icon', # 'iron_cross', 'left_side', 'right_side', 'left_tee', 'right_tee', 'leftbutton', 'middlebutton', # 'rightbutton', 'll_angle', 'lr_angle', 'man', 'mouse', 'pencil', 'pirate', 'plus', 'rtl_logo', 'sailboat', # 'sb_left_arrow', 'sb_right_arrow', 'sb_up_arrow', 'sb_down_arrow', 'shuttle', 'sizing', 'spider', # 'spraycan', 'star', 'target', 'tcross', 'trek', 'ul_angle', 'umbrella', 'ur_angle', 'X_cursor'] # 所有的光标样式 button1 = Button(root, text="开启", command=turn_on,activeforeground="blue",activebackground="yellow") button2 = Button(root, text="关闭", command=turn_off,activeforeground="blue",activebackground="yellow") button1.pack() button2.pack() root.resizable(True, True) mainloop() x = input('请输入一个数:') y = input('请输入一个数:')
图形练习设置按钮
最新推荐文章于 2024-09-15 22:31:42 发布