Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago