def __init__(self, **kwargs): super(ProgramPanel, self).__init__(**kwargs) self.cols = 1 g = GridLayout(cols=2) g.height = 60 g.size_hint_y = None title = HeadingItem() g.add_widget(title) self.my_title = title bg = GridLayout(cols=3) bg.padding = [8, 6] b = Button(text='1. program') b.bind(on_release=self.my_select_block_dialog) bg.add_widget(b) self.my_block_button = b self.my_set_select() b = Button(text='read') b.bind(on_release=self.my_read_block_dialog) bg.add_widget(b) b = Button(text='write') b.bind(on_release=self.my_write_block_dialog) bg.add_widget(b) g.add_widget(bg) self.add_widget(g) g = GridLayout(cols=2) g.height = 40 g.size_hint_y = None g.padding = [8, 6] self.current_path = '/coderoot/packages' self.my_path = TextInput(text=self.current_path, multiline=False, write_tab=False) g.add_widget(self.my_path) self.my_fname = TextInput(text='', multiline=False, write_tab=False) g.add_widget(self.my_fname) self.add_widget(g) self.my_file_chooser = MyFileChooser(path=self.current_path, size_hint=(1, 1), dirselect=True) self.add_widget(self.my_file_chooser) self.my_file_chooser.bind(selection=lambda *x: self.my_select(x[1:])) self.my_file_chooser.bind(path=lambda *x: self.my_set_path(x[1:])) self.stream = None self.popup = None self.writing = False
def __init__(self, **kwargs): super(PlaylistWidget, self).__init__(**kwargs) self.playlist = ClientManeger.server_songs.songs self.bar_width = 30 self.size_hint = (1, 0.71) self.scroll_type = ['bars'] self.bar_inactive_color = (5, 20, 10, 0.5) self.bar_color = (5, 10, 15, .9) self.do_scroll_x = False self.do_scroll_y = True grid = GridLayout() grid.height = 0 grid.size_hint_y = None grid.cols = 1 grid.padding = (5, 5) for song in self.playlist: widg = SongWidget(song) widg.size_hint_y = None grid.size_hint_x = 1.0 # increment grid height grid.height += widg.height grid.add_widget(widg) self.add_widget(grid)
def __init__(self, app, game_controller, user_interaction, *args, **kwargs): super().__init__(*args, **kwargs) ''' params:- app : Visualliser : Object that has spawned this one game_controller : Game assigned to this board user_interaction : bool : True if you want the user to be able to interact with the visuals else False ''' self.rows = 2 board_grid = GridLayout() self.app = app self.game_controller = game_controller # will hold all squares created by below function for later callback self.squares = [] board_map = game_controller.get_map() # Makes a vertical board board_grid.rows = board_map._size[0] board_grid.cols = board_map._size[1] * board_map._size[2] # Loops through all map coords for x, z, y in loops(range(board_map._size[0]), range(board_map._size[2]), range(board_map._size[1])): current = board_map.get_gridpoi(x, y, z) temp = Square(app, game_controller, x, y, z) temp.update_square(x, y, z, current) self.squares.append(temp) board_grid.add_widget(temp) self.add_widget(board_grid) if user_interaction: attack_board_ui = GridLayout() attack_board_ui.size_hint_y = None attack_board_ui.height = 50 attack_board_ui.rows = len(board_map._get_attack_board_array()[0]) attack_board_ui.cols = len(board_map._get_attack_board_array()) for x, y in loops( range(len(board_map._get_attack_board_array()[0])), range(len(board_map._get_attack_board_array()))): temp = Square(app, game_controller, x, y, 'AttackBoard') attack_board_ui.add_widget(temp) self.add_widget(attack_board_ui)
def build(self): box = BoxLayout() box.orientation = 'vertical' navigation_bar = CupertinoNavigationBar() navigation_bar.size_hint_y = 0.15 title = CupertinoLabel() title.text = 'Symbols' title.bold = True title.pos_hint = {'center': (0.5, 0.5)} scrollview = CupertinoScrollView() scrollview.scroll_wheel_distance = 200 layout = GridLayout() layout.cols = 1 layout.spacing = 15 layout.padding = 2, 15 layout.size_hint_y = None layout.bind(minimum_height=layout.setter('height')) navigation_bar.add_widget(title) scrollview.add_widget(layout) with open(root_path + 'symbols.json', 'r') as json: symbols = load(json) for s in symbols: cell = BoxLayout() cell.orientation = 'horizontal' cell.size_hint_y = None cell.height = 20 symbol = CupertinoSymbol() symbol.symbol = s symbol.color = 0, 0, 0, 1 symbol.size_hint_x = 0.2 name = CupertinoLabel() name.text = s name.font_size = 14 name.halign = 'left' name.bind(size=name.setter('text_size')) cell.add_widget(symbol) cell.add_widget(name) layout.add_widget(cell) box.add_widget(navigation_bar) box.add_widget(scrollview) return box
def on_commands(self, inst, newcommands): self.orientation = 'vertical' self.cols = 1 self.clear_widgets() if newcommands == None: return for source in newcommands: commands = newcommands[source] commandbox = GridLayout(rows=1) commandbox.size_hint_y = None commandbox.height = 50 for command in commands: if command['action'] == 'divider': self.add_widget(commandbox) commandbox = GridLayout(rows=1) commandbox.size_hint_y = None commandbox.height = 50 else: btn = Button() btn.text = command['name'] if 'confirm' in command and (command['confirm'] != "" or command['confirm'] != None): btn.background_color = (2, .5, .5, 1) btn.on_press = lambda source=command[ 'source'], action=command[ 'action']: App.get_running_app( ).client.sendCommand( 'api/system/commands/' + str(source) + '/' + str(action), '') commandbox.add_widget(btn) self.add_widget(commandbox)
def buildList(self, b=None): self.clear_widgets() wordsObj = Word() obj = WordUseage().getCounts() words = sorted(wordsObj.readFindString(self.qString)) for wordTemp in words: word = wordsObj.getRowByWord(wordTemp) row = GridLayout() row.rows = 1 row.height = 40 row.size_hint_y = None row.add_widget( Label(text=f'{word["word"]}', size_hint_y=None, height=40)) countValue = 0 if word['id'] in obj.keys(): countValue = obj[word['id']] t = 0 if WordWeighting().wightingExists(word['id']): t = WordWeighting().get(word['id'])['value_id'] textbox = TextInput(text=str(t), size_hint_y=None, height=40, size_hint_x=None, width=30, multiline=False) textbox.wordId = word['id'] textbox.bind(text=self.changeWeighting) row.add_widget( Label(text=str(countValue), size_hint_y=None, height=40)) row.add_widget(textbox) btn = Button(text=f'delete', size_hint_y=None, height=40, on_press=self.deleteCb) btn.rowId = word['id'] btn.word = word['word'] row.add_widget(btn) self.add_widget(row)
def __init__(self, **kwargs): super(InputsScreen, self).__init__(**kwargs) scroll = ScrollView() scroll.size_hint = (1, 1) self.add_widget(scroll) layout = GridLayout() layout.cols = 3 layout.padding = '8dp' layout.spacing = '8dp' layout.size_hint_y = None layout.bind(minimum_height=layout.setter('height')) scroll.add_widget(layout) self.layout = layout
def __init__(self): #A second argument '**kwargs' can be added here, but not needed. super(GUIlayout, self).__init__() #The same here. #Two layouts are going to be used. A 'small' one (a GridLayout named 'seclayout') that is going to contain the buttons, #and a 'big' one (a BoxLayout referred by 'self') that is going to contain the canvas and the small layout. self.orientation = 'vertical' self.spacing = (5,5) self.xdat=[] #List with the measured values. #The small layout and its parameters. seclayout = GridLayout() seclayout.rows = 2 seclayout.cols = 3 seclayout.size_hint_y = .2 #The percentage of the big layout in the y direction that this layout covers. #This is for the canvas to be bigger than the buttons. seclayout.row_force_default = True seclayout.row_default_height = 50 #Buttons self.measurebutton = Button(text="Measure!") self.measurebutton.bind(on_press=lambda x: self.measure(canvas,1,wavefun)) #Lambda x: in order to send arguments to the function and avoid seclayout.add_widget(self.measurebutton) #"TypeError: <lambda>() takes 0 positional arguments but 1 was given" self.measure10button = Button(text="Measure x10") self.measure10button.bind(on_press=lambda x: self.measure(canvas,10,wavefun)) seclayout.add_widget(self.measure10button) self.measure100button = Button(text="Measure x100") self.measure100button.bind(on_press=lambda x: self.measure(canvas,100,wavefun)) seclayout.add_widget(self.measure100button) self.PDFbutton = Button(text="Check!") self.PDFbutton.bind(on_press=lambda x:self.showPDF(canvas)) seclayout.add_widget(self.PDFbutton) self.clearbutton = Button(text="Clear") self.clearbutton.bind(on_press=lambda x: self.clearall(canvas)) seclayout.add_widget(self.clearbutton) self.add_widget(seclayout) #The small layout is attached to the big layout as a usual widget. canvas = FigureCanvasKivyAgg(f) self.add_widget(canvas) #self. because it is attached to the big layout. #Setting plot things that are shared by PDF and histogram. a.set_title('Measurements histogram') a.set_xlabel('x') a.set_ylabel('Frequency') a.axis([-L/2., L/2., 0., 1.])
def __init__(self, series, **kwargs): # make sure we aren't overriding any important functionality super(KivyAllSeriesGui, self).__init__(**kwargs) self.carrusel = Carousel(direction='right') self.carrusel.orientation = 'vertical' self.carrusel.size_hint = (1, 1) self.listaSeries = series self.panel = GridLayout(cols=1) self.thumbnailWidth = 160 self.thumbnailHeight = 280 print(Window.size) self.cantidadColumnas = int(Window.width / self.thumbnailWidth) self.cantidadFilas = int(Window.height / self.thumbnailHeight) print(self.cantidadColumnas) print(self.cantidadFilas) self.searchText = TextInput(text='', multiline=False) self.searchText.size_hint = (0.8, None) self.searchText.size = (0, 30) panelBusqueda = GridLayout(cols=4) panelBusqueda.add_widget(self.searchText) self.btnVine = Button(text="Vine", size_hint=(0.1, None), size=(0, 30)) self.btnLocal = Button(text="Local", size_hint=(0.1, None), size=(0, 30)) self.btnSalir = Button(text="Salir", size_hint=(0.1, None), size=(0, 30)) panelBusqueda.add_widget(self.btnVine) panelBusqueda.add_widget(self.btnLocal) panelBusqueda.add_widget(self.btnSalir) self.btnVine.bind(on_press=self.evntBtnBuscarVine) self.btnLocal.bind(on_press=self.evntBtnBuscarLocal) self.btnLocal.bind(on_press=self.evntBtnBuscarSalir) panelBusqueda.size_hint_y = None self.panel.add_widget(panelBusqueda) self.panel.add_widget(self.carrusel) self.add_widget(self.panel) self.__loadSeries__() self.indice = 0
def __init__(self, assembly_type, **kwargs): super(LinearCameraItem, self).__init__(**kwargs) self.assembly_type = assembly_type self.cols = 1 self.height = self.minimum_height = 400 self.size_hint_y = None self.bind(height=self.setter('height')) g = GridLayout(cols=2) g.height = 60 g.size_hint_y = None title = HeadingItem() g.add_widget(title) self.my_title = title graph_display = self.make_graph_display() self.add_widget(graph_display)
def constroi_titulo2(self): x, y = self.width / 300, self.height / 650 padding = (5 * x, 0 * y, 10 * x, 10 * y) grid = GridLayout(cols=3, padding=(5, 0, 5, 0), spacing=x * 10) grid.size_hint_y = None grid.height = self.height * .1 btn_ok = OkButton(size_hint_x=None, width=self.width * .1) btn_voltar = VoltarButton(size_hint_x=None, width=self.width * .1) label = Label(text=self.titulo) label.font_size = self.fonte_padrao grid.add_widget(btn_voltar) grid.add_widget(label) grid.add_widget(btn_ok) self.add_widget(grid) self.ids[f"{self.nome_tela}_botao_ok"] = btn_ok self.ids[f"{self.nome_tela}_botao_voltar"] = btn_voltar
def constroi_titulo2(self): x, y = self.width / 300, self.height / 650 padding = (5 * x, 0 * y, 10 * x, 10 * y) grid = GridLayout(cols=3, padding=(5, 0, 5, 0), spacing=x * 10) grid.size_hint_y = None grid.height = self.height * .1 branco = LimpaDadosButton(size_hint_x=None, width=self.width * .1, on_press=self.button_fecha) btn_voltar = VoltarButton(size_hint_x=None, width=self.width * .1) label = Label(text=self.titulo, bold=True) label.font_size = self.fonte_padrao * 1.5 grid.add_widget(btn_voltar) grid.add_widget(label) grid.add_widget(branco) self.add_widget(grid) self.ids[f"historico_botao_voltar"] = btn_voltar self.ids["historico_botao_fechar"] = btn_voltar
def __init__(self, comicBooks, **kwargs): # make sure we aren't overriding any important functionality super(KivyAllComicsGui, self).__init__(**kwargs) self.carrusel = Carousel(direction='right') self.carrusel.orientation = 'vertical' self.carrusel.size_hint = (1, 1) self.listaComicBooks = comicBooks self.panel = GridLayout(cols=1) self.thumbnailWidth=160 self.thumbnailHeight = 280 print(Window.size) self.cantidadColumnas = int(Window.width/self.thumbnailWidth) self.cantidadFilas = int(Window.height/self.thumbnailHeight) print(self.cantidadColumnas) print(self.cantidadFilas) self.searchText = TextInput(text='Buscar comic', multiline=False) self.searchText.size_hint_y = None self.searchText.size[1] = 30 panelBusqueda = GridLayout(cols=self.cantidadColumnas) panelBusqueda.add_widget(self.searchText) self.btn = Button(text = "buscar") self.btn.size_hint = (0.1, None) self.btn.size = (32, 32) # self.btn.background_normal = "Better Search.png" panelBusqueda.add_widget(self.btn) self.btn.bind(on_press=self.evntBtnBuscar) panelBusqueda.size_hint_y = None self.panel.add_widget(panelBusqueda) self.panel.add_widget(self.carrusel) self.add_widget(self.panel) self.__loadComicBooks__() self.indice = 0
def build(self): box = BoxLayout() box.orientation = 'vertical' navigation_bar = CupertinoNavigationBar() navigation_bar.height = 60 title = CupertinoLabel() title.text = 'Showcase' title.bold = True title.pos_hint = {'center_x': 0.5, 'center_y': 0.5} scrollview = CupertinoScrollView() scrollview.size_hint_y = None scrollview.height = Window.height - navigation_bar.height layout = GridLayout() layout.cols = 1 layout.spacing = 15 layout.padding = 15 layout.size_hint_y = None layout.bind(minimum_height=layout.setter('height')) system_button = CupertinoSystemButton() system_button.text = 'Send' system_button.size_hint_y = None system_button.height = 20 symbol_button = CupertinoSymbolButton() symbol_button.symbol = 'info' symbol_button.color = 0.05, 0.5, 0.95, 1 symbol_button.size_hint_y = None symbol_button.size = 32, 32 button = CupertinoButton() button.text = 'Hello World' button.size_hint_y = None button.height = 50 segmented_controls = CupertinoSegmentedControls() segmented_controls.size_hint_y = None segmented_controls.height = 30 segmented_controls.add_tab('Segmented') segmented_controls.add_tab('Controls') switch = CupertinoSwitch() switch.size_hint = None, None switch.size = 70, 40 self.progress_bar = CupertinoProgressbar() self.progress_bar.value = 10 self.progress_bar.size_hint_y = None self.progress_bar.height = 5 stepper = CupertinoStepper() stepper.size_hint = None, None stepper.size = 100, 30 stepper.bind(on_plus=lambda widget: self.increment_progress(10), on_minus=lambda widget: self.increment_progress(-10)) ny_label = CupertinoLabel() ny_label.font_name = 'New York' ny_label.text = 'New York Font Label' ny_label.size_hint_y = None ny_label.height = 20 sf_label = CupertinoLabel() sf_label.font_name = 'San Francisco' sf_label.text = 'San Francisco Font Label' sf_label.size_hint_y = None sf_label.height = 20 alert_dialog_button = CupertinoButton() alert_dialog_button.text = 'Open Alert Dialog' alert_dialog_button.size_hint_y = None alert_dialog_button.height = 50 alert_dialog_button.on_release = self.open_alert_dialog action_sheet_button = CupertinoButton() action_sheet_button.text = 'Open Action Sheet' action_sheet_button.size_hint_y = None action_sheet_button.height = 50 action_sheet_button.on_release = self.open_action_sheet text_field = CupertinoTextField() text_field.hint_text = 'Text Field' text_field.size_hint_y = None text_field.height = 30 instructions = CupertinoLabel() instructions.text = 'Enter Text Below:' instructions.size_hint = None, None instructions.size = 120, 20 text_view = CupertinoTextView() text_view.size_hint_y = None text_view.height = 100 navigation_bar.add_widget(title) layout.add_widget(system_button) layout.add_widget(symbol_button) layout.add_widget(button) layout.add_widget(segmented_controls) layout.add_widget(switch) layout.add_widget(self.progress_bar) layout.add_widget(stepper) layout.add_widget(ny_label) layout.add_widget(sf_label) layout.add_widget(alert_dialog_button) layout.add_widget(action_sheet_button) layout.add_widget(text_field) layout.add_widget(instructions) layout.add_widget(text_view) scrollview.add_widget(layout) box.add_widget(navigation_bar) box.add_widget(scrollview) return box
def __init__(self, **kwargs): super().__init__(**kwargs) # self.user_list = ['join'] # Window.color = (0,3,0,1) with self.canvas: # Color(.234, .456, .678, .9) # set the colour # Seting the size and position of canvas self.rect = Rectangle(source='back2.jpg', pos=self.center, size=self.size) # Update the canvas as the screen size change self.bind(pos=self.update_rect, size=self.update_rect) self.cols = 1 self.rows = 2 # self.side_but = Button(text='cool') self.history = ScrollableLabel(height=Window.size[1] * 0.9, size_hint_y=None) self.history_recv = ScrollableLabel(height=Window.size[1] * 0.9, size_hint_y=None) # self.add_widget(self.side_but) side_bar = GridLayout(cols=3) self.box = BoxLayout(orientation='vertical') self.box.size_hint_x = .4 # user_list = self.set_arr() # if len(user_list) > 0: # stack = Stack() # for i in stack.stk: self.side_label = MyLabel(text='Joined', pos=(20, 20), size_hint=(1, 0.5)) self.side_label.text = user_list[0].upper() self.side_label.text = self.side_label.text self.side_label.font_size = '25sp' self.side_label.color = [0.41, 0.42, 0.74, 1] # self.side_label.text_size = (6,4) self.box.add_widget(self.side_label) # else: # label = MyLabel( # text="Joined Users", # pos=(20, 20), # size_hint=(1, 0.5)) # box.add_widget(label) # with label.canvas: # Color(0, 1, 0, 0.25) # Rectangle(pos=label.pos, size=label.size) side_bar.add_widget(self.box) side_bar.add_widget(self.history) side_bar.add_widget(self.history_recv) self.add_widget(side_bar) ######################################### self.new_message = TextInput(width=Window.size[0] * 0.8, size_hint_x=None, multiline=False) self.send = Button(text="Send", background_color=(0, 0, 255, 0.8)) # self.send.halign = 'right' # self.send.size = 80,50 # self.send.size_hint = None,None self.send.bind(on_press=self.send_message) bottom_line = GridLayout(cols=2, row_force_default=True, row_default_height=40) bottom_line.size_hint_y = .07 bottom_line.add_widget(self.new_message) bottom_line.add_widget(self.send) # bottom_line = FloatLayout() # bottom self.add_widget( bottom_line) ############################################ Window.bind(on_key_down=self.on_key_down) Clock.schedule_once(self.focus_text_input, 1) socket_client.start_listening(self.incoming_message, show_error) self.bind(size=self.adjust_fields)