午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python tkinter之ComboBox(下拉框)的使用簡(jiǎn)介

瀏覽:224日期:2022-06-28 11:03:47
1、ComboBox的基礎(chǔ)屬性

# -*- encoding=utf-8 -*-import tkinterfrom tkinter import *from tkinter import ttkif __name__ == ’__main__’: win = tkinter.Tk() # 窗口 win.title(’南風(fēng)丶輕語(yǔ)’) # 標(biāo)題 screenwidth = win.winfo_screenwidth() # 屏幕寬度 screenheight = win.winfo_screenheight() # 屏幕高度 width = 600 height = 500 x = int((screenwidth - width) / 2) y = int((screenheight - height) / 2) win.geometry(’{}x{}+{}+{}’.format(width, height, x, y)) # 大小以及位置 value = StringVar() value.set(’CCC’) values = [’AAA’, ’BBB’, ’CCC’, ’DDD’] combobox = ttk.Combobox( master=win, # 父容器 height=10, # 高度,下拉顯示的條目數(shù)量 width=20, # 寬度 state=’readonly’, # 設(shè)置狀態(tài) normal(可選可輸入)、readonly(只可選)、 disabled cursor=’arrow’, # 鼠標(biāo)移動(dòng)時(shí)樣式 arrow, circle, cross, plus... font=(’’, 20), # 字體 textvariable=value, # 通過(guò)StringVar設(shè)置可改變的值 values=values, # 設(shè)置下拉框的選項(xiàng) ) print(combobox.keys()) # 可以查看支持的參數(shù) combobox.pack() win.mainloop()

Python tkinter之ComboBox(下拉框)的使用簡(jiǎn)介

2、綁定選中事件

# -*- encoding=utf-8 -*-import tkinterfrom tkinter import *from tkinter import ttkdef choose(event): # 選中事件 print(’選中的數(shù)據(jù):{}’.format(combobox.get())) print(’value的值:{}’.format(value.get()))if __name__ == ’__main__’: win = tkinter.Tk() # 窗口 win.title(’南風(fēng)丶輕語(yǔ)’) # 標(biāo)題 screenwidth = win.winfo_screenwidth() # 屏幕寬度 screenheight = win.winfo_screenheight() # 屏幕高度 width = 600 height = 500 x = int((screenwidth - width) / 2) y = int((screenheight - height) / 2) win.geometry(’{}x{}+{}+{}’.format(width, height, x, y)) # 大小以及位置 value = StringVar() value.set(’CCC’) # 默認(rèn)選中CCC==combobox.current(2) values = [’AAA’, ’BBB’, ’CCC’, ’DDD’] combobox = ttk.Combobox( master=win, # 父容器 height=10, # 高度,下拉顯示的條目數(shù)量 width=20, # 寬度 state=’normal’, # 設(shè)置狀態(tài) normal(可選可輸入)、readonly(只可選)、 disabled cursor=’arrow’, # 鼠標(biāo)移動(dòng)時(shí)樣式 arrow, circle, cross, plus... font=(’’, 20), # 字體 textvariable=value, # 通過(guò)StringVar設(shè)置可改變的值 values=values, # 設(shè)置下拉框的選項(xiàng) ) combobox.bind(’<<ComboboxSelected>>’, choose) print(combobox.keys()) # 可以查看支持的參數(shù) combobox.pack() win.mainloop()

Python tkinter之ComboBox(下拉框)的使用簡(jiǎn)介

以上就是Python tkinter之ComboBox(下拉框)的使用簡(jiǎn)介的詳細(xì)內(nèi)容,更多關(guān)于Python tkinter之ComboBox 下拉框的使用的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 婷婷丁香亚洲 | 天堂av网站| 一色桃子av| 秋霞网av | 无码少妇一区二区三区 | 欧美日韩大片 | 超碰手机| 色九九| 亚洲欧美精品在线 | 久久免费小视频 | 黄色精品在线 | 久久免费在线观看视频 | 久久不射视频 | 亚洲一区二区三区四区在线 | 韩国三级av | 日韩免费视频网站 | 一个人看的www在线视频 | 色婷婷狠狠干 | 伊人天堂在线 | 青青青草视频在线观看 | 国产999在线观看 | 超碰手机 | 色av影院| 中文色网 | 成人看的视频 | 好吊视频一区二区三区四区 | 黄色avav | 亚洲精品视频在线 | 欧美日韩国产不卡 | 精品福利一区二区 | 亚洲欧洲精品视频 | 岛国av网站| 久草成人在线视频 | 婷婷中文 | 深夜福利在线视频 | 91久久精品国产 | 久久综合社区 | 97超碰伊人 | 男女激情视频网站 | 99久久成人 | 狠狠干在线视频 |