473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to make a Tkinter widget always visible?

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 <mi*********@gmail.com>
http://pythonwise.blogspot.com
Mar 11 '08 #1
4 4742
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
Mar 11 '08 #2
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 <mi*********@gmail.com>
http://pythonwise.blogspot.com
Mar 11 '08 #3
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
Mar 11 '08 #4
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 <mi*********@gmail.com>
http://pythonwise.blogspot.com
Mar 12 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Harry Pehkonen | last post by:
While setting up some unit tests, I came to the conclusion that a Tkinter Text widget can never be empty, but will always (?) contain a \n. Here is a brief example: >>> import Tkinter >>> t =...
1
by: Pekka Niiranen | last post by:
Hi there, after reading TkInter/thread -recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 I wondered if it was possible to avoid using threads for the following problem: ...
2
by: Tonino | last post by:
Hi, I have a small Tkinter app that gets data from a socket connection to a "server". The app has a Text() widget to display the info that it gets from the socket connection. I have the...
8
by: James Stroud | last post by:
Hello All, I would like for a tkinter text widget to be aware of how big the frame that contains it is, then I would like for it to reset its width to the appropriate number of characters when...
4
by: Edward K. Ream | last post by:
Hello all, Creating a 'Help' menu 'by hand' on the Mac does not work, or rather, it creates a *second* Help menu. There are hints about how to do this at:
1
by: Kevin Walzer | last post by:
I'm trying to toggle the visibility of a Tkinter widget using pack_forget(), and I'm running into unexpected behavior. The widget "hides" correctly, but does not become visible again. My sample...
4
by: MartinRinehart | last post by:
Everything I've read about Tkinter says you create your window and then call its mainloop() method. But that's not really true. This is enough to launch a default window from the console: ...
4
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. ...
0
by: Guilherme Polo | last post by:
On 10/29/08, Olrik Lenstra <o.lenstra@gmail.comwrote: It will be a combination of commands, not a single one. Initially I considered this as "probably without solution", since tcl acquired a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.