Win32 modal dialog problem.
- From: John Gill <jng europe renre com>
- To: gtk-list gnome org
- Subject: Win32 modal dialog problem.
- Date: Tue, 20 Jul 2004 13:59:37 +0100
I've been having problems with modal dialogs on win32.
Specifically, if I have a modal dialog which in turn pops up a modal dialog then I find that the second dialog comes up behind the first dialog -- it gets the focus correctly and is indeed modal, but it is concealed by the original window.
Under linux everything works as expected :)
I can get the win32 version to work a little better by setting the original window to be non-modal before popping up the second modal dialog.
See attached pygtk code for a demonstration of the problem.
Is this a bug in the win32 version of gtk or am I doing something wrong?
John
"""
Test windows modal stuff.
"""
import gtk
class App(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.set_size_request(400, 250)
vbox = gtk.VBox()
self.add(vbox)
button = gtk.Button('Press Me')
button.connect('clicked', self.on_button)
vbox.pack_start(button)
quit = gtk.Button('Quit')
quit.connect('clicked', self.on_quit)
vbox.pack_start(quit)
self.show_all()
self.connect('destroy', gtk.mainquit)
self.set_modal(True)
def on_quit(self, *args):
self.destroy()
gtk.mainquit()
def on_button(self, *args):
NestedDialog(self)
class NestedDialog(gtk.Dialog):
# Set to false to see buggy behaviour on windows
Kludge = True
def __init__(self, parent):
""" Dialog to let user chose values to filter. """
# Initialise Dialog base class
gtk.Dialog.__init__(
self, 'Filter', parent,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_OK, gtk.RESPONSE_OK,
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
self.set_size_request(400, 250)
self.vbox.pack_start(gtk.Label('Simple nesting test'),
expand=True, fill=True)
self.show_all()
# Tell parent it is not modal
if self.Kludge:
pmodal = parent.get_modal()
parent.set_modal(False)
response = self.run()
# Re-set modality of parent
if self.Kludge:
parent.set_modal(pmodal)
self.process_response(response)
def process_response(self, response):
""" Process dialog response """
if response == gtk.RESPONSE_OK:
NestedDialog(self)
self.destroy()
if __name__ == '__main__':
import sys
sys.path.insert(0, 'E:\work\python')
app = App()
gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]