All scripts importing rp2daq need to check for __name__
FilipDominec opened this issue · 2 comments
FilipDominec commented
Suggested new pattern for hello_world.py which works nicely on Windows 10 with multiprocessing support and properly antialiased fonts:
#!/usr/bin/python3
#-*- coding: utf-8 -*-
if __name__ == "__main__":
import tkinter
from tkinter import ttk
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1)
window = tkinter.Tk() # initialize the graphical interface
window.title("RP2DAQ test app")
label = ttk.Label(window)
label.grid(column=0, row=0)
try:
import rp2daq
rp = rp2daq.Rp2daq()
id_string = "".join(chr(b) for b in rp.identify()["data"])
label.config(text = "Successfully connected to " + id_string)
def set_LED(state):
rp.gpio_out(25, state) # onboard LED assigned to gpio 25 on R Pi Pico
btn_on = ttk.Button(window, text='LED on', command=lambda:set_LED(1))
btn_on.grid(column=0, row=1)
btn_off = ttk.Button(window, text='🚫LED off', command=lambda:set_LED(0))
btn_off.grid(column=0, row=2)
except Exception as e:
label.config(text=str(e))
window.mainloop()
epsi1on commented
Hello,
Sorry I think you didn't place the issue in right location. this repo is for C# osciloscope. probably you should place it in your project rp2daq issues
Thanks
FilipDominec commented
Thanks for noting, I sometimes write faster than I think! Anyway, I already committed this code. Let's forget this.