473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,404 developers and data experts.

wx.Wizard creates pages using eval() in a List comprehension

bartonc
6,596 Expert 4TB
Examples of wx.Wizard that I found used explicit names for the pages.
Using eval() in a list comprehension, I am able to go through the imported modules by name and call create() in order to get a page instance. Neat trick, I think...
Expand|Select|Wrap|Line Numbers
  1. #Boa:Wizard:Wizard1
  2.  
  3. import wx
  4. import wx.wizard
  5.  
  6. import SetupWizardPage1
  7. import SetupWizardPage2
  8.  
  9. nSetupWizardPages = 2
  10.  
  11. def create(parent):
  12.     return Wizard1(parent)
  13.  
  14. [wxID_WIZARD1] = [wx.NewId() for _init_ctrls in range(1)]
  15.  
  16. class Wizard1(wx.wizard.Wizard):
  17.     def _init_ctrls(self, prnt):
  18.         # generated method, don't edit
  19.         wx.wizard.Wizard.__init__(self, bitmap=wx.NullBitmap, id=wxID_WIZARD1, parent=prnt,
  20.               pos=wx.Point(459, 285), title='HETAP Data Collection Setup')
  21.  
  22.     def __init__(self, parent):
  23.         self._init_ctrls(parent)
  24.  
  25.     ## the old way
  26. ##        page1 = SetupWizardPage1.ParkListPage(self)
  27. ##        self.page1 = page1
  28. ##        page2 = SetupWizardPage2.TrailListPage(self)
  29.  
  30.     ## I had to add create() to the SimpleWizardPage generated by Boa
  31.         self.pages = pages = [eval("SetupWizardPage%d.create(self)" %i)
  32.                               for i in range(1, nSetupWizardPages + 1)]
  33.  
  34.         self.FitToPage(pages[0])
  35.  
  36.     ## Once they're in a list, chaining becomes a snap
  37.         for i in range(nSetupWizardPages - 1):
  38.             # Use the convenience Chain function to connect the pages in a loop
  39.             wx.wizard.WizardPageSimple_Chain(pages[i], pages[i + 1])
  40.  
  41.  
  42.         self.GetPageAreaSizer().Add(pages[0])
  43.  
  44.     def GetFirstPage(self):
  45.         """I make the wizard responsible for creating the pages, so the caller must
  46.            be able to get the first page for the Wizard.Run() argument"""
  47.         return self.pages[0]
Dec 20 '06 #1
0 5275

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: jsaul | last post by:
Hi there, wouldn't it be useful to have a 'while' conditional in addition to 'if' in list comprehensions? foo = for i in bar: if len(i) == 0: break foo.append(i)
23
by: Fuzzyman | last post by:
Pythons internal 'pointers' system is certainly causing me a few headaches..... When I want to copy the contents of a variable I find it impossible to know whether I've copied the contents *or*...
7
by: PaulThomas | last post by:
I am fighting with XP-Pro and VS.Net trying to allow some of the pages in my application to be accessable by 'all' I am using <authentication mode="Forms" /> and if I Login - everything works...
6
by: Douglas J. Badin | last post by:
Earlier this month, there was a posting about this without a definitive answer. If you place a Wizard inside a FormView's EditItemTemplate the bound fields contained within the View will display...
1
by: siva.isukapalli | last post by:
Hi, We are involved in a porting project (from VC++ 6.0 to .Net VC++ 7.1). ** NOT C# or VB..NET. We have a custom app wizard written in 6.0. This basically creates a project with a set of...
10
by: Debajit Adhikary | last post by:
I have two lists: a = b = What I'd like to do is append all of the elements of b at the end of a, so that a looks like: a =
4
by: Jeff | last post by:
I've been working on porting some perl CMS code to PHP. What I would do in perl is search through a template for instruction and replace those instructions with specific bits for that particular...
9
by: markla | last post by:
Hi, I have an EDM model, which I'm rendering using DynamicData pages. I need to add a derived/calculated field. For example, in a "Person" entity, I have LastName and FirstName. I need to...
0
by: Lie Ryan | last post by:
On Tue, 30 Sep 2008 16:04:34 -0500, William Purcell wrote: when you pass mydict, it is used as the global variables in the eval, right? Then, you passed a code to eval('...', mydict), sometimes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.