Home | Community | Message Board

Kratom Eye
This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Unfolding Nature Shop: Unfolding Nature: Being in the Implicate Order

Jump to first unread post Pages: 1
Python + Tkinter help
    #13888998 -

Anyone good with Python and Tkinter?
I'm trying to write a program for school. I can't for the life of me get an image to display. This code generates a window that is sized to the image I am trying to get it to display, but it only shows the grey background of the window and no image

And I am using a GIF file

Image:


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 creates a story based on user input. """
def __init__(self, master):
""" Initialize Frame. """
## super(Application, self).__init__(master)
Frame.__init__(self, master)
self.grid()
self.create_widgets()

def create_widgets(self):
""" Create widgets to get story information and to display story. """

# create header image
photo = PhotoImage(file="zaxbys.gif")
Label(self, image=photo
).grid(row = 0, column = 0, columnspan = 5, sticky = W)

# main
root = Tk()
root.title("Zaxby's!")
app = Application(root)
root.mainloop()



--------------------

Extras: Filter Print Post Top
Re: Python + Tkinter help [Re: citricacidx]
    #13890417 -

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()



--------------------

Extras: Filter Print Post Top
Jump to top Pages: 1

Unfolding Nature Shop: Unfolding Nature: Being in the Implicate Order


Similar ThreadsPosterViewsRepliesLast post
* Play on Words Ravus 1,018 5 08/04/05 11:26 PM
by Adden
* IMDb's top 250 blewmeanie 953 11 05/03/09 02:30 PM
by blewmeanie
* #occupywallstreet happening now!
( 1 2 3 4 ... 324 325 )
Warrior 163,670 6,480 04/02/12 10:34 PM
by Bodhi of Ankou

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: Entire Staff
346 topic views. 1 members, 9 guests and 176 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2026 Mind Media. Some rights reserved.

Generated in 0.026 seconds spending 0.008 seconds on 16 queries.