Hi, Found a way to make an interactive display, not using threads, but with a simple tcp server hooked to a python interpreter running in the displays MainLoop().
I've attached the files (RemoteXDisplay.py goes into OCC/Display) if anyone want to check it. Still quite rough in the edges and havent stress tested it, but so far it seems to work nicely. Some modifications have to be made to a few other files though: SimpleGui.py line 105: from XDisplay import XOCCWindow w = XOCCWindow(display_xlib.Display()) becomes: from RemoteXDisplay import RemoteXOCCWindow w = RemoteXOCCWindow(display_xlib.Display()) line 115: def start_display(): w.MainLoop() becomes: def start_display(local=None): if local: w.init_server(local) w.MainLoop() PAF/Context.py line 240 def start_display(self): self._start_display(local) becomes def start_display(self, local=None): if self.DISPLAY_INITED: self._start_display(local) start_display now takes an optional argument which is the context/local where the interpreter lives, can be retrieved with globals() so in the PAF examples my_context.start_display() becomes my_context.start_display(globals()) then just start OCCRemoteClient.py Henrik Rudstrom 2009/11/16 Thomas Paviot <tpav...@gmail.com> > 2009/11/16 Thomas Paviot <tpav...@gmail.com> > > 2009/11/15 Henrik Rudstrom <hrudst...@googlemail.com> >> >>> Hi >>> >> >> Hi Henrik, >> >> >>> >>> I noticed there are no interactive viewer with the xlib graphics backend >>> like i've seen for the wx backend. Thought that would be a really nice way >>> to learn, so i made a quick attempt to roll out my own using python's >>> threading: >>> >>> in the PAF examples i replaced >>> my_context.start_display() >>> >>> with >>> >>> class ThreadedView ( threading.Thread ): >>> def __init__(self, context): >>> threading.Thread.__init__(self) >>> self.context = context >>> >>> def run ( self ): >>> self.context.start_display() >>> >>> ThreadedView(my_context).start() >>> >>> >>> This naive implementation promptly threw me a segmentation fault (also >>> tried the opposite, creating an InteractiveConsole in a separate thread, but >>> as soon as i modified any parameters same story) >>> >> >> Whatever the GUI you use, it has to be ran from the main thread (you'll >> get this segfault if you try to do the same with wx or Qt). I don't know how >> Enthought guys did with IPython, but they managed to overcome the GUI >> threading issue, but not with python-xlib. >> >> >>> >>> So my question is: Are there currently any efforts to create an >>> interactive viewer for xlib? if not, could anyone give me pointers/hints to >>> how this could be done? >>> >> >> I don't plan to create a python-xlib based interactive viewer. >> >> >>> >>> Xlib i guess is a more intermediary solution for us poor mac guys (except >>> jelle of course) so if the Qt backend is due in to too long time (??) it >>> would be a waste to put too much effort in it though. >>> >> >> Absolutely. Since python-xlib relies on low level X11 objects/methods, it >> would be necessary to develop a completely new python GUI manager from XLib. >> I know there is such a project, known as PLWM (http://plwm.sf.net), but >> never tested it. >> >> BTW, the python-xlib/PLWM dev teams both released new version of their >> softwares yesterday. >> >> >>> Oh and on the subject of xlib, the menus in the sample apps dont seem to >>> be working for me, is this a known issue or just me? >>> >> >> As I said a few days ago, I didn't move all the samples yet to the new >> graphic driver system. If you want to get them work, you have to replace the >> line: >> from wxSampleGui import display, start_display >> with: >> from SimpleGui import display, start_display. >> > > Excuse-me Henrik, my answer was out of the scope of your question. The good > answer is: with python-xlib graphic driver, hit the key 'n' (next) to switch > from a function to the next one. Since there are no menus, it's the easiest > solution I found. > > > Cheers, > > Thomas > > > > _______________________________________________ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users > >
RemoteXDisplay.py
Description: Binary data
OCCRemoteClient.py
Description: Binary data
_______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users