In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Tkinter list box control Listbox how to use", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Tkinter list box control Listbox how to use" it!
The first step is to build the Listbox control and add list items:
# create a listbox for demo.lb = Listbox (root, activestyle='dotbox', bg= "# ffffa0", fg= "# ff0000", disabledforeground= "# 3f3f3f", highlightbackground= "# 0000ff", font=ftiTimes, height=10, width=20)
# add itemsfor i in range (0jue 20): lb.insert (END, str (I))
The list box control does not provide a command property to specify the event handler, which is implemented using the bind "ListboxSelect" event. The content of the event handling is specified by the lambda expression, which avoids implementing a function that is only used once and is too simple.
# bind eventlb.bind ('', lambda e: label.config (text=str (lb.curselection () lb.grid (row=0, column=0, columnspan=3, sticky=W+E)
Build three Spinbox controls to modify valid / invalid, selected item representation and selection mode properties, respectively.
# create a Spinbox to change state.st_spin = Spinbox (root, values= ('normal',' disabled'), state='readonly', command=lambda:lb.config (state=st_spin.get ()) st_spin.grid (row=1, column=0, columnspan=1, sticky=W)
# create a Spinbox to change activestyle.as_spin = Spinbox (root, values= ('dotbox',' underline', 'none'), state='readonly', command=lambda:lb.config (activestyle=as_spin.get ()) as_spin.grid (row=1, column=1, columnspan=1, sticky=W)
# create a Spinbox to change select mode.sm_spin = Spinbox (root, values= ('browse',' single', 'multiple',' extended'), state='readonly', command=lambda:lb.config (selectmode=sm_spin.get ()) sm_spin.grid (row=1, column=2, columnspan=1, sticky=W)
Finally, a tag is built to represent the selection.
Label=Label (root) label.grid (row=2, column=0, columnspan=4) Thank you for your reading, this is the content of "how to use Tkinter list box control Listbox". After the study of this article, I believe you have a deeper understanding of how to use Tkinter list box control Listbox, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.