Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Can a Tkinter GUI check for abort script:

Reply
Thread Tools

Can a Tkinter GUI check for abort script:

 
 
Michael Yanowitz
Guest
Posts: n/a
 
      12-18-2006
Hello:

I have successfully implemented a Tkinter GUI which has
this (simplified here for explanation):
+-------------------------------------+
| filename: [ ./test3.py] |
| |
| [Run Script] |
+-------------------------------------+

But, now what I would like to do while the script is
running, is replace the "Run Script" with "Abort Script".

+-------------------------------------+
| filename: [ ./test3.py] |
| |
| [Abort Script] |
+-------------------------------------+

So, every tenth of a seconds or ??? better time, I
would like to 'return' to the GUI and check if the
"Abort Script" button has been pressed.
How do I do this? Or is there a better way to
implement this?

Thanks in advance:
Michael Yanowitz


 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      12-18-2006
On Mon, 18 Dec 2006 07:37:47 -0500, "Michael Yanowitz"
<(E-Mail Removed)> declaimed the following in comp.lang.python:

> Hello:
>
> I have successfully implemented a Tkinter GUI which has
> this (simplified here for explanation):
> +-------------------------------------+
> | filename: [ ./test3.py] |
> | |
> | [Run Script] |
> +-------------------------------------+
>
> But, now what I would like to do while the script is
> running, is replace the "Run Script" with "Abort Script".


That should be the easy part... (I'm not a Tkinter tinker, so can't
give specifics)

>
> So, every tenth of a seconds or ??? better time, I
> would like to 'return' to the GUI and check if the
> "Abort Script" button has been pressed.
> How do I do this? Or is there a better way to
> implement this?
>

This is going to be more difficult... ONE) you should not have
/left/ the GUI so there should be no need to return to it... That is,
pushing [run] should invoke a very short function that returns to the
mainloop event handler with only a minimal pause while processing.

TWO) If your "script" is a heavy number cruncher, you probably need
to start a thread to process it -- this lets it operate in parallel with
the GUI mainloop. The thread should have some sort of loop that tests an
attribute for the "abort signal" (this is NOT testing the GUI button for
presses -- rather the GUI [abort] is a short function that will set the
signal attribute so the thread can read it). When the signal is set, the
thread should clean-up and exit.

If the "script" is some external program, you'll need to get
trickier in figuring out how to kill it.
--
Wulfraed Dennis Lee Bieber KD6MOG
http://www.velocityreviews.com/forums/(E-Mail Removed) (E-Mail Removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (E-Mail Removed))
HTTP://www.bestiaria.com/
 
Reply With Quote
 
 
 
 
hg
Guest
Posts: n/a
 
      12-19-2006
Michael Yanowitz wrote:

> Hello:
>
> I have successfully implemented a Tkinter GUI which has
> this (simplified here for explanation):
> +-------------------------------------+
> | filename: [ ./test3.py] |
> | |
> | [Run Script] |
> +-------------------------------------+
>
> But, now what I would like to do while the script is
> running, is replace the "Run Script" with "Abort Script".
>
> +-------------------------------------+
> | filename: [ ./test3.py] |
> | |
> | [Abort Script] |
> +-------------------------------------+
>
> So, every tenth of a seconds or ??? better time, I
> would like to 'return' to the GUI and check if the
> "Abort Script" button has been pressed.
> How do I do this? Or is there a better way to
> implement this?
>
> Thanks in advance:
> Michael Yanowitz


It depends: As you cannot "kill" a thread in Python, you need some mechanism
to stop your script another way (is that a python script or
a .sh / .bat ? ... from what you're writing, it seems you're calling some
external entity which just might launch a bunch of processes)

So do you or not control the inner workings of that external script ?

If you don't, then "killing" might be the way as posted / clearly the
methord will change from environment to environment.

hg

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Real-time developers/designers: Can abort() be used to fail-fast in a safety-critical system? Marc C Programming 16 12-20-2010 01:37 PM
Real-time developers/designers: Can abort() be used to fail-fast in a safety-critical system? Marc C++ 11 12-20-2010 01:37 PM
GUI - GUI value passing paul.foreman Java 5 10-25-2004 08:06 AM
[PY GUI] interest function in python GUI(wxpython,pyqt) program.wxpython,pyqt ulysses Python 4 10-22-2003 03:28 PM
How can I "know" the difference between a session timed out and a session that did session.abort? Jazzis ASP General 2 09-23-2003 07:16 AM



Advertisments