473,408 Members | 1,876 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,408 software developers and data experts.

How to keep a Tkinter-Dialog on top of all other windows?

Hi!

I am creating a dialog-box within my application, using tkinter. The
problem is the following: After the dialogbox is started, the main
application window comes again to top and the dialogbox is covered by
the window of the main application and must be "fetched" again via the
taskbar to continue. Is there a way to "force" the dialogbox on top of
all other windows? (I'm using MSWindows and Python22)

The source of my dialogbox-class is the following:

class NumberEntry:
def __init__(self):
import Tkinter
from Tkconstants import RIDGE
from Tkconstants import BOTH
from Tkconstants import BOTTOM
from Tkconstants import ACTIVE
from Tkconstants import LEFT
from Tkconstants import W
from Tkconstants import E
self.tk = Tkinter.Tk()
self.tk.title("My Dialog")
frame = Tkinter.Frame(self.tk, borderwidth=2)
frame.pack(fill=BOTH,expand=1)

label=Tkinter.Label(frame, text="Telefonnummer:")
label.pack(fill=BOTH,expand=1)

self.entry = Tkinter.Entry(frame, name="entry")
self.entry.pack(fill=BOTH,expand=1)

box = Tkinter.Frame()
w = Tkinter.Button(box, text="OK", width = 10, command=self.OnOk,
default = ACTIVE)
w.pack(side=LEFT, padx=5, pady=5)
w = Tkinter.Button(box, text="Cancel", width=10,
command=self.OnCancel)
w.pack(side=LEFT, padx=5, pady=5)
box.pack()

# try to keep focus on current dialog box
self.tk.focus_set()
self.tk.mainloop()
def OnOk(self):
self.result = self.entry.get()
self.tk.destroy()
def OnCancel(self):
self.tk.destroy()
result = ""
Jul 18 '05 #1
1 5842
"Thomas Nücker" <th************@web.de> wrote in message
news:4b**************************@posting.google.c om...
Hi!

I am creating a dialog-box within my application, using tkinter. The
problem is the following: After the dialogbox is started, the main
application window comes again to top and the dialogbox is covered by
the window of the main application and must be "fetched" again via the
taskbar to continue. Is there a way to "force" the dialogbox on top of
all other windows? (I'm using MSWindows and Python22)

<snip>

I had a similar problem using Python/tkinter embedded in a Win32 app, and
never found a truly satisfactory solution. The best I was able to do was
have the tk window call into my app, passing its window handle (which you
can get via winfo_id()). In my app I have a timer running - as long as that
window exists it will keep calling SetWindowPos with the HWND_TOP flag to
move the Tk window on top of all the app windows. When given the Tk window
handle you need to hunt up through it's parents until you find a window with
no parent, and call SetWindowPos on that window.

If the window being watched no longer exists I just kill the timer and clear
the window handle.

I'd love to find a solution that isn't such a grotesque hack.

Joe Fromm
Jul 18 '05 #2

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

Similar topics

1
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles...
3
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter...
2
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make....
2
by: codecraig | last post by:
Hi, I was reading through the Tkinter tutorial at http://www.pythonware.com/library/tkinter/introduction/index.htm ...and it mentions that by doing, from Tkinter import * you have access to...
1
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the...
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
3
by: dwelch91 | last post by:
I'm trying unsuccessfully to do something in Tk that I though would be easy. After Googling this all day, I think I need some help. I am admittedly very novice with Tk (I started with it...
3
by: seanacais | last post by:
I'm trying to build an unknown number of repeating gui elements dynamically so I need to store the variables in a list of dictionaries. I understand that Scale "variable" name needs to be a...
8
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to...
3
by: joshdw4 | last post by:
I hate to do this, but I've thoroughly exhausted google search. Yes, it's that pesky root window and I have tried withdraw to no avail. I'm assuming this is because of the methods I'm using. I...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.