well I figured out how to get the image to display. I had to set a global variable. I made a global list (picList). Now I can display all the images I want, only problem is what I'm trying to do now.
I have 6 buttons set up for 6 different menu items. what I want to happen is have the user click the button for the item they want, and have it add that item to their order with a price, and update the order total.
Bleh, this shit's way to complicated for me right now.
Code:
# Order Up
# Create a menu mimicking your favorite fast food restaurant.
# Prices and food items should be from that menu.
# Incorporate images, colors, etc. to make your GUI more appealing
from Tkinter import *
class Application(Frame):
""" GUI application that takes a users order and totals it up. """
def __init__(self, master):
""" Initialize Frame. """
## super(Application, self).__init__(master)
Frame.__init__(self, master, bg = "white")
self.grid()
self.create_widgets()
def create_widgets(self):
""" Create widgets to display menu items. """
# create header image
global picList
picList = []
picList.append(PhotoImage(file="zaxbys.gif"))
Label(self, image=picList[0], bg="white"
).grid(row = 0, column = 0, columnspan = 3, sticky = W)
# create a label and button for Chicken Finger Plate
Label(self,
text = "Chicken Finger Plate",
bg = "white",
fg = "navy",
font = "arial 12 bold"
).grid(row = 1, column = 0, sticky = W+E)
picList.append(PhotoImage(file="chickenfingerplate.gif"))
price = float(5.69)
Button(self,
image=picList[1],
height=92,
bg = "white",
relief="solid",
borderwidth=1,
command = self.add_to_order(price)
).grid(row = 2, column = 0, sticky = W+E)
# create a label and button for Wings & Things
Label(self,
text = "Wings & Things",
bg = "white",
fg = "navy",
font = "arial 12 bold"
).grid(row = 1, column = 1, sticky = W+E)
picList.append(PhotoImage(file="wingsnthings.gif"))
price = float(6.49)
Button(self,
image=picList[2],
height=92,
bg = "white",
relief="solid",
borderwidth=1,
command = self.add_to_order(price)
).grid(row = 2, column = 1, sticky = W+E)
# create a label and button for Zaxby's Club
Label(self,
text = "Zaxby's Club",
bg = "white",
fg = "navy",
font = "arial 12 bold"
).grid(row = 1, column = 2, sticky = W+E)
picList.append(PhotoImage(file="clubsand.gif"))
price = float(5.49)
Button(self,
image=picList[3],
height=92,
bg = "white",
relief="solid",
borderwidth=1,
command = self.add_to_order(price)
).grid(row = 2, column = 2, sticky = W+E)
# create a label and button for Cajun Club
Label(self,
text = "Cajun Club",
bg = "white",
fg = "navy",
font = "arial 12 bold"
).grid(row = 3, column = 0, sticky = W+E)
picList.append(PhotoImage(file="cajunsand.gif"))
price = float(5.49)
Button(self,
image=picList[4],
height=92,
bg = "white",
relief="solid",
borderwidth=1,
command = self.add_to_order(price)
).grid(row = 4, column = 0, sticky = W+E)
# create a label and button for The House
Label(self,
text = "The House",
bg = "white",
fg = "navy",
font = "arial 12 bold"
).grid(row = 3, column = 1, sticky = W+E)
picList.append(PhotoImage(file="housezalad.gif"))
price = float(5.99)
Button(self,
image=picList[5],
height=92,
bg = "white",
relief="solid",
borderwidth=1,
command = self.add_to_order(price)
).grid(row = 4, column = 1, sticky = W+E)
# create a label and button for The Zensation
Label(self,
text = "The Zensation",
bg = "white",
fg = "navy",
font = "arial 12 bold"
).grid(row = 3, column = 2, sticky = W+E)
picList.append(PhotoImage(file="zensationzalad.gif"))
price = float(6.29)
Button(self,
image=picList[6],
height=92,
bg = "white",
relief="solid",
borderwidth=1,
command = self.add_to_order(price)
).grid(row = 4, column = 2, sticky = W+E)
self.story_txt = Text(self, width = 75, height = 10, wrap = WORD)
self.story_txt.grid(row = 6, column = 0, columnspan = 5)
def add_to_order(self, price):
global total
total =+ price
# main
root = Tk()
root.title("Zaxby's!")
app = Application(root)
root.mainloop()