Exemplo n.º 1
0
    def main(self):
        # the arguments are    width - height - layoutOrientationOrizontal
        self.main_container = gui.Container(margin='0px auto')
        self.main_container.set_size(1020, 600)
        self.main_container.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)

        self.title = gui.Label('Mine Field GAME')
        self.title.set_size(1000, 30)
        self.title.style['margin'] = '10px'
        self.title.style['font-size'] = '25px'
        self.title.style['font-weight'] = 'bold'

        self.info = gui.Label('Collaborative minefiled game. Enjoy.')
        self.info.set_size(400, 30)
        self.info.style['margin'] = '10px'
        self.info.style['font-size'] = '20px'

        self.lblMineCount = gui.Label('Mines')
        self.lblMineCount.set_size(100, 30)
        self.lblFlagCount = gui.Label('Flags')
        self.lblFlagCount.set_size(100, 30)

        self.time_count = 0
        self.lblTime = gui.Label('Time')
        self.lblTime.set_size(100, 30)

        self.btReset = gui.Button('Restart')
        self.btReset.set_size(100, 30)
        self.btReset.onclick.do(self.new_game)

        self.horizontal_container = gui.Container()
        self.horizontal_container.style['display'] = 'block'
        self.horizontal_container.style['overflow'] = 'auto'
        self.horizontal_container.set_layout_orientation(gui.Container.LAYOUT_HORIZONTAL)
        self.horizontal_container.style['margin'] = '10px'
        self.horizontal_container.append(self.info)
        imgMine = gui.Image('/my_resources:mine.png')
        imgMine.set_size(30, 30)
        self.horizontal_container.append([imgMine, self.lblMineCount])
        imgFlag = gui.Image('/my_resources:flag.png')
        imgFlag.set_size(30, 30)
        self.horizontal_container.append([imgFlag, self.lblFlagCount, self.lblTime, self.btReset])

        self.minecount = 0  # mine number in the map
        self.flagcount = 0  # flag placed by the players

        self.link = gui.Link("https://github.com/dddomodossola/remi",
                             "This is an example of REMI gui library.")
        self.link.set_size(1000, 20)
        self.link.style['margin'] = '10px'

        self.main_container.append([self.title, self.horizontal_container, self.link])

        self.new_game(self)

        self.stop_flag = False
        self.display_time()
        # returning the root widget
        return self.main_container
Exemplo n.º 2
0
    def main(self):
        wid = gui.VBox(width='100%', margin='0px auto')

        width = '300'  #'2048'
        height = '300'  #'1152'
        self.video = gui.Widget(width=300, height=300, _type='video')
        self.video.attributes['autoplay'] = 'true'
        self.video.style['overflow'] = 'hidden'
        self.video.attributes['width'] = width
        self.video.attributes['height'] = height

        self.canvas = gui.Widget(_type='canvas')
        self.canvas.style['display'] = 'none'
        self.canvas.attributes['width'] = width
        self.canvas.attributes['height'] = height

        self.imgGrabber = ImageGrabber(self, width, height)

        self.imgGrabber.new_image.do(self.on_new_image)
        self.imgGrabber.onnewvideodevice.do(self.new_video_device)
        getVideoInputsButton = gui.Button("Get cameras", margin='10px')
        getVideoInputsButton.onclick.do(self.on_get_video_inputs)
        captureButton = gui.Button("Start", margin='10px')
        captureButton.onclick.do(self.on_start_grab, None)
        snapshotButton = gui.Button("Grab Image", margin='10px')
        snapshotButton.onclick.do(self.snapshot)
        self.check_flash = gui.CheckBoxLabel('Flashlight',
                                             False,
                                             width=200,
                                             height=30,
                                             margin='10px')
        self.check_flash.set_on_change_listener(self.on_start_grab)

        self.label = gui.Label('Image capture')
        self.label.style['font-size'] = '18px'

        self.device_list = gui.DropDown(width=100)

        wid.append(self.label)
        wid.append(self.video)
        wid.append(self.canvas)
        wid.append(getVideoInputsButton)
        wid.append(self.device_list)
        wid.append(captureButton)
        wid.append(snapshotButton)
        wid.append(self.check_flash)

        self.opencvVideoWidget = OpencvVideoWidget(self, width=400, height=300)
        wid.append(
            gui.VBox(
                children=[gui.Label("opencv image"), self.opencvVideoWidget],
                style={'bolder': '1px dotted black'}))

        wid.add_child("javascript_image_grabber", self.imgGrabber)

        self.dialog = None

        # returning the root widget
        return wid
Exemplo n.º 3
0
    def main(self):
        self.users = []
        self.save_location = "data.pickle"

        container = gui.Widget(width=500, margin="0px auto")

        menu = gui.Menu(width="100%", height="30px")

        menu_file = gui.MenuItem("File", width=100, height=30)
        menu_load = gui.MenuItem("Load...", width=100, height=30)
        menu_load.set_on_click_listener(self.cbk_select_pickle)
        menu_save = gui.MenuItem("Save", width=100, height=30)
        menu_save.set_on_click_listener(self.cbk_save)
        menu_save_as = gui.MenuItem("Save As...", width=100, height=30)
        menu_save_as.set_on_click_listener(self.cbk_save_as)

        menu.append(menu_file)
        menu_file.append(menu_load)
        menu_file.append(menu_save)
        menu_file.append(menu_save_as)

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

        self.uploader = gui.FileUploader("./", margin="10px")
        self.uploader.set_on_success_listener(self.cbk_load)

        self.save_location_label = gui.Label(f"Saving to {self.save_location}", margin="10px")

        self.table = gui.Table.new_from_list([("ID", "Name", "Onboard", "SPIRIT", "Both")],
            width=300, margin="10px")

        select_user_label = gui.Label("Select a user:"******"10px")
        self.user_list = gui.ListView(margin="10px", width=300)
        self.user_list.set_on_selection_listener(self.cbk_user_selected)

        add_user_button = gui.Button("Add user", width=200, height=30, margin="10px")
        add_user_button.set_on_click_listener(self.cbk_add_user)

        save_button = gui.Button("Save", width=200, height=30, margin="10px")
        save_button.set_on_click_listener(self.cbk_save)

        try:
            self._load(self.save_location)
        except FileNotFoundError:
            pass
        self.update_table()
        self.update_user_list()

        container.append(menubar)
        container.append(self.uploader)
        container.append(self.save_location_label)
        container.append(self.table)
        container.append(select_user_label)
        container.append(self.user_list)
        container.append(add_user_button)
        container.append(save_button)

        return container
    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
    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)
Exemplo n.º 6
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
Exemplo n.º 7
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)
Exemplo n.º 8
0
    def test_init(self):
        widget = gui.Label('testing title')
        self.assertIn('testing title', widget.repr())
        assertValidHTML(widget.repr())

        invalid_types = [{}, [], 123, (4, 5)]
        for each_type in invalid_types:
            with self.assertRaises(Exception) as error:
                gui.Label(each_type)
Exemplo n.º 9
0
 def __init__(self, posKey: str):
     # labels are inserted into HBox
     self._box = gui.HBox()
     self.append(self._box, posKey)
     self._timePosLabel = gui.Label(text="")
     self._box.append(self._timePosLabel, "1")
     self._separatorLabel = gui.Label(text="")
     self._box.append(self._separatorLabel, "2")
     self._trackDuration = gui.Label(text="")
     self._box.append(self._trackDuration, "3")
Exemplo n.º 10
0
    def _closing_page(self):
        """
        This function defines the structure of the closing page of the web application.
        :return: The root remi.gui.Widget object for the closing page.
        """

        # Define root widget.
        main_container = gui.Widget(width='100%',
                                    height='100%',
                                    margin='0px',
                                    style={
                                        'vertical-align': 'middle',
                                        'background-color': UOB_BLUE,
                                        'position': 'fixed'
                                    })

        closing_label = gui.Label('Closing Web Application',
                                  style={
                                      'font-weight': '500',
                                      'color': '#FFFFFF',
                                      'font-size': '50px',
                                      'text-shadow': 'none',
                                      'position': 'absolute',
                                      'top': '0px',
                                      'bottom': '0px',
                                      'left': '0px',
                                      'right': '0px',
                                      'text-align': 'center',
                                      'height': '25%',
                                      'margin': 'auto'
                                  })
        closing_instructions = gui.Label(
            'See the terminal for final messages and confirmation that the application '
            'closed successfully.',
            style={
                'font-weight': '500',
                'color': '#FFFFFF',
                'font-size': '15px',
                'text-shadow': 'none',
                'position': 'absolute',
                'top': '0px',
                'bottom': '0px',
                'left': '0px',
                'right': '0px',
                'text-align': 'center',
                'height': '5%',
                'margin': 'auto'
            })

        # Build up the webpage.
        main_container.append(
            [closing_label, closing_instructions, self.footer])

        # Return the root widget.
        return main_container
Exemplo n.º 11
0
    def create_num_row(self, param_name, description, range_min, range_max,
                       current_value, callback_cb_name, step):
        row = gui.TableRow()
        param_name = gui.Label(NAME_L_SIZE, FIELD_HEIGHT, param_name)
        param_name.attributes['title'] = description
        min_val = gui.Label(MIN_L_SIZE, FIELD_HEIGHT, str(range_min))
        range_slider = gui.Slider(SLIDER_SIZE,
                                  FIELD_HEIGHT,
                                  defaultValue=current_value,
                                  min=range_min,
                                  max=range_max,
                                  step=step)
        range_slider.set_on_change_listener(self, callback_cb_name)
        max_val = gui.Label(MAX_L_SIZE, FIELD_HEIGHT, str(range_max))
        spin_val = gui.SpinBox(EDIT2_SIZE,
                               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(self, callback_cb_name)

        item = gui.TableItem()
        item.append(0, param_name)
        row.append(0, item)

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

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

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

        item = gui.TableItem()
        item.append(4, spin_val)
        row.append(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]
Exemplo n.º 12
0
 def _getLabelBox(self, width, height):
     box = gui.HBox(width=width - 20, height=height, margin='0px auto')
     # index
     box.append(self.__playingMark, '0')
     box.append(gui.Label(text=str(self._index) + ':'), '1')
     box.append(self._getIcon(self._node), '2')
     box.append(gui.Label(text=self._node.label), '3')
     if self._node.isLeaf:
         box.set_on_click_listener(self._playNodeOnClick)
     else:
         box.set_on_click_listener(self._openNodeOnClick)
     return box
Exemplo n.º 13
0
    def nutrients_clicked(self, widget):
        nutrients_setpoints = self.read_from_pickle("nutrients_setpoints")
        ph_value = self.read_from_pickle("ph_sensor")

        self.nutrients_control = gui.GenericDialog(title='Nutrient Control',
                                                   width='100%',
                                                   height='100%')
        nutrients_container = gui.Widget(width='100%',
                                         height='100%',
                                         margin='0px auto',
                                         style={
                                             'text-align': 'center',
                                             'display': 'block',
                                             'overflow': 'auto'
                                         })
        self.ph_label = gui.Label('pH setpoint: ' +
                                  str(nutrients_setpoints['ph']),
                                  width='100%',
                                  height=30,
                                  margin='0px')
        self.ph_slider = gui.Slider(nutrients_setpoints['ph'],
                                    0,
                                    14,
                                    0.25,
                                    width='80%',
                                    height=30,
                                    margin='20px')
        self.ph_slider.onchange.do(self.ph_slider_changed)
        self.ph_sensor_label = gui.Label('current reservoir pH: ',
                                         width='100%',
                                         height=30,
                                         margin='0px')

        spacer = gui.Widget(width='100%',
                            height=75,
                            margin='0px auto',
                            style={
                                'display': 'block',
                                'overflow': 'auto'
                            })
        spacer_label = gui.Label('', width='100%', height=20, margin='0px')

        nutrients_container.append([
            spacer_label, self.ph_label, self.ph_slider, self.ph_sensor_label,
            spacer
        ])
        self.nutrients_control.add_field("nutrients", nutrients_container)
        self.nutrients_control.confirm_dialog.do(self.nutrients_confirm)

        self.ph_sensor_label.set_text("current reservoir pH: " +
                                      str(ph_value["ph"]))

        self.nutrients_control.show(self)
Exemplo n.º 14
0
    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
Exemplo n.º 15
0
    def main(self):
        while True:
           print("Inside")
           global bpm, emg, accelX, accelY, accelZ, tempF, hr, spo2, leftButton, rightButton, data
           container = gui.VBox(width=500, height=200)
           self.lbl = gui.Label('Hello world!')
           self.emgLabel = gui.Label("EMG: ")
           self.tempLabel = gui.Label("Temp: ")
           self.hrLabel = gui.Label("HR: ")
           self.spo2Label = gui.Label("SpO2: ")
           self.xLabel = gui.Label("Accel-X: ")
           self.yLabel = gui.Label("Accel-Y: ")
           self.zLabel = gui.Label("Accel-Z: ")
           self.bt = gui.Button('Press me!')

           self.update = True
           # setting the listener for the onclick event of the button
           self.bt.onclick.do(self.on_button_pressed)

           # appending a widget to another, the first argument is a string key
           container.append(self.lbl)
           container.append(self.emgLabel)
           container.append(self.tempLabel)
           container.append(self.hrLabel)
           container.append(self.spo2Label)
           container.append(self.xLabel)
           container.append(self.yLabel)
           container.append(self.zLabel)
           container.append(self.bt)

           # returning the root widget
           return container
Exemplo n.º 16
0
    def main(self):
        # margin 0px auto allows to center the app to the screen

        horizontalContainer = gui.Widget(
            width='80%',
            layout_orientation=gui.Widget.LAYOUT_VERTICAL,
            margin='0px auto',
            style={
                'display': 'block',
                'overflow': 'auto',
                'background-color': '#b6b6b6'
            })

        wid = gui.VBox(width=300, height=200, margin='0px auto')

        self.lbl = gui.Label('Thread result:', width='80%', height='50%')
        self.lbl.style['margin'] = 'auto'

        self.lbl1 = gui.Label('bottom text')
        self.lbl1.style['margin'] = 'auto'

        bt = gui.Button('Start algorithm', width=200, height=30)
        bt.style['margin'] = 'auto 50px'
        bt.style['background-color'] = 'red'

        bt1 = gui.Button('Stop algorithm', width=200, height=30)
        bt1.style['margin'] = 'auto 50px'
        bt1.style['background-color'] = 'red'

        bt2 = gui.Button('Stop algorithm', width=200, height=30)
        bt2.style['margin'] = 'auto 50px'
        bt2.style['background-color'] = 'red'

        wid.append(self.lbl)
        wid.append(bt)
        wid.append(bt1)
        wid.append(bt2)
        wid.append(self.lbl1)

        self.thread_alive_flag = False
        self.my_thread_result = "Not started yet"

        bt.set_on_click_listener(self.on_button_pressed)
        bt1.set_on_click_listener(self.off_button_pressed)
        bt2.set_on_click_listener(self.add_field)

        horizontalContainer.append([wid])

        # returning the root widget
        return horizontalContainer
Exemplo n.º 17
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
Exemplo n.º 18
0
    def buildRow(self, rowName, rowStatus, header=False):
        gridStyle = {
            'grid-template-columns': '33% 33% 33%',
            'margin': '0px auto'
        }

        headerStyle = {
            'background-color': 'lavender',
            'text-align': 'center',
            'vertical-align': 'middle',
            'font-weight': 'bold'
        }
        rowStyle = {'text-align': 'center', 'vertical-align': 'middle'}
        nameLabel = gui.Label(rowName, style=rowStyle)
        statusLabel = gui.Label(rowStatus, style=rowStyle)

        # need to reconcile what's in the directory when we startup with the statuses on the table.
        if Path(f"{sem_path}/{rowName}").exists():
            statusLabel.style['background-color'] = 'lightcoral'
            statusLabel.text = 'Blocked'
        else:
            statusLabel.style['background-color'] = 'lightgreen'
            statusLabel.text = 'Open'

        if header:
            changeButton = gui.Label("Change")
            changeButton.style.update(headerStyle)
            nameLabel.style.update(headerStyle)
            statusLabel.style.update(headerStyle)
            height = 25
        else:
            changeButton = gui.Button("ChangeState")
            changeButton.associatedLabel = statusLabel
            self.statuses[rowName] = statusLabel
            changeButton.onclick.do(self.on_change_rule_state, statusLabel,
                                    rowName)
            height = 50

        gridContainer = gui.GridBox(width='100%',
                                    height=height,
                                    style=gridStyle)
        gridContainer.set_from_asciiart(
            '|name                           |status        |change        |')
        gridContainer.append({
            'name': nameLabel,
            'status': statusLabel,
            'change': changeButton
        })
        return gridContainer
Exemplo n.º 19
0
    def __init__(self, appInstance, **kwargs):
        super(EditorAttributes, self).__init__(**kwargs)
        self.EVENT_ATTRIB_ONCHANGE = 'on_attribute_changed'
        self.style['overflow-y'] = 'scroll'
        self.style['justify-content'] = 'flex-start'
        self.style['-webkit-justify-content'] = 'flex-start'
        self.titleLabel = gui.Label('Attributes editor')
        self.infoLabel = gui.Label('Selected widget: None')
        self.append(self.titleLabel)
        self.append(self.infoLabel)

        self.titleLabel.style['order'] = '-1'
        self.titleLabel.style['-webkit-order'] = '-1'
        self.infoLabel.style['order'] = '0'
        self.infoLabel.style['-webkit-order'] = '0'

        self.attributesInputs = list()
        #load editable attributes
        self.append(self.titleLabel)
        self.attributeGroups = {}
        for attributeName in html_helper.editorAttributeDictionary.keys():
            attributeEditor = EditorAttributeInput(
                attributeName,
                html_helper.editorAttributeDictionary[attributeName],
                appInstance)
            attributeEditor.set_on_attribute_change_listener(
                self, "onattribute_changed")
            #attributeEditor.style['display'] = 'none'
            if not html_helper.editorAttributeDictionary[attributeName][
                    'group'] in self.attributeGroups.keys():
                groupContainer = EditorAttributesGroup(
                    html_helper.editorAttributeDictionary[attributeName]
                    ['group'],
                    width='100%')
                self.attributeGroups[html_helper.editorAttributeDictionary[
                    attributeName]['group']] = groupContainer
                self.append(groupContainer)
                groupContainer.style['order'] = str(
                    html_helper.editorAttributesGroupOrdering[
                        html_helper.editorAttributeDictionary[attributeName]
                        ['group']])
                groupContainer.style['-webkit-order'] = str(
                    html_helper.editorAttributesGroupOrdering[
                        html_helper.editorAttributeDictionary[attributeName]
                        ['group']])

            self.attributeGroups[html_helper.editorAttributeDictionary[
                attributeName]['group']].append(attributeEditor)
            self.attributesInputs.append(attributeEditor)
Exemplo n.º 20
0
    def main(self):        
        #creating two "pages" widgets to be shown alternatively
        lbl = gui.Label("Page 2. Press the button to change the page.", style={'font-size':'20px'})
        bt2 = gui.Button("change page")
        page2 = gui.HBox(children=[lbl, bt2], style={'margin':'0px auto', 'background-color':'lightgray'})
        
        lbl = gui.Label("Page 1. Press the button to change the page.", style={'font-size':'20px'})
        bt1 = gui.Button("change page")
        page1 = gui.VBox(children=[lbl, bt1], style={'width':'300px', 'height':'200px', 'margin':'0px auto', 'background-color':'white'})

        bt1.set_on_click_listener(self.set_different_root_widget, page2)
        bt2.set_on_click_listener(self.set_different_root_widget, page1)

        # returning the root widget
        return page1
Exemplo n.º 21
0
    def on_button_show_rsc(self, emitter):

        # Clear view w/ message
        self.action_wait()

        # get data
        self.rscs = cluster.get_rd()

        # Clear wait message
        self.view_clear()

        if self.rscs:
            for rsc in self.rscs:
                # A display row for each resources
                row = gui.HBox(style={'border':'1px solid gray', 'margin':'10px', 'text-align':'left'})
                self.disp_rsc_row.append(row)

                # Add row heading
                lbl_msg = str(self.disp_rsc_row_count) + '. Resource: ' + rsc['rsc_name']
                lbl = gui.Label(lbl_msg)
                self.disp_rsc_row[self.disp_rsc_row_count].append(lbl, 'rsc_name')
                print(lbl_msg)

                # Populate the row w/ resource nodes
                rsc_nodes = cluster.get_rsc_by_rsc(rsc['rsc_name'])
                self.rsc_row_add(rsc_nodes, row=self.disp_rsc_row_count)

                self.disp_rsc_row_count += 1
                print('Rsc count: ' + str(self.disp_rsc_row_count))
        else:
            lbl_msg = 'No LINSTOR Resources found'
            self.add_view_line(lbl_msg)

        # Add widgets for Resource Create
        row = gui.HBox(style={'border':'1px solid gray', 'margin':'10px', 'text-align':'left'})
        self.disp_rsc_row.append(row)

        lbl_rsc_create_msg = 'Create a new resource volume'
        lbl_rsc_create = gui.Label(lbl_rsc_create_msg)
        bt_rsc_create = gui.Button('Proceed', width=200, height=30, margin='10px')
        bt_rsc_create.onclick.connect(self.rsc_create)

        self.disp_rsc_row[self.disp_rsc_row_count].append(lbl_rsc_create, 'lbl')
        # text window is global for proper live look up
        self.disp_rsc_row[self.disp_rsc_row_count].append(self.txt_rsc_create, 'new_rsc')
        self.disp_rsc_row[self.disp_rsc_row_count].append(bt_rsc_create, 'btn')
        self.disp_rsc_row_count += 1
        self.view_container.append(self.disp_rsc_row, 'rsc_list')
Exemplo n.º 22
0
    def main(self):
        # build UI
        main_container = gui.VBox(style={'margin': '0px auto'})
        self.lbl_result = gui.Label("")
        self.button_0 = gui.Button("Positive",
                                   width=200,
                                   height=30,
                                   margin='10px')
        self.button_0.set_on_click_listener(self.on_button_0)
        self.button_1 = gui.Button("Negative",
                                   width=200,
                                   height=30,
                                   margin='10px')
        self.button_1.set_on_click_listener(self.on_button_1)
        self.button_2 = gui.Button("No Feedback",
                                   width=200,
                                   height=30,
                                   margin='10px')
        self.button_2.set_on_click_listener(self.on_button_2)
        self.button_3 = gui.Button("Done", width=200, height=30, margin='10px')
        self.button_3.set_on_click_listener(self.on_button_3)
        self.lbl = gui.Label("Compelete!")
        main_container.append([
            self.lbl_result, self.button_0, self.button_1, self.button_2,
            self.button_3, self.lbl
        ])

        self.P_a = [
            0.5, 0.8
        ]  #the probability of getting reward for a_0 and a_1 respectively

        self.sigma = np.ones(2) * 3
        self.h_n = np.zeros([N_S, N_ACT, 3])
        self.p = np.ones([
            N_S, N_ACT
        ]) * 1 / N_ACT  # initial probability that choosing different as
        #        self.record_n = np.zeros(2)
        self.a = int(random.randint(0, N_ACT - 1))  #choose an arm randomly
        self.take_action(self.a)
        self.state = 0
        self.record_n[self.state, self.a] = 1
        self.lamda = np.random.randint(N_ACT, size=N_S)
        #        print(self.record_n)
        self.lbl_result.set_text("The light is %s, the state is %s" %
                                 (str(self.a), str(current_s(self.state))))
        self.iterations = 0
        self.record_a[self.state, self.iterations] = self.a
        return main_container
Exemplo n.º 23
0
    def main(self):
        container = gui.VBox(width = 600, height = 800)
        self.lbl = gui.Label('Hello world!')
        self.btFindStar = gui.Button('FIND_STAR')
        self.btCalibrate = gui.Button('CALIBRATE')
        self.btStartGuide = gui.Button('START GUIDE')
        self.btStopGuide = gui.Button('STOP GUIDE')
        self.gain = gui.Slider(10, 0, 100, 5, width=200, height=20, margin='10px')
        self.gain.set_on_change_listener(self.slider_changed)
	self.image_widget = PILImageViewverWidget(width=200, height=200)

        # setting the listener for the onclick event of the button
        self.btFindStar.set_on_click_listener(self.on_button_pressed)
        self.btCalibrate.set_on_click_listener(self.on_button_pressed)
        self.btStartGuide.set_on_click_listener(self.on_button_pressed)
        self.btStartGuide.set_on_click_listener(self.StartGuide)
        self.btStopGuide.set_on_click_listener(self.StopGuide)

        # appending a widget to another, the first argument is a string key
        container.append(self.image_widget)
        container.append(self.lbl)
        container.append(self.btFindStar)
        container.append(self.btCalibrate)
        container.append(self.btStartGuide)
        container.append(self.btStopGuide)
        container.append(self.gain)

	self.image()
	self.image_widget.load('/home/pi/linguider.png')
        # returning the root widget
        return container
Exemplo n.º 24
0
    def main(self, name='world'):
        #margin 0px auto allows to center the app to the screen
        wid = gui.VBox(width=300, height=200, margin='0px auto')
        lbl = gui.Label('Hello %s!' % name, width='80%', height='50%')
        lbl.style['margin'] = 'auto'

        bt = gui.Button('Press me!', width=200, height=30)
        bt.style['margin'] = 'auto 50px'

        # setting the listener for the onclick event of the button
        self.npressed = 0

        bt.set_on_click_listener(self.on_button_pressed, lbl)
        bt.set_on_mousedown_listener(self.on_button_mousedown, 'data1', 2,
                                     'three')

        #this will never be called, can't register an event more than one time
        bt.set_on_mouseup_listener(self.on_button_mouseup, 'data1')

        # appending a widget to another, the first argument is a string key
        wid.append(lbl)
        wid.append(bt)

        # returning the root widget
        return wid
Exemplo n.º 25
0
    def main(self):
        wid = gui.HBox()
        wid.style['position'] = 'absolute'
        ctrl = gui.VBox(width=400)
        ctrl.style['justify-content'] = 'space-around'

        plotContainer = gui.Widget()

        plt = PlotlyWidget(data=self.data, id='plot')
        self.plt = plt
        plotContainer.append(plt)

        self.historyBox = LabelSpinBox(default_value=100, min=1, max=10000000,
                                       step=1, label='history')

        lbl = gui.Label('GUI')

        bt = gui.Button('Start', width=200, height=30)
        bt.style['margin'] = 'auto 50px'
        bt.style['background-color'] = 'green'

        self.started = False

        # setting the listener for the onclick event of the button
        bt.set_on_click_listener(self.on_button_pressed, ctrl)

        ctrl.append(lbl)
        ctrl.append(self.historyBox)
        ctrl.append(bt)

        # returning the root widget
        wid.append(ctrl)
        wid.append(plotContainer)

        return wid
Exemplo n.º 26
0
    def __init__(self, appInstance, **kwargs):
        super(WorkflowWidget, self).__init__(**kwargs)

        self._appInstance = appInstance
        self.paramsWidget = None

        self.lblTitle = gui.Label("Workflow editor")
        self.lblTitle.add_class("DialogTitle")

        self.createMainMenu()
        self.listView = gui.ListView(width='100%', height='85%')
        self.listView.style['left'] = '0%'
        self.listView.style['overflow-y'] = 'scroll'
        self.listView.style['overflow-x'] = 'hidden'
        self.listView.style['flex-wrap'] = 'wrap'
        self.listView.style['background-color'] = 'white'

        self._moduleList = ModuleList(self.listView, appInstance)

#        self.style['margin'] = '0px'

        self.append(self.lblTitle)
        self.append(self.listView)

        self.listView.set_on_selection_listener(self.moduleSelected)
Exemplo n.º 27
0
    def construct_tabview(self):
        # make tab bar as wide as the frame
        if self.bar_width < self.frame_width:
            blank_width = self.frame_width - self.bar_width
            but = gui.Button('', width=blank_width, height=self.bar_height)
            self.tab_bar.append(but, key='xxblank')
            self.bar_width = self.frame_width

        self.tab_bar.style['width'] = gui.to_pix(self.bar_width)
        self.tab_title = gui.Label('fred',
                                   width=self.frame_width - 30,
                                   height=20)
        self.tab_title.style['margin'] = '2px'

        # frame for the tab panel, different tabs are switched into this frame.
        self.tab_frame = gui.Container(width=self.frame_width,
                                       height=self.frame_height)  #0
        self.tab_frame.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)

        # add the bar, panels and title to the subclassed Widget
        self.append(self.tab_bar, key='tab_bar')
        self.append(self.tab_title, key='tab_title')
        self.append(self.tab_frame, key='tab_frame')
        self.set_size(self.bar_width, self.frame_height + 100)
        return self
Exemplo n.º 28
0
 def __init__(self, **kwargs):
     super(SignalConnectionManager, self).__init__(**kwargs)
     self.label = gui.Label('Signal connections')
     self.append(self.label)
     self.container = gui.VBox(width='100%')
     self.container.style['overflow-y'] = 'scroll'
     self.listeners_list = []
Exemplo n.º 29
0
    def __init__(self, param, appInstance=None):
        super(EditorAttributeInput, self).__init__()

        self._param = param
        attributeName = self._param._k
        attributeDesc = self._param._description

        self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        self.style['display'] = 'block'
        self.style['overflow'] = 'auto'
        self.style['margin'] = '2px'
        self.attributeName = attributeName
        self.EVENT_ATTRIB_ONCHANGE = 'on_attribute_changed'

        self.EVENT_ATTRIB_ONREMOVE = 'onremove_attribute'
        self.removeAttribute = gui.Image('/res/delete.png', width='5%')
        self.removeAttribute.attributes[
            'title'] = 'Remove attribute from this widget.'
        self.removeAttribute.set_on_click_listener(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.append(self.label)
        self.label.attributes['title'] = attributeDesc

        self.__createEditor()

        self.style['display'] = 'block'
        self.set_valid(True)
Exemplo n.º 30
0
    def __init__(self, widget, listenersList, eventConnectionFuncName,
                 eventConnectionFunc, **kwargs):
        super(SignalConnection, self).__init__(**kwargs)
        self.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        self.style['overflow'] = 'hidden'
        self.label = gui.Label(eventConnectionFuncName, width='49%')
        self.label.style['float'] = 'left'
        self.label.style['font-size'] = '10px'
        self.label.style['overflow'] = 'hidden'

        self.dropdown = gui.DropDown(width='49%', height='100%')
        self.dropdown.set_on_change_listener(self, "on_connection")
        self.append(self.label)
        self.append(self.dropdown)
        self.dropdown.style['float'] = 'right'

        self.eventConnectionFunc = eventConnectionFunc
        self.eventConnectionFuncName = eventConnectionFuncName
        self.refWidget = widget
        self.listenersList = listenersList
        self.dropdown.append(gui.DropDownItem("None"))
        for w in listenersList:
            ddi = gui.DropDownItem(w.attributes['editor_varname'])
            ddi.listenerInstance = w
            self.dropdown.append(ddi)
        #selecting in the dropdown the already connected varname
        if self.eventConnectionFunc._event_listener[
                'eventName'] in self.refWidget.eventManager.listeners.keys():
            if self.refWidget.eventManager.listeners[
                    self.eventConnectionFunc._event_listener['eventName']][
                        'instance'] in self.listenersList:
                connectedListenerName = self.refWidget.eventManager.listeners[
                    self.eventConnectionFunc._event_listener['eventName']][
                        'instance'].attributes['editor_varname']
                self.dropdown.set_value(connectedListenerName)