Dec-01-2018, 03:13 AM
im really new to python,this was made using extensive youtube tutorials
im trying to make a GUI app for a game i play:don't starve together
the app should take the ammount of mushrooms(2 red raw,3 green cooked etc) and then say what effects on my final stats they will have(health sanity hunger)
the calculations work(you must manualy enter a 0 in all fields to not get errors but thats not a issue)
my problem is that i cant get my app to display the results,i use a label and tried many online tutorials but alas none worked
im certain the variables get calculated as adding in print(hp) prints the correct result to the console
how can i make my app actually show the new text in place of the 0 i get by default
here is the FULL code(pretty big although i tried to make it readable and well layed out)
i can use integrers strings and floats and do maths in script,i have no knowledge what classes are or anythng that has the word "self" all i have used untill now are loops and basic math so be gentle please
im trying to make a GUI app for a game i play:don't starve together
the app should take the ammount of mushrooms(2 red raw,3 green cooked etc) and then say what effects on my final stats they will have(health sanity hunger)
the calculations work(you must manualy enter a 0 in all fields to not get errors but thats not a issue)
my problem is that i cant get my app to display the results,i use a label and tried many online tutorials but alas none worked
im certain the variables get calculated as adding in print(hp) prints the correct result to the console
how can i make my app actually show the new text in place of the 0 i get by default
here is the FULL code(pretty big although i tried to make it readable and well layed out)
from tkinter import* from math import * from time import sleep #Variables redraw = 0 redrawhp = (-20) redrawhunger = (+12.5) redrawsanity = (0) redcooked = 0 redcookedhp = (1) redcookedhunger = (0) redcookedsanity = (-10) greenraw = 0 greenrawhp = (0) greenrawhunger = (12.5) greenrawsanity = (-50) greencooked = 0 greencookedhp = (-1) greencookedhunger = (0) greencookedsanity = (15) blueraw = 0 bluerawhp = (20) bluerawhunger = (12.5) bluerawsanity = (-15) bluecooked = 0 bluecookedhp = (-3) bluecookedhunger = (0) bluecookedsanity = (10) hp=0 sanity=0 hunger=0 #Functions def calculate(): redraw = entryrawred.get() greenraw = entryrawgreen.get() blueraw = entryrawblue.get() redcooked = entrycookedred.get() greencooked = entrycookedgreen.get() bluecooked = entrycookedblue.get() hp = ((redrawhp)*(int(redraw))+(redcookedhp)*(int(redcooked))+(bluerawhp)*(int(blueraw))+(bluecookedhp)*(int(bluecooked))) hunger = ((redrawhunger)*(int(redraw))+(redcookedhunger)*(int(redcooked))+(bluerawhunger)*(int(blueraw))+(bluecookedhunger)*(int(bluecooked))) sanity = ((redrawsanity)*(int(redraw))+(redcookedsanity)*(int(redcooked))+(bluerawsanity)*(int(blueraw))+(bluecookedsanity)*(int(bluecooked))) hp2 = StringVar() sanity2 = StringVar() hunger2 = StringVar() hp2.set(str(hp)) sanity2.set(str(sanity)) hunger2.set(str(hunger)) print(hp) #gui begin root = Tk() hp2 = StringVar() sanity2 = StringVar() hunger2 = StringVar() hp2.set(hp) sanity2.set(str(sanity)) hunger2.set(str(hunger)) #First column labels,mushroom types labelmushroomtype = Label(root, text="Mushroom Type") labelraw = Label(root, text="Raw Ammount") labelcooked = Label(root, text="Cooked Ammount") #second column labels,mushroom colors labelred = Label(root, text="Red") labelgreen = Label(root, text="Green") labelblue = Label(root, text="Blue") #finale display things labelhp = Label(root, textvariable=hp2) #Entries entryrawred = Entry(root) entrycookedred = Entry(root) entryrawgreen = Entry(root) entrycookedgreen = Entry(root) entryrawblue = Entry(root) entrycookedblue = Entry(root) #Buttons buttoncalculate = Button(root, text="Calculate", command=calculate) #Grid labelmushroomtype.grid(row=0, sticky=W) labelred.grid(row=1, sticky=W) labelgreen.grid(row=2, sticky=W) labelblue.grid(row=3, sticky=W) labelraw.grid(row=0, column=1) entryrawred.grid(row=1, column=1) entryrawgreen.grid(row=2, column=1) entryrawblue.grid(row=3, column=1) labelcooked.grid(row=0, column=2) entrycookedred.grid(row=1, column=2) entrycookedgreen.grid(row=2, column=2) entrycookedblue.grid(row=3, column=2) buttoncalculate.grid(row=4, columnspan=3) labelhp.grid(row=5, column=1) root.mainloop()PLEASE don't use too much terminology,im really new to python and programming itself
i can use integrers strings and floats and do maths in script,i have no knowledge what classes are or anythng that has the word "self" all i have used untill now are loops and basic math so be gentle please
