![]() ![]() But this is a lot more complicated I think the other solution will probably work a lot better for you. Mixing waiting on multiprocessing async results with a tkinter event loop is a bit of a pain, but if you use concurrent.futures, you can just attach the create_image as a callback on the Future returned by the task.Ī different option is to have the background processes create off-screen Canvas objects, draw to them, then capture the results as a BitmapImage or a postscript rendering, which you can then pass to the main process to blit onto a Canvas of its own. So the only Canvas command you need is create_image.Īnd, in fact, you can probably do with tasks on a Pool, which just return the image when they're done, with the main process doing the create_image with the results. The simplest solution is to marshal your Canvas commands and pass them over a Pipe or Queue for the main process to execute.Ī fully general solution isn't that hard, but in your case, it should be even simpler: all you want the background process to do is process an image and then display it. However, that doesn't mean there's no way to do what you want, just that you can't do it directly. ![]() ![]() The following example stores the last values of the position of the mouse to draw a line to the current value. So, the result may be that nothing shows up, that one or both processes freezes, that the GUI doesn't respond to events, that tkinter raises an exception in the child, that tkinter creates a whole separate independent GUI, or, if you're really unlucky, that things unpredictably work sometimes but do one of the other things other times. You could use continuous drawing instead of drawing separate small circles. The Tkinter module is a thin object-oriented layer on top of Tcl/Tk. Then you put buttonsframe in column 1 and it will overlap tableframe. It provides a robust and platform independent windowing toolkit, that is available to Python programmers using the Tkinter module, and its extensions, the Tix and the ttk modules. It is because you have used columnspan3 for tableframe, so tableframe will be across 3 columns, 0 to 2. On some platforms, it just isn't possible at all on other platforms, it would be possible, but only by doing things very differently from the way Tk does on others, it sort of works, but the event loops are all screwed up. Tk/Tcl has long been an integral part of Python. When you are done developing, rerun the command, this time without the -A, like so: python setup.py py2app. Embedding in Tk Embedding in wx 2 Embedding in wx 3. The -A makes the app respond to updates in the code, but makes the app unsharable. Bayesian Methods for Hackers style sheet Dark background style sheet FiveThirtyEight style. GUI widgets cannot be shared between processes. Step 3: Then open the bash terminal in the dictionary the file is in and type this command: python setup.py py2app -A. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |