I have a problem with my program, get() fucntion in BMIWindow method doesnt work, it returns the deafault value instead of what I typed. If I put this whole method into a separate project, it works, but not in the main one. I also tried to run this program function from a separate project, but when switching on the main project, the BMI was first turned on and then the main window, I do not know where the problem is
import tkinter
class main:
def root():
root = tkinter.Tk()
root.geometry('1100x900')
root.winfo_toplevel().title("MyFitnessPlan")
root.resizable(False, False)
#pictureframe
main.PictureFrame = tkinter.Frame(root, width = 830, height = 700, bg = "blue")
main.PictureFrame.grid(column = 1, row = 0, padx = 35, pady = 10)
#next/previousframe
main.Next_Previous = tkinter.Frame(root, width = 120, height = 20, bg = "blue")
#buttonsframe
main.ButtonFrame = tkinter.Frame(root, width = 60, height = 700, bg = "blue")
main.ButtonFrame.grid(column = 0, row = 0, padx = 10, pady = 10)
#bmiframe
main.BMIFrame = tkinter.Frame(root, width = 60, height = 20, bg = "blue")
main.BMIFrame.grid(column = 0, row = 1, padx = 10, pady = 10)
#kcalframe
main.KcalFrame = tkinter.Frame(root, width = 60, height = 20, bg = "blue")
main.KcalFrame.grid(column = 0, row = 2, padx = 10, pady = 10)
#bodypartbutton
BodyPartButton = tkinter.Button(main.ButtonFrame, text = 'Wybierz partie ciala', width = 20, fg = "black", command = main.ShowButtons)
BodyPartButton.grid(column = 0, row = 0, padx = 10, pady = 10)
#bmibutton
BMICalck = tkinter.Button(main.BMIFrame, text = 'Policz BMI', width = 20, fg = "black", command = main.BMIWindow)
BMICalck.grid(column = 0, row = 0, padx = 10, pady = 10)
#kcalbutton
KcalCalck = tkinter.Button(main.KcalFrame, text = 'Policz kacl', width = 20, fg = "black", command= main.KcalWindow)
KcalCalck.grid(column = 0, row = 0, padx = 10, pady = 10)
root.mainloop()
def ShowButtons():
#shownext/previousframe
main.Next_Previous.grid(column = 1, row = 1, padx = 10, pady = 10)
#backbutton
BodyPartButtonBack = tkinter.Button(main.ButtonFrame, text = 'Plecy', width = 20, fg = "black")
BodyPartButtonBack.grid(column = 0, row = 1, padx = 10, pady = 10)
#chetbutton
BodyPartButtonChest = tkinter.Button(main.ButtonFrame, text = 'Klata', width = 20, fg = "black")
BodyPartButtonChest.grid(column = 0, row = 2, padx = 10, pady = 10)
#bicpesbutton
BodyPartButtonBiceps = tkinter.Button(main.ButtonFrame, text = 'Biceps', width = 20, fg = "black")
BodyPartButtonBiceps.grid(column = 0, row = 3, padx = 10, pady = 10)
#Tricepsbutton
BodyPartButtonTriceps = tkinter.Button(main.ButtonFrame, text = 'Triceps', width = 20, fg = "black")
BodyPartButtonTriceps.grid(column = 0, row = 4, padx = 10, pady = 10)
#legsbutton
BodyPartButtonLegs = tkinter.Button(main.ButtonFrame, text = 'Nogi', width = 20, fg = "black")
BodyPartButtonLegs.grid(column = 0, row = 5, padx = 10, pady = 10)
#absbutton
BodyPartButtonAbs = tkinter.Button(main.ButtonFrame, text = 'Brzuch', width = 20, fg = "black")
BodyPartButtonAbs.grid(column = 0, row = 6, padx = 10, pady = 10)
#previousimagebutton
PreviousImage = tkinter.Button(main.Next_Previous, text = 'Poprzednie Zdjecie', width = 40, fg = "black")
PreviousImage.grid(column = 0, row = 0, padx = 10, pady = 10)
#nextimagebutton
NextImage = tkinter.Button(main.Next_Previous, text = 'Nastepne Zdjecie', width = 40, fg = "black")
NextImage.grid(column = 1, row = 0, padx = 10, pady = 10)
def BMIWindow():
BMI = tkinter.Tk()
BMI.geometry('200x200')
BMI.winfo_toplevel().title("BMI")
BMI.resizable(False, False)
def Getval():
text = Age.get()
rext = Weight.get()
fsf = Height.get()
print(text)
print(rext)
print(fsf)
#entryframefield
EntryFrame = tkinter.Frame(BMI, width = 100, height = 20)
EntryFrame.grid(column = 0, row = 1)
#bmivariable
MaleValue = tkinter.IntVar()
FemaleValue = tkinter.IntVar()
Age = tkinter.StringVar()
Weight = tkinter.StringVar()
Height = tkinter.StringVar()
#male/femalecheckbox
MaleCheck = tkinter.Checkbutton(BMI, text = 'Mezczyzna', variable = MaleValue, onvalue = 1, offvalue = 0)
MaleCheck.grid(column = 0, row = 0, padx = 10, pady = 10)
FemaleCheck = tkinter.Checkbutton(BMI, text = 'Kobieta', variable = FemaleValue, onvalue = 2, offvalue = 0)
FemaleCheck.grid(column = 1, row = 0, padx = 10, pady = 10)
#textlabel
tkinter.Label(EntryFrame, text = 'Wzrost: ').grid(column = 0, row = 0)
tkinter.Label(EntryFrame, text = 'Wiek: ').grid(column = 0, row = 1)
tkinter.Label(EntryFrame, text = 'Waga: ').grid(column = 0, row = 2)
#numberentryframe
AgeEntry = tkinter.Entry(EntryFrame, width = 5, textvariable = Age)
AgeEntry.grid(column = 1, row = 0, padx = 5, pady = 5)
WeightEntry = tkinter.Entry(EntryFrame, width = 5, textvariable = Weight)
WeightEntry.grid(column = 1, row = 1, padx = 5, pady = 5)
HeightEntry = tkinter.Entry(EntryFrame, width = 5, textvariable = Height)
HeightEntry.grid(column = 1, row = 2, padx = 5, pady = 5)
#subbmitbutton
SubbmitButton = tkinter.Button(BMI, text = 'Oblicz', width = 10, fg = "black", command = Getval)
SubbmitButton.grid(column = 0, row = 2)
BMI.mainloop()
def KcalWindow():
Kcal = tkinter.Tk()
Kcal.geometry('200x200')
Kcal.winfo_toplevel().title("Kcal")
Kcal.resizable(False, False)