Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(Listbox/Scrollbar)

Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(Listbox/Scrollbar)

导读
动态演示调用python库的tkinter带你进入GUI世界(Listbox/Scrollbar)


tkinter案例应用—Listbox/Scrollbar

1、tkinter应用案例:利用输入框Listbox列表框组件+删除所选中内容按钮

#tkinter应用案例:利用输入框Listbox列表框组件+删除所选中内容按钮
from tkinter import *

master = Tk()
master.title("Jason niu工作室")
theLabel=tk.Label(master,text="进入GUI世界,请开始你的表演!\n关于区块链架构设计,请问你想学习什么技能?")
theLabel.pack() 

theLB = Listbox(master,selectmode=EXTENDED,height=12)
theLB.pack()

list=["1、应用层","1.1、面向普通用户","1.2、app客户端","1.3、交易网站","2、扩展层","2.1、智能合约","3、协议层之网络层","3.1、共识机制","3.2、P2P网络","3.3、共识机制","3.4、加密技术","4、协议层之存储层"]
for item in list:
    theLB.insert(END,item) 

theButton = Button(master,text="删除",                   command=lambda x=theLB:x.delete(ACTIVE))
theButton.pack()

mainloop()

2、tkinter应用案例:利用输入框Listbox列表框组件+且在Listbox内加滚动条

#tkinter应用案例:利用输入框Listbox列表框组件+且在Listbox内加滚动条
from tkinter import *

master = Tk()
master.title("Jason niu工作室")
theLabel=tk.Label(master,text="进入GUI世界,请开始你的表演!\n关于区块链,请问你想学习什么技能?")
theLabel.pack() 

# theLB = Listbox(master,selectmode=EXTENDED)
# theLB.pack()

sb = Scrollbar(master)
sb.pack(side = RIGHT,fill=Y)
theLB = Listbox(master,yscrollcommand=sb.set)
theLB.pack(side=LEFT,fill=BOTH)

list=["1、应用层","1.1、面向普通用户","1.2、app客户端","1.3、交易网站","2、扩展层","2.1、智能合约","3、协议层之网络层","3.1、共识机制","3.2、P2P网络","3.3、共识机制","3.4、加密技术","4、协议层之存储层"]
for item in list: #for循环添加
    theLB.insert(END,item) 

sb.config(command=theLB.yview)

theButton = Button(master,text="删除",                   command=lambda x=theLB:x.delete(ACTIVE))
theButton.pack()

mainloop()
(0)

相关推荐