@@ -351,6 +351,9 @@ def __init__(self, camera, *args, **kwargs):
351351 self .manage_camera_widget .capture_button .clicked .connect (self .check_filepath )
352352 self .camera_preview .picTaken .connect (self .advance )
353353
354+ self .manage_camera_widget .do_disable_GUI .connect (self .disable_GUI )
355+ self .manage_camera_widget .do_enable_GUI .connect (self .enable_GUI )
356+
354357 self .manage_vials_widget .vialSelected .connect (self .on_vial_selected )
355358 self .manage_vials_widget .list_controls .deselect_button .clicked .connect (self .reset_filename )
356359 self .manage_vials_widget .list_controls .create_list_button .clicked .connect (self .do_vial_list_dlg )
@@ -384,9 +387,10 @@ def on_vial_selected(self, new_basename):
384387 def on_fileext_change (self , new_ext ):
385388 self .current_picpath .fileext = new_ext
386389
387- @pyqtSlot ()
388- def advance (self ):
389- self .update_filename ()
390+ @pyqtSlot (bool )
391+ def advance (self , success ):
392+ if success == True :
393+ self .update_filename ()
390394
391395 @pyqtSlot ()
392396 def update_filename (self ):
@@ -408,19 +412,19 @@ def check_filepath(self):
408412 @pyqtSlot ()
409413 def enable_GUI (self ):
410414 ''' Enable GUI buttons. '''
411- self .capture_button .setEnabled (True )
412- self .af_controls .checkbox .setEnabled (True )
413- self .af_controls .button .setEnabled (True )
415+ self .manage_camera_widget . capture_button .setEnabled (True )
416+ self .manage_camera_widget . af_controls .checkbox .setEnabled (True )
417+ self .manage_camera_widget . af_controls .button .setEnabled (True )
414418 # self.manage_vials_widget.list_controls.deselect_button.setEnabled(True)
415419 # self.manage_vials_widget.list_controls.create_list_button.setEnabled(True)
416420 # self.manage_vials_widget.list_controls.save_list_button.setEnabled(True)
417421
418422 @pyqtSlot ()
419423 def disable_GUI (self ):
420424 ''' Disable GUI buttons. '''
421- self .capture_button .setEnabled (False )
422- self .af_controls .checkbox .setEnabled (False )
423- self .af_controls .button .setEnabled (False )
425+ self .manage_camera_widget . capture_button .setEnabled (False )
426+ self .manage_camera_widget . af_controls .checkbox .setEnabled (False )
427+ self .manage_camera_widget . af_controls .button .setEnabled (False )
424428
425429 def make_menubar (self ):
426430 # toolbar = QToolBar("Toolbar test")
@@ -593,6 +597,17 @@ def height(self, value):
593597
594598# CAMERA WIDGETS =======================================================
595599class CameraControls (QWidget ):
600+ '''
601+
602+ Attributes
603+ ----------
604+ do_disable_GUI : pyqtSignal()
605+ do_enable_GUI : pyqtSignal()
606+ '''
607+
608+ do_disable_GUI = pyqtSignal ()
609+ do_enable_GUI = pyqtSignal ()
610+
596611 def __init__ (self , preview ):
597612 super ().__init__ ()
598613
@@ -619,39 +634,41 @@ def __init__(self, preview):
619634 self .af_controls .button .clicked .connect (self .run_af_once )
620635 self .af_controls .checkbox .stateChanged .connect (self .af_requirement_changed )
621636 self .capture_button .clicked .connect (self .capture_button_clicked )
637+
638+ self .preview .picTaken .connect (self .do_enable_GUI .emit )
622639
623640 @pyqtSlot ()
624641 def capture_button_clicked (self ):
625642 ''' Respond to image capture button being clicked. '''
626643 # Disable GUI elements until image capture is complete
627- self .disable_GUI ()
644+ self .do_disable_GUI . emit ()
628645
629646 # Check if autofocus must be performed before image is taken
630647 if self .af_required == True :
631648 # Set up a thread to run autofocus
632649 af_worker = Worker (self .run_af )
633650 # TODO: if fail, run again -- worker.signals.result.connect(self.print_output)
634651 # Link completion of autofocus thread to image capture function
635- af_worker .signals .finished .connect (self .do_capture )
652+ af_worker .signals .finished .connect (self .preview . do_capture )
636653 # Start autofocus Worker thread, which will start image
637654 # capture when autofocus is finished
638655 QThreadPool .globalInstance ().start (af_worker )
639656 else :
640657 # Start taking picture immediately since not doing autofocus
641- self .do_capture ()
658+ self .preview . do_capture ()
642659
643660 @pyqtSlot ()
644661 def run_af (self ):
645662 self .picam2 .autofocus_cycle (self .cam )
646663
647664 @pyqtSlot ()
648665 def run_af_once (self ):
649- self .disable_GUI ()
666+ self .do_disable_GUI . emit ()
650667 # Set up a thread to run autofocus
651668 af_worker = Worker (self .run_af )
652669 # TODO: if fail, run again -- worker.signals.result.connect(self.print_output)
653670 # Link completion of autofocus thread to enabling GUI
654- af_worker .signals .finished .connect (self .enable_GUI )
671+ af_worker .signals .finished .connect (self .do_enable_GUI . emit )
655672 # Start autofocus Worker thread
656673 QThreadPool .globalInstance ().start (af_worker )
657674
@@ -666,8 +683,9 @@ class PreviewPlaceholderWidget(QWidget):
666683 Attributes
667684 ----------
668685 picTaken : pyqtSignal
686+ bool : True if picture was taken successfully, False otherwise
669687 '''
670- picTaken = pyqtSignal ()
688+ picTaken = pyqtSignal (bool )
671689
672690 def __init__ (self ):
673691 super ().__init__ ()
@@ -682,6 +700,7 @@ def __init__(self):
682700 @pyqtSlot ()
683701 def do_capture (self ):
684702 print ("Cannot take picture without camera" )
703+ self .picTaken .emit (False )
685704
686705class CameraPreviewWidget (QWidget ):
687706 '''
@@ -690,8 +709,9 @@ class CameraPreviewWidget(QWidget):
690709 Attributes
691710 ----------
692711 picTaken : pyqtSignal
712+ bool : True if picture was taken successfully, False otherwise
693713 '''
694- picTaken = pyqtSignal ()
714+ picTaken = pyqtSignal (bool )
695715
696716 def __init__ (self , camera , width , height ):
697717 super ().__init__ ()
@@ -727,9 +747,8 @@ def capture_pic(self, job):
727747 print ("Executing capture_pic" )
728748 print (type (job ))
729749 self .picam2 .wait (job )
730- self .enable_GUI ()
731750 print ("Picture saved as %s" % (PicPath .current_filepath ))
732- self .picTaken .emit ()
751+ self .picTaken .emit (True )
733752
734753class AFControlsWidget (QWidget ):
735754 ''' A widget containing the widgets that control autofocus. '''
0 commit comments