code: def main():
      global root
      global video_file
      global video_cam
      global closeBtn
      global screenshotBtn
      global screenshot_count
      global take_a_screenshot
      global close_video_window
      global sourceSelection
      global scaleSelection
      global popup_menu_source
      global popup_menu_scale
      global checkVarLoop
      global chbLoop
  
      # create our window
      root = Tk()
      root.config(background="navy")
      root.title("CAER Video GUI - Python v" + pythonVersion)
      root.geometry("390x140")
      root.resizable(0, 0)
  
      # the following works for a single screen setup
      # if using a multi-screen setup then see the following link:
      # Ref: https://stackoverflow.com/questions/3129322/how-do-i-get-monitor-resolution-in-python/56913005#56913005
      screenDPI = root.winfo_fpixels("1i")
      screen_width = root.winfo_screenwidth()
      screen_height = root.winfo_screenheight()
  
      video_file, video_cam = None, None
  
      take_a_screenshot = False
      screenshot_count = 0
  
      # bind the 'q' keyboard key to quit
      root.bind("q", lambda event: root.destroy())
  
      close_video_window = False
  
      # -----------------------------------------------------------------------
  
      # add a frame to hold top controls
      frame1 = Frame(root, background="navy")
      frame1.pack(side=TOP, fill=X)
  
      # create a label for the video source
      lblSource = Label(
          frame1,
          text="Video Source",
          fg="yellow",
          bg="navy",
          font="Helvetica 10",
      )
      lblSource.pack(side=LEFT, padx=10, pady=10)
  
      # create the video source selection variable and choices
      sourceSelection = StringVar()
      sourceChoices = [
          "None",
          "Open File >>",
          "Camera_0",
          "Camera_1",
          "Camera_2",
          "Camera_3",
      ]
      sourceSelection.set("None")
      sourceSelection.trace("w", select_video_source)
  
      # create the video source selection popup menu
      popup_menu_source = OptionMenu(
          frame1, sourceSelection, *sourceChoices
      )
      popup_menu_source["width"] = 10
      popup_menu_source["font"] = "Helvetica 10"
      popup_menu_source["bg"] = "lightgreen"
      popup_menu_source.pack(side=LEFT, pady=10)
  
      # create the video scale selection variable and choices
      scaleSelection = StringVar()
      scaleChoices = [
          "2.00",
          "1.75",
          "1.50",
          "1.00",
          "0.75",
          "0.50",
          "0.25",
      ]
      scaleSelection.set("1.00")
  
      # create the built-in image selection popup menu
      popup_menu_scale = OptionMenu(
          frame1, scaleSelection, *scaleChoices
      )
      popup_menu_scale["width"] = 3
      popup_menu_scale["font"] = "Helvetica 10"
      popup_menu_scale["bg"] = "lightgreen"
      popup_menu_scale.pack(side=RIGHT, padx=10, pady=10)
  
      # create a label for the video scaling
      lblScale = Label(
          frame1,
          text="Video Scale",
          fg="yellow",
          bg="navy",
          font="Helvetica 10",
      )
      lblScale.pack(side=RIGHT, pady=10)
  
      # -----------------------------------------------------------------------
  
      # add a frame to hold caer version and screen attributes labels
      frame2 = Frame(root, background="navy")
      frame2.pack(side=TOP, fill=X)
  
      lblScreen = Label(
          frame2,
          text="Screen : "
          + str(screen_width)
          + " x "
          + str(screen_height)
          + "   dpi: "
          + str(int(screenDPI)),
          fg="lightgrey",
          bg="navy",
          font="Helvetica 9",
      )
      lblScreen.pack(side=LEFT, padx=10, pady=10)
  
      lblVersion = Label(
          frame2,
          text="caer  v" + caerVersion,
          fg="lightgrey",
          bg="navy",
          font="Helvetica 9",
      )
      lblVersion.pack(side=RIGHT, padx=10, pady=10)
  
      # -----------------------------------------------------------------------
  
      # add a frame to hold Loop checkbox and Close Video, Screenshot and Exit buttons
      frame3 = Frame(root, background="navy")
      frame3.pack(side=TOP, fill=BOTH)
  
      # add Close Video button
      closeBtn = Button(
          frame3,
          text="Close Video",
          width=10,
          fg="blue",
          bg="lightgrey",
          state="disabled",
          relief=RAISED,
          command=close_video,
      )
      closeBtn.pack(side=LEFT, padx=10, pady=10)
  
      # add Screenshot button
      screenshotBtn = Button(
          frame3,
          text="Screenshot",
          width=10,
          fg="blue",
          bg="lightgrey",
          state="disabled",
          relief=RAISED,
          command=take_screenshot,
      )
      screenshotBtn.pack(side=LEFT, padx=1, pady=10)
  
      # add Loop checkbox
      checkVarLoop = IntVar()
      chbLoop = Checkbutton(
          frame3,
          text="Loop",
          variable=checkVarLoop,
          bg="lightgrey",
          fg="blue",
          font="Helvetica 8",
          state="disabled",
      )
      checkVarLoop.set(0)
      chbLoop.pack(side=LEFT, padx=10, pady=8)
  
      # add Exit button
      exitBtn = Button(
          frame3,
          text="Exit",
          width=10,
          fg="red",
          bg="lightgrey",
          relief=RAISED,
          command=root.destroy,
      )
      exitBtn.pack(side=RIGHT, anchor=CENTER, padx=10, pady=10)
  
      # -----------------------------------------------------------------------
  
      # set the minimum window size to the current size
      root.update()
      root.minsize(root.winfo_width(), root.winfo_height())
  
      root.mainloop()
  
imports: from tkinter import *
  from tkinter import filedialog
  import threading
  import platform
  import caer
label_desc: Use image node_id 8 for calling a global function with example usage: main() without return types