Beispiel #1
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
Beispiel #2
0
    def main(self):
        verticalContainer = gui.Container(width='100%',
                                          margin='0px auto',
                                          style={
                                              'display': 'block',
                                              'overflow': 'hidden'
                                          })

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

        self.btn = gui.Button(text="okay")
        self.btn2 = gui.Button(text="nggak okay")
        self.btn3 = gui.Button(text='ini yang ketiga')
        self.container = gui.Container(
            width='100%',
            layout_orientation=gui.Container.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'display': 'block',
                'overflow': 'auto'
            })
        self.h = Container(self)
        self.container.append(self.h)
        horizontalContainer.append(
            [self.btn, self.btn2, self.btn3, self.container])

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

        menu.append([m1])
        m1.append([m11, m12])

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

        return verticalContainer
Beispiel #3
0
    def createMenu(self):
        self.menubar = gui.MenuBar(height='4%')
        menu = gui.Menu(width='100%', height='100%')
        menu.style['z-index'] = '1'
        m1 = gui.MenuItem('File', width=150, height='100%')
        m10 = gui.MenuItem('New', width=150, height=30)
        m11 = gui.MenuItem('Open', width=150, height=30)
        m12 = gui.MenuItem('Save Job...', width=150, height=30)
        #m12.style['visibility'] = 'hidden'
        m121 = gui.MenuItem('Save', width=100, height=30)
        m122 = gui.MenuItem('Save as', width=100, height=30)
        m1.append(m10)
        m1.append(m11)
        m1.append(m12)
        m12.append(m121)
        m12.append(m122)

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

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

        menu.append(m1)
#        menu.append(m2)
        menu.append(m3)
        menu.append(m4)
        
        self.menubar.append(menu)


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

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

        m3.set_on_click_listener(self.menu_project_config_clicked)
        m4.set_on_click_listener(self.menu_spark_clicked)
Beispiel #4
0
    def append_menubar(self, container):
        #menubar
        menu = gui.Menu(width='100%', height='30px')
        menu_index = gui.MenuItem('Index', width=100, height=30)
        menu_editor = gui.MenuItem('Editor', width=100, height=30)
        menu_bash = gui.MenuItem("Bash", width=100, height=30)
        menu_ftp = gui.MenuItem("FTP", width=100, height=30)
        menu_index.set_on_click_listener(self.menu_index_clicked)
        menu_editor.set_on_click_listener(self.menu_editor_clicked)
        menu_bash.set_on_click_listener(self.menu_bash_clicked)
        menu_ftp.set_on_click_listener(self.menu_ftp_clicked)

        menu.append(menu_index)
        menu.append(menu_bash)
        menu.append(menu_editor)
        menu.append(menu_ftp)
        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.append(menu)
        container.append(menubar)
        return container
Beispiel #5
0
    def main(self):
        self.fig = ''
        self.ax = ''
        self.plt = ''
        self.datarom = ''
        menuBar = gui.MenuBar(width='100%', height='50px')
        menu = gui.Menu(width='100%', height='50px')
        diag = gui.MenuItem('Filters', width=100, height=50)
        diag.onclick.do(self.filtersMenu)
        menu.append(diag)
        menuBar.style['align-items'] = 'flex-start'
        menuBar.style['align-items'] = 'flex-start'
        menu.style['justify-content'] = 'flex-start'
        menu.style['justify-content'] = 'flex-start'

        #menuBar.style['align-items'] = 'center'
        #menu.style['align-items'] = 'center'
        menuBar.append(menu)
        self.menu = menu
        self.hbox = gui.VBox(width=600)
        self.hbox.style['margin'] = 'auto'
        #self.hbox.style['align-items'] = 'center'
        self.hbox.append(menuBar)
        fig, ax = plt.subplots()
        lbls, sizes = [], []
        for i in data:
            if filt[i[0]] and filt[i[2]]:
                lbls.append(i[0] + ':' + i[2])
                sizes.append(i[1])
        ax.pie(sizes, labels=lbls)
        ax.axis('equal')
        self.fig = fig
        self.ax = ax
        self.plt = plt
        self.canv = FigureCanvasAgg(self.fig)
        plt.savefig('temp.png')
        self.img = gui.Image(self.draw())
        self.hboxIMG = gui.VBox(width=600)
        self.hboxIMG.append(self.img)
        self.hbox.append(self.hboxIMG)
        return self.hbox
Beispiel #6
0
    def hidemain(self):

        ## the containers the hold the stuff we want to see
        #mainContainer = gui.Container(width='95%', margin='0px auto',
        #                              style={'display': 'block', 'overflow': 'hidden'})

        self.contentContainer = DEFAULT_VISIBLE_CONTAINER()

        ## Core Menu Items
        menu = gui.Menu(width='100%', height='50px')
        mwidth = get_percent(4)
        mheight = 50
        m1 = gui.MenuItem('Current Discussion', width=mwidth, height=mheight)
        m2 = gui.MenuItem('Discussion History', width=mwidth, height=mheight)
        m3 = gui.MenuItem('Plan Next Discussion', width=mwidth, height=mheight)
        m4 = gui.MenuItem('Logout', width=mwidth, height=mheight)
        menu.append([m1, m2, m3, m4])

        m1.onclick.do(partial(self.top_menu_clicked, MENU_CURR_DISC))
        m2.onclick.do(partial(self.top_menu_clicked, MENU_DISC_HIST))
        m3.onclick.do(partial(self.top_menu_clicked, MENU_PLAN_NEXT))
        m4.onclick.do(self.logout)
        #adding in the menu bar and addint it to
        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.append(menu)
        #mainContainer.append([menubar, self.contentContainer])

        self.create_top_menu_objects()

        if (self.userProfile.demo):
            classifierSwitchMsg = "Switch to Classifier Labels" if not self.classifier else "Switch to Gold Labels"
            self.classifierSwitch = gui.Button(classifierSwitchMsg,
                                               margin="5px auto")
            self.classifierSwitch.onclick.do(self.switchClassifierGold)
        # returning the root widget
        #return mainContainer
        return [menubar, self.contentContainer, self.classifierSwitch]
Beispiel #7
0
    def main(self):
        # the margin 0px auto centers the main container
        verticalContainer = gui.Container(width=540, margin='0px auto', style={'display': 'block', 'overflow': 'hidden'})

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        horizontalContainer.append([subContainerLeft, subContainerRight])

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

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

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

        verticalContainer.append([menubar, horizontalContainer])

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

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

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

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

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

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

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

        menubar.append(menu)

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

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

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

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

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

        m3.onclick.connect(self.menu_project_config_clicked)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.menu_new_clicked(None)

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

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

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

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

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

        menu.append(m1)
        menu.append(m2)
        menu.append(m3)

        menubar.append(menu)

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

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

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

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

        m3.set_on_click_listener(self.menu_project_config_clicked)

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

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

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

        self.project.attributes['ondragover'] = "event.preventDefault();"
        self.EVENT_ONDROPPPED = "on_dropped"
        self.project.attributes['ondrop'] = """event.preventDefault();
                var data = JSON.parse(event.dataTransfer.getData('application/json'));
                var params={};
                if( data[0] == 'resize'){
                    document.getElementById(data[1]).style.left = parseInt(document.getElementById(data[1]).style.left) + event.clientX - data[2] + 'px';
                    document.getElementById(data[1]).style.top = parseInt(document.getElementById(data[1]).style.top) + event.clientY - data[3] + 'px';
                    params['left']=document.getElementById(data[1]).style.left;
                    params['top']=document.getElementById(data[1]).style.top;
                }
                if( data[0] == 'add'){
                    params['left']=event.clientX-event.currentTarget.getBoundingClientRect().left;
                    params['top']=event.clientY-event.currentTarget.getBoundingClientRect().top;
                }
                if( data[0] == 'move'){
                    document.getElementById(data[1]).style.left = parseInt(document.getElementById(data[1]).style.left) + event.clientX - data[2] + 'px';
                    document.getElementById(data[1]).style.top = parseInt(document.getElementById(data[1]).style.top) + event.clientY - data[3] + 'px';
                    params['left']=document.getElementById(data[1]).style.left;
                    params['top']=document.getElementById(data[1]).style.top;
                }
                
                sendCallbackParam(data[1],'%(evt)s',params);
                
                return false;""" % {
            'evt': self.EVENT_ONDROPPPED
        }
        self.project.attributes['editor_varname'] = 'App'
        self.project.attributes[self.project.EVENT_ONKEYDOWN] = """
                var params={};
                params['keypressed']=event.keyCode;
                sendCallbackParam('%(id)s','%(evt)s',params);
                if(event.keyCode==46){
                    return false;
                }
            """ % {
            'id': str(id(self)),
            'evt': self.project.EVENT_ONKEYDOWN
        }

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

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

        self.mainContainer.append(menubar)
        self.mainContainer.append(self.subContainer)

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

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

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

        self.instancesWidget = editor_widgets.InstancesWidget(width='100%')
        self.instancesWidget.dropDown.set_on_change_listener(
            self.on_instances_widget_selection)

        self.subContainerRight.append(self.instancesWidget)
        self.subContainerRight.append(self.attributeEditor)

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

        self.resizeHelper = ResizeHelper(width=16, height=16)
        self.dragHelper = DragHelper(width=15, height=15)
        self.menu_new_clicked(None)

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

        # returning the root widget
        return self.mainContainer
Beispiel #10
0
 def test_init(self):
     widget = gui.MenuBar()
     assertValidHTML(widget.repr())
Beispiel #11
0
    def main(self):
        # the margin 0px auto centers the main container
        verticalContainer = gui.Widget(width='100%',
                                       height='100%',
                                       margin='0px auto',
                                       style={
                                           'display': 'block',
                                           'overflow': 'hidden'
                                       })

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

        self.simage = LiveImage("./image.jpg",
                                width='46%',
                                height='80%',
                                margin='2%')

        sensor_container = gui.Widget(width='46%',
                                      height='100%',
                                      margin='2%',
                                      style={
                                          'text-align': 'center',
                                          'display': 'block',
                                          'overflow': 'hidden'
                                      })
        leaf = gui.Widget(width='100%',
                          height='50%',
                          margin='0px auto',
                          style={
                              'text-align': 'center',
                              'display': 'block',
                              'overflow': 'hidden'
                          })
        root = gui.Widget(width='100%',
                          height='50%',
                          margin='0px auto',
                          style={
                              'text-align': 'center',
                              'display': 'block',
                              'overflow': 'hidden'
                          })

        leaf_header = gui.Label('Leaf Chamber',
                                width='100%',
                                height=30,
                                margin='0px')
        root_header = gui.Label('Root Chamber',
                                width='100%',
                                height=30,
                                margin='0px')

        leaf_sensors = gui.Widget(
            width='100%',
            layout_orientation=gui.Widget.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'text-align': 'center',
                'display': 'block',
                'overflow': 'auto'
            })
        root_sensors = gui.Widget(
            width='100%',
            layout_orientation=gui.Widget.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'text-align': 'center',
                'display': 'block',
                'overflow': 'auto'
            })

        self.leaf_t = gui.Label(' C', width='50%', height=30, margin='0px')
        self.leaf_rh = gui.Label('% RH', width='50%', height=30, margin='0px')

        self.root_t = gui.Label(' C', width='50%', height=30, margin='0px')
        self.root_rh = gui.Label('% RH', width='50%', height=30, margin='0px')

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

        menu_height = 30
        menu = gui.Menu(width='100%', height=str(menu_height) + 'px')
        light = gui.MenuItem('Light', width='25%', height=menu_height)
        mist = gui.MenuItem('Mist', width='25%', height=menu_height)
        fan = gui.MenuItem('Fan', width='25%', height=menu_height)
        nutrients = gui.MenuItem('Nutrients', width='25%', height=menu_height)
        light.onclick.do(self.light_clicked)
        mist.onclick.do(self.mist_clicked)
        fan.onclick.do(self.fan_clicked)
        nutrients.onclick.do(self.nutrients_clicked)
        menu.append([light, mist, fan, nutrients])
        menubar = gui.MenuBar(width='100%', height=str(menu_height) + 'px')
        menubar.append(menu)

        leaf_sensors.append([self.leaf_t, self.leaf_rh])
        root_sensors.append([self.root_t, self.root_rh])

        leaf_sensors.style['background-color'] = 'gray'
        root_sensors.style['background-color'] = 'gray'
        leaf_header.style['background-color'] = 'gray'
        root_header.style['background-color'] = 'gray'

        leaf.append([leaf_header, leaf_sensors])
        root.append([root_header, root_sensors])
        sensor_container.append([spacer, leaf, spacer2, root])

        horizontalContainer.append([sensor_container, self.simage])

        verticalContainer.append([menubar, horizontalContainer])

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

        # returning the root widget
        return verticalContainer
Beispiel #12
0
    def main(self):
        verticalContainer = gui.Widget(640, 900, gui.Widget.LAYOUT_VERTICAL,
                                       10)

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

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

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

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

        self.count = 0
        self.counter = gui.Label(200, 30, '')

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

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

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

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

        self.check = gui.CheckBoxLabel(200, 30, 'Label checkbox', True)
        self.check.set_on_change_listener(self, 'on_check_change')

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

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

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

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

        self.link = gui.Link(200, 20, "http://localhost:8081",
                             "A link to here")

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

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

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

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

        self.video = gui.VideoPlayer(
            480, 270, 'http://www.w3schools.com/tags/movie.mp4',
            'http://www.oneparallel.com/wp-content/uploads/2011/01/placeholder.jpg'
        )

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

        subContainerLeft.append('0', self.img)
        subContainerLeft.append('1', self.table)
        subContainerLeft.append('2', self.listView)
        subContainerLeft.append('3', self.link)
        subContainerLeft.append('4', self.video)

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

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

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

        menubar = gui.MenuBar(620, 30)
        menubar.append('1', menu)

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

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

        # returning the root widget
        return verticalContainer
Beispiel #13
0
    def main(self):
        with open("todo.json", "r") as todos:
            todo_list = json.load(todos)
            self.assistant = PersonalAssistant(todo_list)

        container = gui.VBox(
            width=500,
            height="auto",
            margin="0px auto",
            style={
                "display": "block",
                "min-height": "300px",
                "overflow": "hidden",
                "box-shadow": "none",
                "border": "1px solid #d7d7d7",
                "padding-bottom": "10px",
            },
        )

        menu = gui.Menu(
            width="100%",
            height="30px",
            style={
                "display": "relative",
                "background-color": "#58CCE0",
                "padding-top": "0",
            },
        )
        menubar = gui.MenuBar(
            width="100%",
            height="30px",
            style={
                "display": "relative",
                "margin-bottom": "16px",
                "padding-top": "0"
            },
        )
        menubar.append(menu)
        container.append(menubar)

        self.errors = gui.ListView()
        self.errors.attributes["class"] += " errors"

        container.append(self.errors)

        self.label = gui.Label("How can I help you?"
                               " 🤖",
                               width=340,
                               height=10)
        self.label.set_style({
            "font-size": "24px",
            "font-family": "'Montserrat', 'Arial', san-serif",
            "font-weight": "bold",
            "color": "#3b3b3b",
            "text-transform": "uppercase",
            "text-align": "center",
            "margin-bottom": "20px",
        })

        self.todoLabel = gui.Label("Manage to-dos", width=250, height=10)
        self.todoLabel.set_style(LABEL_STYLES)
        self.todoDropDown = gui.DropDown.new_from_list(
            ("Select an action", "Add a to-do", "Remove a to-do",
             "Get to-do list"),
            width=200,
            height=30,
            margin="15px",
        )
        self.todoDropDown.set_style({
            "font-size": "16px",
            "border": "none",
            "background-color": "#f5f5f5"
        })
        self.todoDropDown.select_by_value("")
        self.todoDropDown.onchange.connect(self.todo_drop_down_changed)

        self.birthdayLabel = gui.Label("Manage birthday dates list",
                                       width=250,
                                       height=15)
        self.birthdayLabel.set_style(LABEL_STYLES)
        self.birthdayDropDown = gui.DropDown.new_from_list(
            ("Select an action", "Add a birthday", "Remove a birthday",
             "Get birthday"),
            width=200,
            height=30,
            margin="10px",
        )
        self.birthdayDropDown.set_style({
            "font-size": "16px",
            "border": "none",
            "background-color": "#f5f5f5"
        })
        self.birthdayDropDown.select_by_value("")
        self.birthdayDropDown.onchange.connect(self.birthday_drop_down_changed)

        self.contactsLabel = gui.Label("Manage contacts list",
                                       width=250,
                                       height=15)
        self.contactsLabel.set_style(LABEL_STYLES)

        self.contactDropDown = gui.DropDown.new_from_list(
            ("Select an action", "Add a contact", "Remove a contact",
             "Get contact"),
            width=200,
            height=30,
            margin="10px",
        )
        self.contactDropDown.set_style({
            "font-size": "16px",
            "border": "none",
            "background-color": "#f5f5f5"
        })
        self.contactDropDown.select_by_value("")
        self.contactDropDown.onchange.connect(self.contact_drop_down_changed)

        container.append(self.label)
        container.append(self.todoLabel)
        container.append(self.todoDropDown)
        container.append(self.birthdayLabel)
        container.append(self.birthdayDropDown)
        container.append(self.contactsLabel)
        container.append(self.contactDropDown)

        # return of the root widget
        return container
    def main(self):
        ''' Define a main_window with select options and GUI language choice.'''
        # main_menu = ['Main Menu', 'Hoofdmenu']
        # login = ['Login/Register', 'Login/Registreer']
        read_file = ['Read file', 'Lees file']
        search = ['Search', 'Zoek']
        # query = ['Query', 'Vraag']
        admin = ['DB Admin', 'DB Admin']
        new_net = ['New network', 'Nieuw netwerk']
        save_as = ['Save net', 'Opslaan']
        manual = ['User manual', 'Handleiding']
        wiki = ['Gellish wiki', 'Gellish wiki']

        # Initialize user_db
        user_db = SU.UserDb()
        self.start_up(user_db)

        # Set GUI language default = English: GUI_lang_names[0]
        self.Set_GUI_language(self.GUI_lang_names[0])

        # Define main GUI window conform the REMI gui
        self.container = gui.Widget(margin='2px', style='background-color:#eeffdd')
        # self.container.set_size('100%', '100%')
        self.container.attributes['title'] = 'Communicator'

        # Menu bar
        self.menubar = gui.MenuBar(height=20, width='100%')
        self.container.append(self.menubar)

        import_text = ['Import one or more Gellish files', 'Lees een of meer Gellish files']
        self.read_file_tag = gui.MenuItem(read_file[self.GUI_lang_index], width=100, height=20)
        self.read_file_tag.attributes['title'] = import_text[self.GUI_lang_index]
        self.read_file_tag.onclick.connect(self.read_verify_and_merge_files)
        self.menubar.append(self.read_file_tag)

        self.search_tag = gui.MenuItem(search[self.GUI_lang_index], width=100, height=20)
        self.search_tag.attributes['title'] = 'Open a search window'
        self.search_tag.onclick.connect(self.search_net)
        self.menubar.append(self.search_tag)

        self.manual_tag = gui.MenuItem(manual[self.GUI_lang_index], width=100, height=20)
        self.manual_tag.attributes['title'] = 'Open the Communicator user manual'
        self.manual_tag.onclick.connect(self.user_manual)
        self.menubar.append(self.manual_tag)

        self.wiki_tag = gui.MenuItem(wiki[self.GUI_lang_index], width=100, height=20)
        self.wiki_tag.attributes['title'] = 'Open the Gellish languages wiki'
        self.wiki_tag.onclick.connect(self.open_wiki)
        self.menubar.append(self.wiki_tag)

        self.admin_tag = gui.MenuItem(admin[self.GUI_lang_index], width=100, height=20)
        self.admin_tag.attributes['title'] = 'Save network on file '\
                                             'or delete old and create new network'
        self.menubar.append(self.admin_tag)

        self.save_as_tag = gui.MenuItem(save_as[self.GUI_lang_index], width=100, height=20)
        self.save_as_tag.attributes['title'] = 'Save semantic network on binary file'

        self.admin_tag.append(self.save_as_tag)

        self.new_net_tag = gui.MenuItem(new_net[self.GUI_lang_index], width=100, height=20)
        self.new_net_tag.attributes['title'] = 'Delete old and create new semantic network'

        self.admin_tag.append(self.new_net_tag)

        # Define language selector
        self.lang_container = gui.HBox(width=180, height=20, style='margin-left:200px')

        lang_text = ['Language:', 'Taal:']
        self.lang_label = gui.Label(lang_text[self.GUI_lang_index], width=80, height=20,
                                    style='background-color:#eeffdd')
        self.lang_label.attributes['title'] = 'Select a language for specification of a search'

        self.lang_container.append(self.lang_label)
        # Set default language: GUI_lang_names[0] = English, [1] = Nederlands
        self.lang_default = self.GUI_lang_names[0]
        self.lang_select = gui.DropDown(self.GUI_lang_names, width=100, height=20,
                                        style='background-color:#ffffc0')
        self.lang_select.attributes['title'] = 'The language used for specification of a search'
        self.lang_container.append(self.lang_select)
        self.menubar.append(self.lang_container)

        # Binding GUI language choice
        self.lang_select.onchange.connect(self.Determine_GUI_language)

        # Main Frame
        self.main_frame = gui.VBox(width='100%', height='100%')
        self.container.append(self.main_frame)
        self.main_frame.attributes['color'] = 'green'

        self.query = None
        self.unknown = ['unknown', 'onbekend']
        self.unknown_quid = 0   # initial value of UID for unknowns in queries

        # Define a notebook in window
        self.Define_notebook()
        self.Define_log_sheet()

        # Start up semantic network
        self.start_net()
        # Create display views object
        self.views = Display_views(self.gel_net, self)
        self.save_as_tag.onclick.connect(self.gel_net.save_pickle_db)
        self.new_net_tag.onclick.connect(self.gel_net.reset_and_build_network)
        # If new network is only initialized and not built from files yet,
        # then build a semantic network from Gellish files.
        if self.net_built is False:
            self.gel_net.build_network()
            self.net_built = True

        # The REMI gui requires the return of the container root widget in main
        return self.container
Beispiel #15
0
    def main(self):
        """ GUI contains two vertical containers: Menu at top and all other widgets underneath
            It also contains three horizontal containers:
            Left one contains subject name widget, date, remarks & instructions.
            Middle containers is devoted for table with results.
            Right containers contains the analyze button and data visualization"""

        vertical_container = gui.Widget(width=1050,
                                        margin='0px auto',
                                        style={
                                            'display': 'block',
                                            'overflow': 'hidden'
                                        })
        horizontal_container = gui.Widget(
            width='100%',
            layout_orientation=gui.Widget.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'display': 'block',
                'overflow': 'auto'
            })

        sub_container_left = gui.Widget(width=300,
                                        style={
                                            'display': 'block',
                                            'overflow': 'auto',
                                            'text-align': 'center'
                                        })
        sub_container_right = gui.Widget(width=400,
                                         style={
                                             'display': 'block',
                                             'overflow': 'auto',
                                             'text-align': 'center'
                                         })
        sub_container_instructions = gui.Widget(width=250,
                                                height=450,
                                                margin='10px',
                                                style={
                                                    'display': 'block',
                                                    'overflow': 'auto',
                                                    'text-align': 'left'
                                                })
        """ Subject's number:"""
        self.txt_subject = gui.TextInput(width=230, height=35, margin='1px')
        self.txt_subject.set_text("Subject number")
        self.txt_subject.style['font-size'] = '18px'
        self.txt_subject.style['background'] = 'lightgreen'
        self.txt_subject.style['text-align'] = 'center'
        """ Date: """
        self.date_headline = gui.Label('Acquisition date:',
                                       width=230,
                                       height=20,
                                       margin='1px')
        self.date_headline.style['text-align'] = 'left'
        self.date = gui.Date('2018-01-01', width=230, height=30, margin='1px')
        self.date.style['font-size'] = '16px'
        """ Remarks box: """
        self.txt = gui.TextInput(width=230, height=70, margin='1px')
        self.txt.set_text('Add remarks here')
        """ Instructions: """
        inst1 = gui.Label('Instructions:', width=230, height=25, margin='0px')
        inst1.style['font-size'] = '16px'
        inst1.style['background'] = 'lightgray'
        inst2 = gui.Label("1. Set subject's number and acquisition date",
                          width=230,
                          height=45,
                          margin='0px')
        inst2.style['background'] = 'lightgray'
        inst3 = gui.Label(
            "2. Load files: subject's map file, wanted mask and general population data (mean, sd & template)",
            width=230,
            height=80,
            margin='0px')
        inst3.style['background'] = 'lightgray'
        inst4 = gui.Label("3. Press 'Analyze' button",
                          width=230,
                          height=25,
                          margin='0px')
        inst4.style['background'] = 'lightgray'
        inst5 = gui.Label("4. Export your report",
                          width=230,
                          height=25,
                          margin='0px')
        inst5.style['background'] = 'lightgray'

        sub_container_instructions.append([
            self.txt_subject, self.date_headline, self.date, self.txt, inst1,
            inst2, inst3, inst4, inst5
        ])
        """ Create Table: """
        self.table = gui.Table.new_from_list(
            [['Region', 'value', 'Z-score'],
             ['Prefrontal Lateral R', '80', '1.2'],
             ['Prefrontal Lateral L', '25', '1.99'],
             ['Sensorimotor R', '76', '0.23'],
             ['Sensorimotor L', '88', '2.55']],
            width=250,
            height=500,
            margin='10px')

        sub_container_left.append(self.table, key='table')
        """ Logo: """
        sagol_logo = gui.Image(r'/res/Sagollogo.png',
                               width=300,
                               height=60,
                               margin='25px')
        sagol_logo.style['background'] = 'white'
        """ Analyze button: """
        self.bt_analyze = gui.Button("Analyze",
                                     width=350,
                                     height=30,
                                     margin='16px')
        self.bt_analyze.onclick.connect(self.on_analyze_pressed)
        """ Figure which be replace to visualized results: """
        self.figure_analyzed = gui.Image(r'/res/es.jpg',
                                         width=350,
                                         height=300,
                                         margin='10px')

        sub_container_right.append([sagol_logo, self.bt_analyze])
        sub_container_right.append(self.figure_analyzed, key='image')

        self.sub_container_left = sub_container_left
        self.sub_container_right = sub_container_right
        self.instructions = sub_container_instructions

        horizontal_container.append([
            self.instructions, self.sub_container_left,
            self.sub_container_right
        ])
        """ Menu: """
        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('Select Subject', width=100, height=30)
        m1.onclick.connect(self.menu_subject_clicked)
        m2 = gui.MenuItem('Properties', width=100, height=30)
        m3 = gui.MenuItem("Export as", width=100, height=30)
        m21 = gui.MenuItem('Select Mask', width=200, height=30)
        m21.onclick.connect(self.menu_mask_clicked)
        m22 = gui.MenuItem('General population data', width=200, height=30)
        m31 = gui.MenuItem('PDF', width=100, height=30)
        m31.onclick.connect(self.menu_pdf_clicked)
        m221 = gui.MenuItem('Select mean data', width=100, height=30)
        m221.onclick.connect(self.menu_mean_clicked)
        m222 = gui.MenuItem('Select SD data', width=100, height=30)
        m222.onclick.connect(self.menu_sd_clicked)
        m223 = gui.MenuItem('Select template', width=100, height=30)
        m223.onclick.connect(self.menu_template_clicked)
        menu.append([m1, m2, m3])
        m2.append([m21, m22])
        m3.append([m31])
        m22.append([m221, m222, m223])

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

        vertical_container.append([menubar, horizontal_container])

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

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

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

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

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

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

        menubar.append(menu)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # returning the root widget
        return self.mainContainer
Beispiel #17
0
    def construct_ui(self):
        cv2.setUseOptimized(True)
        #DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR
        global_container = VBox(height="100%")

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

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

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

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

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

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

        container_commands.append(bt_trigger,'bt_trigger')

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

        global_container.append([menubar, main_container])

        self.main_container = main_container

        #self.calibrate_camera()

        self.miniature_selection_list = []

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

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

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

        return global_container
Beispiel #18
0
    def main(self):
        verticalContainer = gui.Widget(width=540)
        verticalContainer.style['display'] = 'block'
        verticalContainer.style['overflow'] = 'hidden'

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # returning the root widget
        return verticalContainer
Beispiel #19
0
    def main(self):
        verticalContainer = gui.Widget(width=1050,
                                       margin='0px auto',
                                       style={
                                           'display': 'block',
                                           'overflow': 'hidden'
                                       })
        horizontalContainer = gui.Widget(
            width='100%',
            layout_orientation=gui.Widget.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'display': 'block',
                'overflow': 'auto'
            })
        subContainerLeft = gui.Widget(width=300,
                                      style={
                                          'display': 'block',
                                          'overflow': 'auto',
                                          'text-align': 'center'
                                      })
        subContainerRight = gui.Widget(width=400,
                                       style={
                                           'display': 'block',
                                           'overflow': 'auto',
                                           'text-align': 'center'
                                       })
        subContainerInstructions = gui.Widget(width=250,
                                              height=250,
                                              margin='10px',
                                              style={
                                                  'display': 'block',
                                                  'overflow': 'auto',
                                                  'text-align': 'left'
                                              })

        subContainerInstructions.style['background'] = 'lightgray'

        sagol_logo = gui.Image(r'/res/Sagollogo.png',
                               width=300,
                               height=60,
                               margin='25px')
        sagol_logo.style['background'] = 'white'
        inst1 = gui.Label('Instructions:', width=230, height=20, margin='10px')
        inst1.style['font-size'] = '16px'
        inst2 = gui.Label("1. Set subject's number and acquisition date",
                          width=230,
                          height=40,
                          margin='10px')
        inst3 = gui.Label(
            "2. Load files: subject's map file, wanted mask and general population data (mean, sd & template)",
            width=230,
            height=70,
            margin='10px')
        inst4 = gui.Label("3. Press 'Analyze' button",
                          width=230,
                          height=20,
                          margin='10px')
        inst5 = gui.Label("4. Export your report",
                          width=230,
                          height=20,
                          margin='10px')

        subContainerInstructions.append([inst1, inst2, inst3, inst4, inst5])

        self.txt_subject = gui.TextInput(width=250, height=35, margin='10px')
        self.txt_subject.set_text("Subject number")
        self.txt_subject.style['font-size'] = '16px'
        self.txt_subject.style['background'] = 'lightgreen'
        self.txt_subject.style['text-align'] = 'center'

        self.date_headline = gui.Label('Acquisition date:',
                                       width=250,
                                       height=20,
                                       margin='10px')
        self.date_headline.style['text-align'] = 'left'
        self.date = gui.Date('2018-01-01', width=250, height=30, margin='10px')
        self.date.style['font-size'] = '16px'

        self.txt = gui.TextInput(width=250, height=70, margin='10px')
        self.txt.set_text('Add remarks here')

        table_content = Table(subject_data).frame_to_list()
        self.table = gui.Table.new_from_list(
            [['Region', 'value', 'Z-score'],
             ['Prefrontal Lateral R', '80', '1.2'],
             ['Prefrontal Lateral L', '25', '1.99'],
             ['Sensorimotor R', '76', '0.23'],
             ['Sensorimotor L', '88', '2.55']],
            width=250,
            height=500,
            margin='10px')

        subContainerLeft.append([
            self.txt_subject, self.date_headline, self.date, self.txt,
            self.table
        ])
        self.bt_analyze = gui.Button("Analyze",
                                     width=350,
                                     height=30,
                                     margin='16px')
        #self.bt_analyze.onclick.connect(self.on_analyze_pressed)

        self.figure_analyzed = gui.Image(r'/res/es.jpg',
                                         width=350,
                                         height=300,
                                         margin='10px')
        subContainerRight.append(
            [sagol_logo, self.bt_analyze, self.figure_analyzed])
        self.sub_container_left = subContainerLeft
        self.sub_container_right = subContainerRight
        self.instructions = subContainerInstructions
        horizontalContainer.append([
            self.instructions, self.sub_container_left,
            self.sub_container_right
        ])

        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('Select Subject', width=100, height=30)
        m1.onclick.connect(self.menu_subject_clicked)
        m2 = gui.MenuItem('Properties', width=100, height=30)
        m3 = gui.MenuItem("Export as", width=100, height=30)
        m21 = gui.MenuItem('Select Mask', width=200, height=30)
        m21.onclick.connect(self.menu_mask_clicked)
        m22 = gui.MenuItem('General population data', width=200, height=30)
        m31 = gui.MenuItem('PDF', width=100, height=30)
        m31.onclick.connect(self.menu_pdf_clicked)
        m221 = gui.MenuItem('Select mean data', width=100, height=30)
        m221.onclick.connect(self.menu_mean_clicked)
        m222 = gui.MenuItem('Select SD data', width=100, height=30)
        m222.onclick.connect(self.menu_sd_clicked)
        m223 = gui.MenuItem('Select template', width=100, height=30)
        m223.onclick.connect(self.menu_template_clicked)
        menu.append([m1, m2, m3])
        m2.append([m21, m22])
        m3.append([m31])
        m22.append([m221, m222, m223])

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

        verticalContainer.append([menubar, horizontalContainer])

        return verticalContainer