2009/12/11 Henrik Rudstrom <hrudst...@googlemail.com> > 2009/12/10 Simon Loic <simon1l...@gmail.com> > >> hi, >> >> Happy to see new ideas woming around. >> >> >>> Or you could just include a bit of javascript: >>> http://google-code-prettify.googlecode.com/svn/trunk/README.html or >>> more<http://www.1stwebdesigner.com/resources/16-free-javascript-code-syntax-highlighters-for-better-programming/> >>> >> >> Why not! It migth be simpler than Pygment for highlighting. >> > A very elegant solution actually. If the browser can do the job for us, it's even better.
> >> >>> Instead of addings somthting to the samples, you could just read in the >>> file, modify it with a script and write it to a temp file to be executed. >>> Think you could automate quite a lot of them with some some regular >>> expressions a bit more complex than this: >>> >>> for line in source.readlines(): >>> line = re.sub("display.DisplayShape\(([.\ ]*)\)", lambda m: >>> "offscreen.add_shape(%s)" % m.group(1), line) >>> line = re.sub("start_display\((.*)\)", lambda m: >>> "offscreen_render(%s)" % m.group(1), line) >>> line = re.sub("add_function_to_menu\((.+),(.+)\)", lambda m: >>> "clear_display()\n%s(filename)\noffscreen_render()" % m.group(2).strip(), >>> line) >>> >> >> I don't know the samples very well, in particular if they all us the exact >> same code sequence for display. Anyway, personally I don't like very much >> this kind of parsing, as it is IMHO error prone. Besides, it may require >> more efforts to maintain (as the regular expressions have to be updated if >> the syntax of display change). However, I admit this reduces changes in the >> samples code. >> > In my mind, a simple copy/paste of the python code to an html page is enough. regexp are certainly very powerful, but I never understood anything and am completely unable to read regexp python code! The solution must be easy to use and, most important, be robust since the samples often change (new ones, deleted deprecated ones, modifications etc.). To be pragmatic, here is what I want: - a script, for instance 'convert_samples_to_html.py' that I launch once, - the script finds all the .py files in the /src/samples/* directory, - run each sample to get the screenshot, - create one html page for each sample, - at the end, a kind of 'index.html' shows all the available samples with hyperlinks to each one. The javascript highlighting solution is good and simple, let's go for it. > Actually a pretty backwards idea when i think of it now, (doing way to much > regexp's lately) actually the way to do it is to let the the offscreen > writer hijack the display object by replacing the import > After a few experiments, the off-screen rendering feature seems not available for OCC (see this thread on the OCC forum: http://www.opencascade.org/org/forum/thread_17706/). But I'm still waiting for other advices that may help. As a consequence, the sample window has to be displayed. Getting the screenshot from the sample can be done from a ipython session (which is wx thread safe). You can for instance: ipython -wthread >> import sample >> sample.start_display() >>sample.display.View.Dump("the_file") I can be done from a pipe. > > Henrik > Cheers, Thomas
_______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users