dabo Commit
Revision 6508
Date: 2011-03-29 16:14:29 -0700 (Tue, 29 Mar 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6508

Changed:
U   trunk/dabo/dApp.py
A   trunk/dabo/ui/dialogs/infoMessage.py

Log:
Added dApp.displayInfoMessage() which presents a dialog with a checkbox
for the user to choose if they will see this particular message in the
future. It saves a key in the preferences to determine this.


Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2011-03-28 12:30:10 UTC (rev 6507)
+++ trunk/dabo/dApp.py  2011-03-29 23:14:29 UTC (rev 6508)
@@ -1305,6 +1305,27 @@
                pass
 
 
+       def displayInfoMessage(self, msgId, msg, defaultShowInFuture=True):
+               """
+               Displays a messagebox dialog along with a checkbox for the user
+               to specify whether or not to show this particular message again
+               in the future.
+
+               If user unchecks "show in future", saves that to the user's
+               preference file and future calls to this function with that
+               msgId will result in no message being shown.
+               """
+               prefKey = "display_info_messages.%s" % msgId
+               if not self.getUserSetting(prefKey, True):
+                       return
+               from dabo.ui.dialogs.infoMessage import DlgInfoMessage
+               dlg = DlgInfoMessage(Message=msg, 
DefaultShowInFuture=defaultShowInFuture)
+               dlg.show()
+               if not dlg.chkShowInFuture.Value:
+                       self.setUserSetting(prefKey, False)
+               dlg.release()
+ 
+
        def clearActiveForm(self, frm):
                """Called by the form when it is deactivated."""
                if frm is self.ActiveForm:

Added: trunk/dabo/ui/dialogs/infoMessage.py
===================================================================
--- trunk/dabo/ui/dialogs/infoMessage.py                                (rev 0)
+++ trunk/dabo/ui/dialogs/infoMessage.py        2011-03-29 23:14:29 UTC (rev 
6508)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+import dabo
+
+if __name__ == "__main__":
+       dabo.ui.loadUI("wx")
+
+import dabo.ui
+from dabo.dLocalize import _
+
+
+class LblMessage(dabo.ui.dLabel):
+       def initProperties(self):
+               self.WordWrap = True
+               self.FontSize = 12
+               self.Width = 500
+
+
+class DlgInfoMessage(dabo.ui.dStandardButtonDialog):
+       def initProperties(self):
+               self.AutoSize = True
+               self.ShowCaption = False
+               self.ShowCloseButton = False
+
+       def addControls(self):
+               vs = self.Sizer = dabo.ui.dSizer("v", DefaultBorder=10)
+               vs.append1x(LblMessage(self, RegID="lblMessage", 
Caption=self.Message))
+               vs.append(dabo.ui.dCheckBox(self, Caption=_("Show this message 
in the future?"), 
+                               Value=self.DefaultShowInFuture, 
RegID="chkShowInFuture",
+                               FontSize=9))
+
+
+       def _getDefaultShowInFuture(self):
+               return getattr(self, "_defaultShowInFuture", True)
+
+       def _setDefaultShowInFuture(self, val):
+               self._defaultShowInFuture = bool(val)
+
+
+       def _getMessage(self):
+               return getattr(self, "_message", "")
+
+       def _setMessage(self, val):
+               self._message = val
+
+
+       DefaultShowInFuture = property(_getDefaultShowInFuture, 
_setDefaultShowInFuture, None, 
+                       _("Specifies whether the 'show in future' checkbox is 
checked by default."))
+
+       Message = property(_getMessage, _setMessage, None,
+                       _("Specifies the message to display."))
+
+
+
+if __name__ == '__main__':
+       app = dabo.dApp(MainFormClass=None)
+       app.setup()
+       dlg = DlgInfoMessage(None, Message="This is a test of the emergency 
broadcast system. If this were an actual " \
+                       "emergency, you would have been given specific 
instructions. This is only a test.")
+       dlg.show()



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to