Threading

Hello again, I got my web headline prog working with Python 2.2.2 wxpython and wonderfull PythonCardPrototype and Infidel's help, it even has a system tray icon!.
I have ordered 3 python books since I'm still using python ( i've tried a lot of languages C, C++ Java, smalltalk, ruby, Icon, snobol VB Delphi etc.)
Now I want to go a bit further and I am looking at threading.
Does anyone know of good examples of threading, since I am so much better at learning from examples. As long as I can work out for my self what is going on I'm fine. I chopped up a threading example but still could not work out what was happening (a bit like me and Classes).
What I want to do is run the 'search' of the headlines in a thread so the main GUI window is not blocked from refreashing and exiting if it is in the middle of a long search or reduce the priority of the searching so it has less of a 'stop all things while I work' approach.

Oh and one more thing. PythonCardPrototype seemes to have a static address for its modules if you ( on windows) 'package' it up it will not find those modules cos the place you put it on the target machine is not likly to be exactly your origonal development directory structor and thus not run unless you provide the correct install path for the PythonCard modules which means fixed directories to place a program. I can do it but the people who are trying out my program all moaned that it had to be in a certain directory. Users !
Thanks in advance, if I've oversteped any marks I apoligise now.
Ade

Comments

  • : Hello again, I got my web headline prog working with Python 2.2.2 wxpython and wonderfull PythonCardPrototype and Infidel's help, it even has a system tray icon!.
    : I have ordered 3 python books since I'm still using python ( i've tried a lot of languages C, C++ Java, smalltalk, ruby, Icon, snobol VB Delphi etc.)
    : Now I want to go a bit further and I am looking at threading.
    : Does anyone know of good examples of threading, since I am so much better at learning from examples. As long as I can work out for my self what is going on I'm fine. I chopped up a threading example but still could not work out what was happening (a bit like me and Classes).
    : What I want to do is run the 'search' of the headlines in a thread so the main GUI window is not blocked from refreashing and exiting if it is in the middle of a long search or reduce the priority of the searching so it has less of a 'stop all things while I work' approach.
    :
    : Oh and one more thing. PythonCardPrototype seemes to have a static address for its modules if you ( on windows) 'package' it up it will not find those modules cos the place you put it on the target machine is not likly to be exactly your origonal development directory structor and thus not run unless you provide the correct install path for the PythonCard modules which means fixed directories to place a program. I can do it but the people who are trying out my program all moaned that it had to be in a certain directory. Users !
    : Thanks in advance, if I've oversteped any marks I apoligise now.
    : Ade

    I've only ever done threading in Java, and then only for animation/game development. Here is a link to threading samples at the Python Cookbook:

    http://aspn.activestate.com/ASPN/Cookbook/Python?kwd=Threads


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • A simple Python threading example:

    import threading
    from threading import *

    class TestThread(threading.Thread):

    def __init__(self,name):
    self.name = name
    print "Thread created"
    Thread.__init__(self)


    def run(self):

    print self.name, " started ...."

    x = 0

    if self.name == "ALPHA":
    x = 1000000

    if self.name == "BETA":
    x = 1500000

    if self.name == "CHARLIE":
    x = 500000

    while x != 0:
    x = x - 1

    print self.name, " finished ..."




    a = TestThread("BETA")
    b = TestThread("ALPHA")
    c = TestThread("CHARLIE")

    a.start()
    b.start()
    c.start()


    CHEERS !!!



    : : Hello again, I got my web headline prog working with Python 2.2.2 wxpython and wonderfull PythonCardPrototype and Infidel's help, it even has a system tray icon!.
    : : I have ordered 3 python books since I'm still using python ( i've tried a lot of languages C, C++ Java, smalltalk, ruby, Icon, snobol VB Delphi etc.)
    : : Now I want to go a bit further and I am looking at threading.
    : : Does anyone know of good examples of threading, since I am so much better at learning from examples. As long as I can work out for my self what is going on I'm fine. I chopped up a threading example but still could not work out what was happening (a bit like me and Classes).
    : : What I want to do is run the 'search' of the headlines in a thread so the main GUI window is not blocked from refreashing and exiting if it is in the middle of a long search or reduce the priority of the searching so it has less of a 'stop all things while I work' approach.
    : :
    : : Oh and one more thing. PythonCardPrototype seemes to have a static address for its modules if you ( on windows) 'package' it up it will not find those modules cos the place you put it on the target machine is not likly to be exactly your origonal development directory structor and thus not run unless you provide the correct install path for the PythonCard modules which means fixed directories to place a program. I can do it but the people who are trying out my program all moaned that it had to be in a certain directory. Users !
    : : Thanks in advance, if I've oversteped any marks I apoligise now.
    : : Ade
    :
    : I've only ever done threading in Java, and then only for animation/game development. Here is a link to threading samples at the Python Cookbook:
    :
    : http://aspn.activestate.com/ASPN/Cookbook/Python?kwd=Threads
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories