Jump to content

Tkinter Formular


Wadikjunge

Recommended Posts

Hey, i have some problems with my tkinter formular maybe someone can help me with that.

from tkinter import *



import mysql.connector

providerlist = ["FIVE","BLAU","KLAR","BASE"]

mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd="",
    database="db",
)

#print(mydb)




def load():
    print(provider)
    mycursor = mydb.cursor()


    sql = "INSERT INTO tbl_prepaid(handynummer, provider, euro) VALUES ( "' + str(handynummer.get()) + '","' + providerlist[provider.get()] + '", "' + str(euro.get()) + '" ) "

    print(sql)

    mycursor.execute(sql)

    mydb.commit()



root = Tk()
Label(root, text="Nummer").grid(row=0)
Label(root, text="Wiederholen").grid(row=1)



e1 = Entry(root)
e2 = Entry(root)

e1.grid(row=0, column=1)
e2.grid(row=1, column=1)


v = IntVar()
w = IntVar()

Label(root,
      text="""Wählen sie einen Provider:""",
      justify = LEFT,
      padx = 20).grid(row=2)
Radiobutton(root,
            text="FIVE",
            variable=v,
            value=1).grid(row=3)
Radiobutton(root,
            text="BLAU",
            padx = 20,
            variable=v,
            value=2).grid(row=4)

Radiobutton(root,
            text="KLAR",
            variable=v,
            value=3).grid(row=5)
Radiobutton(root,
            text="BASE",
            variable=v,
            value=4).grid(row=6)

Radiobutton(root,
            text="5",
            variable=w,
            value=5).grid(row=3, column=2)
Radiobutton(root,
            text="10",
            variable=w,
            value=6).grid(row=4, column=2)

Radiobutton(root,
            text="15",
            variable=w,
            value=7).grid(row=5, column=2)

Button(root, text="Abschicken", command=load ).grid(row=6, column=2)

mainloop()


this is how far i came

thank you for trying to help!

Link to comment
Share on other sites

Hi there, and welcome to the forums!

The only issue I've run into with your code is that provider isn't defined. I can't be sure that's defined in mysql as I removed that module from the code.

What are you trying to make happen, and what's actually happening in this code?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...