dabo Commit
Revision 1383
Date: 2005-09-26 11:09:58 -0700 (Mon, 26 Sep 2005)
Author: paul
Changed:
U trunk/dabo/ui/uiwx/dDialog.py
Log:
Added property ReleaseOnEscape to dDialog, which sets whether or not the
dialog releases itself upon the user hitting <Esc>. Default is True, but
a possible future enhancement could be defaulting it to True only if the
dialog is Modal.
Diff:
Modified: trunk/dabo/ui/uiwx/dDialog.py
===================================================================
--- trunk/dabo/ui/uiwx/dDialog.py 2005-09-26 17:00:04 UTC (rev 1382)
+++ trunk/dabo/ui/uiwx/dDialog.py 2005-09-26 18:09:58 UTC (rev 1383)
@@ -34,6 +34,7 @@
super(dDialog, self)._afterInit()
# Hook method, so that we add the buttons last
self._addControls()
+ self.bindKey("esc", self._onEscape)
def show(self):
@@ -50,7 +51,12 @@
def hide(self):
self.Show(False)
-
+
+ def _onEscape(self, evt):
+ if self.ReleaseOnEscape:
+ self.release()
+
+
def _addControls(self):
"""Any controls that need to be added to the dialog
can be added in this method in framework classes, or
@@ -74,40 +80,67 @@
def _getAutoSize(self):
return self._fit
+
def _setAutoSize(self, val):
self._fit = val
+
+
def _getCaption(self):
return self.GetTitle()
+
def _setCaption(self, val):
if self._constructed():
self.SetTitle(val)
else:
self._properties["Caption"] = val
+
+
def _getCentered(self):
return self._centered
+
def _setCentered(self, val):
self._centered = val
+
+
def _getModal(self):
return self._modal
+
def _setModal(self, val):
self._modal = val
+
+ def _getReleaseOnEscape(self):
+ try:
+ val = self._releaseOnEscape
+ except AttributeError:
+ val = True
+ return val
+
+ def _setReleaseOnEscape(self, val):
+ self._releaseOnEscape = bool(val)
+
+
def _getShowStat(self):
# Dialogs cannot have status bars.
return False
_showStatusBar = property(_getShowStat)
+
AutoSize = property(_getAutoSize, _setAutoSize, None,
"When True, the dialog resizes to fit the added
controls. (bool)")
+
Caption = property(_getCaption, _setCaption, None,
"The text that appears in the dialog's title bar
(str)" )
+
Centered = property(_getCentered, _setCentered, None,
"Determines if the dialog is displayed centered on the
screen. (bool)")
+
Modal = property(_getModal, _setModal, None,
"Determines if the dialog is shown modal (default) or
modeless. (bool)")
+
+ ReleaseOnEscape = property(_getReleaseOnEscape, _setReleaseOnEscape,
None,
+ "Determines if the <Esc> key releases the dialog (the
default).")
-
-
class dOkCancelDialog(dDialog):
def __init__(self, parent=None, properties=None, *args, **kwargs):
self._baseClass = dOkCancelDialog
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev