Good afternoon,
I am brand new to Python, but have been able to put together a very simple gui, with 3 buttons. One collects and prints a single mysql table, one clears the table, one quits the app. Its reading wireless connection info internally that our WLC is logging.
My current thing is that it only prints data to the console in PyCharm (Im on a Mac/iPad) and never displays it to the window with my buttons. How can I print the data either to a pop up window, or the working app window to assist in troubleshooting connection issues with other team memebers. Below is what I have thus far.
<
import tkinter as tk
import mysql.connector
# creating root window
root = tk.Tk()
def run_command():
mydb = mysql.connector.connect(
host="xxx",
user="xxxx",
password="xxxx",
auth_plugin='mysql_native_password',
database="xxxxx"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM ACCOUNTING")
myresult = mycursor.fetchall()
# loop through the rows
for row in myresult:
print(row)
print("\n")
def run_command2():
mydb = mysql.connector.connect(
host="xxxx",
user="xxxx",
password="xxxxx",
auth_plugin='mysql_native_password',
database="xxxx"
)
mycursor = mydb.cursor()
mycursor.execute("TRUNCATE TABLE XXXXX")
print("Table Cleared")
# root window title and dimension
root.title("Radiator Accounting Lookup and Flush")
root.geometry("1024x768")
# creating button
btn = tk.Button(root, text="Read Table", command=run_command)
btn.pack()
btn = tk.Button(root, text="Clear Table", command=run_command2)
btn.pack()
# Create a quit button
quit_button = tk.Button(root, text="Quit", command=root.quit)
quit_button.pack()
# running the main loop
root.mainloop()
</>