PyGubu is a simple Python program that allows to create UI interfaces with Tkinter widgets.
So I have created an UI like this one here on the right
Now, I want that Scrollbar to be as big as the Text widget.
"How can I make the Scrollbar bigger on Tkinter" has been asked many times on StackOverflow. In my case, I cannot use the functions pack() or grid() as I am importing an already semi-finished UI
The code I use to load the Text and the Scrollbar is as the following:
self.log = builder.get_object('log')
self.log_scroll = builder.get_object('log_scroll')
self.log.config(yscrollcommand=self.log_scroll.set)
self.log_scroll.config(command=self.log.yview)
Now, I see two possibilities here:
The easiest way should be setting some attributes from PyGubu to solve this. Yet, PyGubu allows me to change only a minor number of attributes of the Scrollbar, and none of them seems to be relevant
And here I have no idea about what to do. I don't know if I can use pack() and grid() while using a custom-made interface
Any help is appreciated
While writing the question, I've found a not-so-intuitive answer, still the best one:
The property "sticky" is the one who can solve the problem. What is not-so-intuitive is that you can select multiple squares ctrl+click. If you are used to work with Tkinter, it would probably not surprise you, but in my case (first day with Tkinter) I can just consider myself lucky
When you set the sticky option in Pygubu, even when all three squares are highlighted, it sets NS (North South), which is the expected result.
The generated code will also just have 'ns', like this:
self.scroll_bar.grid(column='0', row='0', sticky='ns')
Selecting the central/middle square in Pygubu won't affect 'ns'. It should still give you the expected result when you have the 3 squares highlighted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.