Updated script
This commit is contained in:
parent
ad01149daa
commit
6c42d931b6
@ -42,14 +42,14 @@ def set_res_mode():
|
||||
if not ser:
|
||||
return "TEST"
|
||||
rawdata = send_command(f'[SENSe:]FUNCtion:RESistance')
|
||||
rawdata = send_command(f'[SENSe:]RESistance:RANGe:AUTO')
|
||||
rawdata = send_command(f'[SENSe:]RESistance:RANGe:AUTO ON')
|
||||
return rawdata
|
||||
|
||||
def set_res200_mode():
|
||||
if not ser:
|
||||
return "TEST"
|
||||
rawdata = send_command(f'[SENSe:]FUNCtion:RESistance')
|
||||
rawdata = send_command(f'[SENSe:]RESistance:RANGe:200')
|
||||
rawdata = send_command(f'[SENSe:]RESistance:RANGe 200')
|
||||
return rawdata
|
||||
|
||||
def set_cont_mode():
|
||||
@ -87,10 +87,12 @@ def fetch_device_info():
|
||||
# Fetch the device ID and Channel data
|
||||
multimeter_data = get_multimeter_data()
|
||||
|
||||
# Update the labels
|
||||
multimeter_type_var.set(multimeter_data.split(",")[0])
|
||||
multimeter_data_var.set(multimeter_data.split(",")[1])
|
||||
multimeter_range_var.set(multimeter_data.split(",")[3])
|
||||
if "," in multimeter_data:
|
||||
if len(multimeter_data.split(",")) >= 4:
|
||||
# Update the labels
|
||||
multimeter_type_var.set(multimeter_data.split(",")[0])
|
||||
multimeter_data_var.set(multimeter_data.split(",")[1].replace("+","").replace("Ohm",'\u2126'))
|
||||
multimeter_range_var.set(multimeter_data.split(",")[3].replace("Ohm",'\u2126'))
|
||||
|
||||
# Schedule this function to be called again after 100ms
|
||||
app.after(100, fetch_device_info)
|
||||
@ -105,18 +107,18 @@ multimeter_data_var = tk.StringVar()
|
||||
multimeter_range_var = tk.StringVar()
|
||||
|
||||
# Create dynamic font objects
|
||||
fontSmall = Font(size=10)
|
||||
fontMedium = Font(size=20)
|
||||
fontBig = Font(size=80)
|
||||
fontSmall = Font(size=6)
|
||||
fontMedium = Font(size=14)
|
||||
fontBig = Font(size=24)
|
||||
|
||||
resize_after_id = None
|
||||
|
||||
def apply_font_resize():
|
||||
width = app.winfo_width()
|
||||
|
||||
fontSmall.configure(size=max(4, int(width * 0.02)))
|
||||
fontMedium.configure(size=max(14, int(width * 0.03)))
|
||||
fontBig.configure(size=max(24, int(width * 0.1)))
|
||||
fontSmall.configure(size=max(6, int(width * 0.01)))
|
||||
fontMedium.configure(size=max(14, int(width * 0.02)))
|
||||
fontBig.configure(size=max(24, int(width * 0.09)))
|
||||
|
||||
def resize_loop():
|
||||
apply_font_resize()
|
||||
@ -124,49 +126,49 @@ def resize_loop():
|
||||
|
||||
resize_loop() # start it once
|
||||
|
||||
# Bind resize event
|
||||
#app.bind("<Configure>", resize_fonts)
|
||||
|
||||
# Configure grid to be fully responsive
|
||||
app.rowconfigure(0, weight=4) # Top - medium
|
||||
app.rowconfigure(1, weight=20) # Middle - big
|
||||
app.rowconfigure(2, weight=1) # Bottom - small
|
||||
app.rowconfigure(0, weight=20) # Top - big
|
||||
app.rowconfigure(1, weight=1) # Bottom - small
|
||||
|
||||
for j in range(7):
|
||||
app.columnconfigure(j, weight=1)
|
||||
app.columnconfigure(0, weight=1, uniform="equal", minsize=100)
|
||||
for i in range(7):
|
||||
app.columnconfigure(i+1, weight=1, uniform="equal")
|
||||
|
||||
button_fg = "#444444"
|
||||
|
||||
# Labels
|
||||
# Type and Range
|
||||
tk.Label(app, textvariable=multimeter_type_var, font=fontMedium, bg="black", fg="lightgrey") \
|
||||
.grid(column=0, columnspan=3, row=0, sticky="nsew", padx=0, pady=0)
|
||||
.grid(column=0, columnspan=1, row=1, sticky="nsw", padx=0, pady=0)
|
||||
|
||||
tk.Label(app, textvariable=multimeter_range_var, font=fontMedium, bg="black", fg="lightgrey") \
|
||||
.grid(column=4, columnspan=3, row=0, sticky="nsew", padx=0, pady=0)
|
||||
.grid(column=0, columnspan=1, row=0, sticky="nw", padx=0, pady=0)
|
||||
|
||||
# Data
|
||||
tk.Label(app, textvariable=multimeter_data_var, font=fontBig, bg="black", fg="lightgrey") \
|
||||
.grid(column=0, columnspan=7, row=1, sticky="nsew", padx=0, pady=0)
|
||||
.grid(column=1, columnspan=6, row=0, rowspan=1, sticky="nsew", padx=0, pady=10)
|
||||
|
||||
tk.Button(app, text="RES", command=set_res_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=0, row=2, sticky="nsew", padx=0, pady=0)
|
||||
# Buttons
|
||||
tk.Button(app, text="RES", command=set_res_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=1, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
tk.Button(app, text="RES200", command=set_res200_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=1, row=2, sticky="nsew", padx=0, pady=0)
|
||||
tk.Button(app, text="RES200", command=set_res200_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=2, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
tk.Button(app, text="CONT", command=set_cont_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=2, row=2, sticky="nsew", padx=0, pady=0)
|
||||
tk.Button(app, text="CONT", command=set_cont_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=3, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
tk.Button(app, text="VOLT:DC", command=set_voltdc_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=3, row=2, sticky="nsew", padx=0, pady=0)
|
||||
tk.Button(app, text="VOLT:DC", command=set_voltdc_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=4, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
tk.Button(app, text="VOLT:AC", command=set_voltac_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=4, row=2, sticky="nsew", padx=0, pady=0)
|
||||
tk.Button(app, text="VOLT:AC", command=set_voltac_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=5, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
tk.Button(app, text="DIOD", command=set_diod_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=5, row=2, sticky="nsew", padx=0, pady=0)
|
||||
tk.Button(app, text="DIOD", command=set_diod_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=6, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
tk.Button(app, text="CAP", command=set_cap_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground=button_fg, borderwidth=0) \
|
||||
.grid(column=6, row=2, sticky="nsew", padx=0, pady=0)
|
||||
tk.Button(app, text="CAP", command=set_cap_mode, font=fontSmall, bg="black", fg=button_fg, highlightbackground="black", borderwidth=0) \
|
||||
.grid(column=7, row=1, sticky="nsew", padx=0, pady=0)
|
||||
|
||||
# Initial fetch to start the auto-update process
|
||||
fetch_device_info()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user