-2

I am trying to create this program for a restaurant named Neelam. Here's a sample

from Tkinter import *
root=Tk()
w=Label(root,text="**WELCOME TO NEELAM**")#THIS COMES AS A LABEL
w.pack()
s=Label(root,text="*FINE DINE RESTAURANT*")#SO DOES THIS ONE
s.pack()
category=raw_input('BF-BREAKFAST S-SNACKS\n')#HOW TO MAKE THIS ONE ?
q=input('Enter Quantity\n')

2 Answers2

0

you can use other entry that asks for the quntity. as Bryan said at the comments you shall not use raw_input in gui programming.

you can use the entry like this:

from Tkinter import *

def callback(sv):
    print sv.get()
top = Tk()
L1 = Label(top, text="quantity")
L1.pack( side = LEFT)
sv = StringVar()
sv.trace("w", lambda name, index, mode, sv=sv: callback(sv))
E1 = Entry(top, bd =5, textvariable=sv)
E1.pack(side = RIGHT)
top.mainloop()

EDIT:

added on text change event, for catching the user input inside the entry.

omri_saadon
  • 10,193
  • 7
  • 33
  • 58
0
from Tkinter import *

root = Tk()
welcome = Label(root, text="**Welcome to Neelam**")
welcome.pack()

s = Label(root, text="*Fine Dine Restaurant*")
s.pack()

# create variables to hold values from the entry
foodtype = StringVar()
quantity = StringVar()


# create the entry and its label
foodTypeLabel = Label(root, text="Breakfast(BF) or Snacks(S)")
foodTypeLabel.pack()

# textvariable option referring back to StringVar() instance
foodTypeEntry = Entry(root, textvariable=foodtype)
foodTypeEntry.pack()

quantityLabel = Label(root, text="Quantity:")
quantityEntry = Entry(root, textvariable=quantity)

quantityLabel.pack()
quantityEntry.pack()

# create labels that use text from the variable holding
# the values typed into the Entry widgets
enteredFood = Label(root, textvariable=foodtype)
enteredQuant = Label(root, textvariable=quantity)
enteredFood.pack()
enteredQuant.pack()

root.mainloop()
Charitoo
  • 1,814
  • 17
  • 21