From: Chris F. <cf...@th...> - 2010-07-20 07:46:55
|
You can run Visual Python "alongside" any toolkit, I believe. You can do this with most toolkits, actually, it's just a tricky juggling act, and usually not worth it. All you need to do is run one event loop at a time, and swap between (among?!) them. I've done this with wx and Tkinter in the past. I use GTK and VPython together. GTK has a quirk, though. On Windows, you need to tell GTK about it if you're using multithreading. Yeah, the naive approach runs fine (for the limited tests I've done, there's probably a way to break it) on Linux. Point is, VPython runs in a background thread under the hood, so you need this element if you're on Windows. Here's some demo code: ---------------------------------------------------------- import pygtk pygtk.require('2.0') import gtk from visual import display, frame, convex, color class GtkApp(gtk.Window): def buildVisual(self): scene0 = display(title='Visual Python') f = frame() half1 = convex(frame=f, pos=[ [-0.5,-0.5,-0.5], [0.5,0.5,0.5],[0.0,-0.5,0.5], [0.0,0.5,-0.5], [0.5,-0.5,0.5], [0.5,-0.5,-0.5], [0.5,0.5,-0.5] ], color=color.cyan) half0 = convex(frame=f, pos=[ [-0.5,-0.5,-0.5], [0.5,0.5,0.5], [0.0,-0.5,0.5], [0.0,0.5,-0.5], [-0.5,0.5,-0.5],[-0.5,0.5,0.5],[-0.5,-0.5,0.5] ], color=(0.0,.5,1.0)) def onPress(self, w): print 'close the Visual Python window to exit' def buildGUI(self): box = gtk.VBox(False, 0) btn = gtk.Button('press me') btn.connect('clicked', self.onPress) btn.set_border_width(5) box.pack_start(btn, False, False, 0) btn.show() self.add(box) box.show() def __init__(self): gtk.Window.__init__(self) self.set_title('GIMP Toolkit') self.buildGUI() self.buildVisual() if __name__ == '__main__': gtk.gdk.threads_init() myapp = GtkApp() myapp.show() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave() ---------------------------------------------------------- Here's the relevant bit in the pygtk faq: http://faq.pygtk.org/index.py?req=show&file=faq20.006.htp I believe VPython will run your callbacks/handlers in the main thread, but check this before you try to call pygtk from the wrong thread.. ack! Cheers! On Tuesday 20 July 2010, Stefano Mtangoo wrote: > Hello friends, > I have been for long out of Vpython for long now, but I have plans to > develop Scientific simulation > Program for Physics students. As we know, Visual Did not support > integration with wxPython or any toolkit. > Is that possible now? If no what are plans to implement that feature? > Thanks > > --------------------------------------------------------------------------- > --- This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |