- Tkinter GUI Application Development Cookbook
- Alejandro Rodas de Paz
- 97字
- 2021-08-27 19:44:05
There's more...
If the number of text items is large enough, it may be necessary to add a vertical scroll bar. You can easily connect it using the yscrollcommand option. In our example, we can wrap both widgets in a frame to keep the same layout. Remember to specify the fill option when packing the scroll so that it fills the available space in the y axis:
def __init__(self):
self.frame = tk.Frame(self) self.scroll = tk.Scrollbar(self.frame, orient=tk.VERTICAL) self.list = tk.Listbox(self.frame, yscrollcommand=self.scroll.set) self.scroll.config(command=self.list.yview) # ... self.frame.pack() self.list.pack(side=tk.LEFT) self.scroll.pack(side=tk.LEFT, fill=tk.Y)
Similarly, there is a xscrollcommand option for the horizontal axis.
推薦閱讀
- C語(yǔ)言程序設(shè)計(jì)案例教程
- Apache Spark 2.x Machine Learning Cookbook
- C語(yǔ)言從入門(mén)到精通(第4版)
- 教孩子學(xué)編程:C++入門(mén)圖解
- Oracle Exadata專(zhuān)家手冊(cè)
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- C語(yǔ)言程序設(shè)計(jì)
- Lighttpd源碼分析
- Fast Data Processing with Spark(Second Edition)
- Unity 2017 Game AI Programming(Third Edition)
- Visual C++開(kāi)發(fā)寶典
- Tableau Dashboard Cookbook
- 深入淺出 HTTPS:從原理到實(shí)戰(zhàn)
- Test-Driven iOS Development with Swift
- Mastering Machine Learning with R