From: Adrian M. <adr...@ya...> - 2009-09-04 07:43:21
|
I’m using boa-constructor to create GUI in python with wxpython, and Vpython for 3D and 2D graph. Using the property “exit=false” for “display” allow me to continue with may nice GUI. The problem is that with gcurve this property doesn’t work! I’m wrong, some ideas? Below is the code… (you need to install wxpython) (tested in Linux debian python2.5 and vpython 3.n; and in windows python2.6 vpython5) Build with boa-constructor need wxpython File: Frame1.py ______________________________________________ #Boa:Frame:Frame1 import wx from visual import * from visual.graph import * def create(parent): return Frame1(parent) [wxID_FRAME1] = [wx.NewId() for _init_ctrls in range(1)] [wxID_FRAME1MENU1TEST2D, wxID_FRAME1MENU1TEST3D, ] = [wx.NewId() for _init_coll_menu1_Items in range(2)] class Frame1(wx.Frame): def _init_utils(self): # generated method, don't edit self.menu1 = wx.Menu(title='') self.menuBar1 = wx.MenuBar() self._init_coll_menu1_Items(self.menu1) self._init_coll_menuBar1_Menus(self.menuBar1) def _init_coll_menuBar1_Menus(self, parent): # generated method, don't edit parent.Append(menu=self.menu1, title=u'File') def _init_coll_menu1_Items(self, parent): # generated method, don't edit parent.Append(help='', id=wxID_FRAME1MENU1TEST3D, kind=wx.ITEM_NORMAL, text=u'test 3D') parent.Append(help='', id=wxID_FRAME1MENU1TEST2D, kind=wx.ITEM_NORMAL, text=u'test 2D') self.Bind(wx.EVT_MENU, self.OnMenu1Test3dMenu, id=wxID_FRAME1MENU1TEST3D) self.Bind(wx.EVT_MENU, self.OnMenu1Test2dMenu, id=wxID_FRAME1MENU1TEST2D) def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(486, 335), size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1') self._init_utils() self.SetClientSize(wx.Size(392, 216)) self.SetMenuBar(self.menuBar1) def __init__(self, parent): self._init_ctrls(parent) # &&&&&&&&&&&&&&&&&&&&&&& That is the Vpython Code &&&&&&&&&&&&&& def OnMenu1Test3dMenu(self, event): #Work scene=display(title='Un ejemplo') scene.exit=false floor = box(length=4, height=0.5, width=4, color=color.blue) ball = sphere(pos=(0,4,0), color=color.red) ball.velocity = vector(0,-1,0) def OnMenu1Test2dMenu(self, event): #Work but close the GUI at the end! oscillation = gdisplay(xtitle='Time', ytitle='Response') oscillation.exit=false #don't work funct1 = gcurve(color=color.cyan) funct2 = gvbars(delta=0.5, color=color.red) funct3 = gdots(color=color.yellow) for t in arange(-30, 74, 1): funct1.plot( pos=(t, 5.0+5.0*cos(-0..2*t)*exp(0.015*t)) ) funct2.plot( pos=(t, 2.0+5.0*cos(-0.1*t)*exp(0.015*t)) ) funct3.plot( pos=(t, 5.0*cos(-0.03*t)*exp(0.015*t)) ) ________________________________________________ File: App1.py (run this file..) ______________________________________________ #!/usr/bin/env python #Boa:App:BoaApp import wx import Frame1 modules ={'Frame1': [1, 'Main frame of Application', u'Frame1.py']} class BoaApp(wx.App): def OnInit(self): self.main = Frame1.create(None) self.main.Show() self.SetTopWindow(self.main) return True def main(): application = BoaApp(0) application.MainLoop() if __name__ == '__main__': main() |