wxwidgets issue

20 views
Skip to first unread message

justin...@gmail.com

unread,
Jan 28, 2015, 4:23:35 PM1/28/15
to ie...@googlegroups.com
Hi all,

I'm relatively new to python and looking at a wxwidgets tutorial. Might I have found a bug?

From a tutorial page linked on the wxpython page we have this:


import wx


app = wx.App(False)

frame = wx.Frame(None, wx.ID_ANY, "Hello World")

frame.Show(True)    

app.MainLoop()



This runs fine from the terminal, but within IEP it will only run once without generating the following traceback:

Traceback (most recent call last):

File "<tmp 1>", line 4, in <module>

frame = wx.Frame(None, wx.ID_ANY, "Hello World")

File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_windows.py", line 580, in __init__

_windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))

PyNoAppError: The wx.App object must be created first!


Restarting the shell within IEP allows it to be run again, once per shell instance.

This is Python 2.7.8 on Debian Testing. What silly thing am I doing?

~Justine

Almar Klein

unread,
Jan 29, 2015, 5:13:17 AM1/29/15
to ie...@googlegroups.com
Hi Justine,

The error is indeed a bit strange, and I suspect it's a bug in Wx.
However, most GUI toolkits were not designed to get their app created twice.

You could run the file as a script, which would restart the kernel, and
thus provide wx with a clean sheet.

Or, if you enable WX integration in IEP, you can get rid of the creation
of the app and the entering of the mainloop, and you can rerun the code
as often as you want.

Regards,
Almar


On 28-01-15 22:23, justin...@gmail.com wrote:
> Hi all,
>
> I'm relatively new to python and looking at a wxwidgets tutorial. Might
> I have found a bug?
>
> From a tutorial page linked on the wxpython page we have this:
>
> |
>
> importwx
>
>
> app =wx.App(False)
>
> frame =wx.Frame(None,wx.ID_ANY,"Hello World")
>
> frame.Show(True)
>
> app.MainLoop()
>
> |
>
>
> This runs fine from the terminal, but within IEP it will only run once
> without generating the following traceback:
>
> Traceback (most recent call last):
>
> File "<tmp 1>", line 4, in <module>
>
> frame = wx.Frame(None, wx.ID_ANY, "Hello World")
>
> File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_windows.py", line
> 580, in __init__
>
> _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
>
> PyNoAppError: The wx.App object must be created first!
>
>
> Restarting the shell within IEP allows it to be run again, once per
> shell instance.
>
> This is Python 2.7.8 on Debian Testing. What silly thing am I doing?
>
> ~Justine
>
> --
> You received this message because you are subscribed to the Google
> Groups "Interactive Editor for Python" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to iep_+uns...@googlegroups.com
> <mailto:iep_+uns...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

justin...@gmail.com

unread,
Jan 30, 2015, 2:57:41 PM1/30/15
to ie...@googlegroups.com
Thank you Almar, running as a script does what I need.


>Or, if you enable WX integration in IEP, you can get rid of the creation
of the app and the entering of the mainloop, and you can rerun the code
as often as you want.

I'll have to figure out how to do that, I didn't even know about it.

~Justine

Almar Klein

unread,
Feb 1, 2015, 10:31:50 AM2/1/15
to ie...@googlegroups.com

> >Or, if you enable WX integration in IEP, you can get rid of the creation
> of the app and the entering of the mainloop, and you can rerun the code
> as often as you want.
>
> I'll have to figure out how to do that, I didn't even know about it.

Got to shell menu > Shell configurations, and then the "GUI" option.

- Almar
Reply all
Reply to author
Forward
0 new messages