How to invoke parent's method?

2007-01-06 Thread many_years_after
Hi, pythoners:

 My wxPython program includes  a panel whose parent is a frame. The
panel has a button. When I click the button , I want to let the frame
destroy. How to implement it? Could the panel invoke the frame's
method?
Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to stop program when threads is sleeping

2006-12-25 Thread many_years_after

Carsten Haese wrote:
 On Sun, 2006-12-24 at 22:55 -0800, many_years_after wrote:
  Hi, pythoners:
 
There is a problem I couldn't dispose. I start a thread in the my
  program. The thread will do something before executing time.sleep().
  When the user give a signal to the main thread (such as click the 'end'
  button or close the window), the thread should end it's running. But
  how to end the threading when it's sleeping? I set an flag to the
  thread, but it doesn't work.

 Is the thread supposed to do some additional work after being woken up?
 If not, there is no point in going to sleep in the first place and the
 thread should just terminate when it has completed its task. If yes, I'd
 use a threading.Event object to .wait() on in the sub-thread rather than
 putting it to sleep, and then .set() the event object in the main thread
 when it's time to wake up the sub-thread.

 Hope this helps,

 Carsten.

While , there is something wrong in my expression. What I mean is the
thread will wait some time after doing some tasks. I want to know is
there any method to end the thread or make it out of execution of
waiting. I use time.sleep() to let the thread wait. 
Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


How to stop program when threads is sleeping

2006-12-24 Thread many_years_after
Hi, pythoners:

  There is a problem I couldn't dispose. I start a thread in the my
program. The thread will do something before executing time.sleep().
When the user give a signal to the main thread (such as click the 'end'
button or close the window), the thread should end it's running. But
how to end the threading when it's sleeping? I set an flag to the
thread, but it doesn't work.

  I also thought to put  'time.sleep()'   to the main thread. But I
think the main thread will not response to user's action because it is
executing sleep(). 

 Any ideas?
 Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Try to stop thread Using flag

2006-11-25 Thread many_years_after
Hi,pythoners:

I countered some problems when I try to stop threads using flag.
These are my some important codes:

#  mythread.py
def run(self):
while self.addr != '':### text waiting for processing
if not self.CONTINUE:   ### flag for thread ,means to exit
the RUN func or not
break
print self.name
post(self.params, self.addr)  ### func to process the text
self.addr = furl.readline().strip()


##  myapp.py
 def OnEndProcess(self, event):
   if self.threadList:
for thread in self.threadList:
thread.CONTINUE = False
#   this func is an EVENT processor. When I press the END BUTTON ,
it will be caused.

def OnBeginProcess(self, event):
for i in range(num):
if lines[i]!= '':
thread =
mythread.mythread('Thread'+str(i),lines[i], params)
self.threadList.append(thread)

print '\n Starting Threads'

for i in self.threadList:
i.start()


##  this func is an EVENT processor. When I press the BEGIN BUTTON
, it will be caused.

By test I found this truely acts as supposed:thread exited the *run()*
func. But when I press the BEGIN BUTTON again, an Error was caused:
thread already started.
It's said that if the *run()* func is finished, the thread will become
dead. So how to interprete this?
Any solution?

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list

How to Restart a thread

2006-11-25 Thread many_years_after
class mythread(threading.Thread):
def __init__(self, threadname):
threading.Thread.__init__(self, name = threadname)

def run(self):
print 'i am running'
print 'i quit run()'

thread  = mythread('1')
thread.start()
print threading.activeCount()  ## 1 , this means the thread is active
if not thread.isAlive():
print 'i am dead,you can restart'   ### OK, this is executed. this
means the thread is no alive
thread.start()   thread already started 

This program presentes that the thread quit the *run()* func and is
active but not alive.   How to understand this? It is said if the
thread quit the *run()* func , it's dead.
how to restart it ?

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list

How to make a python file to a DLL?

2006-11-16 Thread many_years_after
Any solution?

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list

How to get the ascii code of Chinese characters?

2006-08-19 Thread many_years_after
Hi,everyone:

 Have you any ideas?

 Say whatever you know about this.


thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread many_years_after
hi:

what I want to do is just to make numbers as people input some Chinese
character(hanzi,i mean).The same character will create the same
number.So I think ascii code can do this very well.

John Machin wrote:
 many_years_after wrote:
  Hi,everyone:
 
   Have you any ideas?
 
   Say whatever you know about this.
 

 Perhaps you had better explain what you mean by ascii code of Chinese
 characters. Chinese characters (hanzi) can be represented in many
 ways on a computer, in Unicode as well as many different legacy
 encodings, such as GB, GBK, big5, two different 4-digit telegraph
 codes, etc etc. They can also be spelled out in roman letters with or
 without tone indications (digits or accents) in the pinyin system --
 is that what you mean by ascii code?

 Perhaps you might like to tell us what you want to do in Python with
 hanzi and ascii codes, so that we can give you a specific answer.
 With examples, please -- like what are the ascii codes for the two
 characters in the common greeting that comes across in toneless pinyin
 as ni hao?
 
 Cheers,
 John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread many_years_after

John Machin wrote:
 many_years_after wrote:
  hi:
 
  what I want to do is just to make numbers as people input some Chinese
  character(hanzi,i mean).The same character will create the same
  number.So I think ascii code can do this very well.
 

 Possibly you have create upside-down. Could you possibly be talking
 about an input method, in which people type in ascii letters (and
 maybe numbers) and the *result* is a Chinese character? In other words,
 what *everybody* uses to input Chinese characters?

 Perhaps you could ask on the Chinese Python newsgroup.

 *GIVE* *EXAMPLES* of what you want to do.
Well, people may input from keyboard. They input some Chinese
characters, then, I want to create a number. The same number will be
created if they input the same Chinese characters.

-- 
http://mail.python.org/mailman/listinfo/python-list


Which field is Python suitable to do some tasks?

2006-08-17 Thread many_years_after
hello , members:
  I have basic knowledge of python programming. But i don't know
what to do next step.
I don't know in which field I should learn more about python and
finally finish some tasks.
Can you give me some ideas?

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list