我一直在尝试与Tkinter一起创建一个GUI来选择程序/网站 启动时启动。你知道吗
网络浏览器和子进程.exeopener在其他脚本中正常工作,Tkinter脚本的模板也正常工作,但是当我开始添加更多变量时
它声明无效语法(特别是在def的CoWeb
变量上)
有人能帮我吗?我缺少一些基本的东西吗?你知道吗
from Tkinter import Tk, Label, Button
import subprocess
import webbrowser
class MyFirstGUI:
def __init__(self, master):
self.master = master
master.title("Greetings")
self.label = Label(master, text="Good Morning Mr. Swordy. What would you like to do?")
self.label.pack()
self.CoWeb_button = Button(master, text="ENE Website", command=self.CoWeb)
self.CoWeb_button.pack()
self.ProjWeb_button = Button(master, text="ENE Projects", command=self.ProjWeb)
self.ProjWeb_button.pack()
self.Excel_button = Button(master, text="Excel", command=self.Excel)
self.Excel_button.pack()
self.AutoCAD_button = Button(master, text="AutoCAD", command=self.AutoCAD)
self.AutoCAD_button.pack()
self.GEarth_button = Button(master, text="Google Earth", command=self.GEarth)
self.GEarth_button.pack()
self.close_button = Button(master, text="Close", command=master.quit)
self.close_button.pack()
def Excel(self):
subprocess.Popen([r"C:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE"]
def CoWeb(self):
url = "https://intranet.enengineering.com/SitePages/Home.aspx"
webbrowser.open_new(url)
def ProjWeb(self):
url = "https://eneprojects.enengineering.com/SitePages/Home.aspx"
webbrowser.open_new(url)
def AutoCAD(self):
subprocess.Popen([r"C:\Program Files\Autodesk\AutoCAD 2016\acad.exe"]
def GEarth(self):
subprocess.Popen([r""C:\Program Files (x86)\Google\Google Earth Pro\client\googleearth.exe"]
root = Tk()
my_gui = MyFirstGUI(root)
root.mainloop()
这没有有效的Python语法:
注意双
"
,即""
。 只需删除一个"
:此外,你的压痕似乎是错误的。你知道吗
定义如下:
必须与以下项目处于同一级别:
看来你错过了这句话的结尾部分:
AutoCAD和GEarth方法中也缺少闭合参数。你知道吗
相关问题 更多 >
编程相关推荐