By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,686 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

on click of button open another script

P: 1
i have a basic window using tkinter with a button
that opens hello message

but before the hello message i want it to run a basic python script the exit the script then show the message

Expand|Select|Wrap|Line Numbers
  1. import Tkinter
  2. import tkMessageBox
  3.  
  4. top = Tkinter.Tk()
  5.  
  6. def FstartCallBack():
  7.    tkMessageBox.showinfo( "Action Complete", "Activated")
  8.  
  9. B = Tkinter.Button(top, text ="Activate", command = FstartCallBack)
  10.  
  11. B.pack()
  12. top.mainloop()
the script is in the same dir and is called on.py
Jun 4 '15 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
You could do something like this:
Expand|Select|Wrap|Line Numbers
  1. import Tkinter
  2.  
  3. top = Tkinter.Tk()
  4.  
  5. def FstartCallBack():
  6.     top.grab_release()
  7.     top.withdraw()
  8.     # run your script here
  9.     B.pack_forget()
  10.     L = Tkinter.Label(top, text="Activated")
  11.     L.pack()
  12.     top.title("Action Complete")
  13.     top.minsize(width=250, height=20)
  14.     top.wm_deiconify()
  15.     top.grab_set()
  16.  
  17. B = Tkinter.Button(top, text ="Activate", command = FstartCallBack)
  18.  
  19. B.pack()
  20. top.mainloop()
Jun 4 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.