Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- from tkinter import *
- root = Tk()
- root.title("моя база")
- root.geometry("500x500")
- lbl4 = Label(root, text="Введите ваше имя:")
- lbl4.pack()
- textbox1 = Entry(root, width=30)
- textbox1.pack()
- cvar1 = StringVar()
- cvar1.set(0)
- c1 = Checkbutton(root, text=1, variable=cvar1, onvalue="(1,)", offvalue=0)
- c1.pack()
- cvar2 = StringVar()
- cvar2.set(0)
- c2 = Checkbutton(root, text=2, variable=cvar2, onvalue="(2,)", offvalue=0)
- c2.pack()
- cvar5 = StringVar()
- cvar5.set(0)
- c1 = Radiobutton(root, text=3, value="(3,)", variable=cvar5)
- c1.pack()
- c2 = Radiobutton(root, text=4, value="(4,)", variable=cvar5)
- c2.pack()
- def baza():
- conn = sqlite3.connect('1.db')
- cursor = conn.cursor()
- cursor.execute('CREATE TABLE IF NOT EXISTS sozd1(otv1 text,otv2 text,otv3 text,otv4 text)')
- a=[]
- u1=[textbox1.get(),cvar1.get(),cvar2.get(),cvar5.get()]
- a.append(u1)
- for i in a:
- cursor.execute('INSERT INTO sozd1 VALUES(?,?,?,?)', i)
- conn.commit()
- def baza2():
- conn = sqlite3.connect('1.db')
- cursor = conn.cursor()
- cursor.execute('SELECT * FROM sozd1 ')
- results1 = cursor.fetchall()
- conn.commit()
- print(results1)
- def obn():
- textbox1.delete(0, END)
- cvar2.set(0)
- cvar1.set(0)
- cvar5.set(0)
- button1 = Button(root, text="добавить", command=baza)
- button1.pack()
- button2 = Button(root, text="вывести", command=baza2)
- button2.pack()
- button3 = Button(root, text="нвоая запись", command=obn)
- button3.pack()
- root.mainloop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement