Python shell integration

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 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?

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?

Hi Mathias,

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

http://sayspy.blogspot.com/2007/04/python-security-paper-online.htm

and

http://wiki.python.org/moin/How%20can%20I%20run%20an%20untrusted%20Python%20script%20safely%20(i.e.%20Sandbox)

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Fahreddın Basegmez wrote:

···

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi Mathias,

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

http://sayspy.blogspot.com/2007/04/python-security-paper-online.htm

and

http://wiki.python.org/moin/How%20can%20I%20run%20an%20untrusted%20Python%20script%20safely%20(i.e.%20Sandbox)

if you succeed stopping the bad guys without inconveniencing the good
ones please let me know.

Regards,

Fahri

Hello Fahri,

Thanks for the links (first one needs an 'l' at the end). I'll check them as soon as possible.

Regards,
Mathias

Lucas Boppre Niehues wrote:

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:

*Standard shell*
>>> import script
>>> obj = script.MyObj()
>>> obj.setParam(param)
>>> ...
>>> obj.compute()
>>> obj.showResult()
[..., ...]

*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

Mathias Lorente wrote:

Lucas Boppre Niehues wrote:

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.

http://wiki.wxpython.org/LongRunningTasks
http://wiki.wxpython.org/Non-Blocking_Gui

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!