0

Good day!

I have data from excel file. Just for example:

Data from excel:

excelfile =[Name   Number
            Ronald    3
            Bautista  4]

so using this code;

A = pd.read_excel (r'excelfile.xlsx')

I can import my data from excel to python.

Now I want to import my data to GUI which I made using Python. Here's my program for my GUI.

from tkinter import *
import pandas as pd
A = pd.read_excel (r'excelfile.xlsx')

main_screen = Tk()
main_screen.geometry("300x250")
main_screen.title("Database")   

main_screen.mainloop()

So how can I import my data to my GUI? Such that the output looks like this:

Output GUI

Thanks for the help!

Ralden123
  • 19
  • 7

1 Answers1

1

It looks like you're confused about what a Database actually is. Your code uses Tkinter, which is a User Interface library, that is used for designing what the user of your program should see.

A database is used only to store and access some data. Here, what you might want to do is to import your data from Excel in a database, but that would be a different feature (which means, a distinct part of your code) from the display of the UI itself. Some database you might take a look at include MongoDB or SQLite, which both have very good librairies for interfacing with Python (mongoengine for MongoDB and sqlite3 for SQLite).

Once the data is in imported to one of those databases, you can take a look at ttk.Treeview (http://www.tkdocs.com/tutorial/tree.html) to display it in a table using Tkinter.

Hope that helps!

paupaulaz
  • 937
  • 1
  • 11
  • 20
  • He is using pandas... no SQL or json – Wolfeius Aug 10 '19 at 13:14
  • True, but Pandas is not a database system either. The goal of Pandas is to process data, and to some extent to load and dump it across various format and support. If the goal here is to persist data (which is the goal of a database) after extracting it from the excel file, then Pandas won't be sufficient. – paupaulaz Aug 10 '19 at 13:23
  • 1
    he meant dataframe and not database... What he wants is to have a tkInter GUI that will show the contents of the excel file. – Wolfeius Aug 10 '19 at 13:28
  • Thank you for educating me. Yes. I'm new in Python and database. I think I misunderstand the term database to GUI. However, I need a code, such that my target output will look like the attached image. – Ralden123 Aug 10 '19 at 13:29
  • SO is not a free software developing service. We help other programmers with bugs or understanding, but the actual coding, reading the documentation, and so forth is your job. There are many other questions in here that answers to your question. – Wolfeius Aug 10 '19 at 13:39