Question
Hello, I am trying to display a sql database in a python GUI but dont know how to go about it. The GUI is suppose
Hello,
I am trying to display a sql database in a python GUI but dont know how to go about it. The GUI is suppose to display restraunt info when a button is clicked in the GUI below but I cant get it to display in the messagebox... the information will only display in the console.
import sqlite3 from sqlite3 import Error
def create_connection(db_file): """ Connection for the database """ try: conn = sqlite3.connect(db_file) return conn except Error as e: print(e)
return None
def Display_all(conn):
cur = conn.cursor() Query = "SELECT * " \ "FROM Restraunts " \
cur.execute(Query)
rows = cur.fetchall() for row in rows: print(row)
class All(): def __init__(self): self.MainWindow = tkinter.Tk() self.Button_F = tkinter.Frame(self.MainWindow) self.Disp_Button = tkinter.Button(self.Button_F, text = 'Find Restraunts', command = self.Display) self.Quit_Button = tkinter.Button(self.Button_F, text = 'Quit',command=self.MainWindow.destroy) self.Disp_Button.pack(side = 'left') self.Quit_Button.pack(sid = 'left') self.Button_F.pack() tkinter.mainloop() def Display(self): Rest = str(Display_all(conn)) tkinter.messagebox.showinfo('Restruants',Rest)
All()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started