[Commits] (morgen) Added a simple Yes/No dialog, and moved some code from Main.py to the sharing

commits at osafoundation.org commits at osafoundation.org
Mon Aug 23 11:59:10 PDT 2004


Commit by: morgen
Modified files:
chandler/application/dialogs/Util.py 1.2 1.3
chandler/parcels/osaf/views/main/Main.py 1.38 1.39

Log message:
Added a simple Yes/No dialog, and moved some code from Main.py to the sharing
parcel.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/dialogs/Util.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.38&r2=text&tr2=1.39

Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.38 chandler/parcels/osaf/views/main/Main.py:1.39
--- chandler/parcels/osaf/views/main/Main.py:1.38	Fri Aug 20 12:39:22 2004
+++ chandler/parcels/osaf/views/main/Main.py	Mon Aug 23 11:59:08 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.38 $"
-__date__ = "$Date: 2004/08/20 19:39:22 $"
+__version__ = "$Revision: 1.39 $"
+__date__ = "$Date: 2004/08/23 18:59:08 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -18,9 +18,9 @@
 import osaf.contentmodel.tests.GenerateItems as GenerateItems
 from repository.persistence.RepositoryError import VersionConflictError
 import repository.util.UUID as UUID
-import osaf.framework.webdav.Dav
+import osaf.framework.sharing.Sharing
+
 
-EVENTS = "http://osafoundation.org/parcels/osaf/framework/blocks/Events"
 
 class MainView(View):
     """
@@ -57,15 +57,8 @@
         notification.data ['Enable'] = False
 
     def onSharingSubscribeToCollectionEvent(self, notification):
-        url =  application.dialogs.Util.promptUser( \
-         Globals.wxApplication.mainFrame, "Subscribe to Collection...",
-         "Collection URL:", "http://code-bear.com/dav/test_item_collection")
-        if url is not None:
-            collection = osaf.framework.webdav.Dav.DAV(url).get( )
-            event = Globals.parcelManager.lookup(EVENTS,
-             "NewItemCollectionItem")
-            event.Post({'collection':collection})
-            Globals.repository.commit()
+        # Triggered from "Tests | Subscribe to collection..."
+        osaf.framework.sharing.Sharing.manualSubscribeToCollection()
 
     def onEditAccountPreferencesEvent (self, notification):
         # Triggered from "File | Prefs | Accounts..."

Index: chandler/application/dialogs/Util.py
diff -u chandler/application/dialogs/Util.py:1.2 chandler/application/dialogs/Util.py:1.3
--- chandler/application/dialogs/Util.py:1.2	Thu Aug 19 14:16:35 2004
+++ chandler/application/dialogs/Util.py	Mon Aug 23 11:59:07 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.2 $"
-__date__ = "$Date: 2004/08/19 21:16:35 $"
+__version__ = "$Revision: 1.3 $"
+__date__ = "$Date: 2004/08/23 18:59:07 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -109,8 +109,8 @@
              self.chandlerTextControls[i].GetValue())
             i += 1
 
-# A simple "prompt-the-user-for-a-string" dialog
 
+# A simple "prompt-the-user-for-a-string" dialog
 
 def promptUser(frame, title, message, value):
     """ Prompt the user to enter in a string.  Return None if cancel is hit.
@@ -173,8 +173,8 @@
 
         sizer.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
 
-        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
-        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
+        # line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
+        # sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
 
         box = wx.BoxSizer(wx.HORIZONTAL)
 
@@ -185,7 +185,7 @@
         btn = wx.Button(self, wx.ID_CANCEL, " Cancel ")
         box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
 
-        sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+        sizer.Add(box, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
 
         self.SetSizer(sizer)
         self.SetAutoLayout(True)
@@ -197,3 +197,67 @@
 
     def GetValue(self):
         return self.textControl.GetValue()
+
+
+# A simple "yes/no" dialog
+
+def promptYesNo(frame, title, message):
+    """ Prompt the user with a Yes/No dialog.  Return True if Yes, False if No.
+        @param frame: A wx parent frame
+        @type frame: wx frame
+        @param title: The title string for the dialog
+        @type title: 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:
+        value = True
+    else:
+        value = False
+
+    win.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, [300,-1],
+         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)



More information about the Commits mailing list