Esempio n. 1
0
    def __init__(self, formset, calibfile, logdir):
        BaseWidget.__init__(self)
        self.set_margin(10)

        self._logdir = logdir

        self._calibfile = 'calibration/t0_calibration.yaml'
        self._calib_dict = {}

        self._daq_queue = Queue()
        self._data = Data(self._logdir)

        self._insight_panel = ControlEmptyWidget(margin=10)
        self._stage_panel = ControlEmptyWidget(margin=10, side='right')
        self._zidaq_panel = ControlEmptyWidget(margin=10)
        self._expmt_panel = ControlEmptyWidget(margin=10)

        self._insight = InsightController('COM6', 0.07, formset['insight'])
        self._insight.parent = self
        self._insight_panel.value = self._insight

        self._delaystage = StageController('COM7', 0.05, formset['stage'])
        self._delaystage.parent = self
        self._stage_panel.value = self._delaystage

        self._zidaq = ziDAQController(formset['zidaq'])
        self._zidaq.parent = self
        self._zidaq_panel.value = self._zidaq

        # Organization and parameter initialization
        self._expmt_widgets()
        self._load_calibration(self._calibfile)

        self.formset = formset['expmt']
Esempio n. 2
0
 def _get_tab_cont_for_section(self, section):
     tab_container = ControlEmptyWidget()
     tab_container.value = \
         SingleTabWidget(
             su2_cfg_obj=self.su2_cfg_obj, des_sect_name=section,
             tabs_ctrl=self)
     return tab_container
Esempio n. 3
0
    def _set_srfs_loader(self):
        """
        Setter for surface loader button
        Returns
        -------
        ControlButton

        """

        # self, su2_cfg_obj: SU2Config,
        # surf_loader_but_label: str = 'Load surfaces from su2 mesh',
        # msh_prsng_params_pth: str = 'su2_msh_parsing_params.yaml'

        _srfs_load_butt = \
            SurfLoader(
                su2_cfg_obj=self.su2_cfg_obj,
                surf_loader_but_label='Load surfaces from su2 mesh',
                msh_prsng_params_pth=self.msh_prsng_params_pth)

        load_butt_cont = ControlEmptyWidget()
        load_butt_cont.value = _srfs_load_butt

        # print(type(_srfs_load_butt))
        # print(isinstance(_srfs_load_butt, ControlButton))
        self.ctrld_tab._srfs_load_butt_cont = load_butt_cont  # load_butt_cont
    def __init__(self, *args, **kwargs):
        self._custom_form_app_id = None

        self.select_form = ControlAutoComplete(
            'Form', changed_event=self.__update_custom_form_evt)
        self.customized_form = ControlEmptyWidget(name='customized_form',
                                                  parent=self)

        super().__init__(*args, **kwargs)
Esempio n. 5
0
    def __init__(self, parent=None):
        BaseWidget.__init__(self, 'Motion counter', parent_win=parent)

        self.set_margin(5)

        self.setMinimumHeight(300)
        self.setMinimumWidth(500)

        self._player = ControlPlayer('Player')
        self._datasets = ControlEmptyWidget('Paths', default=DatasetsDialog())
        self._backgrounds = ControlEmptyWidget('Backgrounds',
                                               default=ObjectsDialog())
        self._show_diff = ControlCheckBox('Show diffs boxes')
        self._threshold = ControlSlider('Threshold',
                                        default=5,
                                        minimum=1,
                                        maximum=255)
        self._radius = ControlSlider('Radius',
                                     default=30,
                                     minimum=1,
                                     maximum=200)
        self._apply = ControlButton('Apply', checkable=True)
        self._compare = ControlCombo('Compare with')
        self._progress = ControlProgress('Progress')

        self._formset = [
            '_datasets', '=', '_compare', '_backgrounds',
            ('_threshold', '_radius', '_show_diff'), '_player', '_apply',
            '_progress'
        ]

        self._compare.add_item('Last frame', 1)
        self._compare.add_item('First frame', 2)
        self._compare.add_item('Background image', 3)

        self.load_order = ['_threshold', '_radius', '_show_diff']

        self._backgrounds.value.datasets_filter = lambda x: isinstance(
            x, Image)
        self._datasets.value.datasets_filter = lambda x: isinstance(
            x, (Contours, Path))
        self._player.process_frame_event = self.__process_frame_event
        self._datasets.value.video_selection_changed_event = self.__video_selection_changed_event

        self._compare.changed_event = self.__compare_changed_event

        self._apply.value = self.__apply_btn_event
        self._apply.icon = conf.ANNOTATOR_ICON_MOTION

        self._progress.hide()
        self._backgrounds.hide()
Esempio n. 6
0
    def _set_new_param_setter(self):
        """
        Sets a button which spawns new parameter creation dialog
        Returns
        -------

        """
        cpc = ConfigParamCreatorButt(su2_cfg_obj=self.su2_cfg_obj,
                                     des_cfg_section=self.fxd_des_section_name,
                                     tabs_ctrl=self.tabs_ctrl)

        cpc_cont = ControlEmptyWidget()
        cpc_cont.value = cpc

        self.ctrld_tab._cfg_param_creator = cpc_cont
Esempio n. 7
0
    def _get_container_for_widget(self, widget=None):
        """Getter for widget container"""
        container = \
            ControlEmptyWidget(label='Container label')
        if widget is not None:
            container.value = \
                widget

            if isinstance(widget, Iterable):
                sample_widget = widget[0]
                self._set_container_size(container, sample_widget)
            else:
                self._set_container_size(container, widget)

        return container
Esempio n. 8
0
    def __init__(self, timeline=None):
        super(ImportWindow, self).__init__('Import file', parent_win=timeline)
        self.setContentsMargins(10, 10, 10, 10)
        self._timeline = timeline

        # Definition of the forms fields
        self._filetype = ControlCombo(
            'Please select the type of file you would like to import:')
        self._importButton = ControlButton('Import')
        self._panel = ControlEmptyWidget('Panel')
        self._file = ControlFile('File to import')

        self._panel.value = self._file
        self._filetype.add_item('Events file', 0)
        self._filetype.add_item('Graph file', 1)
        self._filetype.add_item('Bonsai events file', 2)
        self._filetype.add_item('Bonsai events file (old format)', 3)

        self._formset = [('_filetype', ' '), '_panel', (' ', '_importButton'),
                         ' ']

        self._filetype.changed_event = self.__fileTypeChanged
        self._importButton.value = self.__importData

        from pyforms.gui.dialogs.csv_parser import CsvParserDialog
        self._graphCsvParserDlg = CsvParserDialog()
        self._graphCsvParserDlg.xField.label = "Value column"
        self._graphCsvParserDlg.yField.hide()
        self._graphCsvParserDlg.zField.hide()
        self._graphCsvParserDlg.loadButton.hide()

        self._bonsai_import_dlg = BonsaiImportFileDlg()
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        request_form = UserRequestForm(user_request_app=self)
        self.request_form_id = request_form.uid

        self._editform = ControlEmptyWidget(
            parent=self,
            name='_editform',
            default=request_form
        )

        self._list = ControlQueryList(
            'Requests',
            list_display=['requested_on', 'resource', 'is_closed', 'is_approved'],
            item_selection_changed_event=self.__item_selection_changed_evt
        )

        self._accesses = ControlQueryList(
            'Approved accesses',
            list_display=['resource', 'start_date', 'end_date', 'is_revoked']
        )

        self.formset = [
            '_editform',
            ' ',
            'h3:Your accesses',
            '_accesses',
            'h3:Your requests',
            '_list',
        ]

        self.populate_list()
    def __init__(self, parent=None):
        super(DistancesWindow, self).__init__('Distances', parent_win=parent)
        self.mainwindow = parent

        self.set_margin(5)

        #self.layout().setMargin(5)
        self.setMinimumHeight(400)
        self.setMinimumWidth(800)

        self._datasets_panel = ControlEmptyWidget('Paths')
        self._progress = ControlProgress('Progress')
        self._apply = ControlButton('Apply', checkable=True)

        self._formset = ['_datasets_panel', '_apply', '_progress']

        self.load_order = ['_datasets_panel']

        self.datasets_dialog = DatasetsDialog(self)
        self._datasets_panel.value = self.datasets_dialog
        self.datasets_dialog.datasets_filter = lambda x: isinstance(
            x, (Path, Contours))

        self._apply.value = self.__apply_event
        self._apply.icon = conf.ANNOTATOR_ICON_PATH

        self._progress.hide()
Esempio n. 11
0
    def __init__(self):
        BaseWidget.__init__(self)
        Organisms.__init__(self)

        self._list = ControlList(
            'Organisms',
            add_function=self.__addOrganismBtnAction,
            remove_function=self.__removeOrganismBtnAction)
        self._list.horizontal_headers = [
            'Kingdom', 'Class', 'Order', 'Family', 'Name'
        ]
        self._panel = ControlEmptyWidget()
        self.filedialog = ControlFile()
        self.filedialog.hide()

        self.mainmenu = [{
            'File': [{
                'Open': self.__openMenuAction
            }, {
                'Save': self.__saveMenuAction
            }]
        }]

        # Add by default some entities
        self.add(cat)
        self.add(human)
Esempio n. 12
0
    def __init__(self):

        BaseWidget.__init__(self, 'E-Mail Machine')
        self._panel = ControlEmptyWidget()

        """
        load login screen on startup
        """
        self._panel.value = self.make_login_view()
Esempio n. 13
0
    def __init__(self):
        # Class Vars:
        self.__players = []  # List of players

        # Player Setup Tab -- Init UI Elements
        #super(MBUI, self).__init__("Millennium Blades Helper")
        BaseWidget.__init__(self, "Millennium Blades Helper")
        self._lstPlayers = ControlList('Player List')
        self._btnAddPl = ControlButton('Add Player')
        self._btnRemPl = ControlButton('Remove Selected Player')
        self._btnGenPl = ControlButton('Generate Player Setup')

        # Player Setup Tab -- Set up properties of UI elements, attach callbacks, etc.
        self._lstPlayers.horizontal_headers = [
            'Name', 'Character', 'Starter Deck'
        ]
        self._btnAddPl.value = self.__onAddPlayerClick
        self._btnRemPl.value = self.__onRemoveSelectedPlayerClick
        self._btnGenPl.value = self.__onGeneratePlayerSetupClick

        # Store Setup Tab -- Init UI Elements
        self._lstStore = ControlList('Store Components')
        self._ckAreaLabel = ControlLabel('Sets To Use')
        self._btnGenerateSt = ControlButton('Generate Store')

        # Store Setup Tab -- Set up properties of UI elements, attach callbacks etc.
        self._lstStore.horizontal_headers = ['Category', 'Sets']
        self._btnGenerateSt.value = self.__onGenerateStoreClick

        # Scoring Tab -- Init UI Components
        self._scoringPanel = ControlEmptyWidget()
        self._btnGetScoring = ControlButton('Generate Score Sheet')

        # Scoring Tab -- Set up properties of UI elements, attach callbacks etc.
        self._btnGetScoring.value = self.__onGenerateScoringClick

        # Set Selection Tab -- Init UI Components
        self._chkArea = ControlCheckBoxList('Sets To Use')

        # Set Selection Tab -- Set up properties of UI elements, attach callbacks etc.
        self._chkArea += ('Base Set', True)
        self._chkArea += ('Set Rotation', True)
        self._chkArea += ('MX #1: Crossover', True)
        self._chkArea += ('MX #2: Sponsors', True)
        self._chkArea += ('MX #3: Fusion Chaos', True)
        self._chkArea += ('MX #4: Final Bosses', True)
        self._chkArea += ('MX #5: Futures', True)
        self._chkArea += ('MX #6: Professionals', True)

        # Set up tabs and component flow for UI
        self.formset = [{
            '1. Player Setup':
            ['_lstPlayers', ' ', ('_btnAddPl', '_btnRemPl', '_btnGenPl')],
            '2. Store Setup': ['_lstStore', ' ', '_btnGenerateSt'],
            '3. Scoring': ['_scoringPanel', '_btnGetScoring'],
            '4. Set Selection': ['_chkArea']
        }]
    def __init__(self, parent=None):
        super(BackgroundFinderWindow, self).__init__('Background finder',
                                                     parent_win=parent)
        self.mainwindow = parent

        self.set_margin(5)

        self.setMinimumHeight(400)
        self.setMinimumWidth(400)

        self._panel = ControlEmptyWidget('Videos')
        self._image = ControlImage('Image')
        self._progress = ControlProgress('Progress')
        self._apply = ControlButton('Apply', checkable=True)

        self._matrixSize = ControlSlider('Gaussian blur matrix size',
                                         default=5,
                                         minimum=1,
                                         maximum=11)
        self._sigmaX = ControlSlider('Gaussian blur sigma X',
                                     default=5,
                                     minimum=1,
                                     maximum=11)

        self._jump_2_frame = ControlSlider('Jump n frames',
                                           default=100,
                                           minimum=1,
                                           maximum=10000)
        self._cmp_jump = ControlSlider('Compare with frame in front',
                                       default=100,
                                       minimum=1,
                                       maximum=10000)
        self._threshold = ControlSlider('Threshold',
                                        default=5,
                                        minimum=0,
                                        maximum=255)

        self._formset = [[
            '_panel',
            '||',
            [
                ('_matrixSize', '_sigmaX'),
                ('_jump_2_frame', '_cmp_jump', '_threshold'),
                '_image',
            ],
        ], '_apply', '_progress']

        self.videos_dialog = VideosDialog(self)
        self._panel.value = self.videos_dialog
        self.videos_dialog.interval_visible = False

        self._apply.value = self.__apply_event
        self._apply.icon = conf.ANNOTATOR_ICON_PATH

        self._progress.hide()
Esempio n. 15
0
	def __init__(self, parent=None):
		BaseWidget.__init__(self, 'Regions filter', parent_win=parent)
		self.mainwindow = parent

		self.set_margin(5)
		
		self.setMinimumHeight(300)
		self.setMinimumWidth(500)

		self._paths = []

		self._pathspanel	= ControlEmptyWidget('Path to process')
		self._geomspanel 	= ControlEmptyWidget('Geometries')		
		self._apply  		= ControlButton('Apply', checkable=True)
		self._progress  	= ControlProgress('Progress')

		
		self._formset = [
			'_pathspanel',
			'_geomspanel',
			'_apply',
			'_progress'
		]

		self.load_order = ['_start', '_end', '_panel']

		self.paths_dialog = DatasetsDialog(self)
		self.paths_dialog.objects_filter  = lambda x: isinstance(x, Object2D)
		self.paths_dialog.datasets_filter = lambda x: isinstance(x, (Contours,Path) )
		self._pathspanel.value = self.paths_dialog

		self.geoms_dialog = ObjectsDialog(self)
		self.geoms_dialog.objects_filter = lambda x: isinstance(x, Geometry)
		self._geomspanel.value = self.geoms_dialog


	
		self._apply.value = self.__apply_btn_event
		self._apply.icon  = conf.ANNOTATOR_ICON_REGIONS

		self._progress.hide()
Esempio n. 16
0
    def __init__(self, *args, **kwargs):
        self._parmsapp_uid = None

        self._parms = ControlEmptyWidget(css='ui segment red',
                                         parent=self,
                                         name='_parms')

        super().__init__(*args, **kwargs)

        self.__field_type_changed_evt()

        self.field_type.changed_event = self.__field_type_changed_evt
Esempio n. 17
0
    def _set_sect_creat_btn(self):
        # su2_cfg_obj: SU2Config = SU2Config(),
        #             tabs_ctrl

        tabs_ctrl = CFGSectionSelWidgetCtrl.ctrld_tabs_w.vert_tab_w_ctrl
        # print('CFGSectionSelWidgetCtrl tabs_ctrl')
        # print(tabs_ctrl)
        # input('CFGSectionSelWidgetCtrl tabs_ctrl')

        self.sect_creat_btn = \
            CFGSectionCreatorButton(
                su2_cfg_obj=self.su2_cfg_obj,
                tabs_ctrl=CFGSectionSelWidgetCtrl.ctrld_tabs_w.vert_tab_w_ctrl,
                sections_list=CFGSectionSelWidgetCtrl.ctrld_widget.sections_chckbox_list)

        btn_cont = ControlEmptyWidget()
        btn_cont.value = self.sect_creat_btn

        CFGSectionSelWidgetCtrl.ctrld_widget.sect_creat_btn = btn_cont
        # self.sect_creat_btn
        pass
Esempio n. 18
0
    def __init__(self, **kwargs):
        BaseWidget.__init__(self, 'Polygons Mask')
        Class.__init__(self, **kwargs)

        try:
            self.layout().setContentsMargins(10, 5, 10, 5)
            self.setMinimumHeight(150)
        except:
            pass

        self._panel = ControlEmptyWidget('Panel', default=ObjectsDialog())
        self._panel.value.objects_filter = lambda x: isinstance(x, Geometry)
        self._panel.value.objects_changed_event = self.__objects_changed_event
Esempio n. 19
0
 def _set_cfg_param_creator_butt(self):
     # su2_cfg: SU2Config = None,
     # des_cfg_section: str = 'INPUT_OUTPUT_INFORMATION',
     # cfg_param_creator_butt_label: str = 'Add new parameter'
     butt_cont = ControlEmptyWidget()
     # butt_cont.value = \
     cpb = \
         CreateParamButt(
             su2_cfg_obj=self.su2_cfg_obj,
             des_cfg_section=self.des_cfg_section,
             cfg_param_creator_butt_label=self.cfg_param_creator_butt_label,
             tabs_ctrl=self.tabs_ctrl)
     self.ctrld_w.create_sect_butt = cpb
Esempio n. 20
0
    def __init__(self):
        super(BlackInkBE, self).__init__('BlackInk Backend')
        self._display_name = ControlLabel('')
        self._accounts_admin = ControlToolButton('Accounts Panel',
                                                 maxheight=100,
                                                 maxwidth=100)
        self._accounts_admin.hide()
        self._accounts_admin.value = self._Accounts

        self._user = None
        self._connection = db_connect()

        self._panel = ControlEmptyWidget()
        self._login()
    def __init__(self, **kwargs):
        BaseWidget.__init__(self, 'Polygons Mask')
        Class.__init__(self, **kwargs)

        try:
            self.layout().setContentsMargins(10, 5, 10, 5)
            self.setMinimumHeight(230)
        except:
            pass

        self._panel = ControlEmptyWidget('Panel', default=ObjectsDialog())
        self._panel.value.objects_filter = lambda x: isinstance(x, Image)
        self._panel.value.objects_changed_event = self.__objects_changed_event

        self.formset = ['_field_background_subtract_threshold', '_panel']
Esempio n. 22
0
    def __init__(self, parent_win=None):
        BaseWidget.__init__(self,
                            'Videos and intervals selector',
                            parent_win=parent_win)

        self._panel = ControlEmptyWidget(default=VideosSelectorDialog(
            parent_win=self))
        self._interval = ControlBoundingSlider('Interval', horizontal=True)

        self.formset = ['_panel', '_interval']

        self._intervals = {}

        self._panel.value.video_selection_changed_event = self.__video_selection_changed_event
        self._interval.changed_event = self.__update_intervals_event
Esempio n. 23
0
    def __init__(self, *args, **kwargs):
        user = PyFormsMiddleware.user()
        try:
            person = Person.objects.get(auth_user=user)
        except Person.DoesNotExist:
            person = Person.objects.get(email=user.email)
            person.auth_user = user
            person.save()

        super().__init__(pk=person.pk, *args, **kwargs)

        membership = GroupMembership.objects.filter(person=person).first()
        membership_html = (
            f'<h3><a>{membership.group}</a> - {membership.position}</h3>'
            if membership is not None else '')
        s = (f'<h1>{person.full_name}</h1>'
             '<address>'
             f'{membership_html}'
             '\n'
             f'<a href="mailto:{person.email}" target="_blank">'
             f'<i class="envelope icon"></i>{person.email}</a>'
             '</address>')
        self._summary = ControlSimpleLabel(
            default=s,
            label_visible=False,
            field_css='fourteen wide',
        )

        if hr_module_installed:
            self._privateinfo = ControlEmptyWidget(
                parent=self,
                name='_privateinfo',
                default=ProfilePrivateInfoFormWidget(
                    pk=person.get_privateinfo().pk,
                    has_cancel_btn=False,
                ),
            )

        try:
            img_url = self.model_object.thumbnail_url(
                geometry_string='300x300')
        except AttributeError:
            img_url = static('square-image.png')
        self._img = ControlImg('Image',
                               default=img_url,
                               label_visible=False,
                               field_css='three wide')
    def __init__(self, parent_win=None):
        BaseWidget.__init__(self, 'Datasets', parent_win=parent_win)

        self._panel = ControlEmptyWidget(default=DatasetsSelectorDialog(
            parent_win=self))
        self._interval = ControlBoundingSlider('Interval', horizontal=True)
        self._apply_btn = ControlButton('Apply')

        self.formset = [
            '_panel',
            '_interval',
            '_apply_btn',
        ]

        self._intervals = {}

        self._panel.value.video_selection_changed_event = self.__video_selection_changed_event
        self._interval.changed_event = self.__update_intervals_event
        self._apply_btn.hide()
Esempio n. 25
0
    def __init__(self, parent=None):
        super(SmoothPathsWindow, self).__init__('Smooth paths',
                                                parent_win=parent)
        self.mainwindow = parent

        self.set_margin(5)
        self.setMinimumHeight(400)
        self.setMinimumWidth(800)

        self._datasets_panel = ControlEmptyWidget('Paths')
        self._progress = ControlProgress('Progress')
        self._apply = ControlButton('Apply', checkable=True)

        self._winsize = ControlSlider('Window size',
                                      minimum=3,
                                      default=3,
                                      maximum=100)
        self._order = ControlSlider('Order', minimum=0, default=0, maximum=10)
        self._deriv = ControlSlider('Derivative',
                                    minimum=0,
                                    default=0,
                                    maximum=10)
        self._rate = ControlSlider('Rate', minimum=0, default=0, maximum=10)

        self._formset = [
            '_datasets_panel', '=', '_winsize', '_order', '_deriv', '_rate',
            ' ', '_apply', '_progress'
        ]

        self.load_order = ['_datasets_panel']

        self.datasets_dialog = DatasetsDialog(self)
        self._datasets_panel.value = self.datasets_dialog
        self.datasets_dialog.datasets_filter = lambda x: isinstance(
            x, (Path, Value))

        self._apply.value = self.__apply_event
        self._apply.icon = conf.ANNOTATOR_ICON_PATH

        self._progress.hide()
Esempio n. 26
0
    def _get_param_ctrl_cont(
            self,
            param_label: str,
            param_ctrl: ControlBase,
            srf_sel_button: ControlButton
        or None = None) -> ControlEmptyWidget:
        """
        Getter for entire 'param ensemble': label, control and on-off param
        edit toogle

        Parameters
        ----------
        param_label: ControlLabel
            control with param label
        param_ctrl: Control Base
            param control

        Returns
        -------
        ControlBaseWidget
            container with entire param control assembly

        """
        param_chckbox = self._get_param_ctrl_toogle(param_ctrl)
        curr_ctrl_groupbox = QGroupBox(param_label)
        self._set_grpbx_stylesheet(curr_ctrl_groupbox)

        vert_layout = QVBoxLayout(curr_ctrl_groupbox)
        first_grpbx_row = QHBoxLayout()
        param_ctrl.form.setMinimumWidth(200)
        param_ctrl.form.setMaximumWidth(200)
        first_grpbx_row.addWidget(param_ctrl.form)
        first_grpbx_row.addWidget(param_chckbox._form)

        vert_layout.addLayout(first_grpbx_row)
        if srf_sel_button is not None:
            srf_sel_button_cont = ControlEmptyWidget()
            srf_sel_button_cont.value = srf_sel_button
            vert_layout.addWidget(srf_sel_button_cont.form)

        curr_ctrl_cont = ControlEmptyWidget()

        curr_ctrl_cont._param_chckbox = param_chckbox
        curr_ctrl_cont.form.layout().addWidget(curr_ctrl_groupbox)  # curr_w

        return curr_ctrl_cont
Esempio n. 27
0
    def __init__(self, parent=None):
        super(FindOrientationWindow,
              self).__init__('Estimate countour orientation',
                             parent_win=parent)
        self.mainwindow = parent

        self.set_margin(5)

        self.setMinimumHeight(300)
        self.setMinimumWidth(300)

        self._panel = ControlEmptyWidget('Videos')
        self._progress = ControlProgress('Progress')
        self._apply = ControlButton('Apply', checkable=True)
        self._debug = ControlCheckBox('Create all the intermediate values')

        self._min_steps = ControlSlider('Minimum steps',
                                        default=20,
                                        minimum=1,
                                        maximum=1000)
        self._min_dist = ControlSlider('Minimum distance',
                                       default=30,
                                       minimum=1,
                                       maximum=1000)

        self._panel.value = self.contours_dialog = DatasetsDialog(self)
        self.contours_dialog.datasets_filter = lambda x: isinstance(
            x, Contours)

        self._formset = [
            '_panel', ('_min_steps', '_min_dist'), '_debug', '_apply',
            '_progress'
        ]

        self._apply.value = self.__apply_event
        self._apply.icon = conf.ANNOTATOR_ICON_PATH

        self._progress.hide()
    def __init__(self, **kwargs):
        BaseWidget.__init__(self, 'Path mask')
        Class.__init__(self, **kwargs)

        try:
            self.layout().setContentsMargins(10, 5, 10, 5)
            self.setMinimumHeight(170)
        except:
            pass

        self._control_pathmask_radius       = ControlSlider('Mask radius', default=30,  minimum=1, maximum=600)
        self._panel                         = ControlEmptyWidget('Panel', default=DatasetsDialog() )
        self._panel.value.interval_visible  = False
        self._panel.value.datasets_filter   = lambda x: isinstance(x, (Contours,Path) )

        self._panel.value.datasets_changed_event = self.__update_paths

        self._formset = [ 
            '_panel',
            '_control_pathmask_radius',         
        ]

        self._control_pathmask_radius.changed_event = self.__control_pathmask_radius_changed_event
Esempio n. 29
0
    def __init__(self, experiment=None):
        """

        :param experiment: Experiment this setup belongs to.
        """
        BaseWidget.__init__(self, 'Experiment')
        self.layout().setContentsMargins(5, 10, 5, 5)

        self._name = ControlText('Setup name')
        self._board = ControlCombo('Board')

        self._stoptrial_btn = ControlButton('Skip trial',
                                            default=self._stop_trial_evt)
        self._pause_btn = ControlButton('Pause',
                                        checkable=True,
                                        default=self._pause_evt)
        self._run_task_btn = ControlButton(
            'Run',
            checkable=True,
            default=self._run_task,
            helptext=
            "When a task is running, you can stop all remaining trials by pressing this button. <br/> <b>NOTE:</b> This means that you will need to break the cycle yourself in your task code when the run_state_machine method returns False."
        )
        self._kill_task_btn = ControlButton(
            'Kill',
            default=self._kill_task,
            style="background-color:rgb(255,0,0);font-weight:bold;",
            helptext=
            "<b>NOTE:</b>This will exit the task process abruptly. The code you might have after the trial loop won't execute."
        )

        self._subjects_list = ControlList(
            'Subjects', remove_function=self.__remove_subject)
        self._add_subject = ControlButton('Add subject')
        self._allsubjects = ControlCombo('Add subject')
        self._task = ControlCombo('Protocol',
                                  changed_event=self._task_changed_evt)

        self._detached = ControlCheckBox('Detach from GUI')

        self._varspanel = ControlEmptyWidget()
        self._btn = ControlButton('Open')

        Setup.__init__(self, experiment)

        self.reload_setups()
        self.reload_boards()
        self.reload_tasks()

        self._formset = [
            '_name',
            '_board',
            '_task',
            '_detached',
            ('_run_task_btn', '_kill_task_btn'),
            ('_stoptrial_btn', '_pause_btn'),
            #' ',
            {
                'Subjects': [
                    # '_allsubjects',
                    '',
                    '_add_subject',
                    '_subjects_list',
                ],
                'Variables': [
                    '_varspanel',
                ],
            }
        ]

        self._kill_task_btn.enabled = False
        self._subjects_list.readonly = True
        self._varspanel.value = self.board_task
        self._add_subject.value = self.__add_subject
        self._name.changed_event = self.__name_changed_evt
        self._board.changed_event = self._board_changed_evt
class CustomModelForm(ModelFormWidget):
    def __init__(self, *args, **kwargs):
        self._custom_form_app_id = None

        self.select_form = ControlAutoComplete(
            'Form', changed_event=self.__update_custom_form_evt)
        self.customized_form = ControlEmptyWidget(name='customized_form',
                                                  parent=self)

        super().__init__(*args, **kwargs)

    def create_model_formfields(self):
        super().create_model_formfields()
        ctype = ContentType.objects.get_for_model(self.model)
        self.select_form.queryset = Form.objects.filter(content_type=ctype)

    def __update_custom_form_evt(self):
        formtype = self.select_form.objects.first(
        ) if self.select_form.objects else None

        if formtype:
            custom_form_app = CustomForm(custom_form=formtype)
            self.customized_form.value = custom_form_app
            self._custom_form_app_id = custom_form_app.uid
            self._custom_form_app = custom_form_app
        else:
            self._custom_form_app_id = None
            self._custom_form_app = None
            self.customized_form.value = None
            self.customized_form.mark_to_update_client()

    def save_custom_model_form(self):
        formtype = self.select_form.objects.first()

        if formtype is None:
            ctype = ContentType.objects.get_for_model(self.model)
            FormObject.objects.filter(content_type=ctype,
                                      object_id=self.object_pk).delete()

        else:
            if self._custom_form_app_id:
                custom_form_app = PyFormsMiddleware.get_instance(
                    self._custom_form_app_id)
                custom_form_app.save_custom_form(self.model_object)

    def load_custom_model_form(self):
        if self._custom_form_app_id:
            custom_form_app = self._custom_form_app if self._custom_form_app else PyFormsMiddleware.get_instance(
                self._custom_form_app_id)
            custom_form_app.load_custom_form(self.model_object)

    def validate_object(self, obj):
        obj = super().validate_object(obj)

        formtype = self.select_form.objects.first()
        if formtype is not None:
            if self._custom_form_app_id:
                custom_form_app = PyFormsMiddleware.get_instance(
                    self._custom_form_app_id)
                custom_form_app.validate_custom_form(self.model_object)

        return obj

    def save_event(self, obj, new_object):
        res = super().save_event(obj, new_object)
        self.save_custom_model_form()
        return res

    def show_edit_form(self, pk=None):
        res = super().show_edit_form(pk)

        ctype = ContentType.objects.get_for_model(self.model)
        formobj = FormObject.objects.filter(content_type=ctype,
                                            object_id=pk).first()

        if formobj:
            self.select_form.value = formobj.custom_form.pk

        self.load_custom_model_form()
        return res