0

Im new to programming, and really only doing this for a school project. Im trying to make a GUI that has a series of buttons that when pressed will run a specific emulator. When I try to run this I get a error saying "z26" is undefined. Im not quite sure on how to actually define it.

from tkinter import *
import os

class Application(Frame):

    def __init__(self, master):
        Frame.__init__(self,master)
        self.grid()
        self.create_widgets()

    def create_widgets(self):
        self._button = Button(self, text = "Atari", command = self._openFile)
        self._button.grid()
    def _openFile(self):
        os.startfile(z26.exe)

root = Tk()
root.title("Arcade")
root.geometry("200x85")

app = Application(root)

root.mainloop()

1 Answer 1

1

The problem is that you are using x26.exe as a literal, and it is getting evaluated as though it were part of the Python program itself.

Instead, put the path with quotequotations, to make it a string:

os.startfile('path/z26.exe')

See also the Python documentation for os.startfile(path[, operation]).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.