on click of button open another script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmkmedia
    New Member
    • Jun 2015
    • 1

    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

    Code:
    import Tkinter
    import tkMessageBox
    
    top = Tkinter.Tk()
    
    def FstartCallBack():
       tkMessageBox.showinfo( "Action Complete", "Activated")
    
    B = Tkinter.Button(top, text ="Activate", command = FstartCallBack)
    
    B.pack()
    top.mainloop()
    the script is in the same dir and is called on.py
    Last edited by bvdet; Jun 4 '15, 02:18 PM. Reason: Please use code tags when posting code [code]....[/code]
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    You could do something like this:
    Code:
    import Tkinter
     
    top = Tkinter.Tk()
     
    def FstartCallBack():
        top.grab_release()
        top.withdraw()
        # run your script here
        B.pack_forget()
        L = Tkinter.Label(top, text="Activated")
        L.pack()
        top.title("Action Complete")
        top.minsize(width=250, height=20)
        top.wm_deiconify()
        top.grab_set()
    
    B = Tkinter.Button(top, text ="Activate", command = FstartCallBack)
     
    B.pack()
    top.mainloop()

    Comment

    Working...