Tkinter, tkMessagebox and overrideredirect

marcoberi at gmail.com marcoberi at gmail.com
Tue Jun 5 12:18:51 EDT 2007


Hi everybody.

I have this code snippet that shows a window without a titlebar (using
overrideredirect) and two buttons on it: one quits and the other one
brings up a simple tkMessageBox.
On Windows (any flavour) the tkMessagebox brings up over the
underlying window.
On Linux (apparently any flavour) the tkMessagebox brings up under the
underlying window.
You can drag the popup window near the main window to discover if it's
over or under it.
Obviously I would like to show a popup that is over the main window!
Before asking I tried, I read, I googled, I pulled my hair off, but no
avail...
Any hints?
Thanks a lot for your time.
Ciao.
Marco.

import tkMessageBox
from Tkinter import *

class App():
    def __init__(self):
        self.root = Tk()
        self.root.overrideredirect(1)
        self.frame = Frame(self.root, width=320, height=200,
                           borderwidth=5, relief=RAISED)
        self.frame.pack_propagate(False)
        self.frame.pack()
        self.bQuit = Button(self.frame, text="Quit",
command=self.root.quit)
        self.bQuit.pack(pady=20)
        self.bHello = Button(self.frame, text="Hello",
command=self.hello)
        self.bHello.pack(pady=20)

    def hello(self):
        tkMessageBox.showinfo("Popup", "Hello!")

app = App()
app.root.mainloop()




More information about the Python-list mailing list