CHOCO BLOCK
CHOCO BLOCK

Reputation: 91

Python v3 using idle with Tkinter and Gui, repeating code

I am having some trouble with my code and was wondering if anyone could help me?

I have made a program with two classes that ae designed to act as a phone ordering system. This is based on the company Subway. You can see the gui this code produces here: Output

I have also uploaded the python file, which contains all the code. My question is, can I get the button on line 176 "Save and order another sub", to be pressed so the user can add 5 more subs, while being able to save variables for the costs, so they can all be added up at the end. So essentially repeating the code 5 times while holding 5 variables for costs to be added at the end.

Sorry this is so broad, but I hope this makes sense when you can see what my code is trying to do. What code can I put on line 318 that will help me with this?

Here is the code: https://drive.google.com/file/d/0BydTFZ ... sp=sharing

If someone could reply with the code I need to repeat my program with, I would be very grateful.

Upvotes: 0

Views: 58

Answers (1)

John
John

Reputation: 38

Firstly, you should directly post the relevant code, not links.

Just based on what you wrote, you can have the button add data to a list instead of an arbitrary number of distinct variables. That way, the list can hold any number of sandwich orders.

mylist = []
mylist.append('chicken sub')
mylist.append('vegetarian sub')
sub1 = mylist[0] # sub1 == 'chicken sub'

Upvotes: 1

Related Questions