Controlling location of Pmw.MessageDialog (and other similar widgets)
Python newbie here, newer still to Pmw:
I have the following method defined for showing a Pmw MessageDialog box, and it works as expected and the result value is returned and posted in edit1, which is a Tkinter.Text widget; 'self' here is a Tkinter.Frame. (running Win7-32 and Python v2.7.2):
def _showMessageBar(self):
dialog = Pmw.MessageDialog(self, title = 'DBox',defaultbutton = 0,buttons('OK',Cancel'), message_text = 'DBox')
dialog.iconname(dialog['title'])
try:
result = dialog.activate()
finally:
dialog.deactivate()
self.edit1.insert(END, result+ "\n")
The problem is, the call to dialog.activate() doesn't allow me to control the location of the messageBox.
If I change that call to:
result = dialog.activate(geometry = first+50+20)
then the messageBox widget is placed at the specified coordinates, but this has two side effects:
1) The messageBox widget now has the buttons of main window (close, minimize,maximize) rather than a dialog box (just the close 'X' button)
2) The result value is never posted to edit1.
Question:开发者_开发百科 How do I control the location of the messageBox while maintaining the dialog box buttons/border and getting the value posted to the Text (edit1) widget.
TIA
The answer is that the geometry options need to be in quotes, I wasn't seeing the proper results because an exception was being thrown by the improper geometry specifier. This code:
result = dialog.activate(geometry = "first+50+20")
works fine.
精彩评论