[wxpython-users] Threads

wxPython user mailing list, post #18,493
Author:
Date:
Subject:
 Wesley Nitsckie
 2008-07-18 14:53:36
 [wxpython-users] Threads
Hi All,

Anyone have some tips on how to create a thread. I am connecting to
a server. So while that is happenining I want to run a progress bar until
the connection stuff is completed.

Thanks
Wesley
<div dir="ltr">Hi All,<br><br>Anyone have some tips on how to create a thread.&nbsp; I am connecting to <br>a server. So while that is happenining I want to run a progress bar until<br>the connection stuff is completed.<br><br>
Thanks<br>Wesley<br></div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Wesley Nitsckie
 2008-07-18 14:54:32
 [wxpython-users] Re: Threads
On Fri, Jul 18, 2008 at 2:53 PM, Wesley Nitsckie <[email protected]>
wrote:

> Hi All,
>
> Anyone have some tips on how to create a thread. I am connecting to
> a server. So while that is happenining I want to run a progress bar until
> the connection stuff is completed.
>
> Thanks
> Wesley
>

ps .. I just need the thread part . I have the bit to do the progress bar
and the connection stuff
<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Jul 18, 2008 at 2:53 PM, Wesley Nitsckie &lt;<a href="mailto:wesleynitsckie@gmail.com">wesleynitsckie@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Hi All,<br><br>Anyone have some tips on how to create a thread.&nbsp; I am connecting to <br>a server. So while that is happenining I want to run a progress bar until<br>the connection stuff is completed.<br><br>

Thanks<br>Wesley<br></div>
</blockquote></div><br>ps .. I just need the thread part . I have the bit to do the progress bar and the connection stuff<br></div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Tim van der Leeuw
 2008-07-18 15:26:39
 Re: [wxpython-users] Re: Threads
Hi,

On Fri, Jul 18, 2008 at 2:54 PM, Wesley Nitsckie <[email protected]>
wrote:

>
>
> On Fri, Jul 18, 2008 at 2:53 PM, Wesley Nitsckie <[email protected]>
> wrote:
>
>> Hi All,
>>
>> Anyone have some tips on how to create a thread. I am connecting to
>> a server. So while that is happenining I want to run a progress bar until
>> the connection stuff is completed.
>>
>> Thanks
>> Wesley
>>
>
> ps .. I just need the thread part . I have the bit to do the progress bar
> and the connection stuff
>


There's nothing hard about threading, really.

Code below is not intended to actually work, it is just pseudo-code which I
typed in my mail editor, but should show you the idea.

---- pseudo-code starts ----
from threading import Thread
import wx

# ... Make your progress-bar, WX windows, etc
def init_wx_ap():
pass

def a_method(prog_bar, arg1, arg2):
do_some_work()
wx.CallAfter(prog_bar, value1)
do_some_work()
wx.CallAfter(prog_bar, value2)
do_more_work()
wx.CallAfter(prog_bar, value3)
return

t = Thread(target=a_method, args=(my_prog_bar, arg1, arg2))
t.start()

---- pseudo-code ended ----


See also further examples on:
http://www.wellho.net/solutions/python-python-threads-a-first-example.html

Cheers,

--Tim
<div dir="ltr">Hi,<br><br><div class="gmail_quote">On Fri, Jul 18, 2008 at 2:54 PM, Wesley Nitsckie &lt;<a href="mailto:wesleynitsckie@gmail.com">wesleynitsckie@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr"><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">On Fri, Jul 18, 2008 at 2:53 PM, Wesley Nitsckie &lt;<a href="mailto:wesleynitsckie@gmail.com" target="_blank">wesleynitsckie@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Hi All,<br><br>Anyone have some tips on how to create a thread.&nbsp; I am connecting to <br>a server. So while that is happenining I want to run a progress bar until<br>the connection stuff is completed.<br><br>


Thanks<br>Wesley<br></div>
</blockquote></div><br></div></div>ps .. I just need the thread part . I have the bit to do the progress bar and the connection stuff<br></div>
</blockquote><div><br><br>There&#39;s nothing hard about threading, really.<br><br>Code below is not intended to actually work, it is just pseudo-code which I typed in my mail editor, but should show you the idea.<br><br>
---- pseudo-code starts ----<br>from threading import Thread<br>import wx<br><br># ... Make your progress-bar, WX windows, etc<br>def init_wx_ap():<br>&nbsp;&nbsp;&nbsp; pass<br><br>def a_method(prog_bar, arg1, arg2):<br>&nbsp;&nbsp;&nbsp; do_some_work()<br>
&nbsp;&nbsp;&nbsp; wx.CallAfter(prog_bar, value1)<br>&nbsp;&nbsp;&nbsp; do_some_work()<br></div></div>&nbsp;&nbsp;&nbsp; wx.CallAfter(prog_bar, value2)<br>&nbsp;&nbsp;&nbsp;
do_more_work()<br>&nbsp;&nbsp;&nbsp; wx.CallAfter(prog_bar, value3)<br>&nbsp;&nbsp;&nbsp; return<br><br>t = Thread(target=a_method, args=(my_prog_bar, arg1, arg2))<br>t.start()<br><br>---- pseudo-code ended ----<br><br><br>See also further examples on: <br>
<a href="http://www.wellho.net/solutions/python-python-threads-a-first-example.html">http://www.wellho.net/solutions/python-python-threads-a-first-example.html</a><br><br>Cheers,<br><br>--Tim<br><br></div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Mike Driscoll
 2008-07-18 12:48:50
 Re: [wxpython-users] Re: Threads
Wesley Nitsckie wrote:
>
>
> On Fri, Jul 18, 2008 at 2:53 PM, Wesley Nitsckie
> <[email protected] <mailto:[email protected]>> wrote:
>
> Hi All,
>
> Anyone have some tips on how to create a thread. I am connecting to
> a server. So while that is happenining I want to run a progress
> bar until
> the connection stuff is completed.
>
> Thanks
> Wesley
>
>
> ps .. I just need the thread part . I have the bit to do the progress
> bar and the connection stuff

This is a good wiki entry on the subject:
http://wiki.wxpython.org/LongRunningTasks

I've used the techniques there and I've messed with the delayed result
one in the demo. Both are good places to start. You could also read up
on the docs for the thread modules.

Mike
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users