【发布时间】:2016-04-06 01:41:18
【问题描述】:
我目前正在开发一个程序来扫描文件夹,找到所有 .exe 文件并将它们放在一个可以运行的列表中。
到目前为止,我已经设法获取列表、创建按钮,但还没有运行程序本身。相反,它在打开运行 python 代码时运行程序。
import os
import Tkinter
top = Tkinter.Tk()
def run(exe):
os.system(exe)
exes = []
for root, dirs, files in os.walk(r'./'):
for file in files:
if file.endswith('.exe'):
exes.append(file)
def dispgames(exes):
exes = exes[:-4]
return exes
def runit(game):
os.system(game)
#print(exes)
#print(dispgames(exes))
def radioCreate(typeArray):
for t in typeArray:
b = Tkinter.Button(top, text = dispgames(t), command=runit(t))
b.pack()
radioCreate(exes)
Tkinter.Button(top, text = "Display").pack()
top.mainloop()
任何帮助将不胜感激。
【问题讨论】:
-
请格式化所有代码,而不是第一行。
-
对不起,我不知道如何使用这里的代码 sn-p 功能,有点困惑。我现在已经整理好了。 :)
标签: python button tkinter command startup