def append_instance(self, instance, parent): item = gui.TreeItem(instance.attributes['editor_varname']) if parent == None: parent = self item.instance = instance item.set_on_click_listener(self.on_tree_item_selected) parent.append(item) return item
def main(self, name='world'): wid = gui.VBox(width=350, height=400, margin='0px auto') self.tree = gui.TreeView(width=300, height=300) self.tree.append(gui.TreeItem("item1")) it2 = gui.TreeItem("item2") self.tree.append(it2) subit2 = gui.TreeItem("sub item2") it2.append([gui.TreeItem("sub item1"), subit2, gui.TreeItem("sub item3")]) subit2.append([gui.TreeItem("sub sub item1"), gui.TreeItem("sub sub item2"), gui.TreeItem("sub sub item3")]) wid.append(self.tree) # returning the root widget return wid
def main(self, name='world'): wid = gui.VBox(width=300, height=400) self.tree = gui.TreeView(width=200, height=300) self.tree.append(gui.TreeItem("item1", width=100)) it2 = gui.TreeItem("item2", width=100) self.tree.append(it2) it2.append(gui.TreeItem("sub item1")) subit2 = gui.TreeItem("sub item2") it2.append(subit2) it2.append(gui.TreeItem("sub item3")) subit2.append(gui.TreeItem("sub sub item1")) subit2.append(gui.TreeItem("sub sub item2")) subit2.append(gui.TreeItem("sub sub item3")) wid.append(self.tree) # returning the root widget return wid
def test_init(self): widget = gui.TreeItem('test tree item') widget.append(gui.TreeItem('2nd tree item')) self.assertIn('test tree item', widget.repr()) self.assertIn('2nd tree item', widget.repr()) assertValidHTML(widget.repr())
def main(self): verticalContainer = gui.Widget( width=540, margin='0px auto') #the margin 0px auto centers the main container 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.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') # 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.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
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