Merge pull request #2334 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
PySimpleGUI 2019-12-08 15:45:48 -05:00 committed by GitHub
commit c03a8000bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -36,7 +36,7 @@ SC, GCF, WCF = .1, 1, 7/4
sg.change_look_and_feel('Dark Black 1') # make it look cool sg.change_look_and_feel('Dark Black 1') # make it look cool
# ---------------- A Quick Little Window - to get camera to use ---------------- # ---------------- A Quick Little Window - to get camera to use ----------------
win_get_cam = sg.Window('Which Camera?',[[sg.T('Which camera?')],[sg.Combo(['Front', 'Rear'], default_value='Rear', font='any 20')], [sg.Ok()]], location=(0,0)) win_get_cam = sg.Window('Which Camera?',[[sg.T('Which camera?')],[sg.Combo(['Front', 'Rear'], default_value='Rear', font='any 20')],[sg.T(size=(1,2))], [sg.Ok()]], location=(0,0))
event, values = win_get_cam.read() event, values = win_get_cam.read()
win_get_cam.close() win_get_cam.close()
if event != 'Ok': exit() if event != 'Ok': exit()

View File

@ -11,8 +11,17 @@ import cv2
CAMERA_FRONT = 1 CAMERA_FRONT = 1
CAMERA_REAR = 0 CAMERA_REAR = 0
sg.change_look_and_feel('Dark Black 1') sg.change_look_and_feel('Dark Black 1')
# ---------------- A Quick Little Window - to get camera to use ----------------
win_get_cam = sg.Window('Which Camera?',[[sg.T('Which camera?')],[sg.Combo(['Front', 'Rear'], default_value='Rear', font='any 20')],[sg.T(size=(1,2))], [sg.Ok()]], location=(0,0))
event, values = win_get_cam.read()
win_get_cam.close()
if event != 'Ok': exit()
USE_CAMERA = [CAMERA_FRONT, CAMERA_REAR][values[0]=='Rear']
# define the window layout # define the window layout
layout = [[sg.Image(filename='', key='-IMAGE-', tooltip='Right click for exit menu')], layout = [[sg.Image(filename='', key='-IMAGE-', tooltip='Right click for exit menu')],
[sg.Exit()],] [sg.Exit()],]
@ -23,7 +32,7 @@ window = sg.Window('Demo Application - OpenCV Integration', layout, location=(0,
right_click_menu=['&Right', ['E&xit']], ) # if trying Qt, you will need to remove this right click menu right_click_menu=['&Right', ['E&xit']], ) # if trying Qt, you will need to remove this right click menu
# ---===--- Event LOOP Read and display frames, operate the GUI --- # # ---===--- Event LOOP Read and display frames, operate the GUI --- #
cap = cv2.VideoCapture(CAMERA_REAR) # Setup the OpenCV capture device (webcam) cap = cv2.VideoCapture(USE_CAMERA) # Setup the OpenCV capture device (webcam)
while True: while True:
event, values = window.read(timeout=20) event, values = window.read(timeout=20)
if event in ('Exit', None): if event in ('Exit', None):