def setup_gui(data): b = gui.Box(orientation=gui.Box.HORIZONTAL) b.background = gui.BoxTexture('gui.atlas:bar', [-1], [-1, 1]) b.padding = gui.Rect(6, 6, 6, 6) b.alignment.y = 1 b.fill.x = True b.homogeneous = False b.spacing = 6 play = gui.Button(icon='gui.atlas:play') b.add(play) step = gui.Button(icon='gui.atlas:step') b.add(step) la = gui.Widget(alignment=gui.Alignment(1, 0.5), fill=gui.Fill(True, True)) l = gui.Label(text='time: {:>6.3f}'.format(0)) l.color = gui.Color(1, 1, 1, 1) l.padding = gui.Rect.uniform(3) l.alignment = gui.Alignment(1, 0.5) la.add(l) b.add(la) data.gui.add(b) data.lbl_time = l
def main(self): # the arguments are width - height - layoutOrientationOrizontal wid = gui.Widget(120, 100, False, 10) self.lbl = gui.Label(100, 30, 'Hello world!') self.bt = gui.Button(100, 30, 'Press me!') # setting the listener for the onclick event of the button self.bt.set_on_click_listener(self, 'on_button_pressed') # appending a widget to another, the first argument is a string key wid.append('1', self.lbl) wid.append('2', self.bt) # returning the root widget return wid
def __init__(self, windows_controller, container, name, root_bar, children_bar, size, position, icon_path): rect = pygame.Rect(position, size) gui.Window.__init__(self, container, rect, 1, windows_controller, "bar_section_window") # section attributes self.name = name self.root_bar = root_bar self.children_bar = children_bar font = utilities.get_font(16, True, True) #label_render = font.render(self.name, 1, pygame.Color(TEXT_COLOR)) #label_rect = pygame.Rect((0,0), label_render.get_size()) #label_rect.right = self.rect.right - 8 pos = self.rect.right - 8, 0 label_widget = gui.Text(self.rect, pos[0], pos[1], 1, self.name, 16, pygame.Color(TEXT_COLOR), "normal", gui.Text.ALIGN_RIGHT, True, True) # visuals self.root_bar_display = BarDisplay(BAR_HEIGHT, BAR_WIDTH, (BAR_OFFSET_X, SECTION_TOP_PADDING), self.root_bar, ROOT_BAR_PARTITIONS) self.root_bar_display.show_name = False self.displays_list = self.__get_displays() # obtengo los displays para cada barra. self.fixed_widgets = [label_widget, self.root_bar_display] if icon_path: icon = pygame.image.load(icon_path).convert_alpha() self.icon = gui.Widget(self.rect, pygame.Rect((0, 0), icon.get_size()), 1, icon) self.icon.keep_dirty = True self.fixed_widgets.append(self.icon) else: self.icon = None # visuals constant self.init_top = self.rect[1] self.init_height = size[1] self.max_expand = len(children_bar) * BAR_HEIGHT self.expanded = False # Este flag se activa cuando se están mostrando las sub-barras self.__calculate() # calculo la posición de cada barra en la sección
def createWidget(self): return gui.Widget()
def main(self): verticalContainer = gui.Widget(640, 680, False, 10) horizontalContainer = gui.Widget(620, 620, True, 10) subContainerLeft = gui.Widget(340, 530, False, 10) self.img = gui.Image(100, 100, './res/logo.png') self.table = gui.Table(300, 200) row = gui.TableRow() item = gui.TableTitle() item.append(str(id(item)), 'ID') row.append(str(id(item)), item) item = gui.TableTitle() item.append(str(id(item)), 'First Name') row.append(str(id(item)), item) item = gui.TableTitle() item.append(str(id(item)), 'Last Name') row.append(str(id(item)), item) self.table.append(str(id(row)), row) self.add_table_row(self.table, '101', 'Danny', 'Young') self.add_table_row(self.table, '102', 'Christine', 'Holand') self.add_table_row(self.table, '103', 'Lars', 'Gordon') self.add_table_row(self.table, '104', 'Roberto', 'Robitaille') self.add_table_row(self.table, '105', 'Maria', 'Papadopoulos') # the arguments are width - height - layoutOrientationOrizontal subContainerRight = gui.Widget(240, 560, False, 10) 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) self.spin.set_on_change_listener(self, 'on_spin_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.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.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') # appending a widget to another, the first argument is a string key subContainerRight.append('1', self.lbl) subContainerRight.append('2', self.bt) subContainerRight.append('3', self.txt) subContainerRight.append('4', self.spin) subContainerRight.append('5', self.btInputDiag) subContainerRight.append('5_', self.btFileDiag) subContainerRight.append( '5__', gui.FileDownloader(200, 30, 'download test', './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) horizontalContainer.append('0', subContainerLeft) horizontalContainer.append('1', subContainerRight) menu = gui.Menu(620, 40) m1 = gui.MenuItem(100, 40, 'File') m2 = gui.MenuItem(100, 40, 'View') m2.set_on_click_listener(self, 'menu_view_clicked') m11 = gui.MenuItem(100, 40, 'Save') m12 = gui.MenuItem(100, 40, 'Open') m12.set_on_click_listener(self, 'menu_open_clicked') m111 = gui.MenuItem(100, 40, 'Save') m111.set_on_click_listener(self, 'menu_save_clicked') m112 = gui.MenuItem(100, 40, 'Save as') m112.set_on_click_listener(self, 'menu_saveas_clicked') menu.append('1', m1) menu.append('2', m2) m1.append('11', m11) m1.append('12', m12) m11.append('111', m111) m11.append('112', m112) verticalContainer.append('0', menu) verticalContainer.append('1', horizontalContainer) # returning the root widget return verticalContainer