start work thread right after app mainloop start

hi,

how can I create and start my work thread right after the gui main loop started(when frame/main window shown). I need to start my work thread after mainloop started because I need the value of the main window’s ID(got from my_win.GetHandle() ) to initial/create the work thread instance, if I create the workthread before the main_window shown, I’ll get the wrong value.

Best Regards,
Kevin

found the wx.CallAfter

···

On Thu, Nov 6, 2008 at 11:19 PM, jason zhang jason.gnu@gmail.com wrote:

hi,

how can I create and start my work thread right after the gui main loop started(when frame/main window shown). I need to start my work thread after mainloop started because I need the value of the main window’s ID(got from my_win.GetHandle() ) to initial/create the work thread instance, if I create the workthread before the main_window shown, I’ll get the wrong value.

Best Regards,
Kevin

Hello,

jason zhang wrote:

found the wx.CallAfter

    hi,

    how can I create and start my work thread right after the gui main
    loop started(when frame/main window shown). I need to start my
    work thread after mainloop started because I need the value of the
    main window's ID(got from my_win.GetHandle() ) to initial/create
    the work thread instance, if I create the workthread before the
    main_window shown, I'll get the wrong value.

    Best Regards,
    Kevin

Do you have your own App which derive from wx.App? If so, you can create your main frame and show it in the OnInit method of your App class and then retrieve the window ID. But I think CallAfter is also a good choice.

Mathias

···

On Thu, Nov 6, 2008 at 11:19 PM, jason zhang <jason.gnu@gmail.com > <mailto:jason.gnu@gmail.com>> wrote:

jason zhang wrote:

how can I create and start my work thread right after the gui main
loop started(when frame/main window shown). I need to start my work
thread after mainloop started because I need the value of the main
window's ID(got from my_win.GetHandle() ) to initial/create the work
thread instance, if I create the workthread before the main_window
shown, I'll get the wrong value.

Why do you need the window handle? You can't (reliably) perform any GUI
operations on a window from any other thread other than the one that
created it.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

actually I use that value to specify the player window by a -wid window_handle_id option when start mplayer in slave mode.

···

On Fri, Nov 7, 2008 at 2:00 AM, Tim Roberts timr@probo.com wrote:

jason zhang wrote:

how can I create and start my work thread right after the gui main

loop started(when frame/main window shown). I need to start my work

thread after mainloop started because I need the value of the main

window’s ID(got from my_win.GetHandle() ) to initial/create the work

thread instance, if I create the workthread before the main_window

shown, I’ll get the wrong value.

Why do you need the window handle? You can’t (reliably) perform any GUI

operations on a window from any other thread other than the one that

created it.

Tim Roberts, timr@probo.com

Providenza & Boekelheide, Inc.


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users