I'm trying to create a forum application using Python.
when a new username signs up for the forum I ask him to select the subjects that interest him, and he would like to receive information about, here's an example of one subject checkbox:
nut = IntVar()
nutrition_photo = PhotoImage(file="nutrition.gif")
nutrition_photo = nutrition_photo.subsample(4,4)
nutrition_RB = Checkbutton(scrollable_frame,text="Nutrition" ,image = nutrition_photo,
compound="top", bg="light goldenrod", variable = nut)
nutrition_RB.grid(row=0, column=0)
I tried to create a database table using sqlite3 that contains all of the subjects's preferences of each user (if he chose the subject the cell will contain the value 1, and if he didn't it will contain the value 0):
connection = sqlite3.connect('subjects_info.db')
cursor = connection.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS subjects(
nutrition INTEGER,
cooking INTEGER,
sport INTEGER,
music INTEGER,
health INTEGER,
traveling INTEGER,
tv INTEGER,
art INTEGER,
economics INTEGER,
fashion INTEGER,
history INTEGER,
literature INTEGER,
philosophy INTEGER,
technology INTEGER,
diy INTEGER)
""")
each time a user tries to sign up for the app his selected subjets will add to the database:
def update_subjects():
connection = sqlite3.connect('subjects_info.db')
cursor = connection.cursor()
cursor.execute("""INSERT INTO subjects (nutrition, cooking, sport, music, health, traveling, tv, art, economics, fashion, history, literature, philosophy, technology, diy)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
(nut, cook, spo, mus, hea, tra, tv, art, eco, fas, his, lit, phil, tec, diy)
)
connection.commit()
connection.close()
when i try to choose subjects and click on the button:
b = Button(new_account_frame, text="That's all", command = update_subjects)
b.pack()
I get this error:
InterfaceError: Error binding parameter 0 - probably unsupported type.
Do you any idea what seems to be the problem? and how can I fix it?
Thanks in advance, I'd really appreciate it if you could help me :)
Aucun commentaire:
Enregistrer un commentaire