2017-03-09 72 views
0

プログラミングには新しく、実際には学校プロジェクトでこれを行うだけです。私が押されたときに特定のエミュレータを実行する一連のボタンを持つGUIを作成しようとしています。これを実行しようとすると、 "z26"が定義されていないというエラーが表示されます。私は実際にそれを定義する方法についてはあまり確かではありません。Pythonのtkinterボタンを使って外部プログラムを実行する

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

答えて

0

問題は、x26.exeをリテラルとして使用していて、Pythonプログラム自体の一部であるかのように評価されていることです。代わりに

、その文字列を作るために、quotequotationsとパスを入れて:

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

os.startfile(path[, operation])のためのPythonドキュメントを参照してください。

関連する問題