[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

wxpython application ( problem ?

vedrandekovic

1/2/2008 11:25:00 AM

Hello,

Here is sample of my simple script with wxpython and modules:
subprocess,threading, directpython.......

Code sample:

import wx
import wx.aui
app=wx.App()
frame=wx.Frame(None,title="New project")

#There is also part with wx.aui

frame.Show()
app.MainLoop()


After a few minutes wx application does destroy. Any ides why?
5 Answers

Marc 'BlackJack' Rintsch

1/2/2008 11:30:00 AM

0

On Wed, 02 Jan 2008 03:24:56 -0800, vedrandekovic wrote:

> Here is sample of my simple script with wxpython and modules:
> subprocess,threading, directpython.......

Are you accessing the GUI from threads?

Ciao,
Marc 'BlackJack' Rintsch

vedrandekovic

1/2/2008 11:43:00 AM

0

On 2 sij, 12:29, Marc 'BlackJack' Rintsch <bj_...@gmx.net> wrote:
> On Wed, 02 Jan 2008 03:24:56 -0800, vedrandekovic wrote:
> > Here is sample of my simple script with wxpython and modules:
> > subprocess,threading, directpython.......
>
> Are you accessing the GUI from threads?
>
> Ciao,
> Marc 'BlackJack' Rintsch


Hi again,

yes, so what's the problem?


Regards,
Vedran

Diez B. Roggisch

1/2/2008 12:46:00 PM

0

vedrandekovic@gmail.com wrote:

> On 2 sij, 12:29, Marc 'BlackJack' Rintsch <bj_...@gmx.net> wrote:
>> On Wed, 02 Jan 2008 03:24:56 -0800, vedrandekovic wrote:
>> > Here is sample of my simple script with wxpython and modules:
>> > subprocess,threading, directpython.......
>>
>> Are you accessing the GUI from threads?
>>
>> Ciao,
>> Marc 'BlackJack' Rintsch
>
>
> Hi again,
>
> yes, so what's the problem?

It is the problem. It is usually not allowed to manipulate GUI-objects from
any thread except the main-thread that runs the event-loop. All
GUI-toolkits have guidelines how to cope with that, e.g. custom events in
Qt3, or timers.

This message indicates that WX has similar means:

http://osdir.com/ml/python.matplotlib.general/2005-03/msg...


Diez

Bjoern Schliessmann

1/2/2008 1:18:00 PM

0

vedrandekovic@gmail.com wrote:

> yes, so what's the problem?

http://wxwidgets.org/manuals/stable/wx_wxthreadove...
| If you do decide to use threads in your application, it is
| strongly recommended that no more than one thread calls GUI
| functions. The thread sample shows that it is possible for many
| different threads to call GUI functions at once (all the threads
| created in the sample access GUI), but it is a very poor design
| choice for anything except an example. The design which uses one
| GUI thread and several worker threads which communicate with the
| main one using events is much more robust and will undoubtedly
| save you countless problems (example: under Win32 a thread can
| only access GDI objects such as pens, brushes, &c created by
| itself and not by the other threads).

Regards,


Björn

--
BOFH excuse #241:

_Rosin_ core solder? But...

Mike Driscoll

1/2/2008 2:25:00 PM

0

On Jan 2, 5:24 am, vedrandeko...@gmail.com wrote:
> Hello,
>
> Here is sample of my simple script with wxpython and modules:
> subprocess,threading, directpython.......
>
> Code sample:
>
> import wx
> import wx.aui
> app=wx.App()
> frame=wx.Frame(None,title="New project")
>
> #There is also part with wx.aui
>
> frame.Show()
> app.MainLoop()
>
> After a few minutes wx application does destroy. Any ides why?

I highly recommend reading this wxPython wiki entry about using
threads in wxPython:

http://wiki.wxpython.org/LongRu...

I've found it quite helpful in my own programming.

Mike