Tkinter, tkMessagebox and overrideredirect

Eric Brunel see.signature at no.spam
Wed Jun 6 09:38:53 EDT 2007


On Wed, 06 Jun 2007 14:26:12 +0200, <marcoberi at gmail.com> wrote:
>> As an aside, having a window with overrideredirect(1) creating "normal"
>> windows such as the one created via tkMessageBox.showinfo is asking for
>> problems. What are you trying to do here?
>
> I just need a window without the titlebar as my main window (think of
> it as a kiosk application). No titlebar is mandatory :-(
> I place controls on it and I open popup dialog windows.
> If there is a better way to do it, I would be happy to know it.

My only advice would then be to avoid using the standard functions to  
create dialog boxes, and to create them yourself. For example:
----------------------------------------------------------
 from Tkinter import *

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

     def hello(self):
         dialogWdw = Toplevel()
         dialogWdw.title('Popup')
         Label(dialogWdw, text='Hello!').pack(side=TOP)
         Button(dialogWdw, text='OK',  
command=dialogWdw.destroy).pack(side=TOP)
         dialogWdw.tkraise(self.root)
         self.root.wait_window(dialogWdw)

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

But even with this, you may run into problems. For example, on my Linux  
box with my window manager, the main window goes behind all other windows  
once the button in the dialog is clicked. So I'd say that if you want to  
bypass the window manager, bypass it for everything and do  
overrideredirect(1) on all the windows you create. But this means that  
you'll have to do everything "manually", especially window stacking.
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list