【发布时间】:2016-02-20 04:26:58
【问题描述】:
我正在尝试在程序中创建按钮以将用户带到其他屏幕。我已经在标签上创建了图像,但不确定如何将它们变成可将用户带到另一个页面的功能按钮。您可以在我的代码中看到我需要的 2 个按钮是搜索报价和新报价。谢谢
from tkinter import *
class Window():
def __init__(self,master): #constructor
self.master = master
self.master.title("Borras Roofing Quotation System") #sets title of window
self.master.geometry("2160x1440") #sets size of window
self.master.configure(background = "white") # sets background colour of window.
self.Borras = PhotoImage(file = "Borras.Logo.PNG") #sets up image
self.BorrasLabel = Label(self.master, image = self.Borras, bg = "white", width='1000', height= '500') #puts image onto label
self.BorrasLabel.pack()
self.newquote = PhotoImage(file = "Process_New_Quote_Button.PNG") #sets up image
self.newquoteLabel = Label(self.master, image = self.newquote, bg = "white") #puts image onto label
self.newquoteLabel.place(x = 200, y = 500)
self.searchquote = PhotoImage(file = "Search_Current_Quote_Button.PNG") #sets up image
self.searchquoteLabel = Label(self.master, image = self.searchquote, bg = "white") #puts image onto label
self.searchquoteLabel.place(x = 800, y = 500)
root = Tk()
userPassWindow = Window(root)
root.mainloop()
【问题讨论】:
-
您想知道如何为您的按钮提供功能吗?您是否尝试过添加
command?For example, b = Button(text="Click Me", command=function_name)?
标签: python button tkinter window