安装 Boa Constructor 0.5.2

vie posted @ 2007年5月15日 06:40 in python , 7971 阅读

目前,Boa Constructor 的稳定版本为0.4.4,在python 2.4.x环境下运行正常,但在python 2.5下运行python boa.py时出现了下面的错误:

'module' object has no attribute 'NotebookSizer'

这是因为该版本与python 2.5之间不兼容。下面介绍安装最新开发版本的方法:

首先下载TortoiseCVS 最新版安装,这是一个CVS版本控制软件,下面将用来下载Boa开发版本文件。在适当的目录下新建一个文件夹,打开后在其中点击鼠标右键,选择CVS-->preferences.. 修改language为Chinese(simplified) [GB2312]。然后重新点击鼠标右键,选择CVS 取出.. ,在弹出的对话框中做如下配置:

配置

单击确认后开始下载文件。根据网速情况,大概10分钟后下载完成。

用Boa完成的一个简单的例子:

App1.py:

  1. #!/usr/bin/env python
  2. #Boa:App:BoaApp
  3.  
  4. import wx
  5.  
  6. import Frame1
  7.  
  8. modules ={'Frame1': [1, 'Main frame of Application', u'Frame1.py']}
  9.  
  10. class BoaApp(wx.App):
  11.     def OnInit(self):
  12.         self.main = Frame1.create(None)
  13.         self.main.Show()
  14.         self.SetTopWindow(self.main)
  15.         return True
  16.  
  17. def main():
  18.     application = BoaApp(0)
  19.     application.MainLoop()
  20.  
  21. if __name__ == '__main__':
  22.     main()
  23.  

 

Frame1.py:

  1. #Boa:Frame:Frame1
  2.  
  3. import wx
  4.  
  5. def create(parent):
  6.     return Frame1(parent)
  7.  
  8. [wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1BUTTON2, wxID_FRAME1PANEL1,
  9. ] = [wx.NewId() for _init_ctrls in range(4)]
  10.  
  11. class Frame1(wx.Frame):
  12.     def _init_ctrls(self, prnt):
  13.         # generated method, don't edit
  14.         wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
  15.               pos=wx.Point(495, 302), size=wx.Size(220, 106),
  16.               style=wx.DEFAULT_FRAME_STYLE, title=u'\u5173\u4e8e..')
  17.         self.SetClientSize(wx.Size(212, 79))
  18.  
  19.         self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
  20.               pos=wx.Point(0, 0), size=wx.Size(212, 79),
  21.               style=wx.TAB_TRAVERSAL)
  22.  
  23.         self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label=u'\u5173\u4e8e..',
  24.               name='button1', parent=self.panel1, pos=wx.Point(40, 40),
  25.               size=wx.Size(56, 24), style=0)
  26.         self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
  27.               id=wxID_FRAME1BUTTON1)
  28.  
  29.         self.button2 = wx.Button(id=wxID_FRAME1BUTTON2, label=u'\u9000\u51fa',
  30.               name='button2', parent=self.panel1, pos=wx.Point(128, 40),
  31.               size=wx.Size(48, 24), style=0)
  32.         self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button,
  33.               id=wxID_FRAME1BUTTON2)
  34.  
  35.     def __init__(self, parent):
  36.         self._init_ctrls(parent)
  37.  
  38.     def OnButton1Button(self, event):
  39.         info = wx.AboutDialogInfo()
  40.         info.Name = "Hello World"
  41.         info.Version = "1.0.0"
  42.         info.Copyright = "(C) 2007 viechang"
  43.         wx.AboutBox(info)
  44.  
  45.     def OnButton2Button(self, event):
  46.         self.Close(True)
  47.  

 

一个运行结果如下:

运行结果

该程序在windowsXp + python2.5 + wxpython2.8.3.0 + Boa Constructor 0.5.2 下测试通过。

附:回复求教者留言

完全可以,使用wx库就行

例如: 

  1.  
  2. import wx
  3.  
  4. #----------------------------------------------------------------------
  5.  
  6. class RichTextFrame(wx.Frame):
  7.     def __init__(self, *args, **kw):
  8.         wx.Frame.__init__(self, *args, **kw)
  9.  
  10.     def OnFileOpen(self, evt):
  11.         # This gives us a string suitable for the file dialog based on
  12.         # the file handlers that are loaded
  13.         wildcard, types = rt.RichTextBuffer.GetExtWildcard(save=False)
  14.         dlg = wx.FileDialog(self, "Choose a filename",
  15.                             wildcard=wildcard,
  16.                             style=wx.OPEN)
  17.         if dlg.ShowModal() == wx.ID_OK:
  18.             path = dlg.GetPath()
  19.             if path:
  20.                 fileType = types[dlg.GetFilterIndex()]
  21.                 self.rtc.LoadFile(path, fileType)
  22.         dlg.Destroy()
  23.  
  24.        

Avatar_small
ahmd 说:
2009年3月12日 08:27

このメッセージには返信しないでください。

自動的に送信

((( イスラームを知る )))

http://alslamjp.blogspot.com/

Avatar_small
str 说:
2009年4月19日 15:48

What's The Purpose of life ?

Here you will get the answer :

http://www.islamtomorrow.com/purpose.htm

or

The quran miracles encyclopedia

http://www.55a.net/firas/english/

or

Islam house

http://aslam-ahmd.blogspot.com/

or

An Invitation to The Truth

http://www.harunyahya.com/

Avatar_small
cleaning company dub 说:
2020年2月23日 13:23

Think you're small businesses looking for your professional cleaning issuer? Do you will have a tight spending plan? Do never worry, you may afford them easily. Together with the increasing demand from customers, the wide variety of service solutions has more than doubled. The boosting number has created a tricky competition among the list of service furnishing companies. There are helped a service seekers purchase a cleaning company at ambitious prices. The majority of offer qualified cleaning services along at the affordable fees.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter