469,293 Members | 1,566 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,293 developers. It's quick & easy.

on click of button open another script

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
1 1780
bvdet
2,851 Expert Mod 2GB
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.

Similar topics

reply views Thread by [Yosi] | last post: by
5 posts views Thread by Steve | last post: by
2 posts views Thread by Mariame | last post: by
12 posts views Thread by Thammarat charoenchai. | last post: by
5 posts views Thread by laziers | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.