Help with Python Claqses
Hi Guys and Girls.
I'm new to Python but not programming.
I having trouble understanding how I can update a class that is a Tkinter frame.
The frame is created with a def \_\_init\_\_ and all the text is added.
My question is how do I then reference this frame from a function to update the text on that frame. Basically I am updating a database and want to update the figures in the current frame / window.
Some of the code is below
### Create a class for the Dashboard page. This will also be the start page when the application starts
`class Dashboard (tk.Frame):`
`def __init__(self, parent, controller):`
`tk.Frame.__init__(self,parent, bg="#263D42")`
`label = tk.Label(self, text="Author Dashboard", font=TITLE_FONT, bg="#263D42", fg="white", pady = 20)`
`label.grid(row=0, column=0, sticky="nsew")`
`stat = GetStatsSQL('allPapers')`
`tk.Label(self, text="Number of Publications in the Database", bg="#263D42", fg="white").grid(row=1, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=1, column=1)`
`stat = GetStatsSQL('authors')`
`tk.Label(self, text="Number of Authors in the Database", bg="#263D42", fg="white").grid(row=2, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=2, column=1)`
`stat = GetStatsSQL('journal')`
`tk.Label(self, text="Number of Journals in the Database", bg="#263D42", fg="white").grid(row=3, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=3, column=1)`
`stat = GetStatsSQL('conference')`
`tk.Label(self, text="Number of Conference Papers in the Database", bg="#263D42", fg="white").grid(row=4, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=4, column=1)`
`def update():`
`stat = GetStatsSQL('allPapers')`
`tk.Label(APP, text=stat, bg="#263D42", fg="white").grid(row=1, column=1)`
This is the dashboard class to create and display the dashboard. You can see in the code that there a functions that call SQL to return a result and display it.
What I want to to refresh this page after the database has been changed by another function.
I gave create a function in the Dashboard class but I'm unsure how I can change the tk.label test set when the class was created.
Thanks
Brian
/r/Python
https://redd.it/gudzii
Hi Guys and Girls.
I'm new to Python but not programming.
I having trouble understanding how I can update a class that is a Tkinter frame.
The frame is created with a def \_\_init\_\_ and all the text is added.
My question is how do I then reference this frame from a function to update the text on that frame. Basically I am updating a database and want to update the figures in the current frame / window.
Some of the code is below
### Create a class for the Dashboard page. This will also be the start page when the application starts
`class Dashboard (tk.Frame):`
`def __init__(self, parent, controller):`
`tk.Frame.__init__(self,parent, bg="#263D42")`
`label = tk.Label(self, text="Author Dashboard", font=TITLE_FONT, bg="#263D42", fg="white", pady = 20)`
`label.grid(row=0, column=0, sticky="nsew")`
`stat = GetStatsSQL('allPapers')`
`tk.Label(self, text="Number of Publications in the Database", bg="#263D42", fg="white").grid(row=1, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=1, column=1)`
`stat = GetStatsSQL('authors')`
`tk.Label(self, text="Number of Authors in the Database", bg="#263D42", fg="white").grid(row=2, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=2, column=1)`
`stat = GetStatsSQL('journal')`
`tk.Label(self, text="Number of Journals in the Database", bg="#263D42", fg="white").grid(row=3, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=3, column=1)`
`stat = GetStatsSQL('conference')`
`tk.Label(self, text="Number of Conference Papers in the Database", bg="#263D42", fg="white").grid(row=4, column=0, sticky="w")`
`tk.Label(self, text=stat, bg="#263D42", fg="white").grid(row=4, column=1)`
`def update():`
`stat = GetStatsSQL('allPapers')`
`tk.Label(APP, text=stat, bg="#263D42", fg="white").grid(row=1, column=1)`
This is the dashboard class to create and display the dashboard. You can see in the code that there a functions that call SQL to return a result and display it.
What I want to to refresh this page after the database has been changed by another function.
I gave create a function in the Dashboard class but I'm unsure how I can change the tk.label test set when the class was created.
Thanks
Brian
/r/Python
https://redd.it/gudzii
reddit
Help with Python Claqses
Hi Guys and Girls. I'm new to Python but not programming. I having trouble understanding how I can update a class that is a Tkinter frame. The...