def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') TypeColorVideoPipe.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = ModuleConnection("Video", connecting=TypeColorVideo) self._player = ControlPlayer("Video player") self._colorDomain = ControlCombo("Color domain") self._colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._colorDomain.changed = self._player.refresh self._video.changed = self.newVideoInputChoosen self._player.processFrame = self.processFrame self._formset = [ '_video', '_colorDomain', "_player", ]
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.formset = [ "info:Group your notifications by the frequency you want to received them." ] PERIODS = [(n, c) for c, n in NotificationType.PERIODS] user = PyFormsMiddleware.user() for n in NotificationType.objects.filter( active=True, visible=True).order_by("code"): field_name = "period_{0}".format(n.pk) field = ControlCombo( n.label, items=PERIODS, changed_event=make_lambda_func(self.configure, notification_pk=n.pk), ) try: un = UserNotificationConf.objects.get(notification_type=n, user=user) field.value = un.period except UserNotificationConf.DoesNotExist: field.value = n.period traceback.print_exc() setattr(self, field_name, field) self.formset.append(field_name)
def __init__(self, checkedList): Player.__init__(self, '', '', '') BaseWidget.__init__(self, 'Add New Player') # Init local vars self.__checked = checkedList # Init UI Elements self._txtPlayerName = ControlText('Player Name') self._cboCharacterName = ControlCombo('Character Name') self._cboStarterDeck = ControlCombo('Starter Deck') self._btnAddPlayer = ControlButton('Add Player') # Set up properties of UI elements, attach callbacks, etc. self._btnAddPlayer.value = self.__onAddPlayerClick # Populate Character Names and Starter Decks characters = loader.getFilteredList(MBType.CHARACTER, self.__checked) decks = loader.getFilteredList(MBType.STARTER, self.__checked) for char in characters: self._cboCharacterName.add_item(char, char) for deck in decks: self._cboStarterDeck.add_item(deck, deck) # set up flow of components self.formset = [ '_txtPlayerName', '_cboCharacterName', '_cboStarterDeck', '_btnAddPlayer' ]
class Csv2OwlWidget(BaseWidget): def __init__(self): super(Csv2OwlWidget, self).__init__('csv2owl') self._prefix = ControlFile('Prefixes CSV') self._classes = ControlFile('Classes CSV') self._properties = ControlFile('Properties CSV') self._output_format = ControlCombo('Output Format') self._output_format.add_item('JSON-LD', 'json-ld') self._output_format.add_item('XML', 'pretty-xml') self._generate = ControlButton('Generate') self._generate.value = self.__generateAction def __changeOutput(self): print() def __generateAction(self): if not (self._classes.value and self._properties.value and self._prefix.value): return output_file = 'output.' if 'json' in self._output_format.value: output_file += 'json' else: output_file += 'xml' with open(self._classes.value, 'r') as classes,\ open(self._properties.value, 'r') as properties,\ open(self._prefix.value, 'r') as prefix,\ open(output_file, 'wb') as output_file: graph = csv2owl(classes, properties, prefix) output_file.write( graph.serialize(format=self._output_format.value))
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, task=None, when=None, command=None): title = "Post command editor" if when == TaskCommand.WHEN_POST else "Pre command editor" BaseWidget.__init__(self, title, parent_win=task) self.command = command self.task = task self.when = when self.set_margin(5) self._type = ControlCombo('Type of command', changed_event=self.__type_changed_evt) self._cancelbtn = ControlButton('Cancel', default=self.__cancel_evt) self._okbtn = ControlButton('Ok', default=self.__ok_evt) self._command = ControlText('External command', visible=False) self._filesbrowser = ControlTreeView('Files browser') self._type.add_item('Execute a gui script', 'script') self._type.add_item('Execute a external command', 'external') self.formset = [ '_type', '_command', '_filesbrowser', (' ', '_cancelbtn', '_okbtn'), ' ' ] root_path = os.path.abspath(task.path if task else '/') self.syspath_model = QFileSystemModel(self) self.syspath_model.setRootPath(root_path) self.syspath_model.setNameFilters(['*.py']) self.syspath_model.setNameFilterDisables(False) self._filesbrowser.value = self.syspath_model root_index = self.syspath_model.index(root_path) self._filesbrowser.setRootIndex(root_index) for i in range(1, 4): self._filesbrowser.hideColumn(i)
def __init__(self, parent=None, video=None): BaseWidget.__init__(self, 'Simple workflow editor', parent_win=parent) self._parent = parent self._player = ControlPlayer('Player') self._imgfilters = ControlList('Image filters') self._imageflows = ControlCombo('Image workflows') self._blobsflows = ControlCombo('Blobs workflows') self._blobsfilters = ControlList('Blobs filters') self.formset = [ '_player', '=', [{ 'a:Image filter': ['_imageflows', '_imgfilters'], 'b:Blobs filter': ['_blobsflows', '_blobsfilters'] }] ] self.load_order = [ '_imageflows', '_blobsflows', '_imgfilters', '_blobsfilters' ] self._imgfilters.select_entire_row = True self._blobsfilters.select_entire_row = True self._imageflows.changed_event = self.__imageflows_changed_event self._blobsflows.changed_event = self.__blobsflows_changed_event self._player.process_frame_event = self.__process_frame self.video_capture = video self._pipelines = {} # dictinary with all the available pipelines self._pipeline = None # active pipeline class
def __init__(self): super(Gupload, self).__init__('Gupload') #Definition of the forms fields self._dropdown = ControlCombo('Local Folder') self._plusbutton = ControlButton('Add New Team') self._button = ControlButton('Upload Files') self._progress = ControlText('Progress') #self.panel = ControlEmptyWidget() self._dict = {} self.picklefilename = Path(config_dir, 'foldloc.dat') if not os.path.exists(config_dir): os.mkdir(config_dir) if self.picklefilename.exists(): self.load() else: f = open(self.picklefilename, 'wb') pickle.dump({}, f) f.close() self.load() #Define the button action self._button.value = self.__buttonAction self._plusbutton.value = self.__plusbuttonAction
def __init__(self): super(Example1, self).__init__('dir examples') self.parent = None self._directory = ControlDir('Choose a directory') self._file = ControlFile('Choose a file') self._filetree = ControlFilesTree('Choose a file') self._image = ControlImage('Image') self._boundaries = ControlBoundingSlider('Bounding', horizontal=True) self._button = ControlButton('Click') self._button.value = self.onButtonClick # self._directory.value=self.onButtonClick self._checkbox = ControlCheckBox('Choose a directory') self._checkboxList = ControlCheckBoxList('Choose a file') self._player = ControlPlayer('Choose a file') self._slider = ControlSlider('Slider') self._player.show() self._checkboxList.value = [('Item 1', True), ('Item 2', False), ('Item 3', True)] self._combobox = ControlCombo('Choose a item') self._list = ControlList('List label') self._progress = ControlProgress('Progress bar') self._visvisVolume = ControlVisVisVolume('Visvis') self._timeline = ControlEventTimeline('Timeline') self._combobox.add_item('Item 1', 'Value 1') self._combobox.add_item('Item 2', 'Value 2') self._combobox.add_item('Item 3', 'Value 3') self._combobox.add_item('Item 4') self._list.value = [('Item1', 'Item2', 'Item3',), ('Item3', 'Item4', 'Item5',)] imageWithVolume = np.zeros((100, 100, 100), np.uint8) imageWithVolume[30:40, 30:50, :] = 255 imageWithVolume[30:40, 70:72, :] = 255 self._visvisVolume.value = imageWithVolume self._visvis = ControlVisVis('Visvis') values1 = [(i, random.random(), random.random()) for i in range(130)] values2 = [(i, random.random(), random.random()) for i in range(130)] self._visvis.value = [values1, values2] self.formset = [ '_visvis' , '_directory' , '_button' , '_file' , '_boundaries' , '_filetree' , '_image' , '_slider' , ('_checkboxList', '_player') , ('_checkbox', ' ') , ('_combobox', ' ') , '_progress' , '=' , ('_visvisVolume', '||', '_list') , '_timeline' ]
def __init__(self): super(Gui, self).__init__('Converter') #self._firstname = ControlText('First name') self._fileControl = ControlFile('Select File') self._fileControl.changed_event = self.__fileselectionevent self._toControl = ControlCombo('To', enabled=0) self._buttonControl = ControlButton('Convert', enabled=0) self._buttonControl.value = self.__clicker
def __init__(self): super(MainWindow, self).__init__('Main Window') self._fileInput = ControlFile("Input file") self._cbAlgo = ControlCombo("Algorithm") self._cbAlgo.add_item('Basic recursion', 1) self._cbAlgo.add_item('Depth First Search', 2) self._cbAlgo.add_item('Breadth First Search', 3) self._btnRun = ControlButton("Run") self._btnRun.value = self.__btnRunAction
def __init__(self): super(MainWindow, self).__init__('Maze Solver') self._fileInput = ControlFile("Input file") self._cbAlgo = ControlCombo("Algorithm") self._cbAlgo.add_item('Brute force', 1) self._cbAlgo.add_item('Depth First Search', 2) self._cbAlgo.add_item('Breadth First Search', 3) self._btnRun = ControlButton("Run") self._btnRun.value = self.__btnRunAction self._lblStatus = ControlLabel('STATUS: IDLE')
def __init__(self): super(Csv2OwlWidget, self).__init__('csv2owl') self._prefix = ControlFile('Prefixes CSV') self._classes = ControlFile('Classes CSV') self._properties = ControlFile('Properties CSV') self._output_format = ControlCombo('Output Format') self._output_format.add_item('JSON-LD', 'json-ld') self._output_format.add_item('XML', 'pretty-xml') self._generate = ControlButton('Generate') self._generate.value = self.__generateAction
def __init__(self, board_task, name=None, value=None, datatype='string'): self._varslist = board_task._vars self._combo = ControlCombo(None) self._combo.add_item('Number', 'number') self._combo.add_item('String', 'string') self._combo.value = datatype self._combo.changed_event = self.__datatype_changed_evt self._row_index = self._varslist.rows_count self._varslist += [name, self._combo, value] TaskVariable.__init__(self, board_task, name, value, datatype)
def __init__(self, project=None): """ :param project: project where this board belongs :type project: pycontrolgui.models.project.Project """ BaseWidget.__init__(self, 'Board') self.layout().setContentsMargins(5, 10, 5, 5) self._name = ControlText('Box name') self._serial_port = ControlCombo('Serial port') self._refresh_serials = ControlButton( '', icon=QtGui.QIcon(conf.REFRESH_SMALL_ICON), default=self.__refresh_serials_pressed, helptext="Press here to refresh the list of available devices.") self._log_btn = ControlButton('Console') self._active_bnc = ControlCheckBoxList('BNC') self._active_wired = ControlCheckBoxList('Wired') self._active_behavior = ControlCheckBoxList('Behavior') self._loadports_btn = ControlButton('Load board info') self._netport = ControlNumber('Net port', default=36000 + len(project.boards), minimum=36000, maximum=36100) self._events = ControlList('Events', readonly=True) self._inputchannels = ControlList('Input channels', readonly=True) self._outputchannels = ControlList('Output channels', readonly=True) self._saved_serial_port = None Board.__init__(self, project) self._formset = [ '_name', ('_serial_port', '_refresh_serials'), '_netport', '_log_btn', '=', '_loadports_btn', { 'Ports': [ 'Enabled or disable ports', '_active_bnc', '_active_wired', '_active_behavior', ], 'Events': ['_events'], 'Input ch.': ['_inputchannels'], 'Output ch.': ['_outputchannels'] } ] self._name.changed_event = self.__name_changed_evt self._loadports_btn.value = self.__load_bpod_ports self._fill_serial_ports()
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()
def __init__(self): super(AutoFiller, self).__init__('Auto filler') self._project = ControlCombo('项目') self._project.add_item('后台') self._project.add_item('山东药监') self._project.add_item('沈阳药监') self._product = ControlCombo('产品') self._product.add_item('食品日常检查') self._product.add_item('快速检验') self._level = ControlCombo('严重程度') self._level.add_item('3-平均', '3') self._level.add_item('1-关键', '1') self._level.add_item('2-严重', '2') self._level.add_item('4-较轻', '4') self._type = ControlCombo('缺陷类型') self._type.add_item('1-功能性', '1') self._type.add_item('3-易用性', '3') self._person = ControlText('责任者') self._button = ControlButton('确定') self._button.value = self.__buttonAction self.formset = [('_project', '_product'), ('_level', '_type'), ('_person', '_button')]
def __init__(self): super(SessionForm, self).__init__('Session info') # Definition of the forms fields self._mouseWeight = ControlText( label='Please insert the name of the mouse:') self._probeLeftLabel = ControlLabel('Probe LEFT') self._probeRightLabel = ControlLabel('Probe RIGHT') self._probeLeftX = ControlText('X:', default='0') self._probeLeftY = ControlText('Y:', default='0') self._probeLeftZ = ControlText('Z:', default='0') self._probeLeftD = ControlText('D:', default='0') self._probeLeftAngle = ControlText('Angle:', default='0') self._probeLeftOrigin = ControlCombo('Origin:') self._probeLeftOrigin.add_item('', None) self._probeLeftOrigin.add_item('Bregma', 'bregma') self._probeLeftOrigin.add_item('Lambda', 'lambda') self._probeRightX = ControlText('X:', default='0') self._probeRightY = ControlText('Y:', default='0') self._probeRightZ = ControlText('Z:', default='0') self._probeRightD = ControlText('D:', default='0') self._probeRightAngle = ControlText(label='Angle:', default='0') self._probeRightOrigin = ControlCombo('Origin:') self._probeRightOrigin.add_item('', None) self._probeRightOrigin.add_item('Bregma', 'bregma') self._probeRightOrigin.add_item('Lambda', 'lambda') self._button = ControlButton('Submit') # Define the organization of the forms self.formset = [(' ', ' ', ' ', ' ', ' '), (' ', '_mouseWeight', ' ', ' ', ' '), (' ', '_probeLeftLabel', ' ', '_probeRightLabel', ' '), (' ', '_probeLeftX', ' ', '_probeRightX', ' '), (' ', '_probeLeftY', ' ', '_probeRightY', ' '), (' ', '_probeLeftZ', ' ', '_probeRightZ', ' '), (' ', '_probeLeftD', ' ', '_probeRightD', ' '), (' ', '_probeLeftAngle', ' ', '_probeRightAngle', ' '), (' ', '_probeLeftOrigin', ' ', '_probeRightOrigin', ' '), (' ', '_button', ' '), (' ', ' ', ' ', ' ', ' ')] # The ' ' is used to indicate that a empty space should be placed at the bottom of the win # If you remove the ' ' the forms will occupy the entire window # Define the button action self._button.value = self.__buttonAction self.form_data: dict = {} self.valid_form_data: bool = False
def _get_problem_definition_formset(self): # self._physical_problem_combo = self._get_combo() self._physical_problem_combo = ControlCombo('Governing equations') self._populate_physical_problem_combo(self._physical_problem_combo) self._units_combo = ControlCombo('Units') self._populate_units_combo(self._units_combo) self._regime_type_combo = ControlCombo('Compressibility') self._populate_regime_type_combo(self._regime_type_combo) problem_def_formset = [('_physical_problem_combo', '', '_units_combo', '', '_regime_type_combo'), (' ', ' ', ' '), (' ', ' ', ' '), (' ', ' ', ' ')] return problem_def_formset
def __init__(self, session): """ :param session: session reference :type session: pycontrolgui.windows.detail.entities.session_window.SessionWindow """ super().__init__(session.name) self.session = session self._trials = ControlCombo('Trial', changed_event=self.__draw_diagram_evt) self._image = ControlImage('Diagram') self.formset = ['_trials', '_image'] self.__load_trials() self.__draw_diagram_evt()
class TaskVariableWindow(TaskVariable): def __init__(self, board_task, name=None, value=None, datatype='string'): self._varslist = board_task._vars self._combo = ControlCombo(None) self._combo.add_item('Number', 'number') self._combo.add_item('String', 'string') self._combo.value = datatype self._combo.changed_event = self.__datatype_changed_evt self._row_index = self._varslist.rows_count self._varslist += [name, self._combo, value] TaskVariable.__init__(self, board_task, name, value, datatype) def __datatype_changed_evt(self): datatype = self._combo.value if datatype == 'number': item = self._varslist.get_value(2, self._row_index) if not item.isnumeric(): self._varslist.set_value(2, self._row_index, '0') def tolist(self): return [self.name, self._combo, self.value] @property def name(self): return self._varslist.get_value(0, self._row_index) @name.setter def name(self, value): self._varslist.set_value(0, self._row_index, value) @property def value(self): value = self._varslist.get_value(2, self._row_index) return float(value) if self.datatype == 'number' else value @value.setter def value(self, value): self._varslist.set_value(2, self._row_index, value) @property def datatype(self): return self._varslist.get_value(1, self._row_index).value @datatype.setter def datatype(self, value): self._varslist.get_value(1, self._row_index).value = value
class AdaptativeThreshold(Class, BaseWidget): def __init__(self, **kwargs): BaseWidget.__init__(self, 'Adaptative threshold') Class.__init__(self, **kwargs) try: self.layout().setContentsMargins(10, 5, 10, 5) self.setMinimumHeight(100) except: pass self._field_adaptive_threshold_method = ControlCombo('Method') self._field_adaptive_threshold_type = ControlCombo('Type') self._field_adaptive_threshold_block_size = ControlSlider( 'Block size', default=self._param_adaptivethreshold_block_size, minimum=3, maximum=2999) self._field_adaptive_threshold_c = ControlSlider( 'C', default=self._param_adaptivethreshold_c, minimum=0, maximum=500) self._formset = [('_field_adaptive_threshold_method', '_field_adaptive_threshold_type'), ('_field_adaptive_threshold_block_size', '_field_adaptive_threshold_c')] self._field_adaptive_threshold_method.add_item( 'ADAPTIVE_THRESH_MEAN_C', cv2.ADAPTIVE_THRESH_MEAN_C) self._field_adaptive_threshold_method.add_item( 'ADAPTIVE_THRESH_GAUSSIAN_C', cv2.ADAPTIVE_THRESH_GAUSSIAN_C) self._field_adaptive_threshold_type.add_item('THRESH_BINARY_INV', cv2.THRESH_BINARY_INV) self._field_adaptive_threshold_type.add_item('THRESH_BINARY', cv2.THRESH_BINARY) self._field_adaptive_threshold_method.value = self._param_adaptivethreshold_method self._field_adaptive_threshold_type.value = self._param_adaptivethreshold_type self._field_adaptive_threshold_method.changed_event = self.__adaptative_threshold_changed_evt self._field_adaptive_threshold_type.changed_event = self.__adaptative_threshold_changed_evt self._field_adaptive_threshold_block_size.changed_event = self.__adaptative_threshold_changed_evt self._field_adaptive_threshold_c.changed_event = self.__adaptative_threshold_changed_evt ##################################################################### ### PROPERTIES ###################################################### ##################################################################### def __adaptative_threshold_changed_evt(self): self._param_adaptivethreshold_method = self._field_adaptive_threshold_method.value self._param_adaptivethreshold_type = self._field_adaptive_threshold_type.value self._param_adaptivethreshold_block_size = self._field_adaptive_threshold_block_size.value self._param_adaptivethreshold_c = self._field_adaptive_threshold_c.value - 255
def __init__(self, project=None): """ :param project: project where this board belongs :type project: pycontrolgui.models.project.Project """ BaseWidget.__init__(self, 'Subject') self.layout().setContentsMargins(5, 10, 5, 5) self._selected_setup = None self._name = ControlText('Name') self._setups = ControlCombo('Setup') self._run = ControlButton('Run', checkable=True, default=self._run_task) self._run = ControlButton('Run', checkable=True, default=self._run_task, helptext="When a task is running, you can skip all remaining trials by pressing this button. <br/> <b>NOTE:</b> This means that you will need to break the cycle 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._kill_task_btn.enabled = False self._stoptrial_btn = ControlButton('Skip trial', default=self._stop_trial_evt) self._pause_btn = ControlButton('Pause', checkable=True, default=self._pause_evt) self._stoptrial_btn.enabled = False self._pause_btn.enabled = False self._detached = ControlCheckBox('Detach from GUI', changed_event=self.__detached_changed_evt) Subject.__init__(self, project) self._formset = [ '_name', '_setups', '_detached', ('_run', '_kill_task_btn'), ('_stoptrial_btn', '_pause_btn'), ' ', ] self._name.changed_event = self.__name_changed_evt self.reload_setups()
def __init__(self, object2d=None): DatasetGUI.__init__(self) Path.__init__(self, object2d) BaseWidget.__init__(self, '2D Object', parent_win=object2d) self.create_tree_nodes() self._mark_pto_btn = ControlButton('&Mark point', checkable=True, icon=conf.ANNOTATOR_ICON_MARKPLACE ) self._sel_pto_btn = ControlButton('&Select point', default=self.__sel_pto_btn_event, icon=conf.ANNOTATOR_ICON_SELECTPOINT) self._del_path_btn = ControlButton('Delete path', default=self.__del_path_btn_event, icon=conf.ANNOTATOR_ICON_DELETEPATH, visible=False) self._del_point_btn = ControlButton('Delete point', default=self.__del_point_btn_event, icon=conf.ANNOTATOR_ICON_SELECTPOINT, visible=False) self._use_referencial = ControlCheckBox('Apply') self._referencial_pt = ControlText('Referencial', changed_event=self.__referencial_pt_changed_event) self._interpolation_title = ControlLabel('Interpolation', default='INTERPOLATION', visible=False) self._interpolation_mode = ControlCombo('Mode', changed_event=self.__interpolation_mode_changed_event, visible=False) self._interpolate_btn = ControlButton('Apply', default=self.__interpolate_btn_event, icon=conf.ANNOTATOR_ICON_INTERPOLATE, visible=False) self._remove_btn = ControlButton('Remove dataset',default=self.__remove_path_dataset, icon=conf.ANNOTATOR_ICON_REMOVE) self._pickcolor = ControlButton('Pick a color', default=self.__pick_a_color_event) self._show_object_name = ControlCheckBox('Show object name', default=False) self._show_name = ControlCheckBox('Show name', default=False) self._formset = [ '_name', ('_show_name', '_show_object_name'), ('_referencial_pt', '_use_referencial'), '_remove_btn', ' ', '_pickcolor', ' ', ('_mark_pto_btn', '_sel_pto_btn'), '_del_path_btn', '_del_point_btn', '_interpolation_title', ('_interpolation_mode', '_interpolate_btn'), ' ' ] #### set controls ############################################## self._interpolation_mode.add_item("Auto", -1) self._interpolation_mode.add_item("Linear", 'slinear') self._interpolation_mode.add_item("Quadratic", 'quadratic') self._interpolation_mode.add_item("Cubic", 'cubic')
def __init__(self, *args, **kwargs): global games_json super().__init__("NSScreenshotMaker") self._tmpinputfolder = tempfile.mkdtemp() self._settingsbutton = ControlButton("⚙️") self._settingsbutton.value = self.openSettings self._runbutton = ControlButton("Go!") self._runbutton.value = self.go self._combo = ControlCombo( helptext="The game the Switch will think the screenshot is from") self.gameslist = games_json for k in self.gameslist: self._combo.add_item(k, self.gameslist[k]) self._combo.add_item("Custom", "Custom") self._combolabel = ControlLabel( "Game ID", helptext="The game the Switch will think the screenshot is from") self._imagelist = ControlFilesTree() self._imagelist._form.setDragEnabled(True) self._imagelist._form.setAcceptDrops(True) self._imagelist._form.setDropIndicatorShown(True) self._imagelist._form.dropEvent = self.dropEvent model = QFileSystemModel(parent=None) model.setReadOnly(False) self._imagelist._form.setModel(model) model.setRootPath(QtCore.QDir.currentPath()) self._imagelist._form.setRootIndex( model.setRootPath(self._tmpinputfolder)) self._imagelist._form.setIconSize(QtCore.QSize(32, 32)) self.formset = [("_combolabel", "_combo", "_settingsbutton"), "_imagelist", "_runbutton"] self._firstrunpanel = ControlDockWidget() self._firstrunpanel.hide() self._firstrunwin = FirstRun() if not os.path.isfile( appdirs.AppDirs("NSScreenshotMaker", "").user_data_dir + "/settings.json"): self._firstrunwin.parent = self self._firstrunpanel.value = self._firstrunwin self._firstrunpanel.show() self._firstrunwin.show() self._settingspanel = ControlDockWidget() self._settingspanel.hide() self._settingswin = SettingsWindow()
class NourrissonStep3(BaseWidget): def __init__(self): super(NourrissonStep3, self).__init__('Suivi nourrisson Step 3') #Definition of the forms fields self._gender = ControlCombo('Genre') self._gender.add_item("Fille", "f") self._gender.add_item("Garçon", "g") self._age = ControlSlider("Age (en mois)") self._age.min = 0 self._age.max = 60 self._weight = ControlNumber("Poids (en kg)") self._weight.min = 0 self._weight.max = 50 self._weight.decimals = 1 self._weight.step = 0.1 self._weight.value = 0.0 self._height = ControlNumber("Taille (en cm)") self._height.min = 0 self._height.max = 200 self._height.decimals = 1 self._height.step = 0.1 self._height.value = 0.0 self._skull = ControlNumber("Pérmiètre cranien (en cm)") self._skull.min = 0 self._skull.max = 100 self._skull.decimals = 1 self._skull.step = 0.1 self._skull.value = 0.0 #Define the button action self._button = ControlButton('Vérifier les constantes') self._button.value = self.__buttonAction BaseWidget.isFullScreen = False def __buttonAction(self): print("A faire")
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') TypeBWVideoPipe.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = ModuleConnection("Video", connecting=TypeComponentsVideoPipe) self._player = ControlPlayer("Video player") self._colorComponent = ControlCombo("Component") self._colorComponent.addItem("A", 0) self._colorComponent.addItem("B", 1) self._colorComponent.addItem("C", 2) self._colorComponent.valueUpdated = self.refreshValue self._video.changed = self.newVideoInputChoosen self._formset = [ '_video', '_colorComponent', "_player", ]
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._order = ControlCombo('Order by', label_visible=False, changed_event=self.__load_stats) self._table = ControlList('Topics statistics', horizontal_headers=['Topic', 'Users', 'Funds', 'Total funds', 'Average per fund']) #self._order.add_item('Topics', 0) self._order.add_item('Users', 1) self._order.add_item('Funds', 2) self._order.add_item('Total funds', 3) self._order.add_item('Average per fund', 4) self.formset = [ '_order', '_table' ] self._order.value = 1 self.__load_stats()
def __init__(self): super(AutoFiller, self).__init__('Auto Filler') self._project = ControlCombo('项目') self._project.add_item('后台') self._project.add_item('山东药监') self._project.add_item('济南药监') self._project.add_item('沈阳药监') self._project.add_item('重庆药监') self._product = ControlCombo('产品') self._product.add_item('APP') self._product.add_item('行政执法') self._product.add_item('GIAP审批') self._product.add_item('食品日常检查') self._product.add_item('快速检验') self._product.add_item('药品日常检查') self._product.add_item('化妆品日常检查') self._level = ControlCombo('严重程度') self._level.add_item('3-平均', 3) self._level.add_item('1-关键', 1) self._level.add_item('2-严重', 2) self._level.add_item('4-较轻', 4) self._type = ControlCombo('缺陷类型') self._type.add_item('1-功能性', 1) self._type.add_item('3-易用性', 3) self._person = ControlCombo('责任者') self._person.add_item('刘宝祥') self._person.add_item('厉见德') self._person.add_item('石志伟') self._person.add_item('周鹏') self._person.add_item('王为选') self._button = ControlButton('确定') self._button.value = self.__buttonAction self.set_margin(15) self.formset = [('_project', '_product'), ('_level', '_type'), ('_person', '_button')]
class YoutubeToolKit(BaseWidget): def __init__(self): super(YoutubeToolKit, self).__init__('Youtube ToolKit v1.0') self.set_margin(10) self._accounts = ControlCombo('Account: ') items_account = getDataInFolder('accounts', 'folder') for item in items_account: self._accounts.add_item(item, item) self._input_files = ControlCombo('File video: ') items_input_file = getDataInFolder('input', 'mp4') for item in items_input_file: self._input_files.add_item(item, item) self._ffmpeg_files = ControlCombo("File ffmpeg: ") items_ffmpeg = getDataInFolder('ffmpeg-files', 'txt') for item in items_ffmpeg: self._ffmpeg_files.add_item(item, item) self._title = ControlText("Title") self._description = ControlText("Description") self._tags = ControlText("Tags") self._button_upload = ControlButton('Upload') self._button_upload.value = self.__buttonUploadAction # self._label_alert = ControlLabel("Ready") self._label_alert = ControlText("Status") self._formset = [ ('_accounts', '_input_files', '_ffmpeg_files', '_title', '_description', '_tags', '_button_upload', '_label_alert'), ] def __buttonUploadAction(self): data = { 'title': self._title.value, 'description': self._description.value, 'tags': self._tags.value } self._label_alert.value = "Processing..." output_file_name = processVideo(self._input_files.value, self._ffmpeg_files.value) self._label_alert.value = "Uploading..." # uploadToYoutube(self._accounts.value, output_file_name, data) # os.remove(output_file_name) self._label_alert.value = "Success!" print("Done")
class AlyaGUI(BaseWidget): def __init__(self): super(AlyaGUI,self).__init__('Alya Case Editor') #Layer for IO handling self._fileio = AlyaFileIO() self._log = ControlTextArea('Log') self._fileio.SetLogControl(self.__addlog) #Main form fields self._casepath = ControlDir('Case path', default='/home/costa/Downloads/1111') self._fileio.SetCasePath(self._casepath._value) self._casename = ControlCombo('Case') self._casePathScan = ControlButton('Scan Path') self._casePathScan.value = self.___casePathScan_pressed self._caseReload = ControlButton('Load Case') self._caseReload.value = self.___caseReload_pressed self._casepath.changed_event = self.__casePathChanged #General tab. Here everythong most important to check self._dat_casename = ControlText('Name','') self._dat_run_type = ControlText('Run type','') self._dat_time_interval = ControlText('Time interval to run','') self._dat_number_of_steps = ControlText('Number of steps to run','') self._dom_nodal_points = ControlText('Number of points','') self._dom_elements = ControlText('Number of all elements','') self._dom_number_of_boundary_faces = ControlText('Number of boundary faces','') self._dom_mesh_numbers_verify_button = ControlButton('Verify') self._dom_types_of_elements = ControlText('Types of elements','') self._dom_domain_integration_points = ControlText('Number of integration points','') self._ker_density = ControlText('Density','') self._ker_viscosity = ControlText('Viscosity','') self._ker_steps_to_save = ControlText('Every how many steps to save','') self._nsi_boundary_conditions = ControlTextArea('Nastin boundary conditions') general_tab = [('_dat_casename','_dat_run_type'),('_dat_time_interval','_dat_number_of_steps'),\ ('_dom_nodal_points','_dom_elements','_dom_number_of_boundary_faces','_dom_mesh_numbers_verify_button'),\ ('_dom_types_of_elements','_dom_domain_integration_points'),\ ('_ker_density','_ker_viscosity'),\ '_ker_steps_to_save','_nsi_boundary_conditions'] #Raw casefile tab self._FileEditor = ControlTextArea('File editor') self._FileEditorSaveButton = ControlButton("Save file") self._DatPicker = ControlList('Dat files') self._DatPicker.horizontal_headers = ['Filename','Relative Path'] self._DatPicker.item_selection_changed_event = self.__DAT_selection_changed self._DatPicker.readonly = True self._IncludedFilePicker = ControlList('Included files') self._IncludedFilePicker.horizontal_headers = ['Filename','Section'] self._IncludedFilePicker.readonly = True self._IncludedFilePicker.item_selection_changed_event = self.__INCLUDE_selection_changed self.formset = [ ('_casepath','_casePathScan','||','_casename','_caseReload'),\ {'General': general_tab, \ 'Raw Casefile':[('_FileEditor','||','_DatPicker','||','_IncludedFilePicker'),\ '_FileEditorSaveButton']},'=','_log'] self._log.autoscroll = True self._log.readonly = True def ___fill_general_tab(self, params): self._dat_casename.value = params['alya'] self._dat_run_type.value = params['run_type'] self._dat_time_interval.value = params['time_interval'] self._dat_number_of_steps.value = params['number_of_steps'] self._dom_nodal_points.value = params['nodal_points'] self._dom_elements.value = params['elements'] self._dom_number_of_boundary_faces.value = params['boundaries'] self._dom_types_of_elements.value = params['types_of_elements'] self._dom_domain_integration_points.value = params['domain_integration_points'] self._ker_density.value = params['density'] self._ker_viscosity.value = params['viscosity'] self._ker_steps_to_save.value = params['steps'] self._nsi_boundary_conditions.value = params['nsi_boundary_conditions'] def ___caseReload_pressed(self): # # Reload the case # self.__addlog(f'Loading case {self._casename.value}') params = self._fileio.ExtractImportantParameters( self._casename.value ) self.__addlog(f'Loaded parameters {params}') self.___fill_general_tab(params) def ___casePathScan_pressed(self): # # Scan path for the cases, fill the listbox of cases # Not fully implmented. Does not support more than one case per path yet # self._fileio.SetCasePath(self._casepath._value) self.__addlog(f'Scanning {self._casepath._value} for cases') cases = self._fileio.ListCases() self.__addlog(f'Found the following cases {cases}') self._casename.clear() if cases!=[]: for case in cases: self._casename.add_item(case) self._casename.current_index = 0 self.___caseReload_pressed() dats = self._fileio.ListDats() self._DatPicker.clear() for dat in dats: self._DatPicker += [dat, '.'] def __casePathChanged(self): self.__addlog(f'Case path changed to: {self._casepath._value}') self.___casePathScan_pressed() return True def __addlog(self, string): self._log.__add__(f'{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}: {string}') def __INCLUDE_selection_changed(self): # # Activated when user clicks on an INCLUDED file # selection = self._IncludedFilePicker.get_currentrow_value() print(selection[0]) data = self._fileio.ReadFullFile( selection[0] ) self._FileEditor.value = '' if data!=[]: self._FileEditor.value = ''.join(data) def __DAT_selection_changed(self): # # Activated when user clicks on a dat file # selection = self._DatPicker.get_currentrow_value() data = self._fileio.ReadFullFile( os.path.join(selection[1],selection[0]) ) includes = self._fileio.FindAllIncludedFiles(selection[0]) self.__addlog(f'Found {includes} included files') self._IncludedFilePicker.clear() if includes!=[]: for include in includes: self._IncludedFilePicker += [include[0], include[1]] self._FileEditor.value = '' if data!=[]: self._FileEditor.value = ''.join(data)
def __init__(self): super(AlyaGUI,self).__init__('Alya Case Editor') #Layer for IO handling self._fileio = AlyaFileIO() self._log = ControlTextArea('Log') self._fileio.SetLogControl(self.__addlog) #Main form fields self._casepath = ControlDir('Case path', default='/home/costa/Downloads/1111') self._fileio.SetCasePath(self._casepath._value) self._casename = ControlCombo('Case') self._casePathScan = ControlButton('Scan Path') self._casePathScan.value = self.___casePathScan_pressed self._caseReload = ControlButton('Load Case') self._caseReload.value = self.___caseReload_pressed self._casepath.changed_event = self.__casePathChanged #General tab. Here everythong most important to check self._dat_casename = ControlText('Name','') self._dat_run_type = ControlText('Run type','') self._dat_time_interval = ControlText('Time interval to run','') self._dat_number_of_steps = ControlText('Number of steps to run','') self._dom_nodal_points = ControlText('Number of points','') self._dom_elements = ControlText('Number of all elements','') self._dom_number_of_boundary_faces = ControlText('Number of boundary faces','') self._dom_mesh_numbers_verify_button = ControlButton('Verify') self._dom_types_of_elements = ControlText('Types of elements','') self._dom_domain_integration_points = ControlText('Number of integration points','') self._ker_density = ControlText('Density','') self._ker_viscosity = ControlText('Viscosity','') self._ker_steps_to_save = ControlText('Every how many steps to save','') self._nsi_boundary_conditions = ControlTextArea('Nastin boundary conditions') general_tab = [('_dat_casename','_dat_run_type'),('_dat_time_interval','_dat_number_of_steps'),\ ('_dom_nodal_points','_dom_elements','_dom_number_of_boundary_faces','_dom_mesh_numbers_verify_button'),\ ('_dom_types_of_elements','_dom_domain_integration_points'),\ ('_ker_density','_ker_viscosity'),\ '_ker_steps_to_save','_nsi_boundary_conditions'] #Raw casefile tab self._FileEditor = ControlTextArea('File editor') self._FileEditorSaveButton = ControlButton("Save file") self._DatPicker = ControlList('Dat files') self._DatPicker.horizontal_headers = ['Filename','Relative Path'] self._DatPicker.item_selection_changed_event = self.__DAT_selection_changed self._DatPicker.readonly = True self._IncludedFilePicker = ControlList('Included files') self._IncludedFilePicker.horizontal_headers = ['Filename','Section'] self._IncludedFilePicker.readonly = True self._IncludedFilePicker.item_selection_changed_event = self.__INCLUDE_selection_changed self.formset = [ ('_casepath','_casePathScan','||','_casename','_caseReload'),\ {'General': general_tab, \ 'Raw Casefile':[('_FileEditor','||','_DatPicker','||','_IncludedFilePicker'),\ '_FileEditorSaveButton']},'=','_log'] self._log.autoscroll = True self._log.readonly = True