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.

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
Member Avatar for masterofpuppets

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.