How to make a Tkinter widget always visible?

Discussion in 'Python' started by Miki, Mar 11, 2008.

  1. Miki

    Miki Guest


    I have a simple Tkinter window with [GO] and [Quit] buttons at the

    When I resize the window to be shorter, the first thing to disappear
    are the buttons, however I want these button to be visible at all

    Is there a way to make sure that these buttons are always visible?

    Miki, Mar 11, 2008
    1. Advertisements

  2. Miki

    Kevin Walzer Guest

    There are various ways to do this: you can set the window to be
    non-resizable, or set a minimum size to it, so that it can't be resized
    below that level. However, if you allow arbitrary resizing of the
    window, there's no real way to guarantee that the widgets will be
    visible at all times.
    Kevin Walzer, Mar 11, 2008
    1. Advertisements

  3. Miki

    Miki Guest

    Hello Kevin,

    I've set a minimal size to the window. However when I resize it to be
    shorter, the buttons are hidden while the top frame stays visible.

    Miki, Mar 11, 2008
  4. Miki

    Kevin Walzer Guest

    Please post the code you're using--it will be easier to help if we can
    see exactly what you are trying.

    Kevin Walzer, Mar 11, 2008
  5. Miki

    Miki Guest

    Hello Kevin,
    In a nutshell:
    import Tkinter as tk, tkFont
    from tkMessageBox import showinfo, showerror
    from os import popen

    def main():
    root = tk.Tk()

    # Log window
    tk.Label(root, text="Log:", anchor=tk.W).pack(fill=tk.X)
    frame = tk.Frame(root)
    scrollbar = tk.Scrollbar(frame)
    scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
    log = tk.Text(frame, width=80)
    log.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
    frame.pack(fill=tk.BOTH, expand=1)

    # Button frame
    frame = tk.Frame(root)
    update = tk.Button(frame, text="GO", command=lambda:
    tk.Button(frame, text="Quit",

    root.bind("<Escape>", lambda e: root.quit())
    root.minsize(-1, 100)

    if __name__ == "__main__":
    Miki, Mar 12, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.