Start a new topic

Python and Tkinter

Original Post by: gmendieta Wed Oct 2 18:26:14 2013


Hi all!!

I m trying to make some user interfaces using python. In order to do that, i directly append a python25 installation using sys.path.append("python25_path"), and some others paths in order to make python able to get the dlls and tkinter necessary modules.

I have achieved to change the scene directly from a button of tkinter, for example

Anyway, the problem i have is that, due to app.mainloop() of tkinter, i have to force presagis creator to refresh the window, but i dont know how to use mgRefreshScene() from python, because i dont know hoy to get mgeditorcontext from python.


I need some advice. Even, if someone has tested the new Creator 13 and has noticed some important changes of the API in the field of python user interfaces, id like to know.


Of course, i have get this piece of code working, ill post the code i have written. I guess its an awesome thing to have python interfaces within Creator.


Thanks in advance


Gorka


1 person has this problem

Original Post by: SteveThompson Wed Oct 2 18:37:35 2013


I have achieved to change the scene directly from a button of tkinter, for example.

Anyway, the problem i have is that, due to app.mainloop() of tkinter, i have to force presagis creator to refresh the window, but i dont know how to use mgRefreshScene() from python, because i dont know hoy to get mgeditorcontext from python.

First, this sounds great that you have gotten tkinter to work inside Creator. Admittedly OpenFlight script offers very little "native" UI support. Anything you can share with us (about your experience) will help us enhance Creator to better support UI (for scripts) in the future.


Second, if you make a change to the "current" database in Creator, you should not have to call mgRefreshScene() to see it. At least that is the intention. Creator "monitors" the changes you make and should trigger the scene to refresh automatically. mgRefreshScene is for the changes Creator might have missed. Perhaps there is something Creator is not "monitoring" correctly? Can you tell us what exactly you "changed" that you don't see get refreshed automatically? And if you "force a redraw" (spin the model) does the change get refreshed then? This will help us identify something that needs to be "monitored" better ;-)


Finally, if you are making a tool that "changes" the scene, you should create an "editor context" using mgNewEditorContext. You need one of these to "play nicely" with other "editor" tools that should all play together. You can use this "editor context" to refresh the scene manually. There are sample scripts in the samples/scripts/creatortools that show how to make a "proper" editor tool.


Thanks in advance for any additional feedback you can provide.

Original Post by: gmendieta Wed Oct 2 18:55:58 2013


Yeappp!!! I have already read the first of all tool python example, and eurekaaa, i guess the solution is that. i have been modifying the scene directly from a python script. Tomorrow, with the code in front of me, ill try that. I know that if you code a C plugin, its necessary to create an editor tool, as its written in the 2 volume of the api reference, but i thought that using python script i could directly do it. So, i would change my code and post again to show what im doing.

I guess im going to have some problems to give focus to a window inside creator, and my tkinter windows are going to hide all the time, but till now its a good advance.

So tomorrow ill post my code.

Thank u so much.


p.d. i was creating some group records ( guess the problem is the editor context definition ), and creator refresh the information, but only redraw it when i give the focus to the creator scene window

Original Post by: gmendieta Fri Oct 4 15:56:49 2013


As i wrote yesterday, i attach the example i wrote. Its the first attemp to get a TkInter interface inside Creator. Its mandatory to have python2.5.4 x86 installed in C:\\Python25

Hope useful. Id like to have ur feedback and ideas.


EDIT: I have just noticed that the mouse works correctly. I mean, i can attach a node to another with the interface opened, and even im able to delete a node, only if i use Edit->Delete. It doesnt work if i try to use the supr key from the keyboard.

Login to post a comment