def init__gui__(self):
        self.vbox_list_requests = G.VBox(width="100%")
        self.vbox_list_requests.append(G.Label("[Pending user requests]"))

        self.button_update = G.Button(u"🗘")
        self.button_update.onclick.do(self.a(self.on_update_all))

        self.vbox_publics = G.VBox(width="100%")
        self.vbox_publics.append(G.Label("[Publics]"))

        self.hbox_create_new = G.HBox(width="100%")
        self.edit_name = G.TextInput()
        self.button_add_new = G.Button("+")
        self.hbox_create_new.append([self.edit_name, self.button_add_new])
        self.button_add_new.onclick.do(self.a(self.on_add_new))

        self.vbox_publish_form = G.VBox(width="100%")
        self.select_channels = G.DropDown()
        self.edit_publish =G.TextInput()
        self.button_publish = G.Button("publish")
        self.button_publish.onclick.do(self.a(self.on_publish))
        self.vbox_publish_form.append([
            G.Label("[new publishment]"),
            self.select_channels,
            self.edit_publish,
            self.button_publish
        ])

        self.publics_controls = dict()
示例#2
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)
示例#3
0
文件: survey.py 项目: masasin/spirit
    def cbk_add_user(self, widget):
        self.dialog = gui.GenericDialog(title="New user",
                                        message="Click Ok to save the user",
                                        width="500px")

        self.dname = gui.TextInput(width=200, height=30)
        self.dialog.add_field_with_label("dname", "Name", self.dname)

        self.dage = gui.TextInput(width=200, height=30)
        self.dialog.add_field_with_label("dage", "Age", self.dage)

        self.dgender = gui.DropDown.new_from_list(["Female", "Male", "Other"],
                                                  width=200,
                                                  height=30)
        self.dgender.select_by_value("Male")
        self.dialog.add_field_with_label("dgender", "Gender", self.dgender)

        self.dteleop = gui.TextInput(width=200, height=30)
        self.dteleop.set_value("0")
        self.dialog.add_field_with_label(
            "dteleop", "Total hours flying teleoperated UAVs", self.dteleop)

        self.dflying = gui.TextInput(width=200, height=30)
        self.dflying.set_value("0")
        self.dialog.add_field_with_label("dflying",
                                         "Total hours flying other vehicles",
                                         self.dflying)

        self.dialog.set_on_confirm_dialog_listener(
            self.add_user_dialog_confirm)
        self.dialog.show(self)
    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)
示例#5
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)
    def main(self):

        # trivial main page
        # ********************
        root = gui.VBox(width=600, height=200)  #1

        # button
        button_tabbed_dialog = gui.Button('Open Tabbed Editor',
                                          width=250,
                                          height=30)
        button_tabbed_dialog.set_on_click_listener(
            self.on_tabbed_dialog_button_clicked)
        root.append(button_tabbed_dialog)

        # and fields in main page
        self.t1f1_field = gui.Label('Tab1 Field 1: ', width=400, height=30)
        root.append(self.t1f1_field)

        self.t2f1_field = gui.Label('Tab2 Field 1: ', width=400, height=30)
        root.append(self.t2f1_field)

        # dialog to contain the TabView
        # ***********************************
        self.tabbed_dialog = AdaptableDialog(width=450,
                                             height=300,
                                             title='<b>Tabbed Editor</b>',
                                             message='',
                                             autohide_ok=False)
        self.tabbed_dialog.set_on_confirm_dialog_listener(
            self.tabbed_dialog_confirm)

        # construct a Tabview - frame_width,frame_height,bar height
        frame_width = 400
        self.tabview = TabView(frame_width, 100, 30)

        # add tabs - tab width,key,title
        self.panel1 = self.tabview.add_tab(100, 'tab1', 'Tab 1')
        self.panel2 = self.tabview.add_tab(100, 'tab2', 'Tab 2')

        # and finish building the tabview
        self.tabview.construct_tabview()

        # add some fields to the tab panels
        self.t1field1 = gui.TextInput(width=300, height=35)
        self.t1field1.set_text('Content of Tab 1 field 1')
        append_with_label(self.panel1,
                          'Field 1',
                          self.t1field1,
                          None,
                          width=frame_width)

        self.t2field1 = gui.TextInput(width=250, height=30)
        self.t2field1.set_text('Content of Tab 2 field 1')
        self.panel2.append(self.t2field1)

        # add the tabview to the dialog
        self.tabbed_dialog.append_field(self.tabview, 'tab_view')

        return root
示例#7
0
    def test_init(self):
        widget = gui.TextInput(single_line=True, hint='test text input')
        self.assertIn('test text input', widget.repr())
        assertValidHTML(widget.repr())

        widget = gui.TextInput(single_line=False, hint='test text input')
        self.assertIn('test text input', widget.repr())
        assertValidHTML(widget.repr())
示例#8
0
    def init__gui__(self):
        self.x = gui.TextInput()
        self.y = gui.TextInput()

        self.hbox = hbox = gui.HBox(width="100%")
        hbox.append([gui.Label("X = "), self.x, gui.Label("Y = "), self.y])
        self.label = gui.Label(text=f" Result: ")
        self.button = gui.Button("update")
        self.button.onclick.do(self.onclickbutton)
示例#9
0
文件: web.py 项目: kaschik/hoplite
    def build_keg_settings(self, hx_conf, index, channel):
        cap = hx_conf['channels'][channel]['size'][0]
        tare = hx_conf['channels'][channel]['size'][1]
        name = hx_conf['channels'][channel]['name']
        size_name = hx_conf['channels'][channel]['size_name']
        size = hx_conf['channels'][channel]['size']

        keg_size_list = list(self.h.keg_data)
        keg_size_list.append('custom')

        keg_box = gui.Widget()

        box_name = gui.Label('Sensor ' + str(index) + ' Channel ' + channel)
        keg_box.append(box_name)

        keg_name = gui.HBox()
        keg_name_lbl = gui.Label('Keg Name', width='20%')
        keg_name.append(keg_name_lbl, 'lbl')
        keg_name_val = gui.TextInput(single_line=True, height='1.5em')
        keg_name_val.set_value(name)
        keg_name.append(keg_name_val, 'val')
        keg_box.append(keg_name, 'name')

        keg_size = gui.HBox()
        keg_size_lbl = gui.Label('Keg Size', width='20%')
        keg_size.append(keg_size_lbl, 'lbl')
        keg_size_val = gui.DropDown.new_from_list(keg_size_list)
        keg_size_val.select_by_value(size_name)
        keg_size.append(keg_size_val, 'val')
        keg_box.append(keg_size, 'size')

        custom = gui.HBox()
        vol_lbl = gui.Label('Volume (l)', width='20%')
        custom.append(vol_lbl, 0)
        custom_vol = gui.TextInput(single_line=True,
                                   height='1.5em',
                                   width='30%')
        custom_vol.set_value(str(size[0]))
        custom.append(custom_vol, 1)
        tare_lbl = gui.Label('Empty Weight (kg)', width='30%')
        custom.append(tare_lbl, 2)
        custom_tare = gui.TextInput(single_line=True,
                                    height='1.5em',
                                    width='20%')
        custom_tare.set_value(str(size[1]))
        custom.append(custom_tare, 3)

        keg_box.append(custom, 'custom')

        return keg_box
示例#10
0
    def init__gui__(self):
        self.controls = dict()
        self.vbox_list = G.VBox(width="100%")
        self.hbox_add = G.HBox(width="100%")

        self.edit_new_key = G.TextInput(width="30%")
        self.edit_new_value = G.TextInput(width="30%")
        self.button_add_new = G.Button("add", width=50)
        self.button_add_new.onclick.do(self.a(self.on_add_new))

        self.button_reload = G.Button(u"🗘")
        self.button_reload.onclick.do(self.a(self.reload))

        self.hbox_add.append([self.edit_new_key, self.edit_new_value, self.button_add_new])
        self.cloud.add_background_job(self.update_list)
示例#11
0
    def __init__(self, *args):
        super(OSCWebEditor,
              self).__init__(width=550,
                             height=600,
                             title='<b>Edit OSC Configuration</b>',
                             confirm_name='OK',
                             cancel_name='Cancel')

        self.append_field(gui.Label('<b>This Unit</b>', width=250, height=30))
        e_this_unit_name_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label('OSC Name of This Unit:',
                                     e_this_unit_name_field,
                                     key='e_this_unit_name')

        e_this_unit_ip_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label('IP of This Unit:',
                                     e_this_unit_ip_field,
                                     key='e_this_unit_ip')

        #SLAVE
        self.append_field(gui.Label('<b>OSC Slave</b>', width=250, height=30))

        e_slave_enabled_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label('OSC Slave enabled (yes/no):',
                                     e_slave_enabled_field,
                                     key='e_slave_enabled')

        e_listen_port_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label(
            'Port for listening to commands for this Unit',
            e_listen_port_field,
            key='e_listen_port')

        # MASTER
        self.append_field(gui.Label('<b>OSC Master</b>', width=250, height=30))

        e_master_enabled_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label('OSC Master enabled (yes/no):',
                                     e_master_enabled_field,
                                     key='e_master_enabled')

        e_reply_listen_port_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label(
            'Listen to replies from Slave Unit on Port:',
            e_reply_listen_port_field,
            key='e_reply_listen_port')

        e_slave_units_name_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label('Slave Units OSC Name:',
                                     e_slave_units_name_field,
                                     key='e_slave_units_name')

        e_slave_units_ip_field = gui.TextInput(width=250, height=30)
        self.append_field_with_label('Slave Units IP:',
                                     e_slave_units_ip_field,
                                     key='e_slave_units_ip')

        return
示例#12
0
    def text_message(self, message):
        self.custom_dialog = gui.GenericDialog(title='Dialog Box', width='600px')
        text_input = gui.TextInput(single_line=False)
        text_input.set_text(message)

        self.custom_dialog.add_field_with_label('text_input_messade', 'System Message', text_input)
        self.custom_dialog.show(self)
示例#13
0
    def main(self):
        #creating a container GridBox type
        main_container = gui.GridBox(width='100%',
                                     height='100%',
                                     style={'margin': '0px auto'})

        label = gui.Label('This is a label')
        label.style['background-color'] = 'lightgreen'

        button = gui.Button('Change layout', height='100%')
        button.onclick.do(self.redefine_grid, main_container)

        text = gui.TextInput()

        main_container.set_from_asciiart(
            """
            |label |button                      |
            |label |text                        |
            |label |text                        |
            |label |text                        |
            |label |text                        |
            """, 10, 10)

        main_container.append({'label': label, 'button': button, 'text': text})

        # returning the root widget
        return main_container
    def __init__(self, *args):
        super(Options, self).__init__(title='<b>Edit Options</b>',width=500,height=300,autohide_ok=False)

        # build the gui in _init as it is subclassed
        home_dir_field= gui.TextInput(width=200, height=30)
        self.add_field_with_label('home_dir','Pi Presents Data Home:',home_dir_field)
        # home_dir_field.set_on_change_listener(self, 'validate_home')
        media_dir_field= gui.TextInput(width=200, height=30)
        self.add_field_with_label('media_dir','Inital directory for Media:',media_dir_field)
        # media_dir_field.set_on_change_listener(self, 'validate_media')
        offset_field= gui.TextInput(width=200, height=30)
        self.add_field_with_label('offset','Offset for Current Profiles:',offset_field)
        # offset_field.set_on_change_listener(self, 'validate_offset')
        error_field= gui.Label('',width=400, height=30)
        self.add_field('error',error_field)
        self.set_on_confirm_dialog_listener(self,'eo_confirm')
示例#15
0
    def __init__(self, appInstance, **kwargs):
        super(UrlPathInput, self).__init__(**kwargs)
        gui.EventSource.__init__(self)
        self.appInstance = appInstance
        self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        self.style['display'] = 'block'
        self.style['overflow'] = 'hidden'

        self.txtInput = gui.TextInput(width='80%', height='100%')
        self.txtInput.style['float'] = 'left'
        self.txtInput.onchange.connect(self.on_txt_changed)
        self.append(self.txtInput)

        self.btFileFolderSelection = gui.Widget(width='20%', height='100%')
        self.btFileFolderSelection.style.update({
            'background-repeat':
            'round',
            'background-image':
            "url('/res:folder.png')",
            'background-color':
            'transparent'
        })
        self.append(self.btFileFolderSelection)
        self.btFileFolderSelection.onclick.connect(
            self.on_file_selection_bt_pressed)

        self.selectionDialog = gui.FileSelectionDialog('Select a file', '',
                                                       False, './', True,
                                                       False)
        self.selectionDialog.confirm_value.connect(self.file_dialog_confirmed)
示例#16
0
    def main(self):
        # create "master" container which will hold top container and bottom container
        # We will add widgets to it vertically
        self.masterContainer = gui.Widget(1200, 50, gui.Widget.LAYOUT_VERTICAL, 10)

        # Create top container and then widgets will be added to it horizontally
        topContainer = gui.Widget(1200, 50, gui.Widget.LAYOUT_HORIZONTAL, 10)

        # Create bottom container
        self.bottomContainer = gui.Widget(1200, 0, gui.Widget.LAYOUT_HORIZONTAL, 0)

        # Create widgets that will be placed in the top container
        self.lbl = gui.Label(200, 30, 'Team name:')
        self.txt = gui.TextInput(200, 30)
        self.btn = gui.Button(200, 30, 'Submit')
        self.btn.set_on_click_listener(self, 'on_button_pressed')

        # Add those widgets to the top container
        topContainer.append('1', self.lbl)
        topContainer.append('2', self.txt)
        topContainer.append('3', self.btn)
        
        # At startup, we want to just add the top container to the master container
        self.masterContainer.append('1', topContainer)
        
        # At startup, make it so the textinput widget is ready to accept input
        self.txt.attributes['tabindex'] = "1"
        self.txt.attributes['autofocus'] = "autofocus"

        # return / render the master container
        return self.masterContainer
示例#17
0
  def main(self):
    
# --- open CSV, DictReader, for loop ---
    with open("translations.csv", "r") as words: 
      reader = csv.DictReader(words, delimiter = ",")
      for line in reader:
        english = line["English"].lower()
        spanish = line["Spanish"].lower()
        french = line["French"].lower()
        self.translations[english] = [spanish, french]

# --- GUI ---
    container = gui.VBox(width=500, height=300, style={"box-shadow":"none"})
    self.label = gui.Label("Type an English word to translate!", width=300, height=10, style={"font-size":"16px", "font-weight":"bold", "text-align":"center"})
    self.spanish = gui.Label("SPANISH: ", width=300, height=5, style={"font-size":"14px"})
    self.french = gui.Label("FRENCH: ", width=300, height=5, style={"font-size":"14px"})
    self.textinput = gui.TextInput(width=300, height=26, style={"padding-top":"10px", "padding-left":"10px"})
    self.error = gui.Label("", width=300, height=5, style={"font-style":"italic"})
    self.button = gui.Button("TRANSLATE", width=300, height=40, margin="10px", style={"background-color":"#F16059", "font-weight":"bold", "font-size":"16px", "box-shadow":"none"})

# --- GUI elements ---
    container.append(self.label)
    container.append(self.textinput)
    container.append(self.spanish)
    container.append(self.french)
    container.append(self.error)
    container.append(self.button)

# --- When you click on button, call the function on_button_pressed ---
    self.button.onclick.connect(self.on_button_pressed)
  
    return container
示例#18
0
 async def update_key(self, key, value):
     control = self.controls.get(key, None)
     if control:
         if control['value'] != value:
             control['edit_value'].set_text(value)
     else:
         control = dict(
             label_key=G.Label(key, width="40%"),
             value=value,
             edit_value=G.TextInput(value, width="40%"),
             hbox=G.HBox(width="100%"),
             button_update=G.Button(u"🗘"),
             button_delete=G.Button(u"X")
         )
         self.make_update_handler(control['button_update'], key, control['edit_value'])
         self.make_delete_handler(control['button_delete'], key)
         control['hbox'].append([
             control['label_key'],
             control['edit_value'],
             control['button_update'],
             control['button_delete']
         ])
         control['edit_value'].set_text(value)
         self.vbox_list.append(control['hbox'])
         self.controls[key] = control
         await trio.sleep(0)
示例#19
0
    def main(self):
        wid = gui.VBox(width=300, height=300)

        self._items = ("/test/1", "/test/7")

        self.dd = gui.DropDown.new_from_list(self._items,
                                             width='80%',
                                             height=40)
        self.list = gui.ListView.new_from_list(self._items,
                                               width='80%',
                                               height='50%')
        self.ent = gui.TextInput(width=200, height=30, hint='enter words')
        self.bt = gui.Button('Update Models', width=200, height=30)
        self.bt.style['margin'] = 'auto 50px'

        self.bt.set_on_click_listener(self.on_button_pressed)

        # appending a widget to another, the first argument is a string key
        wid.append(self.dd)
        wid.append(self.list)
        wid.append(self.ent)
        wid.append(self.bt)

        # returning the root widget
        return wid
示例#20
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)
示例#21
0
    def __init__(self, appInstance, **kwargs):
        super(UrlPathInput, self).__init__(**kwargs)
        self.appInstance = appInstance
        self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        self.style['display'] = 'block'
        self.style['overflow'] = 'hidden'

        self.txtInput = gui.TextInput(True, width='80%', height='100%')
        self.txtInput.style['float'] = 'left'
        self.txtInput.set_on_change_listener(self, "on_txt_changed")
        self.append(self.txtInput)

        self.btFileFolderSelection = gui.Widget(width='20%', height='100%')
        self.btFileFolderSelection.style['background-repeat'] = 'round'
        self.btFileFolderSelection.style[
            'background-image'] = "url('/res/folder.png')"
        self.btFileFolderSelection.style['background-color'] = 'transparent'
        self.append(self.btFileFolderSelection)
        self.btFileFolderSelection.set_on_click_listener(
            self, 'on_file_selection_bt_pressed')

        self.selectionDialog = gui.FileSelectionDialog('Select a file', '',
                                                       False, './', True,
                                                       False)
        self.selectionDialog.set_on_confirm_value_listener(
            self, 'file_dialog_confirmed')
示例#22
0
    def main(self):
        # We need to get dynamically the available voices
        self.voices_dict = {}
        # Default English_(Great_Britain) voice
        self.selected_voice_id = 78
        self.voices_dropdown = gui.DropDown.new_from_list(
            ["Loading voices list..."], width=200, height=20, margin='10px')
        self.container = gui.VBox(width=400)
        self.lbl = gui.Label("Text to say:")
        self.text_input = gui.TextInput(width=300)
        self.lbl_rate = gui.Label("Rate (speed) to say:")
        self.rate_slider = gui.Slider(1.0, min=0.1, max=5.0, step=0.1)
        self.lbl_pitch = gui.Label("Pitch of voice:")
        self.pitch_slider = gui.Slider(1.0, min=0.1, max=2.0, step=0.1)
        self.bt_say = gui.Button("Say")
        self.bt_say.onclick.do(self.on_say)

        self.container.append(self.lbl)
        self.container.append(self.text_input)
        self.container.append(self.lbl_rate)
        self.container.append(self.rate_slider)
        self.container.append(self.lbl_pitch)
        self.container.append(self.pitch_slider)
        self.container.append(self.bt_say)
        self.container.append(self.voices_dropdown, key=99999)

        # returning the root widget
        return self.container
示例#23
0
    def main(self):
        #creating a container GridBox type
        main_container = gui.GridBox(width='100%',
                                     height='100%',
                                     style={'margin': '0px auto'})

        label = gui.Label('This is a label')
        label.style['background-color'] = 'lightgreen'

        button = gui.Button('Change layout', height='100%')
        button.onclick.connect(self.redefine_grid, main_container)

        text = gui.TextInput()

        #defining layout matrix, have to be iterable of iterable
        main_container.define_grid(['ab', 'ac'])
        main_container.append({'a': label, 'b': button, 'c': text})
        #setting sizes for rows and columns
        main_container.style.update({
            'grid-template-columns': '10% 90%',
            'grid-template-rows': '10% 90%'
        })

        # returning the root widget
        return main_container
示例#24
0
文件: bootstrap.py 项目: samtux/remi
    def main(self):
        #creating a container VBox type, vertical (you can use also HBox or Widget)
        main_container = gui.VBox(width='500px',
                                  height='500px',
                                  style={
                                      'margin': '0px auto',
                                      'padding': '10px'
                                  })

        #Label
        self.lbl = gui.Label("  Label with Lock Icon")
        self.lbl.add_class("glyphicon glyphicon-lock label label-primary")

        #Text Input
        self.tf = gui.TextInput(hint='Your Input')
        self.tf.add_class("form-control input-lg")

        #Drop Down
        self.dd = gui.DropDown(width='200px')
        self.dd.style.update({'font-size': 'large'})
        self.dd.add_class("form-control dropdown")
        self.item1 = gui.DropDownItem("First Choice")
        self.item2 = gui.DropDownItem("Second Item")
        self.dd.append(self.item1, 'item1')
        self.dd.append(self.item2, 'item2')

        #Table
        myList = [('ID', 'Lastname', 'Firstname', 'ZIP', 'City'),
                  ('1', 'Pan', 'Peter', '99999', 'Neverland'),
                  ('2', 'Sepp', 'Schmuck', '12345', 'Examplecity')]

        self.tbl = gui.Table.new_from_list(content=myList,
                                           width='400px',
                                           height='100px',
                                           margin='10px')
        self.tbl.add_class("table table-striped")

        #Buttons

        #btn adds basic design to a button like rounded corners and stuff
        #btn-success, btn-danger and similar adds theming based on the function
        #if you use btn-success without btn, the button will be standard, but with green background

        self.bt1 = gui.Button("OK", width="100px")
        self.bt1.add_class("btn-success")  #Bootstrap Class:  btn-success

        self.bt2 = gui.Button("Abbruch", width="100px")
        self.bt2.add_class("btn btn-danger")  #Bootstrap Class:  btn btn-danger

        #Build up the gui
        main_container.append(self.lbl, 'lbl')
        main_container.append(self.tf, 'tf')
        main_container.append(self.dd, 'dd')
        main_container.append(self.tbl, 'tbl')
        main_container.append(self.bt1, 'btn1')
        main_container.append(self.bt2, 'btn2')

        # returning the root widget
        return main_container
    def make_gui_elements(self):  # content and behaviour
        #logo:
        self.logo_image = gui.Image('/res/logo.png')
        self.logo_image.attributes[
            "onclick"] = "document.location='https://www.youtube.com/watch?v=t-fcrn1Edik'"

        #playback controls
        self.playback = Namespace()

        self.playback.playing = gui.Label(
            "Now playing: None")  # (TODO): update this

        self.playback.party = gui.Button(icons.PARTY)
        self.playback.party.attributes[
            "onclick"] = "document.body.classList.toggle('dancing');"
        self.playback.party.attributes[
            "title"] = "ENABLE PARTY MODE"  # hover text
        self.playback.previous = gui.Button(icons.PREV)
        self.playback.previous.set_on_click_listener(self.playback_previous)
        self.playback.play = gui.Button(icons.PLAY)
        self.playback.play.set_on_click_listener(self.playback_play)
        self.playback.next = gui.Button(icons.NEXT)
        self.playback.next.set_on_click_listener(self.playback_next)

        self.playback.volume_label = gui.Label("Volume:")
        self.playback.volume_slider = gui.Slider(100, 0, 100, 1)
        self.playback.volume_slider.set_oninput_listener(self.change_volume)

        self.playback.seek_slider = gui.Slider(0, 0, 100, 1)
        self.playback.seek_slider.set_oninput_listener(self.change_seek)

        self.playback.timestamp = gui.Label("--:-- - --:--")

        #playlist
        self.playlist = Namespace()

        self.playlist.table = gui.Table()
        self.playlist.table.append_from_list(
            [['#', 'Name', "length", "", "", "", ""]], fill_title=True)

        self.playlist.looping = gui.CheckBoxLabel(
            "<i><small>loop playlist</small></i>")
        self.playlist.looping.set_on_click_listener(
            self.on_playlist_set_looping)

        self.playlist.shuffle = gui.Button("SHUFFLE")
        self.playlist.shuffle.set_on_click_listener(
            self.on_playlist_clear_shuffle)

        self.playlist.clear = gui.Button("CLEAR")
        self.playlist.clear.set_on_click_listener(self.on_playlist_clear_click)

        #input
        self.input = Namespace()
        self.input.add_song = gui.Label("Add song:")
        self.input.field = gui.TextInput(single_line=True)
        self.input.field.set_on_enter_listener(self.input_submit)
        self.input.submit = gui.Button("Submit!")
        self.input.submit.set_on_click_listener(self.input_submit)
示例#26
0
 def __init__(self, title):
     self.text = ''
     super(ReportDialog, self).__init__(title,
                                        '',
                                        width=600,
                                        height=500,
                                        confirm_name='Done')
     self.textb = gui.TextInput(width=550, height=400, single_line=False)
     self.append_field(self.textb, 'text')
示例#27
0
    def main(self):
        container = gui.VBox(width=800, height=400)
        self.lb_version = gui.Label('Version:')
        self.lb_tc = gui.Label('Traffic Class:')
        self.lb_fl = gui.Label('Flow Label:')
        self.lb_pl = gui.Label('Payload Length:')
        self.lb_nh = gui.Label('Next Header:')
        self.lb_sa = gui.Label('Source Address:')
        self.lb_da = gui.Label('Destination Address:')

        self.txt = gui.TextInput(width=200, height=30, margin='10px')

        self.bt_send = gui.Button('Send')
        self.bt_defaut_value = gui.Button('default value')
        self.bt_reset = gui.Button('reset value')

        # setting the listener for the onclick event of the button
        self.bt_send.onclick.connect(self.on_button_pressed)
        self.bt_defaut_value.onclick.connect(self.on_button_pressed2)

        # appending a widget to another, the first argument is a string key
        horizontalContainer = gui.Widget(
            width='100%',
            layout_orientation=gui.Widget.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'display': 'block',
                'overflow': 'auto'
            })
        subContainerLeft = gui.Widget(width=540,
                                      margin='0px auto',
                                      style={
                                          'display': 'block',
                                          'overflow': 'hidden'
                                      })
        subContainerLeft.append([
            self.lb_version, self.lb_tc, self.lb_fl, self.lb_pl, self.lb_nh,
            self.lb_sa, self.lb_da
        ])
        subContainerRight = gui.Widget(width=540,
                                       margin='0px auto',
                                       style={
                                           'display': 'block',
                                           'overflow': 'hidden'
                                       })
        subContainerRight.append(
            [self.bt_send, self.bt_defaut_value, self.bt_reset])
        horizontalContainer.append([subContainerLeft, subContainerRight])
        container.append([horizontalContainer])

        container.append(self.txt)
        container.append(self.bt_send)
        container.append(self.bt_defaut_value)
        container.append(self.bt_reset)

        # returning the root widget
        return container
示例#28
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()
示例#29
0
    def new_project_tab(self, event):
        self.canvas.empty()
        f1 = gui.Widget()
        f1.add_class('w3-container z-depth-5')
        f1.style['width'] = '100%'
        f1.style['padding'] = '10px 10px'
        f1.style['background-color'] = config["primary-background-color"]
        
        foo = gui.Label('Project Name ')
        foo.style['color'] = config["primary-foreground-color"]
        foo.style['font-size'] = 'x-large'
        foo.style['padding'] = '10px 10px 10px 10px'

        project_name = gui.TextInput(hint='Enter your project name here')
        project_name.style['background-color'] = config["primary-background-color"]
        project_name.style['height'] = gui.to_pix(43)
        project_name.add_class('input-field waves-light')
        project_name.style['padding'] = gui.to_pix(10)

        ok_button = theme.EditorButton(text='Create', icon='add')

        def project_startup_page():
            self.canvas.empty()
            foo = gui.Label(project_name.get_text() + '.cxproj Project')
            foo.add_class('w3-jumbo')
            foo.style['height'] = '200px'
            foo.style['padding'] = '30px 30px 30px 30px'

            create_schematic_button = theme.EditorButton(text='Schematic', icon='edit')
            create_component_button = theme.EditorButton(text='Custom component definition', icon='edit')
            create_cppscript_button = theme.EditorButton(text='C++ Script', icon='edit')
            link_compiler_button = theme.EditorButton(text='Link custom compiler suite', icon='edit')
            lazy_populate_project_files(self, animate=False)

            for widget in [
                    foo, create_schematic_button,
                    create_component_button, create_cppscript_button,
                    link_compiler_button
                ]:
                self.canvas.append(widget)

        
        def project_event(e):
            project_format_file_handler = open(project_name.get_text() + '.cxproj', 'w')
            project_format_file_handler.write('')
            project_format_file_handler.close()
            project_startup_page()

        ok_button.onclick.do(project_event)

        for widget in [foo, project_name, ok_button]:
            f1.append(widget)
        
        for widget in [f1]:
            self.canvas.append(widget)
示例#30
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)