Exemple #1
0
    def main(self):
        wid = gui.VBox(width=500,
                       height=500,
                       style={
                           'margin': '5px auto',
                           'padding': '10px'
                       })

        lbl_description = gui.Label("""Example about TableWidget usage.
                                    Change rows and columns count in order to see the behaviour. 
                                    After changing the size, 'Fill the table' content by means of the button."""
                                    )

        wid.append(lbl_description)

        table = gui.TableWidget(10, 3, True, True, width=300, height=300)
        table.style['font-size'] = '8px'

        container = gui.HBox(width='100%')
        lbl_row_count = gui.Label('Rows:')
        spin_row_count = gui.SpinBox(10, 0, 15)
        spin_row_count.onchange.do(self.on_row_count_change, table)
        container.append(lbl_row_count)
        container.append(spin_row_count)
        wid.append(container)

        container = gui.HBox(width='100%')
        lbl_column_count = gui.Label('Columns:')
        spin_column_count = gui.SpinBox(3, 0, 4)
        spin_column_count.onchange.do(self.on_column_count_change, table)
        container.append(lbl_column_count)
        container.append(spin_column_count)
        wid.append(container)

        bt_fill_table = gui.Button('Fill table', width=100)
        bt_fill_table.onclick.do(self.fill_table, table)
        wid.append(bt_fill_table)

        chk_use_title = gui.CheckBoxLabel('Use title', True)
        chk_use_title.onchange.do(self.on_use_title_change, table)
        wid.append(chk_use_title)

        self.fill_table(table, table)

        table.on_item_changed.do(self.on_table_item_changed)

        wid.append(table)
        # returning the root widget
        return wid
    def prompt_new_widget(self, widget):
        self.varname_list = list()

        self.build_widget_name_list_from_tree(self.appInstance.project)

        self.constructor_parameters_list = self.widgetClass.__init__.__code__.co_varnames[1:] #[1:] removes the self
        param_annotation_dict = ''#self.widgetClass.__init__.__annotations__
        self.dialog = gui.GenericDialog(title=self.widgetClass.__name__, message='Fill the following parameters list', width='40%')
        varNameTextInput = gui.TextInput()
        varNameTextInput.attributes['tabindex'] = '1'
        varNameTextInput.attributes['autofocus'] = 'autofocus'
        self.dialog.add_field_with_label('name', 'Variable name', varNameTextInput)
        #for param in self.constructor_parameters_list:
        for index in range(0,len(self.widgetClass.__init__._constructor_types)):
            param = self.constructor_parameters_list[index]
            _typ = self.widgetClass.__init__._constructor_types[index]
            note = ' (%s)'%_typ.__name__
            editWidget = None
            if _typ==int:
                editWidget = gui.SpinBox('0',-65536,65535)
            elif _typ==bool:
                editWidget = gui.CheckBox()
            else:
                editWidget = gui.TextInput()
            editWidget.attributes['tabindex'] = str(index+2)
            self.dialog.add_field_with_label(param, param + note, editWidget)

        self.dialog.add_field_with_label("editor_newclass", "Overload base class", gui.CheckBox())
        self.dialog.confirm_dialog.do(self.on_dialog_confirm)
        self.dialog.show(self.appInstance)
Exemple #3
0
    def create_num_row(self, param_name, description, range_min, range_max,
                       current_value, callback_cb, step):
        row = gui.TableRow()
        param_name = gui.Label(param_name,
                               width=NAME_L_SIZE,
                               height=FIELD_HEIGHT)
        param_name.attributes['title'] = description
        min_val = gui.Label(str(range_min),
                            width=MIN_L_SIZE,
                            height=FIELD_HEIGHT)
        range_slider = gui.Slider(width=SLIDER_SIZE,
                                  height=FIELD_HEIGHT,
                                  defaultValue=current_value,
                                  min=range_min,
                                  max=range_max,
                                  step=step)
        range_slider.set_on_change_listener(callback_cb)
        max_val = gui.Label(str(range_max),
                            width=MAX_L_SIZE,
                            height=FIELD_HEIGHT)
        spin_val = gui.SpinBox(width=EDIT2_SIZE,
                               height=FIELD_HEIGHT,
                               defaultValue=current_value,
                               min=range_min,
                               max=range_max,
                               step=step)
        # https://github.com/dddomodossola/remi/issues/49
        # Added 46 as it's dot so we allow floating point values
        spin_val.attributes[
            spin_val.
            EVENT_ONKEYPRESS] = 'return event.charCode >= 48 && event.charCode <= 57 || event.charCode == 46 || event.charCode == 13'
        spin_val.set_on_change_listener(callback_cb)
        item = gui.TableItem()
        item.add_child(0, param_name)
        row.add_child(0, item)

        item = gui.TableItem()
        item.add_child(1, min_val)
        row.add_child(1, item)
        min_val.style['float'] = 'none'
        min_val.style['text-align'] = 'center'

        item = gui.TableItem()
        item.add_child(2, range_slider)
        row.add_child(2, item)

        item = gui.TableItem()
        item.add_child(3, max_val)
        row.add_child(3, item)
        max_val.style['float'] = 'none'
        max_val.style['text-align'] = 'center'

        item = gui.TableItem()
        item.add_child(4, spin_val)
        row.add_child(4, item)
        spin_val.style['display'] = 'block'
        spin_val.style['margin'] = '10px auto'
        spin_val.style['float'] = 'none'

        return row, [range_slider.set_value, spin_val.set_value]
Exemple #4
0
    def __init__(self, title='', message=''):
        super(ProjectConfigurationDialog, self).__init__(
            'Project Configuration',
            'Here are the configuration options of the project.',
            width=500)
        #standard configuration
        self.configDict = {}
        self.configDict['config_project_name'] = 'untitled'
        self.configDict['config_address'] = '0.0.0.0'
        self.configDict['config_port'] = 8081
        self.configDict['config_multiple_instance'] = True
        self.configDict['config_enable_file_cache'] = True
        self.configDict['config_start_browser'] = True
        self.configDict['config_resourcepath'] = "./res/"

        self.add_field_with_label('config_project_name', 'Project Name',
                                  gui.TextInput())
        self.add_field_with_label('config_address', 'IP address',
                                  gui.TextInput())
        self.add_field_with_label('config_port', 'Listen port',
                                  gui.SpinBox(8082, 1025, 65535))
        self.add_field_with_label(
            'config_multiple_instance',
            'Use single App instance for multiple users', gui.CheckBox(True))
        self.add_field_with_label('config_enable_file_cache',
                                  'Enable file caching', gui.CheckBox(True))
        self.add_field_with_label('config_start_browser',
                                  'Start browser automatically',
                                  gui.CheckBox(True))
        self.add_field_with_label('config_resourcepath',
                                  'Additional resource path', gui.TextInput())
        self.from_dict_to_fields(self.configDict)
Exemple #5
0
    def menu_dialog_clicked(self, widget):
        self.dialog = gui.GenericDialog(title='Dialog Box', message='Click Ok to transfer content to main page', width='500px')
        self.dtextinput = gui.TextInput(width=200, height=30)
        self.dtextinput.set_value('Initial Text')
        self.dialog.add_field_with_label('dtextinput', 'Text Input', self.dtextinput)

        self.dcheck = gui.CheckBox(False, width=200, height=30)
        self.dialog.add_field_with_label('dcheck', 'Label Checkbox', self.dcheck)
        values = ('Danny Young', 'Christine Holand', 'Lars Gordon', 'Roberto Robitaille')
        self.dlistView = gui.ListView.new_from_list(values, width=200, height=120)
        self.dialog.add_field_with_label('dlistView', 'Listview', self.dlistView)

        self.ddropdown = gui.DropDown.new_from_list(('DropDownItem 0', 'DropDownItem 1'),
                                                    width=200, height=20)
        self.dialog.add_field_with_label('ddropdown', 'Dropdown', self.ddropdown)

        self.dspinbox = gui.SpinBox(min=0, max=5000, width=200, height=20)
        self.dspinbox.set_value(50)
        self.dialog.add_field_with_label('dspinbox', 'Spinbox', self.dspinbox)

        self.dslider = gui.Slider(10, 0, 100, 5, width=200, height=20)
        self.dspinbox.set_value(50)
        self.dialog.add_field_with_label('dslider', 'Slider', self.dslider)

        self.dcolor = gui.ColorPicker(width=200, height=20)
        self.dcolor.set_value('#ffff00')
        self.dialog.add_field_with_label('dcolor', 'Colour Picker', self.dcolor)

        self.ddate = gui.Date(width=200, height=20)
        self.ddate.set_value('2000-01-01')
        self.dialog.add_field_with_label('ddate', 'Date', self.ddate)

        self.dialog.confirm_dialog.do(self.dialog_confirm)
        self.dialog.show(self)
Exemple #6
0
    def __init__(self,
                 label='label',
                 default_value=0,
                 min=0,
                 max=100,
                 step=1,
                 labelWidth=100,
                 spinBoxWidth=80,
                 *args):
        super(self.__class__, self).__init__(*args)

        self._label = gui.Label(label, width=labelWidth)
        self._spinbox = gui.SpinBox(default_value=default_value,
                                    min=min,
                                    max=max,
                                    step=step,
                                    width=spinBoxWidth)

        self.append(self._label, 'label')
        self.append(self._spinbox, 'spinbox')

        self.set_on_change_listener = self._spinbox.set_on_change_listener
        self.set_value = self._spinbox.set_value
        self.get_value = self._spinbox.get_value
        self.setValue = self.set_value
Exemple #7
0
    def __init__(self, title='', message=''):
        super(ProjectConfigurationDialog, self).__init__(
            'Project Configuration',
            'Here are the configuration options of the project.',
            width=500)
        #standard configuration
        self.configDict = {}

        self.configDict[self.KEY_PRJ_NAME] = 'untitled'
        self.configDict[self.KEY_ADDRESS] = '0.0.0.0'
        self.configDict[self.KEY_PORT] = 8081
        self.configDict[self.KEY_MULTIPLE_INSTANCE] = True
        self.configDict[self.KEY_ENABLE_CACHE] = True
        self.configDict[self.KEY_START_BROWSER] = True
        self.configDict[self.KEY_RESOURCEPATH] = "./res/"

        self.add_field_with_label(self.KEY_PRJ_NAME, 'Project Name',
                                  gui.TextInput())
        self.add_field_with_label(self.KEY_ADDRESS, 'IP address',
                                  gui.TextInput())
        self.add_field_with_label(self.KEY_PORT, 'Listen port',
                                  gui.SpinBox(8082, 1025, 65535))
        self.add_field_with_label(
            self.KEY_MULTIPLE_INSTANCE,
            'Use single App instance for multiple users', gui.CheckBox(True))
        self.add_field_with_label(self.KEY_ENABLE_CACHE, 'Enable file caching',
                                  gui.CheckBox(True))
        self.add_field_with_label(self.KEY_START_BROWSER,
                                  'Start browser automatically',
                                  gui.CheckBox(True))
        self.add_field_with_label(self.KEY_RESOURCEPATH,
                                  'Additional resource path', gui.TextInput())
        self.from_dict_to_fields(self.configDict)
Exemple #8
0
    def __createEditor(self):
        attributeType = self._param._type
        additionalInfo = self._param._additionalInfo
        attributeValue = self._param._v
        attributeName = self._param._k
        attributeDesc = self._param._description
        if additionalInfo == None:
            additionalInfo = {}

        dprint('name', attributeName, 'type', attributeType, 'value',
               attributeValue, 'info', additionalInfo)

        self.inputWidget = None

        #'background-repeat':{'type':str, 'description':'The repeat behaviour of an optional background image', ,'additional_data':{'affected_widget_attribute':'style', 'possible_values':'repeat | repeat-x | repeat-y | no-repeat | inherit'}},
        if attributeType == bool or attributeType == 'bool':
            if attributeValue == 'true':
                attributeValue = True
            if attributeValue == 'false':
                attributeValue = False
            self.inputWidget = gui.CheckBox('checked')
        elif attributeType == int or attributeType == float or attributeType == 'int' or attributeType == 'float':
            min_val = -1000000
            if "min" in additionalInfo:
                min_val = additionalInfo['min']
            max_val = 1000000
            if "max" in additionalInfo:
                max_val = additionalInfo['max']
            step_val = 1
            if "step" in additionalInfo:
                step_val = additionalInfo['step']
            self.inputWidget = gui.SpinBox(attributeValue, min_val, max_val,
                                           step_val)
        elif attributeType == gui.ColorPicker:
            self.inputWidget = gui.ColorPicker()
        elif attributeType == 'dropdown':
            self.inputWidget = gui.DropDown()
            for value in additionalInfo['possible_values']:
                self.inputWidget.append(gui.DropDownItem(value), value)
#        elif attributeType == 'url_editor':
#            self.inputWidget = UrlPathInput(self._appInstance)
#        elif attributeType == 'css_size':
#            self.inputWidget = CssSizeInput(self._appInstance)
        else:  # default editor is string
            self.inputWidget = StringEditor()

        self.inputWidget.set_on_change_listener(self.on_attribute_changed)
        self.inputWidget.set_size('50%', '22px')
        self.inputWidget.attributes['title'] = attributeDesc
        self.inputWidget.style['float'] = 'right'
        self.inputWidget.set_value(attributeValue)
        dprint('setValue', attributeValue)
        dprint('getValue', self.inputWidget.get_value())

        self.append(self.inputWidget)
Exemple #9
0
    def menu_dialog_clicked(self):
        self.dialog = gui.GenericDialog(
            title='Dialog Box',
            message='Click Ok to transfer content to main page')

        self.dtextinput = gui.TextInput(200, 30)
        self.dtextinput.set_value('Initial Text')
        self.dialog.add_field_with_label('dtextinput', 'Text Input',
                                         self.dtextinput)

        self.dcheck = gui.CheckBox(200, 30, False)
        self.dialog.add_field_with_label('dcheck', 'Label Checkbox',
                                         self.dcheck)
        values = ('Danny Young', 'Christine Holand', 'Lars Gordon',
                  'Roberto Robitaille')
        self.dlistView = gui.ListView(200, 120)
        key = 0
        for value in values:
            obj = gui.ListItem(170, 20, value)
            self.dlistView.append(str(key), obj)
            key += 1
        self.dialog.add_field_with_label('dlistView', 'Listview',
                                         self.dlistView)

        self.ddropdown = gui.DropDown(200, 20)
        c0 = gui.DropDownItem(200, 20, 'DropDownItem 0')
        c1 = gui.DropDownItem(200, 20, 'DropDownItem 1')
        self.ddropdown.append('0', c0)
        self.ddropdown.append('1', c1)
        self.ddropdown.set_value('Value1')
        self.dialog.add_field_with_label('ddropdown', 'Dropdown',
                                         self.ddropdown)

        self.dspinbox = gui.SpinBox(200, 20, min=0, max=5000)
        self.dspinbox.set_value(50)
        self.dialog.add_field_with_label('dspinbox', 'Spinbox', self.dspinbox)

        self.dslider = gui.Slider(200, 20, 10, 0, 100, 5)
        self.dspinbox.set_value(50)
        self.dialog.add_field_with_label('dslider', 'Slider', self.dslider)

        self.dcolor = gui.ColorPicker(200, 20)
        self.dcolor.set_value('#ffff00')
        self.dialog.add_field_with_label('dcolor', 'Colour Picker',
                                         self.dcolor)

        self.ddate = gui.Date(
            200,
            20,
        )
        self.ddate.set_value('2000-01-01')
        self.dialog.add_field_with_label('ddate', 'Date', self.ddate)

        self.dialog.set_on_confirm_dialog_listener(self, 'dialog_confirm')
        self.dialog.show(self)
    def __init__(self, attributeName, attributeDict, appInstance=None):
        super(EditorAttributeInput, self).__init__()
        gui.EventSource.__init__(self)
        self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        self.style.update({'display':'block',
            'overflow':'auto',
            'margin':'2px',
            'outline':'1px solid lightgray'})
        self.attributeName = attributeName
        self.attributeDict = attributeDict
        self.EVENT_ATTRIB_ONCHANGE = 'on_attribute_changed'

        self.EVENT_ATTRIB_ONREMOVE = 'onremove_attribute'
        self.removeAttribute = gui.Image('/editor_resources:delete.png', width='5%')
        self.removeAttribute.attributes['title'] = 'Remove attribute from this widget.'
        self.removeAttribute.onclick.do(self.on_attribute_remove)
        self.append(self.removeAttribute)

        self.label = gui.Label(attributeName, width='45%', height=22, margin='0px')
        self.label.style['overflow'] = 'hidden'
        self.label.style['font-size'] = '13px'
        self.label.style['outline'] = '1px solid lightgray'
        self.append(self.label)
        self.inputWidget = None

        #'background-repeat':{'type':str, 'description':'The repeat behaviour of an optional background image', ,'additional_data':{'affected_widget_attribute':'style', 'possible_values':'repeat | repeat-x | repeat-y | no-repeat | inherit'}},
        if attributeDict['type'] in (bool,int,float,gui.ColorPicker,gui.DropDown,'url_editor','css_size'):
            if attributeDict['type'] == bool:
                self.inputWidget = gui.CheckBox('checked')
            if attributeDict['type'] == int or attributeDict['type'] == float:
                self.inputWidget = gui.SpinBox(attributeDict['additional_data']['default'], attributeDict['additional_data']['min'], attributeDict['additional_data']['max'], attributeDict['additional_data']['step'])
            if attributeDict['type'] == gui.ColorPicker:
                self.inputWidget = gui.ColorPicker()
            if attributeDict['type'] == gui.DropDown:
                self.inputWidget = gui.DropDown()
                for value in attributeDict['additional_data']['possible_values']:
                    self.inputWidget.append(gui.DropDownItem(value),value)
            if attributeDict['type'] == 'url_editor':
                self.inputWidget = UrlPathInput(appInstance)
            if attributeDict['type'] == 'css_size':
                self.inputWidget = CssSizeInput(appInstance)

        else: #default editor is string
            self.inputWidget = gui.TextInput()

        self.inputWidget.onchange.do(self.on_attribute_changed)
        self.inputWidget.set_size('50%','22px')
        self.inputWidget.attributes['title'] = attributeDict['description']
        self.label.attributes['title'] = attributeDict['description']
        self.append(self.inputWidget)
        self.inputWidget.style['float'] = 'right'

        self.style['display'] = 'block'
        self.set_valid(False)
Exemple #11
0
	def main(self):
		self.w = gui.VBox()

		self.hbox_save_load = gui.HBox(margin="10px")
		self.dtext_conf_file = gui.TextInput(width=200, height=30)
		self.dtext_conf_file.set_value(str(vals.config))
		self.dtext_conf_file.set_on_change_listener(self.dtext_conf_file_changed)
		self.bt_load = gui.Button("Load", width=200, height=30, margin="10px")
		self.bt_load.set_on_click_listener(self.bt_load_changed)
		self.bt_save = gui.Button("Save", width=200, height=30, margin="10px")
		self.bt_save.set_on_click_listener(self.bt_save_changed)
		self.hbox_save_load.append(self.dtext_conf_file)
		self.hbox_save_load.append(self.bt_load)
		self.hbox_save_load.append(self.bt_save)
		self.w.append(self.hbox_save_load)

		self.hbox_nco1 = gui.HBox(margin="10px")
		self.lb_nco1 = gui.Label("/dev/nco1", width="20%", margin="10px")
		self.sd_pinc_nco1 = gui.Slider(vals.pinc_nco1, 0, samp_freq/2, 1, width="25%", margin="10px")
		self.sd_pinc_nco1.set_oninput_listener(self.sd_pinc_nco1_changed)
		self.sb_pinc_nco1 = gui.SpinBox(vals.pinc_nco1, 0, samp_freq/2, 0.02, width="10%", margin="10px")
		self.sb_pinc_nco1.set_on_change_listener(self.sb_pinc_nco1_changed)
		self.sd_poff_nco1 = gui.Slider(vals.poff_nco1, -8192, 8191, 1, width="25%", margin="10px")
		self.sd_poff_nco1.set_oninput_listener(self.sd_poff_nco1_changed)
		self.sb_poff_nco1 = gui.SpinBox(vals.poff_nco1, -8192, 8191, 1, width="10%", margin="10px")
		self.sb_poff_nco1.set_on_change_listener(self.sb_poff_nco1_changed)
		self.cb_pinc_nco1 = gui.CheckBoxLabel("pinc", vals.cb_pinc_nco1, width="5%", margin="10px")
		self.cb_pinc_nco1.set_on_change_listener(self.cb_pinc_nco1_changed)
		self.cb_poff_nco1 = gui.CheckBoxLabel("poff", vals.cb_poff_nco1, width="5%", margin="10px")
		self.cb_poff_nco1.set_on_change_listener(self.cb_poff_nco1_changed)
		self.hbox_nco1.append(self.lb_nco1)
		self.hbox_nco1.append(self.sd_pinc_nco1)
		self.hbox_nco1.append(self.sb_pinc_nco1)
		self.hbox_nco1.append(self.sd_poff_nco1)
		self.hbox_nco1.append(self.sb_poff_nco1)
		self.hbox_nco1.append(self.cb_pinc_nco1)
		self.hbox_nco1.append(self.cb_poff_nco1)
		self.w.append(self.hbox_nco1)

		return self.w
Exemple #12
0
    def menu_dialog_clicked(self):
        self.dialog = gui.GenericDialog(
            title='Dialog Box',
            message='Click Ok to transfer content to main page')
        self.dialog.style['width'] = '300px'
        self.dtextinput = gui.TextInput(width=200, height=30)
        self.dtextinput.set_value('Initial Text')
        self.dialog.add_field_with_label('dtextinput', 'Text Input',
                                         self.dtextinput)

        self.dcheck = gui.CheckBox(False, width=200, height=30)
        self.dialog.add_field_with_label('dcheck', 'Label Checkbox',
                                         self.dcheck)
        values = ('Danny Young', 'Christine Holand', 'Lars Gordon',
                  'Roberto Robitaille')
        self.dlistView = gui.ListView(width=200, height=120)
        for key, value in enumerate(values):
            self.dlistView.append(value, key=str(key))
        self.dialog.add_field_with_label('dlistView', 'Listview',
                                         self.dlistView)

        self.ddropdown = gui.DropDown(width=200, height=20)
        c0 = gui.DropDownItem('DropDownItem 0', width=200, height=20)
        c1 = gui.DropDownItem('DropDownItem 1', width=200, height=20)
        self.ddropdown.append(c0)
        self.ddropdown.append(c1)
        self.ddropdown.set_value('Value1')
        self.dialog.add_field_with_label('ddropdown', 'Dropdown',
                                         self.ddropdown)

        self.dspinbox = gui.SpinBox(min=0, max=5000, width=200, height=20)
        self.dspinbox.set_value(50)
        self.dialog.add_field_with_label('dspinbox', 'Spinbox', self.dspinbox)

        self.dslider = gui.Slider(10, 0, 100, 5, width=200, height=20)
        self.dspinbox.set_value(50)
        self.dialog.add_field_with_label('dslider', 'Slider', self.dslider)

        self.dcolor = gui.ColorPicker(width=200, height=20)
        self.dcolor.set_value('#ffff00')
        self.dialog.add_field_with_label('dcolor', 'Colour Picker',
                                         self.dcolor)

        self.ddate = gui.Date(width=200, height=20)
        self.ddate.set_value('2000-01-01')
        self.dialog.add_field_with_label('ddate', 'Date', self.ddate)

        self.dialog.set_on_confirm_dialog_listener(self, 'dialog_confirm')
        self.dialog.show(self)
Exemple #13
0
    def __init__(self, attributeName, attributeDict, appInstance=None):
        super(EditorAttributeInput, self).__init__()
        self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        self.style['display'] = 'block'
        self.style['overflow'] = 'auto'
        self.style['margin'] = '2px'
        self.attributeName = attributeName
        self.attributeDict = attributeDict
        self.EVENT_ATTRIB_ONCHANGE = 'on_attribute_changed'

        label = gui.Label(attributeName, width='50%', height=22)
        label.style['margin'] = '0px'
        label.style['overflow'] = 'hidden'
        label.style['font-size'] = '13px'
        self.append(label)
        self.inputWidget = None

        #'background-repeat':{'type':str, 'description':'The repeat behaviour of an optional background image', ,'additional_data':{'affected_widget_attribute':'style', 'possible_values':'repeat | repeat-x | repeat-y | no-repeat | inherit'}},
        if attributeDict['type'] in (bool, int, float, gui.ColorPicker,
                                     gui.DropDown, gui.FileSelectionDialog):
            if attributeDict['type'] == bool:
                self.inputWidget = gui.CheckBox('checked')
            if attributeDict['type'] == int or attributeDict['type'] == float:
                self.inputWidget = gui.SpinBox(
                    attributeDict['additional_data']['default'],
                    attributeDict['additional_data']['min'],
                    attributeDict['additional_data']['max'],
                    attributeDict['additional_data']['step'])
            if attributeDict['type'] == gui.ColorPicker:
                self.inputWidget = gui.ColorPicker()
            if attributeDict['type'] == gui.DropDown:
                self.inputWidget = gui.DropDown()
                for value in attributeDict['additional_data'][
                        'possible_values']:
                    self.inputWidget.append(gui.DropDownItem(value), value)
            if attributeDict['type'] == gui.FileSelectionDialog:
                self.inputWidget = UrlPathInput(appInstance)

        else:  #default editor is string
            self.inputWidget = gui.TextInput()

        self.inputWidget.set_size('50%', '22px')
        self.inputWidget.attributes['title'] = attributeDict['description']
        label.attributes['title'] = attributeDict['description']
        self.inputWidget.set_on_change_listener(self, "on_attribute_changed")
        self.append(self.inputWidget)
        self.inputWidget.style['float'] = 'right'

        self.style['display'] = 'block'
Exemple #14
0
 def __init__(self, appInstance, **kwargs):
     super(CssSizeInput, self).__init__(**kwargs)
     self.appInstance = appInstance
     self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
     self.style['display'] = 'block'
     self.style['overflow'] = 'hidden'
     
     self.numInput = gui.SpinBox('0',-999999999, 999999999, 0.1, width='60%', height='100%')
     self.numInput.set_on_change_listener(self, "on_value_changed")
     self.numInput.style['text-align'] = 'right'
     self.append(self.numInput)
     
     self.dropMeasureUnit = gui.DropDown(width='40%', height='100%')
     self.dropMeasureUnit.append( gui.DropDownItem('px'), 'px' )
     self.dropMeasureUnit.append( gui.DropDownItem('%'), '%' )
     self.dropMeasureUnit.select_by_key('px')
     self.dropMeasureUnit.set_on_change_listener(self, "on_value_changed")
     self.append(self.dropMeasureUnit)
Exemple #15
0
    def add_numeric(
        self,
        key: str,
        desc: str,
        default_value=0,
        min_value=0,
        max_value=100,
        step=5,
        **kwargs,
    ):
        spin = gui.SpinBox(
            default_value=default_value,
            min_value=min_value,
            max_value=max_value,
            step=step,
            **kwargs,
        )

        self.add_field(key=key, desc=desc, field=spin)
Exemple #16
0
    def __init__(self, title='', message=''):
        super(ProjectConfigurationDialog, self).__init__('Configuration',
                                                         'Here are the configuration options of the project.', width=500)
#        # standard configuration
#        self.configDict = {}
#
#        self.configDict[self.KEY_PRJ_NAME] = 'untitled'
#        self.configDict[self.KEY_ADDRESS] = '0.0.0.0'
#        self.configDict[self.KEY_PORT] = 8081
#        self.configDict[self.KEY_MULTIPLE_INSTANCE] = True
#        self.configDict[self.KEY_ENABLE_CACHE] = True
#        self.configDict[self.KEY_START_BROWSER] = True
#        self.configDict[self.KEY_RESOURCEPATH] = "./res/"
#
#        self.add_field_with_label(
#            '', 'Project Name', gui.TextInput())
        self.add_field_with_label(
            'external_ip', 'IP address', gui.TextInput())
        self.add_field_with_label(
            'websocket_port', 'Listen port', gui.SpinBox(8082, 1025, 65535))
        self.add_field_with_label(
            'plot_w', 'Window w', gui.SpinBox(600, 100, 65535))
        self.add_field_with_label(
            'plot_h', 'Window h', gui.SpinBox(600, 100, 65535))
        self.add_field_with_label(
            'image_w', 'Image w', gui.SpinBox(20, 1, 100))
        self.add_field_with_label(
            'image_h', 'Image h', gui.SpinBox(20, 1, 100))
        self.add_field_with_label(
            'plot_label_size', 'Plot Label Size', gui.SpinBox(10, 1, 100))
        self.add_field_with_label(
            'axis_label', 'Axis Label', gui.CheckBox(True))
        self.add_field_with_label(
            'su_bin', 'SU Path', gui.TextInput())
        self.add_field_with_label(
            self.KEY_MULTIPLE_INSTANCE, 'Use single App instance for multiple users', gui.CheckBox(True))
        self.add_field_with_label(
            self.KEY_ENABLE_CACHE, 'Enable file caching', gui.CheckBox(True))
        self.add_field_with_label(
            self.KEY_START_BROWSER, 'Start browser automatically', gui.CheckBox(True))
#        self.add_field_with_label(
#            self.KEY_RESOURCEPATH, 'Additional resource path', gui.TextInput())
        self.from_dict_to_fields()
Exemple #17
0
    def main(self):
        self.w = gui.VBox()

        self.hbox_save_load = gui.HBox(margin="10px")
        self.dtext_conf_file = gui.TextInput(width=200, height=30)
        self.dtext_conf_file.set_value(str(vals.config))
        self.dtext_conf_file.set_on_change_listener(
            self.dtext_conf_file_changed)
        self.bt_load = gui.Button("Load", width=200, height=30, margin="10px")
        self.bt_load.set_on_click_listener(self.bt_load_changed)
        self.bt_save = gui.Button("Save", width=200, height=30, margin="10px")
        self.bt_save.set_on_click_listener(self.bt_save_changed)
        self.hbox_save_load.append(self.dtext_conf_file)
        self.hbox_save_load.append(self.bt_load)
        self.hbox_save_load.append(self.bt_save)
        self.w.append(self.hbox_save_load)

        self.hbox_adc1_offset = gui.HBox(margin="10px")
        self.lb_adc1_offset = gui.Label("/dev/adc1_offset",
                                        width="20%",
                                        margin="10px")
        self.sd_adc1_offset = gui.Slider(vals.adc1_offset,
                                         -8192,
                                         8191,
                                         1,
                                         width="60%",
                                         margin="10px")
        self.sd_adc1_offset.set_on_change_listener(self.sd_adc1_offset_changed)
        self.sb_adc1_offset = gui.SpinBox(vals.adc1_offset,
                                          -8192,
                                          8191,
                                          1,
                                          width="20%",
                                          margin="10px")
        self.sb_adc1_offset.set_on_change_listener(self.sb_adc1_offset_changed)
        self.sd_adc1_offset_changed(self.sd_adc1_offset,
                                    self.sd_adc1_offset.get_value())
        self.hbox_adc1_offset.append(self.lb_adc1_offset)
        self.hbox_adc1_offset.append(self.sd_adc1_offset)
        self.hbox_adc1_offset.append(self.sb_adc1_offset)
        self.w.append(self.hbox_adc1_offset)

        self.hbox_adc2_offset = gui.HBox(margin="10px")
        self.lb_adc2_offset = gui.Label("/dev/adc2_offset",
                                        width="20%",
                                        margin="10px")
        self.sd_adc2_offset = gui.Slider(vals.adc2_offset,
                                         -8192,
                                         8191,
                                         1,
                                         width="60%",
                                         margin="10px")
        self.sd_adc2_offset.set_on_change_listener(self.sd_adc2_offset_changed)
        self.sb_adc2_offset = gui.SpinBox(vals.adc2_offset,
                                          -8192,
                                          8191,
                                          1,
                                          width="20%",
                                          margin="10px")
        self.sb_adc2_offset.set_on_change_listener(self.sb_adc2_offset_changed)
        self.sd_adc2_offset_changed(self.sd_adc2_offset,
                                    self.sd_adc2_offset.get_value())
        self.hbox_adc2_offset.append(self.lb_adc2_offset)
        self.hbox_adc2_offset.append(self.sd_adc2_offset)
        self.hbox_adc2_offset.append(self.sb_adc2_offset)
        self.w.append(self.hbox_adc2_offset)

        self.hbox_dds1_offset = gui.HBox(margin="10px")
        self.lb_dds1_offset = gui.Label("/dev/dds1_offset",
                                        width="20%",
                                        margin="10px")
        self.sd_dds1_offset = gui.Slider(vals.dds1_offset,
                                         -8192,
                                         8191,
                                         1,
                                         width="60%",
                                         margin="10px")
        self.sd_dds1_offset.set_on_change_listener(self.sd_dds1_offset_changed)
        self.sb_dds1_offset = gui.SpinBox(vals.dds1_offset,
                                          -8192,
                                          8191,
                                          1,
                                          width="20%",
                                          margin="10px")
        self.sb_dds1_offset.set_on_change_listener(self.sb_dds1_offset_changed)
        self.sd_dds1_offset_changed(self.sd_dds1_offset,
                                    self.sd_dds1_offset.get_value())
        self.hbox_dds1_offset.append(self.lb_dds1_offset)
        self.hbox_dds1_offset.append(self.sd_dds1_offset)
        self.hbox_dds1_offset.append(self.sb_dds1_offset)
        self.w.append(self.hbox_dds1_offset)

        self.hbox_dds2_offset = gui.HBox(margin="10px")
        self.lb_dds2_offset = gui.Label("/dev/dds2_offset",
                                        width="20%",
                                        margin="10px")
        self.sd_dds2_offset = gui.Slider(vals.dds2_offset,
                                         -8192,
                                         8191,
                                         1,
                                         width="60%",
                                         margin="10px")
        self.sd_dds2_offset.set_on_change_listener(self.sd_dds2_offset_changed)
        self.sb_dds2_offset = gui.SpinBox(vals.dds2_offset,
                                          -8192,
                                          8191,
                                          1,
                                          width="20%",
                                          margin="10px")
        self.sb_dds2_offset.set_on_change_listener(self.sb_dds2_offset_changed)
        self.sd_dds2_offset_changed(self.sd_dds2_offset,
                                    self.sd_dds2_offset.get_value())
        self.hbox_dds2_offset.append(self.lb_dds2_offset)
        self.hbox_dds2_offset.append(self.sd_dds2_offset)
        self.hbox_dds2_offset.append(self.sb_dds2_offset)
        self.w.append(self.hbox_dds2_offset)

        self.hbox_ch1_dds_ampl = gui.HBox(margin="10px")
        self.lb_ch1_dds_ampl = gui.Label("/dev/dds_ampl/1",
                                         width="20%",
                                         margin="10px")
        self.sd_ch1_dds_ampl = gui.Slider(vals.ch1_dds_ampl,
                                          -8192,
                                          8191,
                                          1,
                                          width="60%",
                                          margin="10px")
        self.sd_ch1_dds_ampl.set_on_change_listener(
            self.sd_ch1_dds_ampl_changed)
        self.sb_ch1_dds_ampl = gui.SpinBox(vals.ch1_dds_ampl,
                                           -8192,
                                           8191,
                                           1,
                                           width="20%",
                                           margin="10px")
        self.sb_ch1_dds_ampl.set_on_change_listener(
            self.sb_ch1_dds_ampl_changed)
        self.sd_ch1_dds_ampl_changed(self.sd_ch1_dds_ampl,
                                     self.sd_ch1_dds_ampl.get_value())
        self.hbox_ch1_dds_ampl.append(self.lb_ch1_dds_ampl)
        self.hbox_ch1_dds_ampl.append(self.sd_ch1_dds_ampl)
        self.hbox_ch1_dds_ampl.append(self.sb_ch1_dds_ampl)
        self.w.append(self.hbox_ch1_dds_ampl)

        self.hbox_ch2_dds_ampl = gui.HBox(margin="10px")
        self.lb_ch2_dds_ampl = gui.Label("/dev/dds_ampl/2",
                                         width="20%",
                                         margin="10px")
        self.sd_ch2_dds_ampl = gui.Slider(vals.ch2_dds_ampl,
                                          -8192,
                                          8191,
                                          1,
                                          width="60%",
                                          margin="10px")
        self.sd_ch2_dds_ampl.set_on_change_listener(
            self.sd_ch2_dds_ampl_changed)
        self.sb_ch2_dds_ampl = gui.SpinBox(vals.ch2_dds_ampl,
                                           -8192,
                                           8191,
                                           1,
                                           width="20%",
                                           margin="10px")
        self.sb_ch2_dds_ampl.set_on_change_listener(
            self.sb_ch2_dds_ampl_changed)
        self.sd_ch2_dds_ampl_changed(self.sd_ch2_dds_ampl,
                                     self.sd_ch2_dds_ampl.get_value())
        self.hbox_ch2_dds_ampl.append(self.lb_ch2_dds_ampl)
        self.hbox_ch2_dds_ampl.append(self.sd_ch2_dds_ampl)
        self.hbox_ch2_dds_ampl.append(self.sb_ch2_dds_ampl)
        self.w.append(self.hbox_ch2_dds_ampl)

        self.hbox_nco_counter_1 = gui.HBox(margin="10px")
        self.lb_nco_counter_1 = gui.Label("/dev/nco_counter_1",
                                          width="20%",
                                          margin="10px")
        self.sd_pinc_nco_counter_1 = gui.Slider(vals.pinc_nco_counter_1,
                                                0,
                                                samp_freq / 2,
                                                1,
                                                width="25%",
                                                margin="10px")
        self.sd_pinc_nco_counter_1.set_on_change_listener(
            self.sd_pinc_nco_counter_1_changed)
        self.sb_pinc_nco_counter_1 = gui.SpinBox(vals.pinc_nco_counter_1,
                                                 0,
                                                 samp_freq / 2,
                                                 0.02,
                                                 width="10%",
                                                 margin="10px")
        self.sb_pinc_nco_counter_1.set_on_change_listener(
            self.sb_pinc_nco_counter_1_changed)
        self.sd_poff_nco_counter_1 = gui.Slider(vals.poff_nco_counter_1,
                                                -8192,
                                                8191,
                                                1,
                                                width="25%",
                                                margin="10px")
        self.sd_poff_nco_counter_1.set_on_change_listener(
            self.sd_poff_nco_counter_1_changed)
        self.sb_poff_nco_counter_1 = gui.SpinBox(vals.poff_nco_counter_1,
                                                 -8192,
                                                 8191,
                                                 1,
                                                 width="10%",
                                                 margin="10px")
        self.sb_poff_nco_counter_1.set_on_change_listener(
            self.sb_poff_nco_counter_1_changed)
        self.cb_pinc_nco_counter_1 = gui.CheckBoxLabel(
            "pinc", vals.cb_pinc_nco_counter_1, width="5%", margin="10px")
        self.cb_pinc_nco_counter_1.set_on_change_listener(
            self.cb_pinc_nco_counter_1_changed)
        self.cb_poff_nco_counter_1 = gui.CheckBoxLabel(
            "poff", vals.cb_poff_nco_counter_1, width="5%", margin="10px")
        self.cb_poff_nco_counter_1.set_on_change_listener(
            self.cb_poff_nco_counter_1_changed)
        self.hbox_nco_counter_1.append(self.lb_nco_counter_1)
        self.hbox_nco_counter_1.append(self.sd_pinc_nco_counter_1)
        self.hbox_nco_counter_1.append(self.sb_pinc_nco_counter_1)
        self.hbox_nco_counter_1.append(self.sd_poff_nco_counter_1)
        self.hbox_nco_counter_1.append(self.sb_poff_nco_counter_1)
        self.hbox_nco_counter_1.append(self.cb_pinc_nco_counter_1)
        self.hbox_nco_counter_1.append(self.cb_poff_nco_counter_1)
        self.w.append(self.hbox_nco_counter_1)

        self.hbox_nco_counter_2 = gui.HBox(margin="10px")
        self.lb_nco_counter_2 = gui.Label("/dev/nco_counter_2",
                                          width="20%",
                                          margin="10px")
        self.sd_pinc_nco_counter_2 = gui.Slider(vals.pinc_nco_counter_2,
                                                0,
                                                samp_freq / 2,
                                                1,
                                                width="25%",
                                                margin="10px")
        self.sd_pinc_nco_counter_2.set_on_change_listener(
            self.sd_pinc_nco_counter_2_changed)
        self.sb_pinc_nco_counter_2 = gui.SpinBox(vals.pinc_nco_counter_2,
                                                 0,
                                                 samp_freq / 2,
                                                 0.02,
                                                 width="10%",
                                                 margin="10px")
        self.sb_pinc_nco_counter_2.set_on_change_listener(
            self.sb_pinc_nco_counter_2_changed)
        self.sd_poff_nco_counter_2 = gui.Slider(vals.poff_nco_counter_2,
                                                -8192,
                                                8191,
                                                1,
                                                width="25%",
                                                margin="10px")
        self.sd_poff_nco_counter_2.set_on_change_listener(
            self.sd_poff_nco_counter_2_changed)
        self.sb_poff_nco_counter_2 = gui.SpinBox(vals.poff_nco_counter_2,
                                                 -8192,
                                                 8191,
                                                 1,
                                                 width="10%",
                                                 margin="10px")
        self.sb_poff_nco_counter_2.set_on_change_listener(
            self.sb_poff_nco_counter_2_changed)
        self.cb_pinc_nco_counter_2 = gui.CheckBoxLabel(
            "pinc", vals.cb_pinc_nco_counter_2, width="5%", margin="10px")
        self.cb_pinc_nco_counter_2.set_on_change_listener(
            self.cb_pinc_nco_counter_2_changed)
        self.cb_poff_nco_counter_2 = gui.CheckBoxLabel(
            "poff", vals.cb_poff_nco_counter_2, width="5%", margin="10px")
        self.cb_poff_nco_counter_2.set_on_change_listener(
            self.cb_poff_nco_counter_2_changed)
        self.hbox_nco_counter_2.append(self.lb_nco_counter_2)
        self.hbox_nco_counter_2.append(self.sd_pinc_nco_counter_2)
        self.hbox_nco_counter_2.append(self.sb_pinc_nco_counter_2)
        self.hbox_nco_counter_2.append(self.sd_poff_nco_counter_2)
        self.hbox_nco_counter_2.append(self.sb_poff_nco_counter_2)
        self.hbox_nco_counter_2.append(self.cb_pinc_nco_counter_2)
        self.hbox_nco_counter_2.append(self.cb_poff_nco_counter_2)
        self.w.append(self.hbox_nco_counter_2)

        return self.w
Exemple #18
0
    def main(self):
        self.color_flipper = ['orange', 'white']

        self.centering_container = gui.Container(width=640,
                                                 height=360,
                                                 style={
                                                     'background-color':
                                                     'black',
                                                     "position": "absolute"
                                                 })

        #to make a left margin or 50px (because of google glasses curvature), I have to calculate a new height
        _w_margin = 40
        _h_margin = 0  # was _w_margin*360/640
        self.main_container = AsciiContainer(width=640 - _w_margin,
                                             height=360 - _h_margin,
                                             style={
                                                 'background-color':
                                                 'transparent',
                                                 'position':
                                                 'relative',
                                                 'margin-left':
                                                 gui.to_pix(_w_margin),
                                                 'margin-top':
                                                 gui.to_pix(_h_margin / 2)
                                             })

        self.main_container.set_from_asciiart("""
        | t0                                                                                                     |
        | left1        | pfd                                                                                     |
        | left1        | pfd                                                                                     |
        | left1        | pfd                                                                                     |
        | left2        | pfd                                                                                     |
        | left2        | pfd                                                                                     |
        | left2        | pfd                                                                                     |
        | left3        | pfd                                                                                     |
        | left3        | pfd                                                                                     |
        | left3        | pfd                                                                                     |
        | left4        | pfd                                                                                     |
        | left4        | pfd                                                                                     |
        | left4        | pfd                                                                                     |
        | s            | m                                   | t5                                 | t6           |
        | t1                                                                                                     |
        """,
                                              gap_horizontal=0,
                                              gap_vertical=0)

        w = "95%"
        h = 30
        self.slider_pitch = gui.SpinBox(0, -90.0, 90.0, 2.0, width=w, height=h)
        self.slider_orientation = gui.SpinBox(0,
                                              -180,
                                              180,
                                              2,
                                              width=w,
                                              height=h)
        self.slider_roll = gui.SpinBox(0, -180, 180, 2.0, width=w, height=h)
        self.slider_altitude = gui.SpinBox(0, 0, 9999, 1.0, width=w, height=h)
        self.slider_speed = gui.SpinBox(0, 0, 999, 1.0, width=w, height=h)
        """
        controls_container = gui.VBox()
        controls_container.append( gui.VBox(children=[gui.Label('pitch'), self.slider_pitch], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('orientation'), self.slider_orientation], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('roll'), self.slider_roll], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('altitude'), self.slider_altitude], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('speed'), self.slider_speed], width=300) )

        hbox0.append(controls_container)
        """
        h_divisions = 14.0
        self.pfd = PrimaryFlightDisplay(style={'position': 'relative'})
        _style = {
            'text-align': 'center',
            'color': self.standard_label_color,
            'outline': '1px solid black',
            'font-size': '16px'
        }
        self.t0 = gui.Label("T0", style=_style)
        self.t1 = gui.Label("WAITING FOR MAVLINK", style=_style)
        self.t5 = gui.Label("Voltage", style=_style)
        self.t6 = gui.Label("RPM", style=_style)
        self.s = gui.Label("GNSS", style=_style)
        self.m = gui.Label("MODE", style=_style)
        self.left1 = gui.Label("", style=_style)
        self.left2 = gui.Label("", style=_style)
        self.left3 = gui.Label("", style=_style)
        self.left4 = gui.Label("", style=_style)

        self.main_container.append(self.pfd, "pfd")
        self.main_container.append(self.t0, "t0")
        self.main_container.append(self.t1, "t1")
        self.main_container.append(self.t5, "t5")
        self.main_container.append(self.t6, "t6")
        self.main_container.append(self.s, "s")
        self.main_container.append(self.m, "m")
        self.main_container.append(self.left1, "left1")
        self.main_container.append(self.left2, "left2")
        self.main_container.append(self.left3, "left3")
        self.main_container.append(self.left4, "left4")

        # Here I start a parallel thread
        self.thread_alive_flag = True
        t = threading.Thread(target=self.my_threaded_function)
        t.start()

        self.centering_container.append(self.main_container)
        return self.centering_container
Exemple #19
0
    def main(self):
        self.mainContainer = gui.Container(
            width='100%',
            height='100%',
            layout_orientation=gui.Container.LAYOUT_VERTICAL,
            style={
                'background-color': 'white',
                'border': 'none',
                'overflow': 'hidden'
            })

        menubar = gui.MenuBar(height='4%')
        menu = gui.Menu(width='100%', height='100%')
        menu.style['z-index'] = '1'
        m1 = gui.MenuItem('File', width=150, height='100%')
        m10 = gui.MenuItem('New', width=150, height=30)
        m11 = gui.MenuItem('Open', width=150, height=30)
        m12 = gui.MenuItem('Save Your App', width=150, height=30)
        #m12.style['visibility'] = 'hidden'
        m121 = gui.MenuItem('Save', width=100, height=30)
        m122 = gui.MenuItem('Save as', width=100, height=30)
        m123 = gui.MenuItem('Export widget as', width=200, height=30)
        m1.append([m10, m11, m12])
        m12.append([m121, m122, m123])

        m2 = gui.MenuItem('Edit', width=100, height='100%')
        m21 = gui.MenuItem('Cut', width=100, height=30)
        m22 = gui.MenuItem('Paste', width=100, height=30)
        m2.append([m21, m22])

        m3 = gui.MenuItem('Project Config', width=200, height='100%')

        m4 = gui.MenuItem('Became a Patron',
                          width=200,
                          height='100%',
                          style={'font-weight': 'bold'})

        menu.append([m1, m2, m3, m4])

        menubar.append(menu)

        self.toolbar = editor_widgets.ToolBar(width='100%',
                                              height='30px',
                                              margin='0px 0px')
        self.toolbar.style['border-bottom'] = '1px solid rgba(0,0,0,.12)'
        self.toolbar.add_command('/editor_resources:delete.png',
                                 self.toolbar_delete_clicked, 'Delete Widget')
        self.toolbar.add_command('/editor_resources:cut.png',
                                 self.menu_cut_selection_clicked, 'Cut Widget')
        self.toolbar.add_command('/editor_resources:paste.png',
                                 self.menu_paste_selection_clicked,
                                 'Paste Widget')

        lbl = gui.Label("Snap grid", width=100)
        spin_grid_size = gui.SpinBox('15', '1', '100', width=50)
        spin_grid_size.set_on_change_listener(self.on_snap_grid_size_change)

        grid_size = gui.HBox(children=[lbl, spin_grid_size],
                             style={
                                 'outline': '1px solid gray',
                                 'margin': '2px',
                                 'margin-left': '10px'
                             })
        self.toolbar.append(grid_size)

        self.fileOpenDialog = editor_widgets.EditorFileSelectionDialog(
            'Open Project',
            'Select the project file.<br>It have to be a python program created with this editor.',
            False, '.', True, False, self)
        self.fileOpenDialog.confirm_value.do(self.on_open_dialog_confirm)

        self.fileSaveAsDialog = editor_widgets.EditorFileSaveDialog(
            'Project Save', 'Select the project folder and type a filename',
            False, '.', False, True, self)
        self.fileSaveAsDialog.add_fileinput_field('untitled.py')
        self.fileSaveAsDialog.confirm_value.do(self.menu_save_clicked)

        m10.onclick.do(self.menu_new_clicked)
        m11.onclick.do(self.fileOpenDialog.show)
        m121.onclick.do(self.menu_save_clicked)
        m122.onclick.do(self.fileSaveAsDialog.show)
        m123.onclick.do(self.menu_save_widget_clicked)
        m21.onclick.do(self.menu_cut_selection_clicked)
        m22.onclick.do(self.menu_paste_selection_clicked)

        m3.onclick.do(self.menu_project_config_clicked)
        m4.onclick.do(self.menu_became_a_patron)

        self.subContainer = gui.HBox(
            width='100%',
            height='96%',
            layout_orientation=gui.Container.LAYOUT_HORIZONTAL)
        self.subContainer.style.update({
            'position': 'relative',
            'overflow': 'hidden',
            'align-items': 'stretch'
        })

        # here are contained the widgets
        self.widgetsCollection = editor_widgets.WidgetCollection(self,
                                                                 width='100%',
                                                                 height='50%')

        self.projectConfiguration = editor_widgets.ProjectConfigurationDialog(
            'Project Configuration',
            'Write here the configuration for your project.')

        self.attributeEditor = editor_widgets.EditorAttributes(self,
                                                               width='100%')
        self.attributeEditor.style['overflow'] = 'hide'
        self.signalConnectionManager = editor_widgets.SignalConnectionManager(
            width='100%', height='50%', style={'order': '1'})

        self.mainContainer.append([menubar, self.subContainer])

        self.subContainerLeft = gui.VBox(width='20%', height='100%')
        self.subContainerLeft.style['position'] = 'relative'
        self.subContainerLeft.style['left'] = '0px'
        self.widgetsCollection.style['order'] = '0'
        self.subContainerLeft.append({
            'widgets_collection':
            self.widgetsCollection,
            'signal_manager':
            self.signalConnectionManager
        })
        self.subContainerLeft.add_class('RaisedFrame')

        self.centralContainer = gui.VBox(width='56%', height='100%')
        self.centralContainer.append(self.toolbar)

        self.subContainerRight = gui.Container(width='24%', height='100%')
        self.subContainerRight.style.update({
            'position': 'absolute',
            'right': '0px',
            'overflow-y': 'auto',
            'overflow-x': 'hidden'
        })
        self.subContainerRight.add_class('RaisedFrame')

        self.instancesWidget = editor_widgets.InstancesWidget(width='100%')
        self.instancesWidget.treeView.on_tree_item_selected.do(
            self.on_instances_widget_selection)

        self.subContainerRight.append({
            'instances_widget': self.instancesWidget,
            'attributes_editor': self.attributeEditor
        })

        self.subContainer.append([
            self.subContainerLeft, self.centralContainer,
            self.subContainerRight
        ])

        self.drag_helpers = [
            ResizeHelper(self, width=16, height=16),
            DragHelper(self, width=15, height=15),
            SvgDraggablePoint(self, 'cx', 'cy', [gui.SvgCircle]),
            SvgDraggableCircleResizeRadius(self, [gui.SvgCircle]),
            SvgDraggablePoint(self, 'x1', 'y1', [gui.SvgLine]),
            SvgDraggablePoint(self, 'x2', 'y2', [gui.SvgLine]),
            SvgDraggablePoint(self, 'x', 'y', [gui.SvgRectangle, gui.SvgText]),
            SvgDraggableRectangleResizePoint(self, [gui.SvgRectangle])
        ]
        for drag_helper in self.drag_helpers:
            drag_helper.stop_drag.do(self.on_drag_resize_end)

        self.menu_new_clicked(None)
        self.on_snap_grid_size_change(spin_grid_size,
                                      spin_grid_size.get_value())

        self.projectPathFilename = ''
        self.editCuttedWidget = None  # cut operation, contains the cutted tag

        # returning the root widget
        return self.mainContainer
Exemple #20
0
def createSpinBox(minv, maxv, w, h, sclass, callback):
    spin = gui.SpinBox(0, minv, maxv, width=w, height=h)
    spin.onchange.do(callback)
    spin.add_class(sclass)

    return spin
Exemple #21
0
    def main(self):
        # the margin 0px auto centers the main container
        verticalContainer = gui.Container(width=540, margin='0px auto', style={'display': 'block', 'overflow': 'hidden'})

        horizontalContainer = gui.Container(width='100%', layout_orientation=gui.Container.LAYOUT_HORIZONTAL, margin='0px', style={'display': 'block', 'overflow': 'auto'})

        subContainerLeft = gui.Container(width=320, style={'display': 'block', 'overflow': 'auto', 'text-align': 'center'})
        self.img = gui.Image('/res:logo.png', height=100, margin='10px')
        self.img.onclick.do(self.on_img_clicked)

        self.table = gui.Table.new_from_list([('ID', 'First Name', 'Last Name'),
                                              ('101', 'Danny', 'Young'),
                                              ('102', 'Christine', 'Holand'),
                                              ('103', 'Lars', 'Gordon'),
                                              ('104', 'Roberto', 'Robitaille'),
                                              ('105', 'Maria', 'Papadopoulos')], width=300, height=200, margin='10px')
        self.table.on_table_row_click.do(self.on_table_row_click)

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Container(style={'width': '220px', 'display': 'block', 'overflow': 'auto', 'text-align': 'center'})
        self.count = 0
        self.counter = gui.Label('', width=200, height=30, margin='10px')

        self.lbl = gui.Label('This is a LABEL!', width=200, height=30, margin='10px')

        self.bt = gui.Button('Press me!', width=200, height=30, margin='10px')
        # setting the listener for the onclick event of the button
        self.bt.onclick.do(self.on_button_pressed)

        self.txt = gui.TextInput(width=200, height=30, margin='10px')
        self.txt.set_text('This is a TEXTAREA')
        self.txt.onchange.do(self.on_text_area_change)

        self.spin = gui.SpinBox(1, 0, 100, width=200, height=30, margin='10px')
        self.spin.onchange.do(self.on_spin_change)

        self.progress = gui.Progress(1, 100, width=200, height=5)

        self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px')
        self.check.onchange.do(self.on_check_change)

        self.btInputDiag = gui.Button('Open InputDialog', width=200, height=30, margin='10px')
        self.btInputDiag.onclick.do(self.open_input_dialog)

        self.btFileDiag = gui.Button('File Selection Dialog', width=200, height=30, margin='10px')
        self.btFileDiag.onclick.do(self.open_fileselection_dialog)

        self.btUploadFile = gui.FileUploader('./', width=200, height=30, margin='10px')
        self.btUploadFile.onsuccess.do(self.fileupload_on_success)
        self.btUploadFile.onfailed.do(self.fileupload_on_failed)

        items = ('Danny Young','Christine Holand','Lars Gordon','Roberto Robitaille')
        self.listView = gui.ListView.new_from_list(items, width=300, height=120, margin='10px')
        self.listView.onselection.do(self.list_view_on_selected)

        self.link = gui.Link("http://localhost:8081", "A link to here", width=200, height=30, margin='10px')

        self.dropDown = gui.DropDown.new_from_list(('DropDownItem 0', 'DropDownItem 1'),
                                                   width=200, height=20, margin='10px')
        self.dropDown.onchange.do(self.drop_down_changed)
        self.dropDown.select_by_value('DropDownItem 0')

        self.slider = gui.Slider(10, 0, 100, 5, width=200, height=20, margin='10px')
        self.slider.onchange.do(self.slider_changed)

        self.colorPicker = gui.ColorPicker('#ffbb00', width=200, height=20, margin='10px')
        self.colorPicker.onchange.do(self.color_picker_changed)

        self.date = gui.Date('2015-04-13', width=200, height=20, margin='10px')
        self.date.onchange.do(self.date_changed)

        self.video = gui.Widget( _type='iframe', width=290, height=200, margin='10px')
        self.video.attributes['src'] = "https://drive.google.com/file/d/0B0J9Lq_MRyn4UFRsblR3UTBZRHc/preview"
        self.video.attributes['width'] = '100%'
        self.video.attributes['height'] = '100%'
        self.video.attributes['controls'] = 'true'
        self.video.style['border'] = 'none'

        self.tree = gui.TreeView(width='100%', height=300)
        ti1 = gui.TreeItem("Item1")
        ti2 = gui.TreeItem("Item2")
        ti3 = gui.TreeItem("Item3")
        subti1 = gui.TreeItem("Sub Item1")
        subti2 = gui.TreeItem("Sub Item2")
        subti3 = gui.TreeItem("Sub Item3")
        subti4 = gui.TreeItem("Sub Item4")
        subsubti1 = gui.TreeItem("Sub Sub Item1")
        subsubti2 = gui.TreeItem("Sub Sub Item2")
        subsubti3 = gui.TreeItem("Sub Sub Item3")
        self.tree.append([ti1, ti2, ti3])
        ti2.append([subti1, subti2, subti3, subti4])
        subti4.append([subsubti1, subsubti2, subsubti3])

        # appending a widget to another, the first argument is a string key
        subContainerRight.append([self.counter, self.lbl, self.bt, self.txt, self.spin, self.progress, self.check, self.btInputDiag, self.btFileDiag])
        # use a defined key as we replace this widget later
        fdownloader = gui.FileDownloader('download test', '../remi/res/logo.png', width=200, height=30, margin='10px')
        subContainerRight.append(fdownloader, key='file_downloader')
        subContainerRight.append([self.btUploadFile, self.dropDown, self.slider, self.colorPicker, self.date, self.tree])
        self.subContainerRight = subContainerRight

        subContainerLeft.append([self.img, self.table, self.listView, self.link, self.video])

        horizontalContainer.append([subContainerLeft, subContainerRight])

        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('File', width=100, height=30)
        m2 = gui.MenuItem('View', width=100, height=30)
        m2.onclick.do(self.menu_view_clicked)
        m11 = gui.MenuItem('Save', width=100, height=30)
        m12 = gui.MenuItem('Open', width=100, height=30)
        m12.onclick.do(self.menu_open_clicked)
        m111 = gui.MenuItem('Save', width=100, height=30)
        m111.onclick.do(self.menu_save_clicked)
        m112 = gui.MenuItem('Save as', width=100, height=30)
        m112.onclick.do(self.menu_saveas_clicked)
        m3 = gui.MenuItem('Dialog', width=100, height=30)
        m3.onclick.do(self.menu_dialog_clicked)

        menu.append([m1, m2, m3])
        m1.append([m11, m12])
        m11.append([m111, m112])

        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.append(menu)

        verticalContainer.append([menubar, horizontalContainer])

        #this flag will be used to stop the display_counter Timer
        self.stop_flag = False

        # kick of regular display of counter
        self.display_counter()

        # returning the root widget
        return verticalContainer
    def main(self, robot, appCallback):
        self.robot = robot

        root = gui.VBox(width=600)

        title = gui.Label('Motor Tester')
        title.style['margin'] = '24px'
        title.style['font-size'] = '36px'
        title.style['font-weight'] = 'bold'
        root.append(title)

        self.talonBox = gui.SpinBox(default_value=0, min_value=0, max_value=99, step=1)
        self.talonBox.set_on_change_listener(self.queuedEvent(robot.c_setTalon))
        root.append(sea.hBoxWith(
            gui.Label('Talon:'),
            gui.HBox(width=SPACE),
            self.talonBox
        ))

        self.selectedTalonLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Selected talon:'),
            gui.HBox(width=SPACE),
            self.selectedTalonLbl
        ))

        self.outputVoltageLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Output voltage:'),
            gui.HBox(width=SPACE),
            self.outputVoltageLbl
        ))

        self.outputCurrentLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Output current:'),
            gui.HBox(width=SPACE),
            self.outputCurrentLbl
        ))

        self.encoderPositionLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Encoder position:'),
            gui.HBox(width=SPACE),
            self.encoderPositionLbl
        ))

        self.encoderVelocityLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Encoder velocity:'),
            gui.HBox(width=SPACE),
            self.encoderVelocityLbl
        ))

        controlTabBox = gui.TabBox(width='100%')
        root.append(controlTabBox)

        controlTabBox.add_tab(gui.Widget(), 'Disabled',
            self.queuedEvent(robot.c_updateDisabled))

        self.outputSlider = gui.Slider(default_value="0", min=-100, max=100,
                                       width='100%')
        controlTabBox.add_tab(self.outputSlider, 'Percent Output',
                              self.c_percentOutputTab)
        self.outputSlider.set_on_change_listener(
            self.queuedEvent(robot.c_updatePercentOutput))

        velocityFrame = gui.HBox(width='100%')
        controlTabBox.add_tab(velocityFrame, 'Velocity', self.c_velocityTab)
        self.velocityOutputSlider = gui.Slider(default_value="0",
                                               min=-100, max=100, width='100%')
        velocityFrame.append(self.velocityOutputSlider)
        self.maxVelocityBox = gui.SpinBox(
            default_value='8000', min=0, max=1000000, step=100, width='100')
        velocityFrame.append(self.maxVelocityBox)
        self.velocityOutputSlider.set_on_change_listener(
            self.queuedEvent(robot.c_updateVelocity),
            self.velocityOutputSlider, self.maxVelocityBox)
        self.maxVelocityBox.set_on_change_listener(
            self.queuedEvent(robot.c_updateVelocity),
            self.velocityOutputSlider, self.maxVelocityBox)

        self.offsetBox = gui.SpinBox('0', -1000000, 1000000, 100)
        holdButton = gui.Button('Hold', width='100')
        holdButton.set_on_click_listener(
            self.queuedEvent(robot.c_updatePosition), self.offsetBox)
        controlTabBox.add_tab(sea.hBoxWith(
            gui.Label('Offset:'),
            gui.HBox(width=SPACE),
            self.offsetBox,
            holdButton
        ), 'Hold Position', self.queuedEvent(robot.c_updateDisabled))

        # margin
        root.append(gui.HBox(height=10))

        appCallback(self)
        return root
    def main(self):
        verticalContainer = gui.Widget(640, 680, gui.Widget.LAYOUT_VERTICAL,
                                       10)

        horizontalContainer = gui.Widget(620, 620,
                                         gui.Widget.LAYOUT_HORIZONTAL, 10)

        subContainerLeft = gui.Widget(340, 530, gui.Widget.LAYOUT_VERTICAL, 10)
        self.img = gui.Image(100, 100, './res/logo.png')

        self.table = gui.Table(300, 200)
        row = gui.TableRow()
        item = gui.TableTitle()
        item.append(str(id(item)), 'ID')
        row.append(str(id(item)), item)
        item = gui.TableTitle()
        item.append(str(id(item)), 'First Name')
        row.append(str(id(item)), item)
        item = gui.TableTitle()
        item.append(str(id(item)), 'Last Name')
        row.append(str(id(item)), item)
        self.table.append(str(id(row)), row)
        self.add_table_row(self.table, '101', 'Danny', 'Young')
        self.add_table_row(self.table, '102', 'Christine', 'Holand')
        self.add_table_row(self.table, '103', 'Lars', 'Gordon')
        self.add_table_row(self.table, '104', 'Roberto', 'Robitaille')
        self.add_table_row(self.table, '105', 'Maria', 'Papadopoulos')

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget(240, 560, gui.Widget.LAYOUT_VERTICAL,
                                       10)

        self.lbl = gui.Label(200, 30, 'This is a LABEL!')

        self.bt = gui.Button(200, 30, 'Press me!')
        # setting the listener for the onclick event of the button
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        self.txt = gui.TextInput(200, 30)
        self.txt.set_text('This is a TEXTAREA')
        self.txt.set_on_change_listener(self, 'on_text_area_change')

        self.spin = gui.SpinBox(200, 30, 100)
        self.spin.set_on_change_listener(self, 'on_spin_change')

        self.btInputDiag = gui.Button(200, 30, 'Open InputDialog')
        self.btInputDiag.set_on_click_listener(self, 'open_input_dialog')

        self.btFileDiag = gui.Button(200, 30, 'File Selection Dialog')
        self.btFileDiag.set_on_click_listener(self,
                                              'open_fileselection_dialog')

        self.btUploadFile = gui.FileUploader(200, 30, './')
        self.btUploadFile.set_on_success_listener(self,
                                                  'fileupload_on_success')
        self.btUploadFile.set_on_failed_listener(self, 'fileupload_on_failed')

        self.listView = gui.ListView(300, 120)
        self.listView.set_on_selection_listener(self, "list_view_on_selected")
        li0 = gui.ListItem(279, 20, 'Danny Young')
        li1 = gui.ListItem(279, 20, 'Christine Holand')
        li2 = gui.ListItem(279, 20, 'Lars Gordon')
        li3 = gui.ListItem(279, 20, 'Roberto Robitaille')
        self.listView.append('0', li0)
        self.listView.append('1', li1)
        self.listView.append('2', li2)
        self.listView.append('3', li3)

        self.dropDown = gui.DropDown(200, 20)
        c0 = gui.DropDownItem(200, 20, 'DropDownItem 0')
        c1 = gui.DropDownItem(200, 20, 'DropDownItem 1')
        self.dropDown.append('0', c0)
        self.dropDown.append('1', c1)
        self.dropDown.set_on_change_listener(self, 'drop_down_changed')
        self.dropDown.set_value('DropDownItem 0')

        self.slider = gui.Slider(200, 20, 10, 0, 100, 5)
        self.slider.set_on_change_listener(self, 'slider_changed')

        self.colorPicker = gui.ColorPicker(200, 20, '#ffbb00')
        self.colorPicker.set_on_change_listener(self, 'color_picker_changed')

        self.date = gui.Date(200, 20, '2015-04-13')
        self.date.set_on_change_listener(self, 'date_changed')

        # appending a widget to another, the first argument is a string key
        subContainerRight.append('1', self.lbl)
        subContainerRight.append('2', self.bt)
        subContainerRight.append('3', self.txt)
        subContainerRight.append('4', self.spin)
        subContainerRight.append('5', self.btInputDiag)
        subContainerRight.append('5_', self.btFileDiag)
        subContainerRight.append(
            '5__',
            gui.FileDownloader(200, 30, 'download test',
                               '../remi/res/logo.png'))
        subContainerRight.append('5___', self.btUploadFile)
        subContainerRight.append('6', self.dropDown)
        subContainerRight.append('7', self.slider)
        subContainerRight.append('8', self.colorPicker)
        subContainerRight.append('9', self.date)
        self.subContainerRight = subContainerRight

        subContainerLeft.append('0', self.img)
        subContainerLeft.append('1', self.table)
        subContainerLeft.append('2', self.listView)

        horizontalContainer.append('0', subContainerLeft)
        horizontalContainer.append('1', subContainerRight)

        menu = gui.Menu(620, 30)
        m1 = gui.MenuItem(100, 30, 'File')
        m2 = gui.MenuItem(100, 30, 'View')
        m2.set_on_click_listener(self, 'menu_view_clicked')
        m11 = gui.MenuItem(100, 30, 'Save')
        m12 = gui.MenuItem(100, 30, 'Open')
        m12.set_on_click_listener(self, 'menu_open_clicked')
        m111 = gui.MenuItem(100, 30, 'Save')
        m111.set_on_click_listener(self, 'menu_save_clicked')
        m112 = gui.MenuItem(100, 30, 'Save as')
        m112.set_on_click_listener(self, 'menu_saveas_clicked')

        menu.append('1', m1)
        menu.append('2', m2)
        m1.append('11', m11)
        m1.append('12', m12)
        m11.append('111', m111)
        m11.append('112', m112)

        verticalContainer.append('0', menu)
        verticalContainer.append('1', horizontalContainer)

        # returning the root widget
        return verticalContainer
Exemple #24
0
	def main(self):
		self.w = gui.VBox()

		self.hbox_save_load = gui.HBox(margin="10px")
		self.dtext_conf_file = gui.TextInput(width=200, height=30)
		self.dtext_conf_file.set_value(str(vals.config))
		self.dtext_conf_file.set_on_change_listener(self.dtext_conf_file_changed)
		self.bt_load = gui.Button("Load", width=200, height=30, margin="10px")
		self.bt_load.set_on_click_listener(self.bt_load_changed)
		self.bt_save = gui.Button("Save", width=200, height=30, margin="10px")
		self.bt_save.set_on_click_listener(self.bt_save_changed)
		self.hbox_save_load.append(self.dtext_conf_file)
		self.hbox_save_load.append(self.bt_load)
		self.hbox_save_load.append(self.bt_save)
		self.w.append(self.hbox_save_load)

		self.hbox_adc1_offset = gui.HBox(margin="10px")
		self.lb_adc1_offset = gui.Label("/dev/adc1_offset", width="20%", margin="10px")
		self.sd_adc1_offset = gui.Slider(vals.adc1_offset, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_adc1_offset.set_oninput_listener(self.sd_adc1_offset_changed)
		self.sb_adc1_offset = gui.SpinBox(vals.adc1_offset, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_adc1_offset.set_on_change_listener(self.sb_adc1_offset_changed)
		self.sd_adc1_offset_changed(self.sd_adc1_offset, self.sd_adc1_offset.get_value())
		self.hbox_adc1_offset.append(self.lb_adc1_offset)
		self.hbox_adc1_offset.append(self.sd_adc1_offset)
		self.hbox_adc1_offset.append(self.sb_adc1_offset)
		self.w.append(self.hbox_adc1_offset)

		self.hbox_dac1_offset = gui.HBox(margin="10px")
		self.lb_dac1_offset = gui.Label("/dev/dac1_offset", width="20%", margin="10px")
		self.sd_dac1_offset = gui.Slider(vals.dac1_offset, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_dac1_offset.set_oninput_listener(self.sd_dac1_offset_changed)
		self.sb_dac1_offset = gui.SpinBox(vals.dac1_offset, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_dac1_offset.set_on_change_listener(self.sb_dac1_offset_changed)
		self.sd_dac1_offset_changed(self.sd_dac1_offset, self.sd_dac1_offset.get_value())
		self.hbox_dac1_offset.append(self.lb_dac1_offset)
		self.hbox_dac1_offset.append(self.sd_dac1_offset)
		self.hbox_dac1_offset.append(self.sb_dac1_offset)
		self.w.append(self.hbox_dac1_offset)

		self.hbox_ch1_mod_input_ampl = gui.HBox(margin="10px")
		self.lb_ch1_mod_input_ampl = gui.Label("/dev/mod_input_ampl", width="20%", margin="10px")
		self.sd_ch1_mod_input_ampl = gui.Slider(vals.ch1_mod_input_ampl, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_ch1_mod_input_ampl.set_oninput_listener(self.sd_ch1_mod_input_ampl_changed)
		self.sb_ch1_mod_input_ampl = gui.SpinBox(vals.ch1_mod_input_ampl, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_ch1_mod_input_ampl.set_on_change_listener(self.sb_ch1_mod_input_ampl_changed)
		self.sd_ch1_mod_input_ampl_changed(self.sd_ch1_mod_input_ampl, self.sd_ch1_mod_input_ampl.get_value())
		self.hbox_ch1_mod_input_ampl.append(self.lb_ch1_mod_input_ampl)
		self.hbox_ch1_mod_input_ampl.append(self.sd_ch1_mod_input_ampl)
		self.hbox_ch1_mod_input_ampl.append(self.sb_ch1_mod_input_ampl)
		self.w.append(self.hbox_ch1_mod_input_ampl)

		self.hbox_mod_input_nco = gui.HBox(margin="10px")
		self.lb_mod_input_nco = gui.Label("/dev/mod_input_nco", width="20%", margin="10px")
		self.sd_pinc_mod_input_nco = gui.Slider(vals.pinc_mod_input_nco, 0, 62500000, 1, width="25%", margin="10px")
		self.sd_pinc_mod_input_nco.set_oninput_listener(self.sd_pinc_mod_input_nco_changed)
		self.sb_pinc_mod_input_nco = gui.SpinBox(vals.pinc_mod_input_nco, 0, 62500000, 0.02, width="10%", margin="10px")
		self.sb_pinc_mod_input_nco.set_on_change_listener(self.sb_pinc_mod_input_nco_changed)
		self.sd_poff_mod_input_nco = gui.Slider(vals.poff_mod_input_nco, -8192, 8191, 1, width="25%", margin="10px")
		self.sd_poff_mod_input_nco.set_oninput_listener(self.sd_poff_mod_input_nco_changed)
		self.sb_poff_mod_input_nco = gui.SpinBox(vals.poff_mod_input_nco, -8192, 8191, 1, width="10%", margin="10px")
		self.sb_poff_mod_input_nco.set_on_change_listener(self.sb_poff_mod_input_nco_changed)
		self.cb_pinc_mod_input_nco = gui.CheckBoxLabel("pinc", vals.cb_pinc_mod_input_nco, width="5%", margin="10px")
		self.cb_pinc_mod_input_nco.set_on_change_listener(self.cb_pinc_mod_input_nco_changed)
		self.cb_poff_mod_input_nco = gui.CheckBoxLabel("poff", vals.cb_poff_mod_input_nco, width="5%", margin="10px")
		self.cb_poff_mod_input_nco.set_on_change_listener(self.cb_poff_mod_input_nco_changed)
		self.hbox_mod_input_nco.append(self.lb_mod_input_nco)
		self.hbox_mod_input_nco.append(self.sd_pinc_mod_input_nco)
		self.hbox_mod_input_nco.append(self.sb_pinc_mod_input_nco)
		self.hbox_mod_input_nco.append(self.sd_poff_mod_input_nco)
		self.hbox_mod_input_nco.append(self.sb_poff_mod_input_nco)
		self.hbox_mod_input_nco.append(self.cb_pinc_mod_input_nco)
		self.hbox_mod_input_nco.append(self.cb_poff_mod_input_nco)
		self.w.append(self.hbox_mod_input_nco)

		self.hbox_ch1_mod_out_pid2_ampl = gui.HBox(margin="10px")
		self.lb_ch1_mod_out_pid2_ampl = gui.Label("/dev/mod_out_pid2_ampl", width="20%", margin="10px")
		self.sd_ch1_mod_out_pid2_ampl = gui.Slider(vals.ch1_mod_out_pid2_ampl, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_ch1_mod_out_pid2_ampl.set_oninput_listener(self.sd_ch1_mod_out_pid2_ampl_changed)
		self.sb_ch1_mod_out_pid2_ampl = gui.SpinBox(vals.ch1_mod_out_pid2_ampl, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_ch1_mod_out_pid2_ampl.set_on_change_listener(self.sb_ch1_mod_out_pid2_ampl_changed)
		self.sd_ch1_mod_out_pid2_ampl_changed(self.sd_ch1_mod_out_pid2_ampl, self.sd_ch1_mod_out_pid2_ampl.get_value())
		self.hbox_ch1_mod_out_pid2_ampl.append(self.lb_ch1_mod_out_pid2_ampl)
		self.hbox_ch1_mod_out_pid2_ampl.append(self.sd_ch1_mod_out_pid2_ampl)
		self.hbox_ch1_mod_out_pid2_ampl.append(self.sb_ch1_mod_out_pid2_ampl)
		self.w.append(self.hbox_ch1_mod_out_pid2_ampl)

		self.hbox_mod_out_pid2_nco = gui.HBox(margin="10px")
		self.lb_mod_out_pid2_nco = gui.Label("/dev/mod_out_pid2_nco", width="20%", margin="10px")
		self.sd_pinc_mod_out_pid2_nco = gui.Slider(vals.pinc_mod_out_pid2_nco, 0, 62500000, 1, width="25%", margin="10px")
		self.sd_pinc_mod_out_pid2_nco.set_oninput_listener(self.sd_pinc_mod_out_pid2_nco_changed)
		self.sb_pinc_mod_out_pid2_nco = gui.SpinBox(vals.pinc_mod_out_pid2_nco, 0, 62500000, 0.02, width="10%", margin="10px")
		self.sb_pinc_mod_out_pid2_nco.set_on_change_listener(self.sb_pinc_mod_out_pid2_nco_changed)
		self.sd_poff_mod_out_pid2_nco = gui.Slider(vals.poff_mod_out_pid2_nco, -8192, 8191, 1, width="25%", margin="10px")
		self.sd_poff_mod_out_pid2_nco.set_oninput_listener(self.sd_poff_mod_out_pid2_nco_changed)
		self.sb_poff_mod_out_pid2_nco = gui.SpinBox(vals.poff_mod_out_pid2_nco, -8192, 8191, 1, width="10%", margin="10px")
		self.sb_poff_mod_out_pid2_nco.set_on_change_listener(self.sb_poff_mod_out_pid2_nco_changed)
		self.cb_pinc_mod_out_pid2_nco = gui.CheckBoxLabel("pinc", vals.cb_pinc_mod_out_pid2_nco, width="5%", margin="10px")
		self.cb_pinc_mod_out_pid2_nco.set_on_change_listener(self.cb_pinc_mod_out_pid2_nco_changed)
		self.cb_poff_mod_out_pid2_nco = gui.CheckBoxLabel("poff", vals.cb_poff_mod_out_pid2_nco, width="5%", margin="10px")
		self.cb_poff_mod_out_pid2_nco.set_on_change_listener(self.cb_poff_mod_out_pid2_nco_changed)
		self.hbox_mod_out_pid2_nco.append(self.lb_mod_out_pid2_nco)
		self.hbox_mod_out_pid2_nco.append(self.sd_pinc_mod_out_pid2_nco)
		self.hbox_mod_out_pid2_nco.append(self.sb_pinc_mod_out_pid2_nco)
		self.hbox_mod_out_pid2_nco.append(self.sd_poff_mod_out_pid2_nco)
		self.hbox_mod_out_pid2_nco.append(self.sb_poff_mod_out_pid2_nco)
		self.hbox_mod_out_pid2_nco.append(self.cb_pinc_mod_out_pid2_nco)
		self.hbox_mod_out_pid2_nco.append(self.cb_poff_mod_out_pid2_nco)
		self.w.append(self.hbox_mod_out_pid2_nco)

		self.hbox_kp_pid1 = gui.HBox(margin="10px")
		self.lb_kp_pid1 = gui.Label("/dev/pid1/kp", width="20%", margin="10px")
		self.sd_kp_pid1 = gui.Slider(vals.kp_pid1, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_kp_pid1.set_oninput_listener(self.sd_kp_pid1_changed)
		self.sb_kp_pid1 = gui.SpinBox(vals.kp_pid1, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_kp_pid1.set_on_change_listener(self.sb_kp_pid1_changed)
		self.sd_kp_pid1_changed(self.sd_kp_pid1, self.sd_kp_pid1.get_value())
		self.hbox_kp_pid1.append(self.lb_kp_pid1)
		self.hbox_kp_pid1.append(self.sd_kp_pid1)
		self.hbox_kp_pid1.append(self.sb_kp_pid1)
		self.w.append(self.hbox_kp_pid1)

		self.hbox_ki_pid1 = gui.HBox(margin="10px")
		self.lb_ki_pid1 = gui.Label("/dev/pid1/ki", width="20%", margin="10px")
		self.sd_ki_pid1 = gui.Slider(vals.ki_pid1, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_ki_pid1.set_oninput_listener(self.sd_ki_pid1_changed)
		self.sb_ki_pid1 = gui.SpinBox(vals.ki_pid1, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_ki_pid1.set_on_change_listener(self.sb_ki_pid1_changed)
		self.sd_ki_pid1_changed(self.sd_ki_pid1, self.sd_ki_pid1.get_value())
		self.cb_rst_int_pid1 = gui.CheckBoxLabel("rst_int", vals.rst_int_pid1, width="5%", margin="10px")
		self.cb_rst_int_pid1.set_on_change_listener(self.cb_rst_int_pid1_changed)
		self.hbox_ki_pid1.append(self.lb_ki_pid1)
		self.hbox_ki_pid1.append(self.sd_ki_pid1)
		self.hbox_ki_pid1.append(self.sb_ki_pid1)
		self.hbox_ki_pid1.append(self.cb_rst_int_pid1)
		self.w.append(self.hbox_ki_pid1)

		self.hbox_ki_piid1 = gui.HBox(margin="10px")
		self.lb_ki_piid1 = gui.Label("/dev/pid1/kii", width="20%", margin="10px")
		self.sd_ki_piid1 = gui.Slider(vals.ki_piid1, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_ki_piid1.set_oninput_listener(self.sd_ki_piid1_changed)
		self.sb_ki_piid1 = gui.SpinBox(vals.ki_piid1, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_ki_piid1.set_on_change_listener(self.sb_ki_piid1_changed)
		self.sd_ki_piid1_changed(self.sd_ki_piid1, self.sd_ki_piid1.get_value())
		self.hbox_ki_piid1.append(self.lb_ki_piid1)
		self.hbox_ki_piid1.append(self.sd_ki_piid1)
		self.hbox_ki_piid1.append(self.sb_ki_piid1)
		self.w.append(self.hbox_ki_piid1)

		self.hbox_sp_pid1 = gui.HBox(margin="10px")
		self.lb_sp_pid1 = gui.Label("/dev/pid1/setpoint", width="20%", margin="10px")
		self.sd_sp_pid1 = gui.Slider(vals.sp_pid1, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_sp_pid1.set_oninput_listener(self.sd_sp_pid1_changed)
		self.sb_sp_pid1 = gui.SpinBox(vals.sp_pid1, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_sp_pid1.set_on_change_listener(self.sb_sp_pid1_changed)
		self.sd_sp_pid1_changed(self.sd_sp_pid1, self.sd_sp_pid1.get_value())
		self.hbox_sp_pid1.append(self.lb_sp_pid1)
		self.hbox_sp_pid1.append(self.sd_sp_pid1)
		self.hbox_sp_pid1.append(self.sb_sp_pid1)
		self.w.append(self.hbox_sp_pid1)

		self.hbox_sign_pid1 = gui.HBox(margin="10px")
		self.lb_sign_pid1 = gui.Label("/dev/pid1/sign", width="20%", margin="10px")
		self.sd_sign_pid1 = gui.Slider(vals.sign_pid1, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_sign_pid1.set_oninput_listener(self.sd_sign_pid1_changed)
		self.sb_sign_pid1 = gui.SpinBox(vals.sign_pid1, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_sign_pid1.set_on_change_listener(self.sb_sign_pid1_changed)
		self.sd_sign_pid1_changed(self.sd_sign_pid1, self.sd_sign_pid1.get_value())
		self.hbox_sign_pid1.append(self.lb_sign_pid1)
		self.hbox_sign_pid1.append(self.sd_sign_pid1)
		self.hbox_sign_pid1.append(self.sb_sign_pid1)
		self.w.append(self.hbox_sign_pid1)

		self.hbox_kp_pid2 = gui.HBox(margin="10px")
		self.lb_kp_pid2 = gui.Label("/dev/pid2/kp", width="20%", margin="10px")
		self.sd_kp_pid2 = gui.Slider(vals.kp_pid2, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_kp_pid2.set_oninput_listener(self.sd_kp_pid2_changed)
		self.sb_kp_pid2 = gui.SpinBox(vals.kp_pid2, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_kp_pid2.set_on_change_listener(self.sb_kp_pid2_changed)
		self.sd_kp_pid2_changed(self.sd_kp_pid2, self.sd_kp_pid2.get_value())
		self.hbox_kp_pid2.append(self.lb_kp_pid2)
		self.hbox_kp_pid2.append(self.sd_kp_pid2)
		self.hbox_kp_pid2.append(self.sb_kp_pid2)
		self.w.append(self.hbox_kp_pid2)

		self.hbox_ki_pid2 = gui.HBox(margin="10px")
		self.lb_ki_pid2 = gui.Label("/dev/pid2/ki", width="20%", margin="10px")
		self.sd_ki_pid2 = gui.Slider(vals.ki_pid2, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_ki_pid2.set_oninput_listener(self.sd_ki_pid2_changed)
		self.sb_ki_pid2 = gui.SpinBox(vals.ki_pid2, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_ki_pid2.set_on_change_listener(self.sb_ki_pid2_changed)
		self.sd_ki_pid2_changed(self.sd_ki_pid2, self.sd_ki_pid2.get_value())
		self.cb_rst_int_pid2 = gui.CheckBoxLabel("rst_int", vals.rst_int_pid2, width="5%", margin="10px")
		self.cb_rst_int_pid2.set_on_change_listener(self.cb_rst_int_pid2_changed)
		self.hbox_ki_pid2.append(self.lb_ki_pid2)
		self.hbox_ki_pid2.append(self.sd_ki_pid2)
		self.hbox_ki_pid2.append(self.sb_ki_pid2)
		self.hbox_ki_pid2.append(self.cb_rst_int_pid2)
		self.w.append(self.hbox_ki_pid2)

		self.hbox_sp_pid2 = gui.HBox(margin="10px")
		self.lb_sp_pid2 = gui.Label("/dev/pid2/setpoint", width="20%", margin="10px")
		self.sd_sp_pid2 = gui.Slider(vals.sp_pid2, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_sp_pid2.set_oninput_listener(self.sd_sp_pid2_changed)
		self.sb_sp_pid2 = gui.SpinBox(vals.sp_pid2, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_sp_pid2.set_on_change_listener(self.sb_sp_pid2_changed)
		self.sd_sp_pid2_changed(self.sd_sp_pid2, self.sd_sp_pid2.get_value())
		self.hbox_sp_pid2.append(self.lb_sp_pid2)
		self.hbox_sp_pid2.append(self.sd_sp_pid2)
		self.hbox_sp_pid2.append(self.sb_sp_pid2)
		self.w.append(self.hbox_sp_pid2)

		self.hbox_sign_pid2 = gui.HBox(margin="10px")
		self.lb_sign_pid2 = gui.Label("/dev/pid2/sign", width="20%", margin="10px")
		self.sd_sign_pid2 = gui.Slider(vals.sign_pid2, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_sign_pid2.set_oninput_listener(self.sd_sign_pid2_changed)
		self.sb_sign_pid2 = gui.SpinBox(vals.sign_pid2, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_sign_pid2.set_on_change_listener(self.sb_sign_pid2_changed)
		self.sd_sign_pid2_changed(self.sd_sign_pid2, self.sd_sign_pid2.get_value())
		self.hbox_sign_pid2.append(self.lb_sign_pid2)
		self.hbox_sign_pid2.append(self.sd_sign_pid2)
		self.hbox_sign_pid2.append(self.sb_sign_pid2)
		self.w.append(self.hbox_sign_pid2)

		self.hbox_pid2_offset = gui.HBox(margin="10px")
		self.lb_pid2_offset = gui.Label("/dev/pid2_offset", width="20%", margin="10px")
		self.sd_pid2_offset = gui.Slider(vals.pid2_offset, -8192, 8191, 1, width="60%", margin="10px")
		self.sd_pid2_offset.set_oninput_listener(self.sd_pid2_offset_changed)
		self.sb_pid2_offset = gui.SpinBox(vals.pid2_offset, -8192, 8191, 1, width="20%", margin="10px")
		self.sb_pid2_offset.set_on_change_listener(self.sb_pid2_offset_changed)
		self.sd_pid2_offset_changed(self.sd_pid2_offset, self.sd_pid2_offset.get_value())
		self.hbox_pid2_offset.append(self.lb_pid2_offset)
		self.hbox_pid2_offset.append(self.sd_pid2_offset)
		self.hbox_pid2_offset.append(self.sb_pid2_offset)
		self.w.append(self.hbox_pid2_offset)

		return self.w
Exemple #25
0
    def construct_ui(self):
        cv2.setUseOptimized(True)
        #DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR
        global_container = VBox(height="100%")

        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('File', width=100, height=30)
        m12 = gui.MenuItem('Open', width=100, height=30)
        m12.onclick.connect(self.menu_open_clicked)
        menu.append(m1)
        m1.append(m12)

        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.style.update({"margin":"0px","position":"static","overflow":"visible","grid-area":"menubar","background-color":"#455eba", "z-index":"1"})
        menubar.append(menu)

        main_container = GridBox()
        main_container.attributes.update({"class":"GridBox","editor_constructor":"()","editor_varname":"main_container","editor_tag_type":"widget","editor_newclass":"False","editor_baseclass":"GridBox"})
        main_container.default_layout = """
        |container_commands |container_image                                                                                            |c_pars    |c_pars    |c_pars   |
        |container_commands |container_image                                                                                            |c_pars    |c_pars    |c_pars   |
        |container_commands |container_image                                                                                            |c_pars    |c_pars    |c_pars   |
        |container_commands |container_image                                                                                            |c_pars    |c_pars    |c_pars   |
        |container_commands |container_image                                                                                            |c_pars    |c_pars    |c_pars   |
        |container_commands |container_miniature                                                                                        |c_pars    |c_pars    |c_pars   |
        |container_process  |container_process                                                                                          |start_stop|live_video|overprint|    
        """
        main_container.set_from_asciiart(main_container.default_layout)

        #main_container.append(menubar,'menubar')
        container_commands = VBox()
        container_commands.style.update({"margin":"0px","display":"flex","justify-content":"flex-start","align-items":"center","flex-direction":"column","position":"static","overflow":"auto","grid-area":"container_commands","border-width":"2px","border-style":"dotted","border-color":"#8a8a8a"})

        #parametri di stile per i pulsanti
        btparams = {"margin":"2px","width":"100px","height":"30px","top":"20px","position":"static","overflow":"auto","order":"-1"}

        bt_trigger = Button('Trigger')
        bt_trigger.style.update({"background-color":"green", **btparams})

        container_commands.append(bt_trigger,'bt_trigger')

        bt_set_logo = Button('Imposta logo')
        bt_set_logo.style.update({"background-color":"darkorange", **btparams})
        container_commands.append(bt_set_logo,'bt_set_logo')
        main_container.append(container_commands,'container_commands')

        bt_search_logo = Button('Trova logo', style={"background-color":"orange", **btparams})
        bt_search_logo.onclick.connect(self.onclick_search_logo)
        container_commands.append(bt_search_logo, "bt_search_logo")

        bt_apply_calib_to_image = Button('Applica calibrazione', style={"background-color":"darkblue", **btparams})
        bt_apply_calib_to_image.onclick.connect(self.onclick_apply_calib_to_image)
        container_commands.append(bt_apply_calib_to_image, "bt_apply_calib_to_image")

        bt_perspective_correct = Button('Correggi prospettiva', style={"background-color":"darkblue", **btparams})
        bt_perspective_correct.onclick.connect(self.onclick_perspective_correction)
        container_commands.append(bt_perspective_correct, "bt_perspective_correct")

        bt_apply_filter = Button('Applica filtro threshold', style={"background-color":"black", **btparams})
        bt_apply_filter.onclick.connect(self.onclick_apply_filter, image_utils.threshold)
        container_commands.append(bt_apply_filter, "bt_apply_filter_threshold")

        bt_apply_filter = Button('Applica filtro canny', style={"background-color":"darkgray", **btparams})
        bt_apply_filter.onclick.connect(self.onclick_apply_filter, image_utils.canny)
        container_commands.append(bt_apply_filter, "bt_apply_filter_canny")

        bt_apply_filter = Button('Equalizza histogramma', style={"background-color":"violet", **btparams})
        bt_apply_filter.onclick.connect(self.onclick_apply_filter, image_utils.histogram_equalize)
        container_commands.append(bt_apply_filter, "bt_apply_filter_equalize")

        self.logo_image = None
        self.process_image = None #immagine impostata dal thread di processo, e aggiornata a video in idle()

        self.camera = nastro_mindvision.MindVisionCamera()
        
        #self.camera.start()

        self.camera_image = OpencvImageWidget("./test.bmp", self)#, width="100%", height="100%")
        self.camera_image.attributes.update({"class":"Widget","editor_constructor":"()","editor_varname":"container_image","editor_tag_type":"widget","editor_newclass":"False","editor_baseclass":"Widget"})
        container_camera_image = gui.Widget()
        container_camera_image.append(self.camera_image)

        self.resizer = widgets.ResizeHelper(container_camera_image, width=14, height=14, style={'background-color':'yellow', 'border':'1px dotted black', 'z-index':'2'})
        self.dragger = widgets.DragHelper(container_camera_image, width=14, height=14, style={'background-color':'yellow', 'border':'1px dotted black', 'z-index':'2'})
        self.selection_area_widget = gui.Widget(width=30, height=30, style={'background-color':'transparent', 'border':'2px dotted white', 'position':'absolute', 'top':'10px', 'left':'10px'})
        container_camera_image.append([self.resizer, self.dragger, self.selection_area_widget])
        self.resizer.setup(self.selection_area_widget, container_camera_image)
        self.dragger.setup(self.selection_area_widget, container_camera_image)
        main_container.append(container_camera_image,'container_image')
        container_camera_image.style.update({"margin":"0px","position":"relative","overflow":"scroll","grid-area":"container_image", "z-index": "-1"})

        #widget che mostra l'area di ricerca del logo
        self.roi_logo_widget = gui.Widget(width=100, height=100, style={'background-color':'transparent', 'border':'3px dotted green', 'position':'absolute', 'top':'10px', 'left':'10px'})
        container_camera_image.append(self.roi_logo_widget)

        container_parameters = VBox()
        container_parameters.style.update({"margin":"0px","display":"flex","justify-content":"flex-start","align-items":"center","flex-direction":"column","position":"static","overflow":"auto","grid-area":"c_pars","border-color":"#808080","border-width":"2px","border-style":"dotted"})
        
        lbl_exposure = Label('Esposizione')
        spin_exposure = SpinBox(1000,8,1000000,1)
        container = VBox(children = [lbl_exposure, spin_exposure], style = {"margin":"0px","display":"flex","justify-content":"flex-start","align-items":"center","flex-direction":"column","position":"static","overflow":"auto","order":"-1"})
        container_parameters.append(container, 'container_exposure')
        
        lbl_horizonal_perspective = Label('Horizontal perspective')
        self.spin_horizontal_perspective = gui.SpinBox(0, -1.0, 1.0, 0.1)
        lbl_vertical_perspective = Label('Vertical perspective')
        self.spin_vertical_perspective = gui.SpinBox(0, -1.0, 1.0, 0.1)
        self.spin_horizontal_perspective.onchange.connect(self.on_perspective_change)
        self.spin_vertical_perspective.onchange.connect(self.on_perspective_change)
        container = VBox(children = [lbl_horizonal_perspective, self.spin_horizontal_perspective, lbl_vertical_perspective, self.spin_vertical_perspective], style = {"margin":"0px","display":"flex","justify-content":"flex-start","align-items":"center","flex-direction":"column","position":"static","overflow":"auto","order":"-1"})
        container_parameters.append(container, 'container_perspective')

        
        lbl = Label("H Logo")
        self.spin_h_logo = SpinBox(1024, 100, 1000000,1)
        container = VBox(children = [lbl, self.spin_h_logo], style = {"margin":"0px","display":"flex","justify-content":"flex-start","align-items":"center","flex-direction":"column","position":"static","overflow":"auto","order":"-1"})
        container_parameters.append(container, 'container_h_logo')


        main_container.append(container_parameters,'c_pars')
        container_miniature = HBox()
        container_miniature.style.update({"margin":"0px","display":"flex","justify-content":"flex-end","align-items":"center","flex-direction":"row-reverse","position":"static","overflow-x":"scroll","grid-area":"container_miniature","background-color":"#e0e0e0"})
        main_container.append(container_miniature,'container_miniature')
        container_process = HBox()
        container_process.style.update({"margin":"0px","display":"flex","justify-content":"space-around","align-items":"center","flex-direction":"row","position":"static","overflow":"auto","grid-area":"container_process","background-color":"#e6e6e6","border-color":"#828282","border-width":"2px","border-style":"dotted"})
        main_container.append(container_process,'container_process')

        self.plot_histo_image_rgb = widgets.SvgPlot(256, 150)
        self.plot_histo_image_rgb.plot_red = widgets.SvgComposedPoly(0,0,256,1.0, 'red')
        self.plot_histo_image_rgb.plot_green = widgets.SvgComposedPoly(0,0,256,1.0, 'green')
        self.plot_histo_image_rgb.plot_blue = widgets.SvgComposedPoly(0,0,256,1.0, 'blue')
        self.plot_histo_image_rgb.append_poly([self.plot_histo_image_rgb.plot_red, self.plot_histo_image_rgb.plot_green, self.plot_histo_image_rgb.plot_blue])
        container_process.append(self.plot_histo_image_rgb)

        self.plot_histo_image_hsv = widgets.SvgPlot(256, 150)
        self.plot_histo_image_hsv.plot_hue = widgets.SvgComposedPoly(0,0,180,1.0, 'pink')
        self.plot_histo_image_hsv.plot_saturation = widgets.SvgComposedPoly(0,0,256,1.0, 'green')
        self.plot_histo_image_hsv.plot_value = widgets.SvgComposedPoly(0,0,256,1.0, 'black')
        self.plot_histo_image_hsv.append_poly([self.plot_histo_image_hsv.plot_hue, self.plot_histo_image_hsv.plot_saturation, self.plot_histo_image_hsv.plot_value])
        container_process.append(self.plot_histo_image_hsv)

        start_stop = Button('Start')
        start_stop.style.update({"margin":"0px","position":"static","overflow":"auto","background-color":"#39e600","font-weight":"bolder","font-size":"30px","height":"100%","letter-spacing":"3px"})
        main_container.append(start_stop,'start_stop')
        main_container.children['container_commands'].children['bt_trigger'].onclick.connect(self.onclick_bt_trigger)
        main_container.children['container_commands'].children['bt_set_logo'].onclick.connect(self.onclick_bt_set_logo)
        spin_exposure.onchange.connect(self.onchange_spin_exposure)
        main_container.children['start_stop'].onclick.connect(self.onclick_start_stop, self.camera.start)
        
        live_video = Button('Live Start')
        live_video.style.update({"margin":"0px","position":"static","overflow":"auto","background-color":"blue","font-weight":"bolder","font-size":"30px","height":"100%","letter-spacing":"3px"})
        main_container.append(live_video, "live_video")
        main_container.children['live_video'].onclick.connect(self.onclick_live_video, self.camera.start)
        
        image_overprint = Button('Overprint')
        image_overprint.style.update({"margin":"0px","position":"static","overflow":"auto","background-color":"violet","font-weight":"bolder","font-size":"30px","height":"100%","letter-spacing":"3px"})
        main_container.append(image_overprint, "overprint")
        main_container.children['overprint'].onclick.connect(self.onclick_overprint, self.camera.start)
        

        global_container.append([menubar, main_container])

        self.main_container = main_container

        #self.calibrate_camera()

        self.miniature_selection_list = []

        #load parameters
        self.shelve = shelve.open("./params.txt")
        try:
            print(self.shelve, self.shelve['spin_exposure'], self.shelve['spin_horizontal_perspective'])
            spin_exposure.set_value( int(self.shelve['spin_exposure']) )
            self.onchange_spin_exposure(spin_exposure, int(self.shelve['spin_exposure']) )

            self.spin_horizontal_perspective.set_value( float(self.shelve['spin_horizontal_perspective']) )
            self.spin_vertical_perspective.set_value( float(self.shelve['spin_vertical_perspective']) )

            self.spin_h_logo.set_value(float(self.shelve['spin_h_logo']))
        except:
            pass

        return global_container
Exemple #26
0
    def __init__(self, settings: Settings):
        super().__init__()

        form_title = Title(Level.H4, "ARF File column")
        self.append(form_title)

        self._arf_selection = gui.DropDown()
        self._arf_selection.append(gui.DropDownItem("1"))
        self._arf_selection.append(gui.DropDownItem("2"))
        self._arf_selection.append(gui.DropDownItem("3"))
        self._arf_selection.append(gui.DropDownItem("4"))
        self._arf_selection.set_value(str(settings.arf_column))
        arf_input = LabeledInput(
            "Column of the ARF file to use for the cos correction (column 0 is sza)",
            self._arf_selection,
            style="margin-bottom: 10px")
        self.append(arf_input)

        form_title = Title(Level.H4, "Daily file settings")
        self.append(form_title)

        self._weighted_irradiance_type_selection = gui.DropDown()
        for t in WeightedIrradianceType:
            self._weighted_irradiance_type_selection.append(
                gui.DropDownItem(t))
        self._weighted_irradiance_type_selection.set_value(
            settings.weighted_irradiance_type)
        weighted_irradiance_type_input = LabeledInput(
            "Type of weight function to use for the weighted irradiance",
            self._weighted_irradiance_type_selection,
            style="margin-bottom: 10px",
        )
        self.append(weighted_irradiance_type_input)

        coscor_title = Title(Level.H4, "Cos correction")
        coscor_title.set_style("margin-top: 14px")
        self.append(coscor_title)

        self._no_coscor_checkbox = gui.CheckBoxLabel("Skip cos correction",
                                                     style="height: 30px")
        self._no_coscor_checkbox.set_value(settings.no_coscor)
        self.append(self._no_coscor_checkbox)

        coscor_title = Title(Level.H4, "Temperature correction")
        coscor_title.set_style("margin-top: 14px")
        self.append(coscor_title)
        temperature_explanation = IconLabel(
            "Each value of the spectrum F for a temperature T (°C) will be corrected with a correction "
            "factor C and a reference temperature Tref (°C) with the formula: F * [1 + C * (T - Tref)]",
            "info_outline",
            style="margin-bottom: 10px",
        )
        self.append(temperature_explanation)

        # Temperature correction dual field
        temp_correction = gui.HBox(
            style="justify-content: stretch; width: 260px")
        self._temp_factor_spin = gui.SpinBox(
            settings.temperature_correction_factor,
            -4,
            4,
            0.01,
            style="width: 100px; height: 25px")
        self._temp_ref_spin = gui.SpinBox(settings.temperature_correction_ref,
                                          -50,
                                          50,
                                          0.5,
                                          style="width: 100px; height: 25px")
        temp_factor_label = gui.Label("C:", style="flex-grow: 1")
        temp_correction.append(temp_factor_label)
        temp_correction.append(self._temp_factor_spin)
        temp_ref_label = gui.Label("Tref:",
                                   style="margin-left: 8px; flex-grow: 1")
        temp_correction.append(temp_ref_label)
        temp_correction.append(self._temp_ref_spin)
        self.append(temp_correction)

        default_title = Title(Level.H4, "Default values")
        default_title.set_style("margin-top: 14px")
        self.append(default_title)
        default_explanation = IconLabel(
            "Will be used if no value is found in the files or via api",
            "info_outline",
            style="margin-bottom: 10px")
        self.append(default_explanation)

        # Albedo field
        self._albedo_spin = gui.SpinBox(settings.default_albedo, 0, 1, 0.01)
        albedo_input = LabeledInput("Albedo",
                                    self._albedo_spin,
                                    style="margin-bottom: 10px")
        self.append(albedo_input)

        # Aerosol dual field
        aerosol = gui.HBox(style="justify-content: stretch; width: 100%")
        self._alpha_spin = gui.SpinBox(settings.default_aerosol.alpha,
                                       0,
                                       2,
                                       0.01,
                                       style="width: 110px; height: 25px")
        self._beta_spin = gui.SpinBox(settings.default_aerosol.beta,
                                      0,
                                      1.5,
                                      0.01,
                                      style="width: 110px; height: 25px")
        alpha_label = gui.Label("α:", style="flex-grow: 1")
        aerosol.append(alpha_label)
        aerosol.append(self._alpha_spin)
        beta_label = gui.Label("β:", style="margin-left: 8px; flex-grow: 1")
        aerosol.append(beta_label)
        aerosol.append(self._beta_spin)
        aerosol_input = LabeledInput("Aerosol",
                                     aerosol,
                                     style="margin-bottom: 10px")
        self.append(aerosol_input)

        # Ozone field
        self._ozone_spin = gui.SpinBox(settings.default_ozone, 200, 600, 0.5)
        ozone_input = LabeledInput("Ozone",
                                   self._ozone_spin,
                                   style="margin-bottom: 10px")
        self.append(ozone_input)

        self._straylight_checkbox = gui.CheckBoxLabel(
            "Apply straylight correction", style="min-height: 30px")
        self._straylight_checkbox.set_value(
            settings.default_straylight_correction ==
            StraylightCorrection.APPLIED)
        self.append(self._straylight_checkbox)

        source_title = Title(Level.H4, "Data source")
        source_title.set_style("margin-top: 14px")
        self.append(source_title)
        source_explanation = IconLabel(
            "Data can either come from files on disk or from the online database eubrewnet.",
            "info_outline",
            style="margin-bottom: 10px; line-height: 14pt",
        )
        self.append(source_explanation)

        self._form_selection_checkbox = gui.CheckBoxLabel(
            "Specify files manually instead of giving a date and a brewer id",
            style="min-height: 30px; margin-bottom: 6px")
        self._form_selection_checkbox.set_value(settings.manual_mode)
        self._form_selection_checkbox.onchange.do(
            lambda w, v: self._update_manual_mode(v))
        self.append(self._form_selection_checkbox)

        self._source_container = VBox()

        self._uv_source_selection = gui.DropDown()
        for source in DataSource:
            self._uv_source_selection.append(gui.DropDownItem(source))
        self._uv_source_selection.set_value(settings.uv_data_source)
        uv_source_input = LabeledInput("UV data source",
                                       self._uv_source_selection,
                                       style="margin-bottom: 10px")
        self._source_container.append(uv_source_input)

        self._ozone_source_selection = gui.DropDown()
        for source in DataSource:
            self._ozone_source_selection.append(gui.DropDownItem(source))
        self._ozone_source_selection.set_value(settings.ozone_data_source)
        ozone_source_input = LabeledInput("Ozone data source",
                                          self._ozone_source_selection,
                                          style="margin-bottom: 10px")
        self._source_container.append(ozone_source_input)

        self._uvr_source_selection = gui.DropDown()
        for source in DataSource:
            self._uvr_source_selection.append(gui.DropDownItem(source))
        self._uvr_source_selection.set_value(settings.uvr_data_source)
        uvr_source_input = LabeledInput("UVR data source",
                                        self._uvr_source_selection,
                                        style="margin-bottom: 10px")
        self._source_container.append(uvr_source_input)

        self._brewer_model_source_selection = gui.DropDown()
        for source in DataSource:
            self._brewer_model_source_selection.append(
                gui.DropDownItem(source))
        self._brewer_model_source_selection.set_value(
            settings.brewer_model_data_source)
        brewer_model_source_input = LabeledInput(
            "Brewer model data source",
            self._brewer_model_source_selection,
            style="margin-bottom: 10px")
        self._source_container.append(brewer_model_source_input)

        self.append(self._source_container)
        self._update_manual_mode(settings.manual_mode)

        woudc_title = Title(Level.H4, "WOUDC output")
        woudc_title.set_style("margin-top: 14px")
        self.append(woudc_title)
        gawsis_link = gui.Link("https://woudc.org/", "WOUDC")
        woudc_explanation = IconLabel(
            "Create files in the WOUDC format which can be submitted to\xa0",
            "info_outline",
            style="margin-bottom: 10px",
        )
        woudc_explanation.append(gawsis_link)

        self.append(woudc_explanation)

        self._woudc_checkbox = gui.CheckBoxLabel(
            "Create WOUDC files", style="min-height: 30px; margin-bottom: 6px")
        self._woudc_checkbox.set_value(settings.activate_woudc)
        self._woudc_checkbox.onchange.do(lambda w, v: self._update_woudc(v))
        self.append(self._woudc_checkbox)

        woudc_info = settings.woudc_info
        self._woudc_info_container = VBox()

        self._agency_input = gui.Input(default_value=woudc_info.agency)
        agency_input = LabeledInput("Agency", self._agency_input)
        self._woudc_info_container.append(agency_input)

        self._version_input = gui.Input(default_value=woudc_info.version)
        version_input = LabeledInput("Version", self._version_input)
        self._woudc_info_container.append(version_input)

        self._scientific_authority_input = gui.Input(
            default_value=woudc_info.scientific_authority)
        scientific_authority_input = LabeledInput(
            "Scientific Authority", self._scientific_authority_input)
        self._woudc_info_container.append(scientific_authority_input)

        self._platform_id_input = gui.Input(
            default_value=woudc_info.platform_id)
        platform_id_input = LabeledInput("Platform ID",
                                         self._platform_id_input)
        self._woudc_info_container.append(platform_id_input)

        self._platform_name_input = gui.Input(
            default_value=woudc_info.platform_name)
        platform_name_input = LabeledInput("Platform Name",
                                           self._platform_name_input)
        self._woudc_info_container.append(platform_name_input)

        self._country_input = gui.Input(default_value=woudc_info.country_iso3)
        country_input = LabeledInput("Country (ISO 3)", self._country_input)
        self._woudc_info_container.append(country_input)

        self._gaw_id_input = gui.Input(default_value=woudc_info.gaw_id)
        gaw_id_input = LabeledInput("GAW Id", self._gaw_id_input)
        self._woudc_info_container.append(gaw_id_input)

        self._altitude_spin = gui.SpinBox(woudc_info.altitude, 0, 6000, 1)
        altitude_input = LabeledInput("Altitude",
                                      self._altitude_spin,
                                      style="margin-bottom: 10px")
        self._woudc_info_container.append(altitude_input)

        self.append(self._woudc_info_container)
        self._update_woudc(settings.activate_woudc)
    def main(self):
        self.w = gui.VBox()

        self.hbox_save_load = gui.HBox(margin="10px")
        self.dtext_conf_file = gui.TextInput(width=200, height=30)
        self.dtext_conf_file.set_value(str(vals.config))
        self.dtext_conf_file.set_on_change_listener(
            self.dtext_conf_file_changed)
        self.bt_load = gui.Button("Load", width=200, height=30, margin="10px")
        self.bt_load.set_on_click_listener(self.bt_load_changed)
        self.bt_save = gui.Button("Save", width=200, height=30, margin="10px")
        self.bt_save.set_on_click_listener(self.bt_save_changed)
        self.hbox_save_load.append(self.dtext_conf_file)
        self.hbox_save_load.append(self.bt_load)
        self.hbox_save_load.append(self.bt_save)
        self.w.append(self.hbox_save_load)

        self.hbox_ch1_perturb_ampl = gui.HBox(margin="10px")
        self.lb_ch1_perturb_ampl = gui.Label("/dev/perturb_ampl",
                                             width="20%",
                                             margin="10px")
        self.sd_ch1_perturb_ampl = gui.Slider(vals.ch1_perturb_ampl,
                                              -8192,
                                              8191,
                                              1,
                                              width="60%",
                                              margin="10px")
        self.sd_ch1_perturb_ampl.set_oninput_listener(
            self.sd_ch1_perturb_ampl_changed)
        self.sb_ch1_perturb_ampl = gui.SpinBox(vals.ch1_perturb_ampl,
                                               -8192,
                                               8191,
                                               1,
                                               width="20%",
                                               margin="10px")
        self.sb_ch1_perturb_ampl.set_on_change_listener(
            self.sb_ch1_perturb_ampl_changed)
        self.sd_ch1_perturb_ampl_changed(self.sd_ch1_perturb_ampl,
                                         self.sd_ch1_perturb_ampl.get_value())
        self.hbox_ch1_perturb_ampl.append(self.lb_ch1_perturb_ampl)
        self.hbox_ch1_perturb_ampl.append(self.sd_ch1_perturb_ampl)
        self.hbox_ch1_perturb_ampl.append(self.sb_ch1_perturb_ampl)
        self.w.append(self.hbox_ch1_perturb_ampl)

        self.hbox_perturb_nco = gui.HBox(margin="10px")
        self.lb_perturb_nco = gui.Label("/dev/perturb_nco",
                                        width="20%",
                                        margin="10px")
        self.sd_pinc_perturb_nco = gui.Slider(vals.pinc_perturb_nco,
                                              0,
                                              62500000,
                                              1,
                                              width="25%",
                                              margin="10px")
        self.sd_pinc_perturb_nco.set_oninput_listener(
            self.sd_pinc_perturb_nco_changed)
        self.sb_pinc_perturb_nco = gui.SpinBox(vals.pinc_perturb_nco,
                                               0,
                                               62500000,
                                               0.02,
                                               width="10%",
                                               margin="10px")
        self.sb_pinc_perturb_nco.set_on_change_listener(
            self.sb_pinc_perturb_nco_changed)
        self.sd_poff_perturb_nco = gui.Slider(vals.poff_perturb_nco,
                                              -8192,
                                              8191,
                                              1,
                                              width="25%",
                                              margin="10px")
        self.sd_poff_perturb_nco.set_oninput_listener(
            self.sd_poff_perturb_nco_changed)
        self.sb_poff_perturb_nco = gui.SpinBox(vals.poff_perturb_nco,
                                               -8192,
                                               8191,
                                               1,
                                               width="10%",
                                               margin="10px")
        self.sb_poff_perturb_nco.set_on_change_listener(
            self.sb_poff_perturb_nco_changed)
        self.cb_pinc_perturb_nco = gui.CheckBoxLabel("pinc",
                                                     vals.cb_pinc_perturb_nco,
                                                     width="5%",
                                                     margin="10px")
        self.cb_pinc_perturb_nco.set_on_change_listener(
            self.cb_pinc_perturb_nco_changed)
        self.cb_poff_perturb_nco = gui.CheckBoxLabel("poff",
                                                     vals.cb_poff_perturb_nco,
                                                     width="5%",
                                                     margin="10px")
        self.cb_poff_perturb_nco.set_on_change_listener(
            self.cb_poff_perturb_nco_changed)
        self.hbox_perturb_nco.append(self.lb_perturb_nco)
        self.hbox_perturb_nco.append(self.sd_pinc_perturb_nco)
        self.hbox_perturb_nco.append(self.sb_pinc_perturb_nco)
        self.hbox_perturb_nco.append(self.sd_poff_perturb_nco)
        self.hbox_perturb_nco.append(self.sb_poff_perturb_nco)
        self.hbox_perturb_nco.append(self.cb_pinc_perturb_nco)
        self.hbox_perturb_nco.append(self.cb_poff_perturb_nco)
        self.w.append(self.hbox_perturb_nco)

        return self.w
Exemple #28
0
 def test_init(self):
     widget = gui.SpinBox()
     assertValidHTML(widget.repr())
    def main(self):
        verticalContainer = gui.Widget(width=540)
        verticalContainer.style['display'] = 'block'
        verticalContainer.style['overflow'] = 'hidden'

        horizontalContainer = gui.Widget(width='100%', layout_orientation=gui.Widget.LAYOUT_HORIZONTAL, margin='0px')
        horizontalContainer.style['display'] = 'block'
        horizontalContainer.style['overflow'] = 'auto'
        
        subContainerLeft = gui.Widget(width=320)
        subContainerLeft.style['display'] = 'block'
        subContainerLeft.style['overflow'] = 'auto'
        subContainerLeft.style['text-align'] = 'center'
        self.img = gui.Image('/res/logo.png', width=100, height=100, margin='10px')
        self.img.set_on_click_listener(self, 'on_img_clicked')

        self.table = gui.Table(width=300, height=200, margin='10px')
        self.table.from_2d_matrix([['ID', 'First Name', 'Last Name'],
                                   ['101', 'Danny', 'Young'],
                                   ['102', 'Christine', 'Holand'],
                                   ['103', 'Lars', 'Gordon'],
                                   ['104', 'Roberto', 'Robitaille'],
                                   ['105', 'Maria', 'Papadopoulos']])

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget()
        subContainerRight.style['width'] = '220px'
        subContainerRight.style['display'] = 'block'
        subContainerRight.style['overflow'] = 'auto'
        subContainerRight.style['text-align'] = 'center'
        self.count = 0
        self.counter = gui.Label('', width=200, height=30, margin='10px')

        self.lbl = gui.Label('This is a LABEL!', width=200, height=30, margin='10px')

        self.bt = gui.Button('Press me!', width=200, height=30, margin='10px')
        # setting the listener for the onclick event of the button
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        self.txt = gui.TextInput(width=200, height=30, margin='10px')
        self.txt.set_text('This is a TEXTAREA')
        self.txt.set_on_change_listener(self, 'on_text_area_change')

        self.spin = gui.SpinBox(100, width=200, height=30, margin='10px')
        self.spin.set_on_change_listener(self, 'on_spin_change')

        self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px')
        self.check.set_on_change_listener(self, 'on_check_change')

        self.btInputDiag = gui.Button('Open InputDialog', width=200, height=30, margin='10px')
        self.btInputDiag.set_on_click_listener(self, 'open_input_dialog')

        self.btFileDiag = gui.Button('File Selection Dialog', width=200, height=30, margin='10px')
        self.btFileDiag.set_on_click_listener(self, 'open_fileselection_dialog')

        self.btUploadFile = gui.FileUploader('./', width=200, height=30, margin='10px')
        self.btUploadFile.set_on_success_listener(self, 'fileupload_on_success')
        self.btUploadFile.set_on_failed_listener(self, 'fileupload_on_failed')

        items = ('Danny Young','Christine Holand','Lars Gordon','Roberto Robitaille')
        self.listView = gui.ListView.new_from_list(items, width=300, height=120, margin='10px')
        self.listView.set_on_selection_listener(self, "list_view_on_selected")

        self.link = gui.Link("http://localhost:8081", "A link to here", width=200, height=30, margin='10px')

        self.dropDown = gui.DropDown(width=200, height=20, margin='10px')
        c0 = gui.DropDownItem('DropDownItem 0', width=200, height=20)
        c1 = gui.DropDownItem('DropDownItem 1', width=200, height=20)
        self.dropDown.append(c0)
        self.dropDown.append(c1)
        self.dropDown.set_on_change_listener(self, 'drop_down_changed')
        self.dropDown.set_value('DropDownItem 0')

        self.slider = gui.Slider(10, 0, 100, 5, width=200, height=20, margin='10px')
        self.slider.set_on_change_listener(self, 'slider_changed')

        self.colorPicker = gui.ColorPicker('#ffbb00', width=200, height=20, margin='10px')
        self.colorPicker.set_on_change_listener(self, 'color_picker_changed')

        self.date = gui.Date('2015-04-13', width=200, height=20, margin='10px')
        self.date.set_on_change_listener(self, 'date_changed')

        self.video = gui.VideoPlayer('http://www.w3schools.com/tags/movie.mp4',
                                     'http://www.oneparallel.com/wp-content/uploads/2011/01/placeholder.jpg',
                                     width=300, height=270, margin='10px')
        # appending a widget to another, the first argument is a string key
        subContainerRight.append(self.counter)
        subContainerRight.append(self.lbl)
        subContainerRight.append(self.bt)
        subContainerRight.append(self.txt)
        subContainerRight.append(self.spin)
        subContainerRight.append(self.check)
        subContainerRight.append(self.btInputDiag)
        subContainerRight.append(self.btFileDiag)
        # use a defined key as we replace this widget later
        fdownloader = gui.FileDownloader('download test', '../remi/res/logo.png', width=200, height=30, margin='10px')
        subContainerRight.append(fdownloader, key='file_downloader')
        subContainerRight.append(self.btUploadFile)
        subContainerRight.append(self.dropDown)
        subContainerRight.append(self.slider)
        subContainerRight.append(self.colorPicker)
        subContainerRight.append(self.date)
        self.subContainerRight = subContainerRight

        subContainerLeft.append(self.img)
        subContainerLeft.append(self.table)
        subContainerLeft.append(self.listView)
        subContainerLeft.append(self.link)
        subContainerLeft.append(self.video)

        horizontalContainer.append(subContainerLeft)
        horizontalContainer.append(subContainerRight)

        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('File', width=100, height=30)
        m2 = gui.MenuItem('View', width=100, height=30)
        m2.set_on_click_listener(self, 'menu_view_clicked')
        m11 = gui.MenuItem('Save', width=100, height=30)
        m12 = gui.MenuItem('Open', width=100, height=30)
        m12.set_on_click_listener(self, 'menu_open_clicked')
        m111 = gui.MenuItem('Save', width=100, height=30)
        m111.set_on_click_listener(self, 'menu_save_clicked')
        m112 = gui.MenuItem('Save as', width=100, height=30)
        m112.set_on_click_listener(self, 'menu_saveas_clicked')
        m3 = gui.MenuItem('Dialog', width=100, height=30)
        m3.set_on_click_listener(self, 'menu_dialog_clicked')

        menu.append(m1)
        menu.append(m2)
        menu.append(m3)
        m1.append(m11)
        m1.append(m12)
        m11.append(m111)
        m11.append(m112)

        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.append(menu)

        verticalContainer.append(menubar)
        verticalContainer.append(horizontalContainer)

        # kick of regular display of counter
        self.display_counter()

        # returning the root widget
        return verticalContainer
Exemple #30
0
    def main(self):
        self.mainContainer = gui.Widget(
            width='100%',
            height='100%',
            layout_orientation=gui.Widget.LAYOUT_VERTICAL)
        self.mainContainer.style['background-color'] = 'white'
        self.mainContainer.style['border'] = 'none'

        menubar = gui.MenuBar(height='4%')
        menu = gui.Menu(width='100%', height='100%')
        menu.style['z-index'] = '1'
        m1 = gui.MenuItem('File', width=150, height='100%')
        m10 = gui.MenuItem('New', width=150, height=30)
        m11 = gui.MenuItem('Open', width=150, height=30)
        m12 = gui.MenuItem('Save Your App', width=150, height=30)
        #m12.style['visibility'] = 'hidden'
        m121 = gui.MenuItem('Save', width=100, height=30)
        m122 = gui.MenuItem('Save as', width=100, height=30)
        m1.append([m10, m11, m12])
        m12.append([m121, m122])

        m2 = gui.MenuItem('Edit', width=100, height='100%')
        m21 = gui.MenuItem('Cut', width=100, height=30)
        m22 = gui.MenuItem('Paste', width=100, height=30)
        m2.append([m21, m22])

        m3 = gui.MenuItem('Project Config', width=200, height='100%')

        menu.append([m1, m2, m3])

        menubar.append(menu)

        self.toolbar = editor_widgets.ToolBar(width='100%',
                                              height='30px',
                                              margin='0px 0px')
        self.toolbar.style['border-bottom'] = '1px solid rgba(0,0,0,.12)'
        self.toolbar.add_command('/editor_resources:delete.png',
                                 self.toolbar_delete_clicked, 'Delete Widget')
        self.toolbar.add_command('/editor_resources:cut.png',
                                 self.menu_cut_selection_clicked, 'Cut Widget')
        self.toolbar.add_command('/editor_resources:paste.png',
                                 self.menu_paste_selection_clicked,
                                 'Paste Widget')

        lbl = gui.Label("Snap grid", width=100)
        spin_grid_size = gui.SpinBox('1', '1', '100', width=50)
        spin_grid_size.set_on_change_listener(self.on_snap_grid_size_change)
        grid_size = gui.HBox(children=[lbl, spin_grid_size],
                             style={
                                 'outline': '1px solid gray',
                                 'margin': '2px',
                                 'margin-left': '10px'
                             })
        self.toolbar.append(grid_size)

        self.fileOpenDialog = editor_widgets.EditorFileSelectionDialog(
            'Open Project',
            'Select the project file.<br>It have to be a python program created with this editor.',
            False, '.', True, False, self)
        self.fileOpenDialog.confirm_value.connect(self.on_open_dialog_confirm)

        self.fileSaveAsDialog = editor_widgets.EditorFileSaveDialog(
            'Project Save', 'Select the project folder and type a filename',
            False, '.', False, True, self)
        self.fileSaveAsDialog.add_fileinput_field('untitled.py')
        self.fileSaveAsDialog.confirm_value.connect(
            self.on_saveas_dialog_confirm)

        m10.onclick.connect(self.menu_new_clicked)
        m11.onclick.connect(self.fileOpenDialog.show)
        m121.onclick.connect(self.menu_save_clicked)
        m122.onclick.connect(self.fileSaveAsDialog.show)
        m21.onclick.connect(self.menu_cut_selection_clicked)
        m22.onclick.connect(self.menu_paste_selection_clicked)

        m3.onclick.connect(self.menu_project_config_clicked)

        self.subContainer = gui.HBox(
            width='100%',
            height='96%',
            layout_orientation=gui.Widget.LAYOUT_HORIZONTAL)
        self.subContainer.style.update({
            'position': 'relative',
            'overflow': 'auto',
            'align-items': 'stretch'
        })

        #here are contained the widgets
        self.widgetsCollection = editor_widgets.WidgetCollection(self,
                                                                 width='100%',
                                                                 height='50%')

        self.project = Project(width='100%', height='100%')
        self.project.style['min-height'] = '400px'

        self.project.attributes['ondragover'] = "event.preventDefault();"
        self.EVENT_ONDROPPPED = "on_dropped"
        self.project.attributes['ondrop'] = """event.preventDefault();
                var data = JSON.parse(event.dataTransfer.getData('application/json'));
                var params={};
                if( data[0] == 'add'){
                    params['left']=event.clientX-event.currentTarget.getBoundingClientRect().left;
                    params['top']=event.clientY-event.currentTarget.getBoundingClientRect().top;
                }
                sendCallbackParam(data[1],'%(evt)s',params);
                
                return false;""" % {
            'evt': self.EVENT_ONDROPPPED
        }
        self.project.attributes['editor_varname'] = 'App'
        self.project.onkeydown.connect(self.onkeydown)

        self.projectConfiguration = editor_widgets.ProjectConfigurationDialog(
            'Project Configuration',
            'Write here the configuration for your project.')

        self.attributeEditor = editor_widgets.EditorAttributes(self,
                                                               width='100%')
        self.attributeEditor.style['overflow'] = 'hide'
        self.signalConnectionManager = editor_widgets.SignalConnectionManager(
            width='100%', height='50%')

        self.mainContainer.append([menubar, self.subContainer])

        self.subContainerLeft = gui.Widget(width='20%', height='100%')
        self.subContainerLeft.style['position'] = 'relative'
        self.subContainerLeft.style['left'] = '0px'
        self.subContainerLeft.append(
            [self.widgetsCollection, self.signalConnectionManager])
        self.subContainerLeft.add_class('RaisedFrame')

        self.centralContainer = gui.VBox(width='56%', height='100%')
        self.centralContainer.append([self.toolbar, self.project])

        self.subContainerRight = gui.Widget(width='24%', height='100%')
        self.subContainerRight.style.update({
            'position': 'absolute',
            'right': '0px',
            'overflow': 'scroll'
        })
        self.subContainerRight.add_class('RaisedFrame')

        self.instancesWidget = editor_widgets.InstancesWidget(width='100%')
        self.instancesWidget.treeView.on_tree_item_selected.connect(
            self.on_instances_widget_selection)

        self.subContainerRight.append(
            [self.instancesWidget, self.attributeEditor])

        self.subContainer.append([
            self.subContainerLeft, self.centralContainer,
            self.subContainerRight
        ])
        self.project.style['position'] = 'relative'

        self.drag_helpers = [
            ResizeHelper(self.project, width=16, height=16),
            DragHelper(self.project, width=15, height=15),
            SvgDraggablePoint(self.project, 'cx', 'cy', [gui.SvgCircle]),
            SvgDraggableCircleResizeRadius(self.project, [gui.SvgCircle]),
            SvgDraggablePoint(self.project, 'x1', 'y1', [gui.SvgLine]),
            SvgDraggablePoint(self.project, 'x2', 'y2', [gui.SvgLine]),
            SvgDraggablePoint(self.project, 'x', 'y',
                              [gui.SvgRectangle, gui.SvgText]),
            SvgDraggableRectangleResizePoint(self.project, [gui.SvgRectangle])
        ]
        for drag_helper in self.drag_helpers:
            drag_helper.stop_drag.connect(self.on_drag_resize_end)

        self.menu_new_clicked(None)

        self.projectPathFilename = ''
        self.editCuttedWidget = None  #cut operation, contains the cutted tag

        # returning the root widget
        return self.mainContainer