I would like to integrate a Python shell into my application. I tried 'wx.py.shell' and this works quite well.
But I can import '__main__' and modify all my application. I would prefer to give access to some specific functions/objects.
Moreover, I would like to update the GUI while functions are launched from the shell. But when some function calls are wrapped into one function which is launched, I would like to update the GUI only once (not for each call of each function).
Do you have any suggestion/hint?
Regards,
Mathias Lorente
I use an integrated shell in the application I have been developing
(Mekanimo) and I think it is so nice that users can access any part of
the application including the GUI from the shell. As a matter of fact
now I am developing the new features from the shell first, and then
integrate them into the GUI. So, some advanced users may be able to
modify the application in ways you never imagined and I think this is
a really powerful feature.
If you really want to restrict access (I am not even sure if this is
possible) please check
if you succeed stopping the bad guys without inconveniencing the good
ones please let me know.
Regards,
Fahri
···
On Thu, Feb 12, 2009 at 3:31 AM, Mathias Lorente <mathias.lorente@insilicio.com> wrote:
Dear list,
I would like to integrate a Python shell into my application. I tried
'wx.py.shell' and this works quite well.
But I can import '__main__' and modify all my application. I would prefer to
give access to some specific functions/objects.
Moreover, I would like to update the GUI while functions are launched from
the shell. But when some function calls are wrapped into one function which
is launched, I would like to update the GUI only once (not for each call of
each function).
Do you have any suggestion/hint?
Regards,
Mathias Lorente
On Thu, Feb 12, 2009 at 3:31 AM, Mathias Lorente > <mathias.lorente@insilicio.com> wrote:
Dear list,
I would like to integrate a Python shell into my application. I tried
'wx.py.shell' and this works quite well.
But I can import '__main__' and modify all my application. I would prefer to
give access to some specific functions/objects.
Moreover, I would like to update the GUI while functions are launched from
the shell. But when some function calls are wrapped into one function which
is launched, I would like to update the GUI only once (not for each call of
each function).
Do you have any suggestion/hint?
Regards,
Mathias Lorente
I use an integrated shell in the application I have been developing
(Mekanimo) and I think it is so nice that users can access any part of
the application including the GUI from the shell. As a matter of fact
now I am developing the new features from the shell first, and then
integrate them into the GUI. So, some advanced users may be able to
modify the application in ways you never imagined and I think this is
a really powerful feature.
If you really want to restrict access (I am not even sure if this is
possible) please check
I have done shell integration once, but it was quite straightforward: full access, no refresh questions.
And using python you can pretty much mess with the whole computer. If you already gave this kind of liberty, why do you want to lock the application?
It is the responsibility of the user to mess its computer or not, I just want that he is not allowed to mess my application too easily.
And I think GUI update is done automatically once you have called MainLoop(), so there shouldn't be much to do.
I'm sorry if I misunderstood you, but your point is not clear. What should the user do with this integrated shell?
Well, in fact, the API I want to expose should be available through some scripts which do not rely on GUI. For example, the user can import my script, then create an object and launch calculus and show results:
*GUI application*
# import is done automatically for the embeded shell
>>> obj = MyObj()
# create the object and its 'GUI representation' along with the 'panel of parameters'
>>> obj.setParam(param) # or parameters are set directly from the GUI
>>> obj.compute() # or launch from the GUI
>>> obj.showResult()
# nothing is return into this shell and the result panel of the object is shown.
I hope I'm clear enough this time.
Let me know if you have any suggestion.
Regards,
Mathias
I have done shell integration once, but it was quite straightforward: full access, no refresh questions.
And using python you can pretty much mess with the whole computer. If you already gave this kind of liberty, why do you want to lock the application?
It is the responsibility of the user to mess its computer or not, I just want that he is not allowed to mess my application too easily.
You can do things like preload the namespace in the shell with objects that provide only the "safe" methods of your application objects. The determined user can still get to the other things if they try, but there would be less chance that they would do something bad accidentally.
And I think GUI update is done automatically once you have called MainLoop(), so there shouldn't be much to do.
I'm sorry if I misunderstood you, but your point is not clear. What should the user do with this integrated shell?
Well, in fact, the API I want to expose should be available through some scripts which do not rely on GUI. For example, the user can import my script, then create an object and launch calculus and show results:
I hope I'm clear enough this time.
PyShell always runs the code in the context of the main thread, so the usual rules for non-blocking vs. long running tasks applies. In other words, if something takes a long time to execute then the user will notice that GUI updates and etc. are blocked and unable to continue until the long running thing has completed.