[Tutor] using a button to make a variable in Tk

Patrick Thorstenson pthorstenson at co.montezuma.co.us
Thu Nov 18 23:24:24 CET 2004


I have a GUI in Tk with 2 buttons. I would like one button to make a
variable called "abortcode"  equal to 3 (text number) and have the other
button make "abortcode" equal to 5. 
 
Then if abortcode equals "5" exit, or "3" continue with the script (it
doesn't have to be 3 or 5). This last part I have - I just need to know
how to make the variable equal to 3 or 5. 
 
OR is there an easier way to do this? Basically, this script in its
entirety creates new parcels for our county. Before the final update
process occurs, the program needs to allow the user to view the possible
parcel updates and then decide to continue the process or abort the
program. "Destroy" only kills the GUI but I need to exit the entire
script.  
 
 
#####
 
from Tkinter import *
 
class App:
    
  def __init__(self, master):
         
    frame = Frame(master)
    frame.pack()
    
    self.button = Button(frame, text="continue on and update parcels",
fg="red", Abortcode = 3????) #this should = 3
    self.button.pack(side=LEFT)
    
    self.stop = Button(frame, text="Stop the update process",
fg="orange", Abortcode = 5????) #this should = 5
    self.stop.pack(side=RIGHT)
    
  
    
root = Tk()
app = App(root)
root.mainloop()
 
#end test area
 
abortcode = "5"
 
if abortcodeb == "5":
  sys.exit
 
else:
  gp.Rename_management(renametest_Copy_shp, Output_data_element__2_, "")
 
####
 
 
 
Patrick Thorstenson
GIS Specialist
Montezuma County
(970) 564-9298
pthorstenson at co.montezuma.co.us
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20041118/f0949127/attachment.htm


More information about the Tutor mailing list