Warm tip: This article is reproduced from stackoverflow.com, please click
python tkinter user-interface pygubu

How to expand a Scrollbar in Tkinter when working with a pre-made user interface (pygubu)

发布于 2020-06-11 10:28:14

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

enter image description here

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:


1. Solving from PyGubu

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

2. Solving from Python

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

Questioner
Federico Dorato
Viewed
16
Federico Dorato 2020-03-27 21:08

While writing the question, I've found a not-so-intuitive answer, still the best one:

enter image description here

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