Made it so the TableLaptop is in a window
This commit is contained in:
parent
705259f0e8
commit
7106e68c1a
@ -1,21 +1,35 @@
|
|||||||
from networktables import NetworkTables
|
from networktables import NetworkTables
|
||||||
from time import sleep
|
|
||||||
import configparser
|
import configparser
|
||||||
|
import tkinter as tk
|
||||||
|
from tkinter import ttk
|
||||||
|
|
||||||
NetworkTables.initialize()
|
NetworkTables.initialize()
|
||||||
NetworkTables.startServer()
|
NetworkTables.startServer()
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('config.ini')
|
config.read('config.ini')
|
||||||
|
table_name = config.get('settings', 'tables')
|
||||||
|
table = NetworkTables.getTable(table_name)
|
||||||
|
|
||||||
table = config.get('settings', 'tables')
|
root = tk.Tk()
|
||||||
|
root.title("TableLaptop")
|
||||||
|
root.geometry("300x150")
|
||||||
|
|
||||||
table = NetworkTables.getTable(table)
|
status_label = ttk.Label(root, text="Waiting for data...")
|
||||||
print("Server started, waiting for data...")
|
status_label.pack(pady=20)
|
||||||
|
|
||||||
while True:
|
|
||||||
|
ttk.Button(root, text="Close", command=root.destroy).pack()
|
||||||
|
|
||||||
|
def update_data():
|
||||||
cpu = table.getNumber("CPU Usage", -1)
|
cpu = table.getNumber("CPU Usage", -1)
|
||||||
temp = table.getNumber("Temperature", -1)
|
temp = table.getNumber("Temperature", -1)
|
||||||
mem = table.getNumber("Memory", -1)
|
mem = table.getNumber("Memory", -1)
|
||||||
print(f"CPU: {cpu}%, Temp: {temp}C Mem:{mem} MB")
|
|
||||||
sleep(1)
|
status_label.config(text=f"CPU: {cpu}%, Temp: {temp}C Mem: {mem} MB")
|
||||||
|
|
||||||
|
root.after(1000, update_data)
|
||||||
|
|
||||||
|
print("Server started, waiting for data...")
|
||||||
|
update_data()
|
||||||
|
root.mainloop()
|
||||||
|
Loading…
Reference in New Issue
Block a user