954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Running an executable file using Tkinter

I have just started getting into python and Tkinter and so far it's all been very interesting and the help good to, but now i have ran into a problem. I'm sure it's very easy to solve but i just can't seem to figure it out or find anything on the web.

I am developing a GUI and i want to make it so that when a button is pressed it will run an executable file. But i have no idea how to add this to the button i have. Any help would be fantastic.

paulo3k
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

This is one way.

import os

def on_button(event):
'''event handling on push button open notepad'''
os.startfile('notepad') #or path to your exe
snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294
 

this is a similar way to do this :)

from Tkinter import *

root = Tk()......
...
...
def openExe():
      os.startfile( "some path to .exe file" )

b = Button( root, text = "Open", command = openExe ); b.pack()

mainloop()


You could of course add an entry field to specify which file to open or something like that :)

masterofpuppets
Posting Whiz in Training
272 posts since Jul 2009
Reputation Points: 20
Solved Threads: 74
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You