[Commits] (morgen) Using standard wx dialogs for yes/no and ok
dialogs.
commits at osafoundation.org
commits at osafoundation.org
Wed Sep 15 17:00:03 PDT 2004
Commit by: morgen
Modified files:
chandler/application/dialogs/Util.py 1.6 1.7
chandler/parcels/osaf/framework/sharing/Sharing.py 1.15 1.16
chandler/parcels/osaf/views/main/Main.py 1.59 1.60
Log message:
Using standard wx dialogs for yes/no and ok dialogs.
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/dialogs/Util.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/sharing/Sharing.py.diff?r1=text&tr1=1.15&r2=text&tr2=1.16
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.59&r2=text&tr2=1.60
Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.59 chandler/parcels/osaf/views/main/Main.py:1.60
--- chandler/parcels/osaf/views/main/Main.py:1.59 Tue Sep 14 18:30:59 2004
+++ chandler/parcels/osaf/views/main/Main.py Wed Sep 15 17:00:01 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.59 $"
-__date__ = "$Date: 2004/09/15 01:30:59 $"
+__version__ = "$Revision: 1.60 $"
+__date__ = "$Date: 2004/09/16 00:00:01 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -345,7 +345,8 @@
"""
Globals.wxApplication.mainFrame.GetStatusBar().blockItem.setStatusMessage (statusMessage, progressPercentage)
if alert:
- application.dialogs.Util.showAlert(Globals.wxApplication.mainFrame, statusMessage)
+ application.dialogs.Util.ok(Globals.wxApplication.mainFrame,
+ "", statusMessage)
self.setStatusMessage ('')
def SharingInvitees (self, itemCollection):
Index: chandler/parcels/osaf/framework/sharing/Sharing.py
diff -u chandler/parcels/osaf/framework/sharing/Sharing.py:1.15 chandler/parcels/osaf/framework/sharing/Sharing.py:1.16
--- chandler/parcels/osaf/framework/sharing/Sharing.py:1.15 Mon Sep 13 14:28:37 2004
+++ chandler/parcels/osaf/framework/sharing/Sharing.py Wed Sep 15 17:00:01 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.15 $"
-__date__ = "$Date: 2004/09/13 21:28:37 $"
+__version__ = "$Revision: 1.16 $"
+__date__ = "$Date: 2004/09/16 00:00:01 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -35,20 +35,22 @@
collectionName, url)
collection = collectionFromSharedUrl(url)
if collection is not None:
- application.dialogs.Util.showAlert( \
- Globals.wxApplication.mainFrame,
- "Received an invite for an already subscribed collection:\n"
+ application.dialogs.Util.ok( \
+ Globals.wxApplication.mainFrame, "Sharing Invitation",
+ "Received an invite for an already subscribed collection:\n" \
"%s\n%s" % (collection.displayName, url))
else:
- if application.dialogs.Util.promptYesNo( \
+ if application.dialogs.Util.yesNo( \
Globals.wxApplication.mainFrame, "Sharing Invitation",
- "%s\nhas invited you to subscribe to '%s'\nWould you like to accept the invitation?" % (fromAddress, collectionName) ):
+ "%s\nhas invited you to subscribe to '%s'\n" \
+ "Would you like to accept the invitation?" \
+ % (fromAddress, collectionName) ):
subscribeToWebDavCollection(url)
def _errorCallback(self, notification):
# When we receive this event, display the error
error = notification.data['error']
- application.dialogs.Util.showAlert( \
+ application.dialogs.Util.ok( \
Globals.wxApplication.mainFrame, error)
@@ -60,7 +62,7 @@
# See if we are already subscribed to the collection
if collection is not None:
- application.dialogs.Util.showAlert( \
+ application.dialogs.Util.ok( \
Globals.wxApplication.mainFrame,
"Already subscribed to collection '%s':\n"
"%s" % (collection.displayName, url))
Index: chandler/application/dialogs/Util.py
diff -u chandler/application/dialogs/Util.py:1.6 chandler/application/dialogs/Util.py:1.7
--- chandler/application/dialogs/Util.py:1.6 Wed Aug 25 16:30:08 2004
+++ chandler/application/dialogs/Util.py Wed Sep 15 17:00:00 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.6 $"
-__date__ = "$Date: 2004/08/25 23:30:08 $"
+__version__ = "$Revision: 1.7 $"
+__date__ = "$Date: 2004/09/16 00:00:00 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -203,87 +203,43 @@
# A simple "yes/no" dialog
-def promptYesNo(frame, title, message):
+def yesNo(parent, caption, message):
""" Prompt the user with a Yes/No dialog. Return True if Yes, False if No.
- @param frame: A wx parent frame
+ @param parent: A wx parent
@type frame: wx frame
- @param title: The title string for the dialog
- @type title: String
+ @param caption: The caption string for the dialog
+ @type caption: String
@param message: A message prompting the user for input
@type item: String
-
"""
- win = yesNoDialog(frame, -1, title, message)
- win.CenterOnScreen()
- val = win.ShowModal()
- if val == wx.ID_OK:
+ dlg = wx.MessageDialog(parent, message, caption,
+ wx.YES_NO | wx.ICON_QUESTION)
+ val = dlg.ShowModal()
+
+ if val == wx.ID_YES:
value = True
else:
value = False
- win.Destroy()
+ dlg.Destroy()
return value
-class yesNoDialog(wx.Dialog):
- def __init__(self, parent, ID, title, message,
- size=wx.DefaultSize, pos=wx.DefaultPosition,
- style=wx.DEFAULT_DIALOG_STYLE):
-
- # Instead of calling wx.Dialog.__init__ we precreate the dialog
- # so we can set an extra style that must be set before
- # creation, and then we create the GUI dialog using the Create
- # method.
- pre = wx.PreDialog()
- pre.Create(parent, ID, title, pos, size, style)
-
- # This next step is the most important, it turns this Python
- # object into the real wrapper of the dialog (instead of pre)
- # as far as the wxPython extension is concerned.
- self.this = pre.this
-
- # Now continue with the normal construction of the dialog
- # contents
- sizer = wx.BoxSizer(wx.VERTICAL)
- label = wx.StaticText(self, -1, message, wx.DefaultPosition, [450,80],
- wx.ALIGN_CENTRE)
- sizer.Add(label, 0, wx.ALIGN_CENTER|wx.ALL, 5)
-
- box = wx.BoxSizer(wx.HORIZONTAL)
-
- btn = wx.Button(self, wx.ID_OK, " Yes ")
- btn.SetDefault()
- box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
-
- btn = wx.Button(self, wx.ID_CANCEL, " No ")
- box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
-
- sizer.Add(box, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
-
- self.SetSizer(sizer)
- self.SetAutoLayout(True)
- sizer.Fit(self)
# A simple alert dialog
-def showAlert(parent, message):
- xrcFile = os.path.join(application.Globals.chandlerDirectory,
- 'application', 'dialogs', 'Alert_wdr.xrc')
- resources = wx.xrc.XmlResource(xrcFile)
- frame = alertDialog(parent, resources, message=message)
- frame.ShowModal()
- frame.Destroy()
-
-class alertDialog(wx.Dialog):
- def __init__(self, parent, resources, message=""):
- pre = wx.PreDialog()
- self.resources = resources
- resources.LoadOnDialog(pre, parent, 'Alert')
- self.this = pre.this
- text = wx.xrc.XRCCTRL(self, "ID_TEXT")
- text.SetLabel(message)
- wx.EVT_BUTTON( self, wx.xrc.XRCID( "ID_OK" ), self.OnOk )
+def ok(parent, caption, message):
+ """ Display a message dialog with an OK button
+ @param parent: A wx parent
+ @type frame: wx frame
+ @param caption: The caption string for the dialog
+ @type caption: String
+ @param message: A message
+ @type item: String
+ """
- def OnOk(self, evt):
- self.EndModal(True)
+ dlg = wx.MessageDialog(parent, message, caption,
+ wx.OK | wx.ICON_INFORMATION)
+ dlg.ShowModal()
+ dlg.Destroy()
More information about the Commits
mailing list