Currently, the URL is written directly in the code.
Could someone more advanced please improve the program?
I'm using ctk.CTkEntry,
but if I could be greedy,
it would be nice if the entered address could be saved as a history,
like in a combo box.
### def create_root ###
ipcam_value = ctk.BooleanVar(value=modules.globals.ipcam)
ipcam_switch = ctk.CTkSwitch(root, text='IP Camera', variable=ipcam_value, cursor='hand2', command=lambda: setattr(modules.globals, 'ipcam', ipcam_value.get()))
ipcam_switch.place(relx=0.1, rely=0.75)
ipcam_url_value = modules.globals.ipcam_url
ipcam_url_textbox = ctk.CTkEntry(root, placeholder_text="URL", width=340 )
ipcam_url_textbox.place(relx=0.35, rely=0.75)
### def webcam_preview ###
if modules.globals.source_path is None:
# No image selected
return
global preview_label, PREVIEW
# If ipcam_switch is ON, set the value of ipcam_url_textbox to webcam_url
if modules.globals.ipcam:
#webcam_url = ipcam_url_textbox.get()
webcam_url = 'http://192.168.1.10:8888/video'
else:
webcam_url = 0
cap = cv2.VideoCapture(webcam_url) # Use index for the webcam (adjust the index accordingly if necessary)
webcam_url = ipcam_url_textbox.get()
This is the part that should receive the text you entered, but it doesn't work properly.
I added a field to input a URL.
However, I'm a beginner at programming,
so it doesn't work properly.
Currently, the URL is written directly in the code.
Could someone more advanced please improve the program?
I'm using ctk.CTkEntry, but if I could be greedy, it would be nice if the entered address could be saved as a history, like in a combo box.