【问题标题】:Custom Python GUI Button + Link自定义 Python GUI 按钮 + 链接
【发布时间】:2014-01-24 23:31:41
【问题描述】:
我正在学习 python GUI 的基础知识,并且遇到了按钮制作。我如何将我在 Photoshop 中完成的文件链接为按钮?当你点击它时,它会让你说,谷歌?
这就是我所拥有的:
from Tkinter import *
root = Tk()
root.title("Simple GUI")
root.geometry("800x600")
app = Frame(root)
app.grid()
button1 = Button(app, text "Sample Button!")
button1.grid()
root.mainloop()
【问题讨论】:
标签:
python
user-interface
tkinter
【解决方案2】:
使用类似以下的内容:
from Tkinter import *
import ImageTk, webbrowser
def launchGoogle():
webbrowser.open('http://www.google.com')
root = Tk()
root.title("Simple GUI")
root.geometry("800x600")
app = Frame(root)
app.grid()
icon = ImageTk.PhotoImage(file="logo11w.png")
button1 = Button(app, text="Sample Button!", image=icon, command=launchGoogle)
button1.grid()
root.mainloop()