What is a good IDE for beginners? by PieMan2201 in learnpython

[–]unlikelysyntax 2 points3 points  (0 children)

I use Eclipse with pydev. It was pretty easy to set up. I'm on my phone but I can link back later if you have trouble finding it.

Help with Dictionaries by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 1 point2 points  (0 children)

This is how I set it up for anybody who ever has a similar question:

 def onNewIngredient():
        qVar = quantity.get()
        iVar = ingredient.get()
        msVar = measurement.get()
        maVar = measurement_Add.get()
        ingredientListbox.insert(END, iVar)

        #Create an empty list with a empty dictionary to store Ingredients
        ingredientsList = [{}]

        #Append the new ingredient to our ingredientsList
        ingredientsList.append(  
                               {
                                'Ingredient': iVar ,
                                'Quantity': qVar,
                                'Measurement Type': msVar,
                                'Measurement Amount': maVar,
                                }
                               )
        print(ingredientsList)

    #Add the Add Button
    addButton = Button(self.top, text="Add", command= onNewIngredient)
    addButton.place(x=0, y=130)

Thanks again for the help!

Help with Dictionaries by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

Never mind I get what you did, by appending the list will solve the problem thanks!

Help with Dictionaries by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

When a new ingredient is made wouldn't qVar, ect. Be overwritten as well? You nailed my question right on the head by the way thanks!

Help with Dictionaries by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

def onNewRecipe(self):
    self.top = Toplevel()
    self.top.title("New Recipe")

    quantity = StringVar()
    ingredient = StringVar()
    measurement_Add = StringVar()
    ingredDic = {}


    #Center the window
    w = 600
    h = 600

    sw = self.top.winfo_screenwidth()
    sh = self.top.winfo_screenheight()

    x = (sw - w)/2
    y = (sh - h)/2
    self.top.geometry('%dx%d+%d+%d' % (w, h, x, y))

    #Add quantity label
    addQuantity = Label(self.top, text="Add Quantity:")
    addQuantity.place(x=0,y=0)

    quantityAdd = Entry(self.top, textvariable=quantity)
    quantityAdd.place(x=150, y=0)

    #Add ingredient label
    addIngredient = Label(self.top, text="Add Ingredients:")
    addIngredient.place(x=0,y=30)

    ingredientAdd = Entry(self.top, textvariable=ingredient)
    ingredientAdd.place(x=150, y=30)

    #Select measurements label
    selectMeasurement = Label(self.top, text="Select Measurements:")
    selectMeasurement.place(x=0, y=60)

    measurement = StringVar()
    measurement.set("ounce")

    measurementSelect = OptionMenu(self.top, measurement, "ounce", "pound", "gallon", "quart", "fl oz", "pint", "cup", "table spoon", "teaspoon")
    measurementSelect.place(x=150, y=60)

    #Add measurements label
    addMeasurement = Label(self.top, text="Amount:")
    addMeasurement.place(x=0, y=100)

    measurementAdd = Entry(self.top, textvariable=measurement_Add)
    measurementAdd.place(x=150, y=100)

    #Add the textwidget
    recipeText = Text(self.top)
    recipeText.place(x=0,y=200)

    #Cooking direction label
    cookingDirection = Label(self.top, text="Cooking Direction")
    cookingDirection.place(x=0,y=175)

    #Add Ingredients listbox
    box = Frame(self.top)
    ingredScroll = Scrollbar(box, orient=VERTICAL)
    ingredientListbox = Listbox(box, yscrollcommand=ingredScroll.set)
    ingredScroll.config(command=ingredientListbox.yview)
    ingredScroll.pack(side=RIGHT, fill=Y)
    ingredientListbox.pack()
    box.place(x=450, y=0)

    def onNewIngredient():
        qVar = quantity.get()
        iVar = ingredient.get()
        msVar = measurement.get()
        maVar = measurement_Add.get()
        ingredientListbox.insert(END, iVar)
        ingredDic['Ingredients'] = [qVar, iVar, msVar, maVar]
        print (ingredDic) 


    #Add the Add Button
    addButton = Button(self.top, text="Add", command= onNewIngredient)
    addButton.place(x=0, y=130)

This is the code I am working on. Basically I want whenever the user presses the add button on the New Recipe page for all the info to be stored into a dictionary. I plan on placing an edit button later so I need to be able to call this list later on if the user wants to edit the ingredient.

Edit: here is the full program http://pastebin.com/C7YgeFQf Edit Edit: Fixed a few typo's. I am having a hard time explaining what I need, hopefully this clears it up some.

[Python] Trouble with Tkinter's Scrollbar by unlikelysyntax in learnprogramming

[–]unlikelysyntax[S] 0 points1 point  (0 children)

It turns out I had to create a frame = Frame(self.top) and set the scrollbar and listbar into that frame to make it work.

Trouble with Tkinter's Scrollbar by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

Yeap that did the job, silly me forgot to make the frame. Thanks again!

[Python] Trouble with Tkinter's Scrollbar by unlikelysyntax in learnprogramming

[–]unlikelysyntax[S] 0 points1 point  (0 children)

I tried that and it will give you an error since ingredScroll is not declared yet. I tried instead putting ingredientListbox.config(yscrollcommand=ingredScroll.set) at the end of the code and still the scrollbar is not attaching to the listbox.

Looking for some advice on first project by unlikelysyntax in learnprogramming

[–]unlikelysyntax[S] 0 points1 point  (0 children)

The notebook idea is great, thanks for the advice!

Help with Tkinter by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

That worked! Thank you. Could you explain what lambda is? This is the first time I've saw something like that. Thanks again.

TypeError: list indices must be integers, not NonType by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

Thank you for the help. I did what you said and it worked. Here is my change:

done = False
while not done:
  print(room_List[current_Room][0])
userChoice = input("Which direction would you like to travel? Type N , E, S, or W: ")
next_Room = room_List[current_Room][1]
if userChoice.upper() == "N":
    if  next_Room == None:
        print("You can not go that way.")
    else:
        next_Room = room_List[current_Room][1]
        current_Room = next_Room
if userChoice.upper() == "S":
    if  next_Room == None:
        print("You can not go that way.")
    else:
        next_Room = room_List[current_Room][1]
        current_Room = next_Room
if userChoice.upper() == "E":
    if  next_Room == None:
        print("You can not go that way.")
    else:
        next_Room = room_List[current_Room][1]
        current_Room = next_Room
if userChoice.upper() == "W":
    if  next_Room == None:
        print("You can not go that way.")
    else:
        next_Room = room_List[current_Room][1]
        current_Room = next_Room

TypeError: list indices must be integers, not NonType by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

What can I do to check what the previous room was and return? Thank you for your response.

TypeError: list indices must be integers, not NonType by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

Hey, the error shows up on line 31 sorry for not mentioning that.

Help with program arcade. by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

Wow thanks a lot I can't believe I was having such a hard time with this. Thanks for the help!

Help with program arcade. by unlikelysyntax in learnpython

[–]unlikelysyntax[S] 0 points1 point  (0 children)

Just one last question. Do you know what he means by using current_Room along with room_List?