Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 14th, 2004, 05:13 AM
softking softking is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 softking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Solution required

I have a situation as following. I want to run a program in the background. then display a message box that process is running. i want to give user an option, like Cancel button, to terminate the process. But i am running the process in some thread. And threads can not be killed. So Please help me about how i should do that Canceling thing.

Please, its urgent

Thanks
Vikram Karandikar

Reply With Quote
  #2  
Old May 14th, 2004, 05:56 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,226 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 35 m 17 sec
Reputation Power: 263
A thread is a function that runs in the background, and the thread terminates when the function ends. So all you need to do is to return from the function.

I presume the dialog box is non-modal, since displaying a modal dialog will stop the thread from doing its thing. I suggest having a boolean flag somewhere that the dialog sets to True when the user clicks Cancel, and the thread function checks this flag at regular intervals and returns when it is True.

What GUI library are you using? If it is wxPython then there are issues with using the GUI from outside of the main thread. You may find this page useful: http://wiki.wxpython.org/index.cgi/LongRunningTasks

There may be similar issues with Tkinter, but it has been a while since I have used it so I can't say for sure.

Dave - The Developers' Coach

Reply With Quote
  #3  
Old May 14th, 2004, 06:45 AM
softking softking is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 softking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for your quick reply. I am using wxPython, and that was the my next question, why its not working. But any ways, i will read the page and will find the way out. Again thanks

Vikram Karandikar

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Solution required


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT