Exemple #1
0
    def main(self):
        # the margin 0px auto centers the main container
        verticalContainer = gui.Widget(width=540,
                                       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=320,
                                      style={
                                          'display': 'block',
                                          'overflow': 'auto',
                                          'text-align': 'center'
                                      })
        self.img = gui.Image('/res/logo.png', height=100, margin='10px')
        self.img.onclick.connect(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.connect(self.on_table_row_click)

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget(
            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.connect(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.connect(self.on_text_area_change)

        self.spin = gui.SpinBox(1, 0, 100, width=200, height=30, margin='10px')
        self.spin.onchange.connect(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.connect(self.on_check_change)

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

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

        self.btUploadFile = gui.FileUploader('./',
                                             width=200,
                                             height=30,
                                             margin='10px')
        self.btUploadFile.onsuccess.connect(self.fileupload_on_success)
        self.btUploadFile.onfailed.connect(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.connect(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.connect(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.connect(self.slider_changed)

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

        self.date = gui.Date('2015-04-13', width=200, height=20, margin='10px')
        self.date.onchange.connect(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.connect(self.menu_view_clicked)
        m11 = gui.MenuItem('Save', width=100, height=30)
        m12 = gui.MenuItem('Open', width=100, height=30)
        m12.onclick.connect(self.menu_open_clicked)
        m111 = gui.MenuItem('Save', width=100, height=30)
        m111.onclick.connect(self.menu_save_clicked)
        m112 = gui.MenuItem('Save as', width=100, height=30)
        m112.onclick.connect(self.menu_saveas_clicked)
        m3 = gui.MenuItem('Dialog', width=100, height=30)
        m3.onclick.connect(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
Exemple #2
0
    def main(self):
        verticalContainer = gui.Widget(width=540)
        verticalContainer.style['display'] = 'block'
        verticalContainer.style['overflow'] = 'hidden'

        horizontalContainer = gui.Widget(width='100%')
        horizontalContainer.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        horizontalContainer.style['display'] = 'block'
        horizontalContainer.style['overflow'] = 'auto'
        horizontalContainer.style['margin'] = '0px'
        
        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)
        self.img.style['margin'] = '10px'
        self.img.style['margin'] = '10px'
        self.img.set_on_click_listener(self, 'on_img_clicked')

        self.table = gui.Table(width=300, height=200)
        self.table.style['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)
        self.counter.style['margin'] = '10px'

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

        self.bt = gui.Button('Press me!', width=200, height=30)
        self.bt.style['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)
        self.txt.style['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)
        self.spin.style['margin'] = '10px'
        self.spin.set_on_change_listener(self, 'on_spin_change')

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

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

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

        self.btUploadFile = gui.FileUploader('./', width=200, height=30)
        self.btUploadFile.style['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)
        self.listView.set_size(300, 120)
        self.listView.style['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)
        self.link.style['margin'] = '10px'

        self.dropDown = gui.DropDown(width=200, height=20)
        self.dropDown.style['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)
        self.slider.style['margin'] = '10px'
        self.slider.set_on_change_listener(self, 'slider_changed')

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

        self.date = gui.Date('2015-04-13', width=200, height=20)
        self.date.style['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)
        self.video.style['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)
        fdownloader.style['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()
        menu.set_size('100%', '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()
        menubar.set_size('100%', '30px')
        menubar.append(menu)

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

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

        # returning the root widget
        return verticalContainer
Exemple #3
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, gui.SvgImage]),
            SvgDraggableRectangleResizePoint(self,
                                             [gui.SvgRectangle, gui.SvgImage])
        ]
        for drag_helper in self.drag_helpers:
            drag_helper.stop_drag.do(self.on_drag_resize_end)

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

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

        # returning the root widget
        return self.mainContainer
Exemple #4
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='24%',
                                                               height='100%')
        self.attributeEditor.style['position'] = 'absolute'
        self.attributeEditor.style['right'] = '0px'
        self.attributeEditor.add_class('RaisedFrame')

        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.subContainer.append(self.subContainerLeft)

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

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

        self.resizeHelper = ResizeHelper(width=16, height=16)
        self.menu_new_clicked()

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

        # returning the root widget
        return self.mainContainer
Exemple #5
0
    def main(self):
        # the margin 0px auto centers the main container
        verticalContainer = gui.Widget(width=540, 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=320, style={'display': 'block', 'overflow': 'auto', '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.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.set_on_table_row_click_listener(self.on_table_row_click)

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget(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.set_on_click_listener(self.on_button_pressed)

        self.txt = gui.TextInput(width=200, height=30, margin='10px')
        self.txt.set_text(str(self.count))
        self.txt.set_on_change_listener(self.on_text_area_change)

        self.spin = gui.SpinBox(-10, -100, 1000, 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.new_from_list(('DropDownItem 0', 'DropDownItem 1'),
                                                   width=200, height=20, margin='10px')
        self.dropDown.set_on_change_listener(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.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')
                                     
        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)
        self.tree.append(ti2)
        self.tree.append(ti3)
        ti2.append(subti1)
        ti2.append(subti2)
        ti2.append(subti3)
        ti2.append(subti4)
        subti4.append(subsubti1)
        subti4.append(subsubti2)
        subti4.append(subsubti3)
        
        # 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)
        subContainerRight.append(self.tree)
        self.subContainerRight = subContainerRight

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

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

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

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

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

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

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

        # returning the root widget
        return verticalContainer
Exemple #6
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.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.on_saveas_dialog_confirm)

        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)
        m21.onclick.do(self.menu_cut_selection_clicked)
        m22.onclick.do(self.menu_paste_selection_clicked)

        m3.onclick.do(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.do(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.do(
            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.do(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
Exemple #7
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
Exemple #8
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
    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
Exemple #10
0
    def main(self):
        # print 'DOING MAIN executed once when server starts'
        # ***************************************
        # INIT
        # ***************************************
        self.editor_issue="1.3"

        # get directory holding the code
        self.editor_dir=sys.path[0]

        ColourMap().init()
        
        # initialise editor options OSC config class, and OSC editors
        self.eo=Options()
        self.eo.init_options(self.editor_dir)
        self.osc_config=OSCConfig()
        self.osc_ute= OSCUnitType()

        
        # initialise variables
        self.init() 

        # BUILD THE GUI
        # frames
        root = gui.Widget(width=900,height=500) #1
        root.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)         
        top_frame=gui.Widget(width=900,height=40)#1
        top_frame.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)
        bottom_frame=gui.Widget(width=900,height=300)#1
        bottom_frame.set_layout_orientation(gui.Widget.LAYOUT_HORIZONTAL)       
        root.append(top_frame)
        root.append(bottom_frame)

        left_frame=gui.Widget(width=350,height=400)#1
        left_frame.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)
        left_frame.style['margin']='10px'
        middle_frame=gui.VBox(width=50,height=300)#1
        middle_frame.style['margin']='10px'
        # middle_frame.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)   
        right_frame=gui.Widget(width=350,height=400)#1
        right_frame.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)   
        updown_frame=gui.VBox(width=50,height=300)#1
        updown_frame.style['margin']='10px'
        # updown_frame.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)   

        bottom_frame.append(left_frame)
        bottom_frame.append(middle_frame)
        bottom_frame.append(right_frame)
        bottom_frame.append(updown_frame)

        #menu
        menu = gui.Menu(width=700, height=30)
        top_frame.append(menu)

        #profile menu
        profile_menu = gui.MenuItem('Profile',width=80, height=30)
        profile_open_menu = gui.MenuItem('Open',width=120, height=30)
        profile_open_menu.set_on_click_listener(self,'open_existing_profile')
        profile_validate_menu = gui.MenuItem('Validate',width=120, height=30)
        profile_validate_menu.set_on_click_listener(self, 'validate_profile')
        profile_new_menu = gui.MenuItem('New',width=120, height=30)
        profile_menu.append(profile_open_menu)
        profile_menu.append(profile_validate_menu)
        profile_menu.append(profile_new_menu)

        pmenu = gui.MenuItem('Exhibit',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_exhibit_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('Media Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_mediashow_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('Art Media Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_artmediashow_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('Menu',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_menu_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('Presentation',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_presentation_profile')
        profile_new_menu.append(pmenu)        
        pmenu = gui.MenuItem('Interactive',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_interactive_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('Live Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_liveshow_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('Art Live Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_artliveshow_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem('RadioButton Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_radiobuttonshow_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem( 'Hyperlink Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_hyperlinkshow_profile')
        profile_new_menu.append(pmenu)
        pmenu = gui.MenuItem( 'Blank',width=150, height=30)
        pmenu.set_on_click_listener(self, 'new_blank_profile')
        profile_new_menu.append(pmenu)
        
        # shows menu              
        show_menu = gui.MenuItem( 'Show',width=80, height=30)
        show_delete_menu = gui.MenuItem('Delete',width=120, height=30)
        show_delete_menu.set_on_click_listener(self, 'remove_show')    
        show_edit_menu = gui.MenuItem('Edit',width=120, height=30)
        show_edit_menu.set_on_click_listener(self, 'm_edit_show')
        show_copy_to_menu = gui.MenuItem( 'Copy To',width=120, height=30)
        show_copy_to_menu.set_on_click_listener(self, 'copy_show')
        show_add_menu = gui.MenuItem( 'Add',width=120, height=30)
        show_menu.append(show_delete_menu)
        show_menu.append(show_edit_menu)
        show_menu.append(show_copy_to_menu)
        show_menu.append(show_add_menu)


        pmenu = gui.MenuItem('Menu',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_menushow')
        show_add_menu.append(pmenu)
        
        pmenu = gui.MenuItem( 'Media Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_mediashow')
        show_add_menu.append(pmenu)
        
        pmenu = gui.MenuItem('Live Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_liveshow')
        show_add_menu.append(pmenu)

        pmenu = gui.MenuItem('Hyperlink Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_hyperlinkshow')
        show_add_menu.append(pmenu)

        pmenu = gui.MenuItem('RadioButton Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_radiobuttonshow')
        show_add_menu.append(pmenu)

        pmenu = gui.MenuItem( 'Art Mediashow Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_artmediashow')
        show_add_menu.append(pmenu)

        pmenu = gui.MenuItem( 'Art Liveshow Show',width=150, height=30)
        pmenu.set_on_click_listener(self, 'add_artliveshow')
        show_add_menu.append(pmenu)

        # medialists menu
        medialist_menu = gui.MenuItem( 'Medialist',width=80, height=30)
        
        medialist_delete_menu = gui.MenuItem( 'Delete',width=120, height=30)
        medialist_delete_menu.set_on_click_listener(self, 'remove_medialist')

        
        medialist_add_menu = gui.MenuItem( 'Add',width=120, height=30)
        medialist_add_menu.set_on_click_listener(self, 'add_medialist')
        
        medialist_copy_to_menu = gui.MenuItem('Copy To',width=120, height=30)
        medialist_copy_to_menu.set_on_click_listener(self, 'copy_medialist')
        
        medialist_menu.append(medialist_add_menu)
        medialist_menu.append(medialist_delete_menu)
        medialist_menu.append(medialist_copy_to_menu)

        # tracks menu
        track_menu = gui.MenuItem('Track',width=80, height=30)

        track_delete_menu = gui.MenuItem('Delete',width=120, height=30)
        track_delete_menu.set_on_click_listener(self, 'remove_track')
        track_edit_menu = gui.MenuItem( 'Edit',width=120, height=30)
        track_edit_menu.set_on_click_listener(self, 'm_edit_track')
        track_add_from_dir_menu = gui.MenuItem('Add Directory',width=120, height=30)
        track_add_from_dir_menu.set_on_click_listener(self, 'add_tracks_from_dir')
        track_add_from_file_menu = gui.MenuItem('Add File',width=120, height=30)
        track_add_from_file_menu.set_on_click_listener(self, 'add_track_from_file')
        track_new_menu = gui.MenuItem('New',width=120, height=30)

        track_new_video_menu = gui.MenuItem('Video',width=120, height=30)
        track_new_video_menu.set_on_click_listener(self, 'new_video_track')
        track_new_audio_menu = gui.MenuItem('Audio',width=120,height=30)
        track_new_audio_menu.set_on_click_listener(self, 'new_audio_track')
        track_new_image_menu = gui.MenuItem( 'Image',width=120, height=30)
        track_new_image_menu.set_on_click_listener(self, 'new_image_track')
        track_new_web_menu = gui.MenuItem( 'Web',width=120, height=30)
        track_new_web_menu.set_on_click_listener(self, 'new_web_track')
        track_new_message_menu = gui.MenuItem('Message',width=120, height=30)
        track_new_message_menu.set_on_click_listener(self, 'new_message_track')
        track_new_show_menu = gui.MenuItem('Show',width=120, height=30)
        track_new_show_menu.set_on_click_listener(self, 'new_show_track')
        track_new_menu_menu = gui.MenuItem('Menu',width=120, height=30)
        track_new_menu_menu.set_on_click_listener(self, 'new_menu_track')

        track_new_menu.append(track_new_video_menu)
        track_new_menu.append(track_new_audio_menu)
        track_new_menu.append(track_new_image_menu)
        track_new_menu.append(track_new_web_menu)        
        track_new_menu.append(track_new_message_menu)
        track_new_menu.append(track_new_show_menu)
        track_new_menu.append(track_new_menu_menu)
        
        track_menu.append(track_delete_menu)
        track_menu.append(track_edit_menu)
        track_menu.append(track_add_from_dir_menu)
        track_menu.append(track_add_from_file_menu)
        track_menu.append(track_new_menu)


      
        options_menu = gui.MenuItem('Options',width=80, height=30)
        options_edit_menu=gui.MenuItem('Edit',width=80, height=30)
        options_edit_menu.set_on_click_listener(self, 'edit_options')
        options_menu.append(options_edit_menu)

        # osc menu
        osc_menu = gui.MenuItem( 'OSC',width=80, height=30)  
        osc_create_menu = gui.MenuItem( 'Create',width=120, height=30)
        osc_create_menu.set_on_click_listener(self, 'create_osc')
        osc_edit_menu = gui.MenuItem( 'Edit',width=120, height=30)
        osc_edit_menu.set_on_click_listener(self, 'edit_osc')
        osc_delete_menu = gui.MenuItem( 'Delete',width=120, height=30)
        osc_delete_menu.set_on_click_listener(self, 'delete_osc')
        osc_menu.append(osc_create_menu)
        osc_menu.append(osc_edit_menu)
        osc_menu.append(osc_delete_menu)
        
        # help menu
        help_menu = gui.MenuItem( 'Help',width=80, height=30)
        help_text_menu = gui.MenuItem( 'Help',width=80, height=30)
        help_text_menu.set_on_click_listener(self, 'show_help')
        about_menu = gui.MenuItem( 'About',width=80, height=30)
        about_menu.set_on_click_listener(self, 'show_about')
        help_menu.append(help_text_menu)
        help_menu.append(about_menu)

        menu.append(profile_menu)
        menu.append(show_menu)
        menu.append(medialist_menu)
        menu.append(track_menu)
        menu.append(osc_menu)
        menu.append(options_menu)
        menu.append(help_menu)


        
        #shows and medialists
        shows_label=gui.Label('<b>Shows</b>',width=300, height=20)
        shows_label.style['margin']='5px'
        self.shows_display= gui.ListView(width=350, height=150)
        self.shows_display.set_on_selection_listener(self,'show_selected')
        
        medialists_label=gui.Label('<b>Medialists</b>',width=300, height=20)
        medialists_label.style['margin']='5px'
        self.medialists_display= gui.ListView(width=350, height=150)
        self.medialists_display.set_on_selection_listener(self,'medialist_selected')

        left_frame.append(shows_label)
        left_frame.append(self.shows_display)         
        left_frame.append(medialists_label)
        left_frame.append(self.medialists_display)

        #edit show button
        edit_show = gui.Button('Edit\nShow',width=50, height=50)
        edit_show.set_on_click_listener(self, 'm_edit_show')
        middle_frame.append(edit_show)

        #tracks
        tracks_label=gui.Label('<b>Tracks in Selected Medialist</b>',width=300, height=20)
        tracks_label.style['margin']='5px'
        self.tracks_display= gui.ListView(width=350, height=300)
        self.tracks_display.set_on_selection_listener(self,'track_selected')

        right_frame.append(tracks_label)
        right_frame.append(self.tracks_display)  

        #tracks buttons
        add_track = gui.Button('Add',width=50, height=50)
        add_track.set_on_click_listener(self, 'add_track_from_file')
        updown_frame.append(add_track)
        
        edit_track = gui.Button('Edit',width=50, height=50)
        edit_track.set_on_click_listener(self, 'm_edit_track')
        updown_frame.append(edit_track)        

        up_track = gui.Button('Up',width=50, height=50)
        up_track.set_on_click_listener(self, 'move_track_up')
        updown_frame.append(up_track)

        down_track = gui.Button('Down',width=50, height=50)
        down_track.set_on_click_listener(self, 'move_track_down')
        updown_frame.append(down_track)
        return root
Exemple #11
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
Exemple #12
0
    def main(self):
        # get directory holding the code
        self.manager_dir = sys.path[0]

        if not os.path.exists(self.manager_dir + os.sep + 'pp_manager.py'):
            print 'Pi Presents Manager - Bad Application Directory'
            exit()

        # object if there is no options file
        self.options_file_path = self.manager_dir + os.sep + 'pp_config' + os.sep + 'pp_web.cfg'
        if not os.path.exists(self.options_file_path):
            print 'Pi Presents Manager - Cannot find web options file'
            exit()

        # read the options
        self.options_config = self.read_options(self.options_file_path)
        self.get_options(self.options_config)
        # print 'options got'

        #create upload directory if necessary
        self.upload_dir_path = self.pp_home_dir + os.sep + 'pp_temp'
        if not os.path.exists(self.upload_dir_path):
            os.makedirs(self.upload_dir_path)

        self.pp_profiles_dir = self.pp_home_dir + os.sep + 'pp_profiles' + self.pp_profiles_offset
        if not os.path.exists(self.pp_profiles_dir):
            print 'Profiles directory does not exist: ' + self.pp_profiles_dir
            exit()

        #init variables
        self.profile_objects = []
        self.current_profile = ''

        # Initialise an instance of the Pi Presents and Web Editor driver classes
        self.pp = PiPresents()
        self.ed = WebEditor()
        self.ed.init(self.manager_dir)

        # root and frames
        root = gui.VBox(width=450, height=600)  #10
        top_frame = gui.VBox(width=450, height=40)  #1
        middle_frame = gui.VBox(width=450, height=500)  #5
        button_frame = gui.HBox(width=250, height=40)  #10

        # menu
        menu = gui.Menu(width=430, height=30)

        # media menu
        media_menu = gui.MenuItem('Media', width=100, height=30)
        media_copy_menu = gui.MenuItem('Copy', width=100, height=30)
        media_upload_menu = gui.MenuItem('Upload', width=100, height=30)
        media_copy_menu.set_on_click_listener(self, 'on_media_copy_clicked')
        media_upload_menu.set_on_click_listener(self,
                                                'on_media_upload_clicked')

        #profile menu
        profile_menu = gui.MenuItem('Profile', width=100, height=30)
        profile_copy_menu = gui.MenuItem('Copy', width=100, height=30)
        profile_copy_menu.set_on_click_listener(self,
                                                'on_profile_copy_clicked')
        profile_upload_menu = gui.MenuItem('Upload', width=100, height=30)
        profile_upload_menu.set_on_click_listener(self,
                                                  'on_profile_upload_clicked')
        profile_download_menu = gui.MenuItem('Download', width=100, height=30)
        profile_download_menu.set_on_click_listener(
            self, 'on_profile_download_clicked')

        # editor menu
        editor_menu = gui.MenuItem('Editor', width=100, height=30)
        editor_run_menu = gui.MenuItem('Run', width=100, height=30)
        editor_run_menu.set_on_click_listener(self,
                                              'on_editor_run_menu_clicked')
        editor_exit_menu = gui.MenuItem('Exit', width=100, height=30)
        editor_exit_menu.set_on_click_listener(self,
                                               'on_editor_exit_menu_clicked')

        #options menu
        options_menu = gui.MenuItem('Options', width=100, height=30)
        options_manager_menu = gui.MenuItem('Manager', width=100, height=30)
        options_manager_menu.set_on_click_listener(
            self, 'on_options_manager_menu_clicked')
        options_autostart_menu = gui.MenuItem('Autostart',
                                              width=100,
                                              height=30)
        options_autostart_menu.set_on_click_listener(
            self, 'on_options_autostart_menu_clicked')

        # list of profiles
        self.profile_list = gui.ListView(width=300, height=300)
        self.profile_list.set_on_selection_listener(self,
                                                    'on_profile_selected')

        #status and buttons

        self.profile_name = gui.Label('Selected Profile: ',
                                      width=400,
                                      height=20)

        self.pp_state_display = gui.Label('', width=400, height=20)

        self.run_pp = gui.Button('Run', width=80, height=30)
        self.run_pp.set_on_click_listener(self, 'on_run_button_pressed')

        self.exit_pp = gui.Button('Exit', width=80, height=30)
        self.exit_pp.set_on_click_listener(self, 'on_exit_button_pressed')

        self.refresh = gui.Button('Refresh List', width=120, height=30)
        self.refresh.set_on_click_listener(self, 'on_refresh_pressed')

        self.status = gui.Label('Manager for Pi Presents Started',
                                width=400,
                                height=30)

        # Build the layout

        # buttons
        button_frame.append(self.run_pp)
        button_frame.append(self.exit_pp)
        button_frame.append(self.refresh)

        # middle frame
        middle_frame.append(self.pp_state_display)
        middle_frame.append(button_frame)
        middle_frame.append(self.profile_list)
        middle_frame.append(self.profile_name)
        middle_frame.append(self.status)

        # menus
        profile_menu.append(profile_copy_menu)
        profile_menu.append(profile_upload_menu)
        profile_menu.append(profile_download_menu)

        media_menu.append(media_copy_menu)
        media_menu.append(media_upload_menu)

        editor_menu.append(editor_run_menu)
        editor_menu.append(editor_exit_menu)

        options_menu.append(options_manager_menu)
        options_menu.append(options_autostart_menu)

        menu.append(profile_menu)
        menu.append(media_menu)
        menu.append(editor_menu)
        menu.append(options_menu)

        top_frame.append(menu)

        root.append(top_frame)
        root.append(middle_frame)

        # display the initial list of profiles
        self.display_profiles()

        # kick of regular display of Pi Presents running state
        self.display_state()

        # returning the root widget
        return root