1

I'm creating a program that helps solve quadratic equations - this is only an outcast to the layout, but essentially when I input the parameters (A, B and C) it should store it and then I can use it later.

this is what I got so far (Don't mind the names and text, it's in danish):

Vara = StringVar()
Varb = StringVar()
Varc = StringVar()

#Parabel
def Parabel():

    parabel = Tk()
    parabel.minsize(600, 400)
    parabel.maxsize(600,400)
    parabel.title("Parablens rødder")

    pLabel = Label(parabel, text = "Parablens rødder").pack(side = TOP)
    pLabel1 = Label(parabel, text = "Indtast parameterne A, B, C:").pack()
    #A
    pLabel2 = Label(parabel, text = "A:").pack()
    pEntry1 = Entry(parabel, textvariable = Vara).pack()
    #B
    pLabel3 = Label(parabel, text = "B:").pack()
    pEntry2 = Entry(parabel, textvariable = Varb).pack()
    #C
    pLabel4 = Label(parabel, text = "C:").pack()
    pEntry3 = Entry(parabel, textvariable = Varc).pack()

    pButton = Button(parabel, text = "OK", command = para ).pack()


def para():
    a = Vara.get()
    b = Varb.get()
    c = Varc.get()

    print(a,b,c) # just to test if they got stored,

From what I've read about this should work, but when I print a,b,c it comes up blank.

1 Answer 1

1

If this is the complete program, then it has a few problems. On my PC it didn't run at all (no GUI, exceptions), maybe you can run it, but it won't do anything logical. This is why:

1) You can't create StringVar before calling Tk(). In my code (trying to fix yours) I added two lines at the very beginning:

from Tkinter import *
root = Tk()

2) You didn't activate the Tkinter's main loop. I added this line at the bottom of Parabel():

root.mainloop()

3) I added a line calling to your function:

Parabel()

And I got it running Ok.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry i forgot to mention, this is only a cutout of the program. I can send you the full program if that helps? Thank you for responding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.