• tkinter中spinbox递增和递减控件(十)


    spinbox递增和递减控件

    复制代码
     1 import tkinter
     2 
     3 wuya = tkinter.Tk()
     4 wuya.title("wuya")
     5 wuya.geometry("300x200+10+20")
     6 
     7 # 创建一个frame
     8 frm1 = tkinter.Frame(wuya)
     9 frm1.pack(side='left')
    10 
    11 def func1():
    12     text1.delete(0.0,'end')
    13     text1.insert('insert',spb1.get())
    14 
    15 # 创建递增或递减控件,放置在frm1中
    16 spb1 = tkinter.Spinbox(frm1,from_=0,to=20,command=func1)
    17 # from_为开始的值,to为终止的值
    18 spb1.pack()
    19 
    20 text1 = tkinter.Text(frm1)
    21 text1.pack()
    22 
    23 
    24 
    25 # 创建一个frame
    26 frm2 = tkinter.Frame(wuya)
    27 frm2.pack(side='left')
    28 
    29 def func2():
    30     text2.delete(0.0,'end')
    31     text2.insert('insert', spb2.get())
    32 
    33 # 设置递增或递减的值
    34 val = ('上海','北京','天津','海南')
    35 # 创建递增或递减控件,放置在frm1中
    36 spb2 = tkinter.Spinbox(frm2, values=val, increment=1,command=func2)
    37 # from_为开始的值,to为终止的值,increment为递增或递减的步长
    38 spb2.pack()
    39 
    40 text2 = tkinter.Text(frm2)
    41 text2.pack()
    42 
    43 wuya.mainloop()
    复制代码

    结果:

  • 相关阅读:
    BZOJ BLO 1123 (割点)【双连通】
    P4291 [HAOI2008]排名系统
    P3165 [CQOI2014]排序机械臂
    P3224 [HNOI2012]永无乡
    P1169 [ZJOI2007]棋盘制作
    P2303 [SDOi2012]Longge的问题
    P2216 [HAOI2007]理想的正方形
    P2473 [SCOI2008]奖励关
    P2617 Dynamic Rankings
    P2518 [HAOI2010]计数
  • 原文地址:https://www.cnblogs.com/anita-harbour/p/9315475.html
Copyright © 2020-2023  润新知