How to make a Tkinter widget always visible?

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

  1. Miki

    Miki Guest

    Hello,

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

    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
    times.

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

    Thanks,
    --
    Miki <>
    http://pythonwise.blogspot.com
    Miki, Mar 11, 2008
    #1
    1. Advertising

  2. Miki

    Kevin Walzer Guest

    Miki wrote:
    > Hello,
    >
    > I have a simple Tkinter window with [GO] and [Quit] buttons at the
    > bottom.
    >
    > 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
    > times.
    >
    > Is there a way to make sure that these buttons are always visible?
    >


    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
    Code by Kevin
    http://www.codebykevin.com
    Kevin Walzer, Mar 11, 2008
    #2
    1. Advertising

  3. Miki

    Miki Guest

    Hello Kevin,

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

    >
    > 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.

    Thanks.

    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.

    Thanks,
    --
    Miki <>
    http://pythonwise.blogspot.com
    Miki, Mar 11, 2008
    #3
  4. Miki

    Kevin Walzer Guest

    Miki wrote:
    > Hello Kevin,
    >
    >>> Is there a way to make sure that these buttons are always visible?

    >> 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.

    > Thanks.
    >
    > 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.
    >


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

    --K

    --
    Kevin Walzer
    Code by Kevin
    http://www.codebykevin.com
    Kevin Walzer, Mar 11, 2008
    #4
  5. Miki

    Miki Guest

    Hello Kevin,

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

    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.config(state=tk.DISABLED)
    log.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
    scrollbar.config(command=log.yview)
    frame.pack(fill=tk.BOTH, expand=1)

    # Button frame
    frame = tk.Frame(root)
    update = tk.Button(frame, text="GO", command=lambda:
    showinfo("OUCH"))
    update.pack(side=tk.LEFT)
    tk.Button(frame, text="Quit",
    command=root.quit).pack(side=tk.LEFT)
    frame.pack(fill=tk.X)


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

    if __name__ == "__main__":
    main()
    -------------------------------
    When I pack the buttons frame first (using side=BOTTOM), it stays
    visible at all times.

    Thanks,
    --
    Miki <>
    http://pythonwise.blogspot.com
    Miki, Mar 12, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spamfurnace
    Replies:
    1
    Views:
    2,624
    Scott M.
    May 24, 2004
  2. Patrick Olurotimi Ige
    Replies:
    7
    Views:
    5,938
    Patrick Olurotimi Ige
    Jun 15, 2005
  3. Frederic Rentsch
    Replies:
    0
    Views:
    220
    Frederic Rentsch
    Jul 8, 2012
  4. Terry Reedy
    Replies:
    15
    Views:
    607
    Frederic Rentsch
    Jul 16, 2012
  5. Frederic Rentsch
    Replies:
    0
    Views:
    415
    Frederic Rentsch
    Jul 9, 2012
Loading...

Share This Page