Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you create a LabelFrame with a scrollbar in Tkinter?
    primarykey
    data
    text
    <p>I'm using Python and Tkinter to create a GUI for a program I'm writing, and I'm having a couple of problems.</p> <p>I have three objects descended from LabelFrame in an object descended from Frame. One of the LabelFrame descendants is two columns of corresponding Label and Entry objects.</p> <p><img src="https://i.stack.imgur.com/ZhiXa.png" alt="freq_frame example"></p> <p>The problem is that there are a varying number of Label and Entry pairs, and there can be more than fit on the screen. I need a way to make a scrollbar for this LabelFrame so that everything fits on the screen. I've tried various ways of making a Scrollbar object, but nothing seems to work. How can I bind a scrollbar to this frame?</p> <p>Also, I need to be able to refresh or reload this LabelFrame when the <code>load_message()</code> method is called, but it just redisplays the new pairs on top of the old ones (so when there are less pairs in the new set, the old set is still visible at the bottom). I've tried using <code>grid_forget()</code> but either nothing changes or the whole frame doesn't display. How can I forget this display and then redisplay it?</p> <p>Here is the code for this class:</p> <pre><code>class freq_frame(LabelFrame): def __init__(self, master = None, text = 'Substitutions'): LabelFrame.__init__(self, master, text = text) self.grid() def load_message(self): self.frequency = get_freq(message) self.create_widgets() def create_widgets(self): self.label_list = [Label(self, text = get_label(char, self.frequency[char]), justify = LEFT) for char in self.frequency.keys()] self.entry_list = [Entry(self, width = 1) for char in self.frequency.keys()] for n in range(len(self.label_list)): self.label_list[n].grid(column = 0, row = n) for n in range(len(self.entry_list)): self.entry_list[n].grid(column = 1, row = n) </code></pre> <p>If anyone can help with either of these problems, I'd appreciate it.</p> <p>Also, this question seems like it might be a little thin, but I don't know what to add. Don't hesitate to ask for more information (but be specific).</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload