Я не понимаю, почему мои виджеты входа не принимают никаких входных данных. ⇐ Python
Я не понимаю, почему мои виджеты входа не принимают никаких входных данных.
I tried doing everything but my Entry boxes aren't ready to accept any input
First just install ttkbootstrap to execute the code.
pip install ttkbootstrap import tkinter as tk from tkinter import messagebox as mgb from ttkbootstrap import * import sqlite3 as sql conn = sql.connect("Stock Data.db") cursor = conn.cursor() def AddData(Date, Quality, Quantity, Invoice, Supplier): cursor.execute(f'''INSERT INTO Stock (Date, Quality, Quantity, Invoice, Supplier) VALUES ('{Date}','{Quality}',{Quantity},{Invoice},'{Supplier}'));''') def SortData(): pass def ResetAdd(): Date.set("Date") Quality.set("Quality") Quantity.set("Quantity") Invoice.set("Invoice Number") Supplier.set("Supplier") def ResetSort(): pass frame = Window("Stock Book", themename="superhero") if mgb.askquestion("First Time", "Is this app opened for the FIRST TIME?") == "yes": cursor.execute('DROP TABLE IF EXISTS Stock') cursor.execute(''' CREATE TABLE Stock (Date TEXT, Quality TEXT, Quantity INT, Invoice INT, Supplier TEXT);''') root = Frame(frame, padding=10) root.pack(pady=5, fill=X, side=TOP) nb = Notebook(root) nb.pack(side=LEFT, padx=(10, 0), expand=YES, fill=BOTH) AddDataFrame = Frame(nb, padding=15) AddDataFrame.pack(fill=BOTH, pady=(10, 5), expand=YES) Date = StringVar(AddDataFrame) DatEntry = Entry(AddDataFrame, width=50, textvariable=Date) #Date DatEntry.pack(fill=X, pady=5) Quality = StringVar(AddDataFrame) QualityEntry = Entry(AddDataFrame, textvariable=Quality) #Quality QualityEntry.pack(fill=X, pady=5) Quantity = StringVar(AddDataFrame) QuantityEntry = Entry(AddDataFrame, textvariable=Quantity) #Quantity QuantityEntry.pack(fill=X, pady=5) Invoice = StringVar(AddDataFrame) InvoiceNumberEntry = Entry(AddDataFrame, textvariable=Invoice) #Invoice SupplierNumber InvoiceNumberEntry.pack(fill=X, pady=5) Supplier = StringVar(AddDataFrame) SupplierEntry = Entry(AddDataFrame, textvariable=Supplier) #Supplier SupplierEntry.pack(fill=X, pady=5) ResetButton = Button(AddDataFrame, text="RESET", style="Danger.TButton", width=22, command=ResetAdd) #Reset ResetButton.pack(pady=10, side = LEFT) SaveButton = Button(AddDataFrame, text="ADD DATA", style="Success.TButton", width=22, command=lambda:AddData( Date.get(), Quality.get(), Quantity.get(), Invoice.get(), Supplier.get() )) #Save SaveButton.pack(pady=10, side = RIGHT) SortDataFrame = Frame(nb, padding=15) SortDataFrame.pack(fill=BOTH, pady=(10, 5), expand=YES) SorterEntry = Entry(SortDataFrame, width=50) #Sorter SorterEntry.pack(fill=X, pady=5) SorterEntry.insert(END, "Sorter") SortererEntry = Entry(SortDataFrame) #Quality SortererEntry.pack(fill=X, pady=5) SortererEntry.insert(END, "Value") ResetButton = Button(SortDataFrame, text="RESET", style="Danger.TButton", width=22, command=ResetSort) #Reset ResetButton.pack(pady=10, side = LEFT) SortButton = Button(SortDataFrame, text="SORT", style="Success.TButton", width=22, command=SortData) #Sort SortButton.pack(pady=10, side = RIGHT) nb.add(AddDataFrame, text="Add Data", sticky=NW) nb.add(SortDataFrame, text="Sort Data", sticky=NW) tk.mainloop() I tried reading the docs, changing the code, re-running the code a 100 times, restarting my laptop, everything, but it wont accept any input.
Источник: https://stackoverflow.com/questions/781 ... -any-input
I tried doing everything but my Entry boxes aren't ready to accept any input
First just install ttkbootstrap to execute the code.
pip install ttkbootstrap import tkinter as tk from tkinter import messagebox as mgb from ttkbootstrap import * import sqlite3 as sql conn = sql.connect("Stock Data.db") cursor = conn.cursor() def AddData(Date, Quality, Quantity, Invoice, Supplier): cursor.execute(f'''INSERT INTO Stock (Date, Quality, Quantity, Invoice, Supplier) VALUES ('{Date}','{Quality}',{Quantity},{Invoice},'{Supplier}'));''') def SortData(): pass def ResetAdd(): Date.set("Date") Quality.set("Quality") Quantity.set("Quantity") Invoice.set("Invoice Number") Supplier.set("Supplier") def ResetSort(): pass frame = Window("Stock Book", themename="superhero") if mgb.askquestion("First Time", "Is this app opened for the FIRST TIME?") == "yes": cursor.execute('DROP TABLE IF EXISTS Stock') cursor.execute(''' CREATE TABLE Stock (Date TEXT, Quality TEXT, Quantity INT, Invoice INT, Supplier TEXT);''') root = Frame(frame, padding=10) root.pack(pady=5, fill=X, side=TOP) nb = Notebook(root) nb.pack(side=LEFT, padx=(10, 0), expand=YES, fill=BOTH) AddDataFrame = Frame(nb, padding=15) AddDataFrame.pack(fill=BOTH, pady=(10, 5), expand=YES) Date = StringVar(AddDataFrame) DatEntry = Entry(AddDataFrame, width=50, textvariable=Date) #Date DatEntry.pack(fill=X, pady=5) Quality = StringVar(AddDataFrame) QualityEntry = Entry(AddDataFrame, textvariable=Quality) #Quality QualityEntry.pack(fill=X, pady=5) Quantity = StringVar(AddDataFrame) QuantityEntry = Entry(AddDataFrame, textvariable=Quantity) #Quantity QuantityEntry.pack(fill=X, pady=5) Invoice = StringVar(AddDataFrame) InvoiceNumberEntry = Entry(AddDataFrame, textvariable=Invoice) #Invoice SupplierNumber InvoiceNumberEntry.pack(fill=X, pady=5) Supplier = StringVar(AddDataFrame) SupplierEntry = Entry(AddDataFrame, textvariable=Supplier) #Supplier SupplierEntry.pack(fill=X, pady=5) ResetButton = Button(AddDataFrame, text="RESET", style="Danger.TButton", width=22, command=ResetAdd) #Reset ResetButton.pack(pady=10, side = LEFT) SaveButton = Button(AddDataFrame, text="ADD DATA", style="Success.TButton", width=22, command=lambda:AddData( Date.get(), Quality.get(), Quantity.get(), Invoice.get(), Supplier.get() )) #Save SaveButton.pack(pady=10, side = RIGHT) SortDataFrame = Frame(nb, padding=15) SortDataFrame.pack(fill=BOTH, pady=(10, 5), expand=YES) SorterEntry = Entry(SortDataFrame, width=50) #Sorter SorterEntry.pack(fill=X, pady=5) SorterEntry.insert(END, "Sorter") SortererEntry = Entry(SortDataFrame) #Quality SortererEntry.pack(fill=X, pady=5) SortererEntry.insert(END, "Value") ResetButton = Button(SortDataFrame, text="RESET", style="Danger.TButton", width=22, command=ResetSort) #Reset ResetButton.pack(pady=10, side = LEFT) SortButton = Button(SortDataFrame, text="SORT", style="Success.TButton", width=22, command=SortData) #Sort SortButton.pack(pady=10, side = RIGHT) nb.add(AddDataFrame, text="Add Data", sticky=NW) nb.add(SortDataFrame, text="Sort Data", sticky=NW) tk.mainloop() I tried reading the docs, changing the code, re-running the code a 100 times, restarting my laptop, everything, but it wont accept any input.
Источник: https://stackoverflow.com/questions/781 ... -any-input
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как создать вложенные виджеты, такие как MDCard, содержащие внутри себя другие виджеты?
Anonymous » » в форуме Python - 0 Ответы
- 38 Просмотры
-
Последнее сообщение Anonymous
-