commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8063 - gnuradio/branches/developers/michaelld/wxgui/g


From: michaelld
Subject: [Commit-gnuradio] r8063 - gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python
Date: Thu, 20 Mar 2008 08:40:24 -0600 (MDT)

Author: michaelld
Date: 2008-03-20 08:40:24 -0600 (Thu, 20 Mar 2008)
New Revision: 8063

Modified:
   gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py
Log:
Better way to determine which API to use when instantiating the
user-provided top_block creation class.

Converted from UpperCamelCase to lower_case function names for DoClose
and DoSetup .



Modified: 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py
===================================================================
--- gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py 
2008-03-20 13:46:19 UTC (rev 8062)
+++ gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py 
2008-03-20 14:40:24 UTC (rev 8063)
@@ -56,7 +56,7 @@
         self.SetTopWindow (frame)
 
         # set up the app, including finally starting the top_block
-        frame.DoSetup ()
+        frame.do_setup ()
         return True
 
 class stdframe (wx.Frame):
@@ -80,12 +80,12 @@
            mainmenu = wx.MenuBar ()
             menu = wx.Menu ()
             item = menu.Append (200, 'E&xit', 'Exit')
-            self.Bind (wx.EVT_MENU, self.DoClose, item)
+            self.Bind (wx.EVT_MENU, self.do_close, item)
             mainmenu.Append (menu, "&File")
             self.SetMenuBar (mainmenu)
 
-        # bind the frame's close event to the local DoClose method
-        self.Bind (wx.EVT_CLOSE, self.DoClose)
+        # bind the frame's close event to the local do_close method
+        self.Bind (wx.EVT_CLOSE, self.do_close)
 
         # create the panel, which in turn will call the user's
         # code to create the whole GUI & top_block & such
@@ -110,7 +110,7 @@
         if pos == wx.DefaultPosition:
             self.Centre ()
 
-    def DoClose (self, event):
+    def do_close (self, event):
         """
         Close this frame.  Will tell the panel to close first, then
         destroy itself (which will also close itself).  All incoming
@@ -120,7 +120,7 @@
             print "stdframe::Close() Starting."
 
         # tell the panel to close itself
-        self.panel.DoClose ()
+        self.panel.do_close ()
 
         # tell this frame to destroy itself
         self.Destroy ()
@@ -142,18 +142,18 @@
         """
         return self.panel.top_block
 
-    def DoSetup (self):
+    def do_setup (self):
         """
         Any application-specific post-GUI layout setup goes here.
         For now, just tell the created panel to do its setup.
         """
         if self._debug:
-            print "stdframe::DoSetup() Starting."
+            print "stdframe::do_setup() Starting."
 
-        self.panel.DoSetup ()
+        self.panel.do_setup ()
 
         if self._debug:
-            print "stdframe::DoSetup() Returning."
+            print "stdframe::do_setup() Returning."
 
 class stdpanel (wx.Panel):
     def __init__ (self, parent, top_block_maker, usage, debug):
@@ -167,48 +167,53 @@
         # create a vertical (auto) sizer box for placing GUI items
         vbox = wx.BoxSizer (wx.VERTICAL)
 
-        # call the method for creating the top_block
-        try:
-            # try the "new" method first
+        # the function call to create the top_block depends on the
+        # number of arguments.
+        if top_block_maker.__init__.func_code.co_argcount == 7:
+            # "new" method
+            if debug:
+                print "stdpanel::__init__: Using new method to create 
top_block"
             self.top_block = top_block_maker (parent, self, vbox, sys.argv,
                                               usage, debug)
-        except:
-            # try the "old" method second
+        else:
+            # "old" method
+            if debug:
+                print "stdpanel::__init__: Using old method to create 
top_block"
             self.top_block = top_block_maker (parent, self, vbox, sys.argv)
 
         self.SetSizer (vbox)
         self.SetAutoLayout (True)
         vbox.Fit (self)
 
-    def DoClose (self):
+    def do_close (self):
         if self._debug:
-            print "stdpanel:DoClose() Starting."
+            print "stdpanel:do_close() Starting."
 
         # tell the top_block to close itself
-        self.top_block.DoClose ()
+        self.top_block.do_close ()
 
         # stop the top_block
         self.top_block.stop ()
 
         if self._debug:
-            print "stdpanel:DoClose() Starting."
+            print "stdpanel:do_close() Starting."
 
-    def DoSetup (self):
+    def do_setup (self):
         """
         Set up the application - anything that must be done before
         starting the top_block running.
         """
         if self._debug:
-            print "stdpanel::DoSetup() Starting."
+            print "stdpanel::do_setup() Starting."
 
         # set up the top_block (to be overloaded by the user's app)
-        self.top_block.DoSetup ()
+        self.top_block.do_setup ()
 
         # set the top_block going
         self.top_block.start ()
 
         if self._debug:
-            print "stdpanel::DoSetup() Returning."
+            print "stdpanel::do_setup() Returning."
 
     def set_status_text (self, text, which=0):
         """
@@ -226,11 +231,11 @@
         self._parent = panel
         self._debug = debug
 
-    def DoClose (self):
+    def do_close (self):
         # overload for the specific user's app
         pass
 
-    def DoSetup (self):
+    def do_setup (self):
         # overload for the specific user's app
         pass
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]