-1

Just wondering if there is a better way to display MySql data to users of my app.

Basically I store look-up data then put it in a pop-up window for viewing:

    for row in all_reinforcement_data:
        r_total = ("Total number of reinforcement entries", mycursor.rowcount)
        r_id = ("\n\nId", row[0])

 messagebox.showinfo("Reinforcement Data Results", r_total + r_id)

Which doesn't look too polished but gives me what I want:

enter image description here

Is there any other ways of showing the user the data. In some form they could copy and paste from, ideally an excell spreadsheet or something similar.

  • You might want to read some of the content on tkdocs.com - it has examples of most of the widgets available in tkinter. – Bryan Oakley Jun 23 '20 at 19:33
  • This question already has answers here:[pretty-print-data-in-tkinter-label](https://stackoverflow.com/questions/58658656) – stovfl Jun 23 '20 at 20:07
  • You can try `ttk.Treeview`. – acw1668 Jun 24 '20 at 00:40
  • @stovfl I don't think that really answers the question: as far as I can tell OP is asking for the data to be copy+pasteable – Minion3665 Jun 24 '20 at 07:22
  • @Minion3665 This is a comment only. Let the OP decide if the given link is helpful or not. ***asking for the data to be copy+pasteable***: It isn't clear for me what the OP want to do here? – stovfl Jun 24 '20 at 07:50
  • 1
    I settled for a combination; Exporting the data to excel with pandas so the user has the option to manipulate it later and having a new window pop up with read only information for instant reference. – Joseph Joe Soltan Jun 24 '20 at 09:06

1 Answers1

0

In a messagebox I don't believe you could do it. You could attempt to do it in a normal window with an entry that you could only copy out of, similarly to this question.

For example, you could do this to show the rows in a simple window:

from tkinter import *
row_info = Tk()
row_info.title("Reinforcement Data Results")

title = Label(text="Total number of reinforcement entries:")
title.pack()

data = Entry(row_info, borderwidth=0, justify='center')
data.insert(END, mycursor.row_count)
data.pack()

data.configure(state="readonly")

close = Button(row_info, text="Ok", command=row_info.destroy)
close.pack()

row_info.mainloop()
Minion3665
  • 879
  • 11
  • 25