def show_add_origin_popup(self, button): p = AddEdgePopup(title='Add origins') valid_orig = self.story.nodes() valid_orig.remove(self.current_node) for orig in valid_orig: b = ToggleButton(text=orig, size_hint_y=None, height=dp(30)) if orig in self.story.predecessors(self.current_node): b.state = 'down' p.node_list.add_widget(b) p.node_list.add_widget(Widget()) def save_callback(button): to_add = [] to_remove = [] for child in p.node_list.children: if isinstance(child, ToggleButton): node_name = child.text if child.state == 'down': to_add.append(node_name) else: to_remove.append(node_name) for node in to_add: if node not in self.story.predecessors(self.current_node): self.story.add_edge(node, self.current_node) for node in to_remove: if node in self.story.predecessors(self.current_node): self.story.remove_edge(node, self.current_node) p.dismiss() p.save_btn.bind(on_release=save_callback) p.open()
def build(self): self.provider = None self.sensors_values = [] self.gps_values = ['', '', 0, 0] self.trigger_sensor_update_values = \ Clock.create_trigger(self.sensor_update_values, 0) self.trigger_gps_update_values = \ Clock.create_trigger(self.gps_update_values, 0) # search categories self.categories = ['gps-location'] for key in sensortypes: self.categories.append('sensor-{}'.format(key)) # create main ui root = MainUI() # fill the dropdown with all the categories for cat in self.categories: btn = ToggleButton(text=cat, size_hint_y=None, height='44sp', group='sensors') btn.bind(on_release=self.select_category) root.dropdown.add_widget(btn) return root
def showOutput(self): content = BoxLayout(orientation='vertical') box = BoxLayout(orientation='vertical') availables = out.getAvailable() first = True self.allChoices = [] for available in availables: checkbox = ToggleButton(text=available, group='output') self.allChoices.append(checkbox) if first: checkbox.state = 'down' first = False box.add_widget(checkbox) content.add_widget(box) menu = BoxLayout(orientation = "horizontal", size_hint_y = 0.2) cancelButton = Button(text="Cancel") outputButton = Button(text="Output") menu.add_widget(outputButton) menu.add_widget(cancelButton) content.add_widget(menu) self._popup = Popup(title="Output", content= content, size_hint=(0.9,0.9)) cancelButton.bind(on_release=self.cancelOutput) self.outputing = True outputButton.bind(on_release=self.saveOutput) self._popup.open()
def declare_buttons(self): # sight clear self.sight_clear_btn = Button(text="Clear S", font_size='20sp') self.sight_clear_btn.bind(on_press=self.sight_clear) # Hearing clear self.hearing_clear_btn = Button(text="Clear H", font_size='20sp') self.hearing_clear_btn.bind(on_press=self.hearing_clear) # Bum btn self.bum_btn = Button(text="Bum", font_size='20sp') self.bum_btn.bind(on_release=self.bum) # Bip btn self.bip_btn = Button(text="Bip", font_size='20sp') self.bip_btn.bind(on_release=self.bip) # Check btn self.check_btn = Button(text="Check", font_size='20sp') self.check_btn.bind(on_release=self.check) # Clack btn self.clack_btn = Button(text="Clack", font_size='20sp') self.clack_btn.bind(on_release=self.clack) # Toggle button (Words, Numbers) self.episodes_tgl_btn = ToggleButton(text="Episodes", font_size='20sp', group="bbcc_protocol", state="down", allow_no_selection=False) self.intentions_tgl_btn = ToggleButton(text="Intentions", font_size='20sp', group="bbcc_protocol", allow_no_selection=False)
def __init__(self, **kwargs): kwargs['background_normal'] = 'media/btn.png' if kwargs['group'] == 'notes': kwargs['background_down'] = 'media/btn_down_g.png' else: kwargs['background_down'] = 'media/btn_down.png' kwargs['border'] = (2, ) * 4 if kwargs.get('state') == 'down': kwargs['color'] = COLOR_DOWN else: kwargs['color'] = COLOR_NORMAL if kwargs['group'] == 'notes': kwargs['font_name'] = 'DroidSans-Regular.ttf' kwargs['font_size'] = 15 kwargs['markup'] = False self.rel = kwargs['rel'] del kwargs['rel'] ToggleButton.__init__(self, **kwargs) self.bind(state=state_change)
def __init__(self, row, **kwargs): super(DirectionRow, self).__init__(**kwargs) self.rows = 1 self.add_widget( ToggleButton(font_name='myfont', font_size='22sp', text="→", group=str(row))) self.add_widget( ToggleButton(font_name='myfont', font_size='22sp', text="←", group=str(row))) self.add_widget( ToggleButton(font_name='myfont', font_size='22sp', text='⇆', group=str(row))) self.add_widget( ToggleButton(font_name='myfont', font_size='22sp', text='⇄', group=str(row)))
def set(self): self.selectMale = False self.selectFemale = False self.orientation = 'horizontal' self.spacing = 10 self.padding = (10, 10) self.l = Label(text='Gender', size_hint=(1.5, 1), font_name="candara", font_size=25, color=(0, 0, 0, 1)) self.add_widget(self.l) self.m = ToggleButton(text='Male', group='gender', font_size=18, size_hint=(1, .7), on_press=self.selectM, background_color=(.5, 0, 1, .6)) self.add_widget(self.m) self.f = ToggleButton(text='Female', group='gender', font_size=18, size_hint=(1, .7), on_press=self.selectF, background_color=(.5, 0, 1, .6)) self.add_widget(self.f)
def build(self): # Set up the layout: layout = GridLayout(cols=5, spacing=30, padding=30, row_default_height=150) # Make the background gray: with layout.canvas.before: Color(.2,.2,.2,1) self.rect = Rectangle(size=(800,600), pos=layout.pos) # Instantiate the first UI object (the GPIO input indicator): inputDisplay = InputButton(text="Input") # Schedule the update of the state of the GPIO input button: Clock.schedule_interval(inputDisplay.update, 1.0/10.0) # Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl = ToggleButton(text="COUCH") outputControl.bind(on_press=press_callback) beepButton = Button(text="COUNTER") beepButton.bind(on_press=press_callback) # Add the UI elements to the layout: layout.add_widget(inputDisplay) layout.add_widget(outputControl) layout.add_widget(beepButton) return layout
def stop_record(self): global stream global audio global playButton global finishButton stream.stop_stream() stream.close() audio.terminate() self.record_button.__setattr__('pos_hint', {'center_x': .38, 'y': .5}) playButton = ToggleButton( text='Play', size_hint=(None, None), size=(150, 50), pos_hint={'center_x': .62, 'y': .5}) finishButton = ToggleButton( text='Edit', size_hint=(None, None), size=(100, 40), pos_hint={'right': .97, 'y': .25} ) playButton.bind(on_press=self.toggle_audio) self.ids.layout2.add_widget(playButton) self.ids.layout2.add_widget(finishButton)
def __init__(self, **kwargs): super(root, self).__init__(**kwargs) self.cols = 2 firebase = fire.FirebaseApplication(fburl, token) redLedState = firebase.get('/redLed') if (redLedState == True): redLedState = "On" else: redLedState = "Off" yellowLedState = firebase.get('/yellowLed') if (yellowLedState == True): yellowLedState = "On" else: yellowLedState = "Off" self.add_widget(Label(text="Yellow LED", size_hint=(0.5, 1))) self.yellowLedButton = ToggleButton(text=yellowLedState, on_press=self.clickYellow, size_hint=(0.5, 0.5)) self.add_widget(self.yellowLedButton) self.add_widget(Label(text="Red LED", size_hint=(0.5, 1))) self.redLedButton = ToggleButton(text=redLedState, on_press=self.clickRed, size_hint=(0.5, 0.5)) self.add_widget(self.redLedButton)
def build(self): self.ui=ThermoWidget() self.ui.weatherText='ThermoWidget' self.ui.picSource='weather/1.jpg' self.ui.tempDataText="temps" self.ui.setPointText="0.0" self.ui.ipAddressText="192.168.0.0" self.ui.averageTempText="0.0" self.ui.zoneAlertsText="Loading..." btn=self.ui.ids['increase'] btn.bind(on_release=self.increaseSetPoint) btn=self.ui.ids['decrease'] btn.bind(on_release=self.decreaseSetPoint) self.zones=self.ui.ids['zones'] for z in range(0,4): btnstate='down' if self.currentZone==z else 'normal' btn = ToggleButton( allow_no_selection=False, text=str(z), group='zonegroup', size_hint=(None, None), halign='center', state=btnstate, background_normal='normal.png', background_down='down.png') btn.bind(on_release=self.switch_zone) self.zones.add_widget(btn) self.ui.weatherText=self.config.get('startup', 'weatherText') temp = subprocess.check_output(["ifconfig","wlan0"],universal_newlines=True) pos1=temp.find("inet addr:") pos2=temp.find(" Bcast:") self.ui.ipAddressText=temp[pos1+10:pos2] self.connectMQTT() Clock.schedule_interval(self.mainLoop, 10.0) return self.ui
def buildCategory(self, category): container = StackLayout() for device in category.devices: state = 'down' if device.is_on else 'normal' GPIO.output(device.pin, device.is_on) def callback(widget): device = widget.device is_on = not device.is_on Device.objects(id=widget.device.id).update(is_on=is_on) device.is_on = is_on Logger.info("Application: Seting pin %d to %s" % (device.pin, is_on)) GPIO.output(device.pin, is_on) button = ToggleButton(text=device.label, width=80, size_hint=(None, 0.15), state=state, on_press=callback) button.device = device container.add_widget(button) Logger.info("Application: Adding device %s on" % device.label) #container.add_widget( LightWidget()) return container
def build(self): # Set up the layout: layout = GridLayout(cols=5, spacing=30, padding=30, row_default_height=150) # Make the background gray: with layout.canvas.before: Color(.2,.2,.2,1) self.rect = Rectangle(size=(800,600), pos=layout.pos) # Instantiate the first UI object (the GPIO input indicator): inputDisplay = InputButton(text="Input") # Schedule the update of the state of the GPIO input button: Clock.schedule_interval(inputDisplay.update, 1.0/10.0) # Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl = ToggleButton(text="LED") outputControl.bind(on_press=press_callback) beepButton = Button(text="BEEP!") beepButton.bind(on_press=press_callback) wimg = Image(source='logo.png') speedSlider = Slider(orientation='vertical', min=1, max=30, value=speed) speedSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed) # Add the UI elements to the layout: layout.add_widget(wimg) layout.add_widget(inputDisplay) layout.add_widget(outputControl) layout.add_widget(beepButton) layout.add_widget(speedSlider) # Start flashing the LED Clock.schedule_once(flash, 1.0/speed) return layout
def build(self): parent = BoxLayout(orientation='vertical') self.graph = Graph(colors=[ Color(1, 0, 0), Color(0, 1, 0), Color(0, 0, 1), Color(1, 0, 1), Color(0, 1, 1), Color(1, 1, 0) ], height='32dp', size_hint=(1, None)) self.index = 0 self.cameras = {} #self.camera = Camera(index = 1, play = True) self.gobutton = ToggleButton(text='Go', height='48dp', size_hint=(1, None), on_press=self.on_gobutton) self.switchcambutton = ToggleButton(text='Alternate camera', height='48dp', size_hint=(1, None), on_press=self.on_switchcambutton) parent.add_widget(self.graph, index=0) #parent.add_widget(self.camera) parent.add_widget(self.gobutton, index=2) parent.add_widget(self.switchcambutton, index=3) self.parent = parent self.gobutton.state = 'down' self.on_gobutton(self.gobutton) return parent
def __init__(self, **kwargs): self._buttons = {} super(PlaygroundSizeView, self).__init__(**kwargs) for title, values in self.default_sizes: grid = GridLayout(rows=4) def sort_sizes(item): return item[1][1] * item[1][0] values = sorted(values, key=sort_sizes, reverse=True) for name, size in values: btn = ToggleButton(text='', markup=True) btntext = ('%s\n[color=777777][size=%d]%dx%d[/size][/color]' % (name, btn.font_size * 0.8, size[0], size[1])) btn.text = btntext btn.bind(on_press=partial(self.set_size, size)) grid.add_widget(btn) self._buttons[name] = btn item = AccordionItem(title=title) item.add_widget(grid) self.accordion.add_widget(item) self.accordion.select(self.accordion.children[-1]) self.update_buttons()
def submit_button(self): options = {'disable': False, 'colour': False, 'sharing': False} disable_group = ToggleButton.get_widgets('disable') colour_group = ToggleButton.get_widgets('colour') sharing_group = ToggleButton.get_widgets('sharing') # In what format to send the options to the main program???? for x in disable_group: if x.text == 'Yes' and x.state == 'down': options['disable'] = True print x.text + " " + x.state for x in colour_group: if x.text == 'Yes' and x.state == 'down': options['colour'] = True print x.text + " " + x.state for x in sharing_group: if x.text == '(1)' and x.state == 'down': options['sharing'] = True print x.text + " " + x.state app = App.get_running_app().root app.call_stage1(options, self.stage_duration)
def fill_with_chars(self): self.scroll_lay.clear_widgets() if self.save.is_saved: main_lay = self.save.get_saved() self.scroll_lay.add_widget(main_lay) return grids = {} fav = App.get_running_app().get_fav_chars() favorites = list( filter(lambda x: x.name in fav.value, characters.values())) mod = ceil(len(favorites) / 7) fav_button = ToggleButton(text='Favorites', size_hint=(1, None), height=25) if fav_button.text in self.value: fav_button.state = 'down' fav_button.bind(state=self.series_dropdown) self.main_lay.add_widget(fav_button) if fav_button.state is 'down': grids['Favorites'] = GridLayout(cols=7, size_hint=(1, None), height=60 * mod) self.main_lay.add_widget(grids['Favorites']) for s in sorted(main_series_list): self.create_series_rows(grids, s) for g in grids: self.fill_rows_with_chars(g, grids) self.main_lay.bind(minimum_height=self.main_lay.setter('height')) self.save.save() self.scroll_lay.add_widget(self.main_lay)
def render_distribuite(self,tab): self.dist_layout = GridLayout(cols=2) self.Blayout=BoxLayout(orientation='vertical') self.Blayout.size_hint=( 1, 1) btnDistr=Button(text='Start Distribuite',size_hint=(1, .1)) btnDistr.bind(on_press=self.start_dist) self.btnReckivy=ToggleButton(text='Choose recipes for Kivy Launcher',size_hint=(1, .1)) self.btnReckivy.bind(on_release=self.select_kivy_rec) self.recipe_layout = GridLayout(cols=4) thedir=os.path.join(self.py4a_path,'recipes') recipes=[ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ] for r in recipes: t=ToggleButton(text=r) t.bind(state=self.add_remove) self.recipe_layout.add_widget(t) self.Blayout.add_widget(btnDistr) self.Blayout.add_widget(self.btnReckivy) self.Blayout.add_widget(self.recipe_layout) self.dist_layout.add_widget(self.Blayout) self.dist_layout.add_widget(self.kvc) tab.add_widget(self.dist_layout)
def build(self): # Set up the layout: layout = MyGridLayout(cols=4, spacing=30, padding=30, row_default_height=150) # Make the background gray: with layout.canvas.before: Color(.2,.2,.2,1) self.rect = Rectangle(size=(800,600), pos=layout.pos) #Start Temp adn Humidity measurment Clock.schedule_interval(tempHumiMeasure,900) Clock.schedule_once(tempHumiMeasure,5) Clock.schedule_interval(Night,1) Clock.schedule_interval(ledAuto,0) Clock.schedule_once(partial(setDisplaySleepTime,15),1) # Instantiate the first UI object (the GPIO input indicator): bellImage = ImageButton(source='Bell.png') bellImage.bind(on_press=showLastBells) # Schedule the update of the state of the GPIO input button: Clock.schedule_interval(partial(bellImageRefresh,bellImage), 1.0/10.0) # Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl = ToggleButton(text="LED",font_size='25sp') outputControl.bind(on_press=press_callback) Clock.schedule_interval(partial(refreshLedButton,outputControl),0.5) timeLabel = Label(text='time',font_size='50sp') Clock.schedule_interval(partial(timeRefresh,timeLabel), 1) # Add the UI elements to the layout: layout1 = BoxLayout(orientation='vertical') l1 = Label(text="temp",font_size='25sp') Clock.schedule_interval(partial(tempRefresh,l1), 60) Clock.schedule_once(partial(tempRefresh,l1), 5) l2 = Label(text="humi",font_size='25sp') Clock.schedule_interval(partial(humiRefresh,l2), 60) Clock.schedule_once(partial(humiRefresh,l2), 5) l3 = Label(text=" ",font_size='25sp') videoArchiveBtn = Button(text='Video archív') videoArchiveBtn.bind(on_press=videoArchiveBtnCallback) layout1.add_widget(timeLabel) layout1.add_widget(l1) layout1.add_widget(l2) layout1.add_widget(l3) layout1.add_widget(videoArchiveBtn) layout2 = FloatLayout() sleepBtn = ImageButton(source='sleep.png', pos=(670,405)) sleepBtn.bind(on_press=sleepDisplayButton) layout2.add_widget(sleepBtn) layout1.add_widget(layout2) layout.add_widget(layout1) layout.add_widget(bellImage) layout.add_widget(outputControl) return layout
def right_click(self, inst, touch): if touch.button == 'right': try: if inst.collide_point(touch.x, touch.y): favorite = App.get_running_app().get_fav_chars() favorite.options = characters config = ConfigParser() config.read('mysteryonline.ini') fav_list = str(config.get('other', 'fav_characters').strip('[]')) fav_list = fav_list.replace("'", "") fav_list = fav_list.split(',') fav_list = [x.strip() for x in fav_list] for option in favorite.options: state = 'down' if option in favorite.value and option in fav_list else 'normal' btn = ToggleButton(text=option, state=state, size_hint_y=None, height=50) favorite.buttons.append(btn) for btn in favorite.buttons: if btn.text is characters[inst.name].name: if btn.state == 'normal': btn.state = 'down' else: btn.state = 'normal' favorite.value = [btn.text for btn in favorite.buttons if btn.state == 'down'] favorite.buttons.clear() self.save.is_saved = False self.main_lay.clear_widgets() self.fill_with_chars() except AttributeError: pass
def subscroll(self): """ opens scroll list of substitute characters in a popup """ for btn in SMApp.teamlist: if btn.state == 'down': SMApp.nameOff = btn btn.state = 'normal' curs.execute('SELECT * FROM Subs') layout2 = GridLayout(cols=2, spacing=10, size_hint_y=None) layout2.bind(minimum_height=layout2.setter('height')) for row in curs: btn = ToggleButton(text=str(row[0]), size_hint_y=None, height=40) if row[1] == 1: btn.background_color = (0.5, 1, 0.9, 1) layout2.add_widget(btn) btn.bind(on_press=subChar) SMApp.sublist.append(btn) lbl = Label(text=str(row[2]), size_hinty=None, height=40) layout2.add_widget(lbl) root = ScrollView(size_hint=(None, None), size=(400, 400)) root.add_widget(layout2) SMApp.popup2 = Popup(content=root, size=(7, 10), size_hint=(0.55, 0.8), title="list of subs") SMApp.popup2.open()
class BoardGrid(GridLayout): def __init__(self, **kwargs): self.mode = kwargs.pop('mode') super(BoardGrid, self).__init__(**kwargs) self.cols = 10 self.rows = 10 self.fill_grid() def fill_grid(self): board = g.player1.board col = board.columns[:10] row = board.index if self.mode == 'player': board_list = board.iloc[:, :10].stack().tolist() if self.mode == 'opponent': board_list = board.iloc[:, 12:].stack().tolist() print(self.mode) for i in board_list: self.btn = ToggleButton(text=str(i)) self.add_widget(self.btn) self.btn.bind(on_press=self.pressed) def pressed(self, instance): winner = g.goRound()
def __init__(self, **kwargs): super().__init__(**kwargs) self.orientation = 'lr-tb' self.start_cell_input = None self.end_cell_input = None # Padding = gauche, haut, droit, bas self.padding = dp(10) self.spacing = dp(2) # for i in range(100): # b = Button(text=str(i+1), size_hint=(None, None), size=(dp(60), dp(60))) # self.add_widget(b) for i in self.wb.sheetnames: b = ToggleButton(text=i, size_hint=(None, None), size=(dp(260), dp(60)), group="sheet") # b = Button(text=i, size_hint=(None, None),) self.add_widget(b) b.bind(on_press=self.callback) self.start_cell_input = TextInput(size_hint=(None, None), size=(dp(60), dp(60)), multiline=False) self.start_cell_input.bind(text=self.on_text) self.add_widget(self.start_cell_input) self.end_cell_input = TextInput(size_hint=(None, None), size=(dp(60), dp(60)), multiline=False) self.end_cell_input.bind(text=self.on_text) self.add_widget(self.end_cell_input) validate = Button(text="Convert", size_hint=(None, None), size=(dp(260), dp(60))) validate.bind(on_press=self.validate) self.add_widget(validate)
def __init__(self, **kwargs): super(Screen, self).__init__(**kwargs) #Screen Options self.cols = 1 #screen have just 1 column self.rows = 2 #screen have 2 rows self.padding = 20 #define buttons listButton = ToggleButton(id='list', text='Lista') ledButton = ToggleButton(id='led', text='LED') USBConnect = ToggleButton(id='connect', text='Connect') #subscreen for USB LIST global USB USB = GridLayout( cols=1) #define a gridlayout to place USBs device list #top subscreen to USB OPTIONS USBOptions = BoxLayout(orientation='horizontal', spacing='10') USBOptions.add_widget(listButton) USBOptions.add_widget(USB) USBOptions.add_widget(USBConnect) #subscreen control menu menuOptions = BoxLayout(orientation='horizontal', spacing='10') menuOptions.add_widget(ledButton) #placing widget self.add_widget(USBOptions) self.add_widget(menuOptions)
def build(self): global function_callback self.ids.gridlayout2.clear_widgets() with open("database1.json", "r") as f: data = f.read() f.close() db = json.loads(data) if len(btns_down) > 1: print('error') pass elif len(btns_down) == 1: for key in db.keys(): if btns_down[0] == key: name = key else: print('not in dict') else: pass #create object for func in LightsView function_callback = LightsView() try: for element in db[name]: btn = ToggleButton(text='%s' % element, size=(600, 40), size_hint=(None, None)) #create button btn.bind(state=function_callback.lightscallback) self.ids.gridlayout2.add_widget(btn) #add to gridlayout self.ids.gridlayout2.bind( minimum_height=self.ids.gridlayout2.setter('height')) except: print('error') pass
def add_button(self, name, func, is_tf=True, is_toggle=True, **kwargs): """ Create buttons handling different options and attaching to the given function. By default, the function is an image transforms and is applied through self.on_click_transform. For more specific functions, you need to define them in th class and use is_tf=False. :param name: Button label :param func: function to run on click :param is_tf: True if the function is a direct image transform. """ if is_tf: self.tf_buttons[name] = (func, kwargs) btn = ToggleButton(text=name, on_press=self.on_click_transform) else: self.buttons[name] = func if is_toggle: btn = ToggleButton(text=name, on_press=func) else: btn = Button(text=name, on_press=func) btns = self.ids['buttons'] btns.add_widget(btn)
def __init__(self, root, **kwargs): super(NewAppointmentPopup, self).__init__(**kwargs) self._root = root self._popupLayout = BoxLayout(orientation = 'vertical') self._datetimePicker = DatetimePicker() self._appointmentTitleInput = TextInput(text='Was?', multiline=False) self._memberLayout = BoxLayout(orientation='horizontal') self._memberButton1 = ToggleButton(text='Papa', group='members', state='down') self._memberButton2 = ToggleButton(text='Mama', group='members') self._memberButton3 = ToggleButton(text='Fiete', group='members') self._memberButton4 = ToggleButton(text='Oma', group='members') self._memberLayout.add_widget(self._memberButton1) self._memberLayout.add_widget(self._memberButton2) self._memberLayout.add_widget(self._memberButton3) self._memberLayout.add_widget(self._memberButton4) self._saveButton = Button(text='Speichern') self._cancelButton = Button(text='Abbrechen') self._popupLayout.add_widget(self._datetimePicker) self._popupLayout.add_widget(self._appointmentTitleInput) self._popupLayout.add_widget(self._memberLayout) self._popupLayout.add_widget(self._saveButton) self._popupLayout.add_widget(self._cancelButton) self.title='Neuer Termin:' self.content=self._popupLayout self.auto_dismiss=False self._saveButton.bind(on_press=self._newAppointmentCallback) self._cancelButton.bind(on_press=self.dismiss)
def __init__(self,**kwargs): super(root_widget,self).__init__(**kwargs) # ============================================================================= # Here, we instantiate our labels and toggle buttons. With respect to # the grid: # row 1 col 1 refers to label 1 # row 1 col 2 refers to toggle button 1 # row 2 col 1 refers to label 2 # row 2 col 2 refers to toggle button 2 # ============================================================================= self.l1 = Label(text = "Yellow LED", font_size = 15) self.t1 = ToggleButton(text = "off" if firebase.get("/yellow_led_status") == "normal" else "on", # <-- Toggle button makes reference to firebase before displaying text state = firebase.get("/yellow_led_status"), # <-- Toggle button makes reference to firebase before displaying state on_press = self.print_on_1, # <-- When toggle button is pressed (mouse click), it goes into "down" state; calls on print_on_1 function on_release = self.print_off_1) # <-- When toggle button is released (let go of mouse click)), it goes into "normal" state; calls on print_off_1 function self.l2 = Label(text = "Red LED", font_size = 15) self.t2 = ToggleButton(text = "off" if firebase.get("/red_led_status") == "normal" else "on", # This part is the same as above, but for the red LED state = firebase.get("/red_led_status"), # on_press = self.print_on_2, # on_release = self.print_off_2) # # ============================================================================= # The following four lines is where we add the two label widgets and two # toggle button widgets to the root widget. # This is necessary because the build/run function in kivy can only # return one object, which is the root widget by convention. # ============================================================================= self.add_widget(self.l1) self.add_widget(self.t1) self.add_widget(self.l2) self.add_widget(self.t2)
def set_aperture(self,new_ind): self.ids.fitdisplay.remove_plot(self.thetrace) self.ids.fitdisplay.remove_plot(self.thefit) self.ids.pointlist.clear_widgets() self.ap_index = new_ind x1, y1 = zip(*self.tracepoints[self.ap_index]) x2, y2 = x1, self.polyfits[self.ap_index](x1) self.thetrace = MeshLinePlot(color=(1,0,0,1), points = [x for (i, x) in \ self.tracepoints[self.ap_index] if self.traceselectors[self.ap_index][i]]) self.thetrace.mode = 'points' self.ids.fitdisplay.add_plot(self.thetrace) self.thefit = MeshLinePlot(color=(0,1,0,1), points = izip(x2, y2)) self.ids.fitdisplay.add_plot(self.thefit) x2, y2 = zip(*self.fitpoints[self.ap_index]) tmp = x1 + x2 self.xmin, self.xmax = tmp.min(), tmp.max() tmp = y1 + y2 self.ymin, self.ymax = tmp.min(), tmp.max() self.point_buttons = [] for i, p in enumerate(self.tracepoints[self.ap_index]): tmp = ToggleButton(text='X: {0:7.2d}, Y: {1:7.2d}'.format(*p), \ on_press=self.toggle_point(i, tmp.state)) tmp.state = 'down' if self.traceselectors[self.ap_index][i] else 'normal' self.point_buttons.append(tmp) self.ids.pointlist.add_widget(tmp)
def __init__(self): super(GameBoardEditModeInput, self).__init__("edit mode") self.app = App.get_running_app() self.value = self.app.data['game_board']['edit_mode'] self.options = BoxLayout(orientation='horizontal', size_hint=[1.0, None], height=20) self.alternate_button = ToggleButton(text="alternate", group='game_board_edit_mode', font_size=13) self.consecutive_button = ToggleButton(text="consecutive", group='game_board_edit_mode', font_size=13) self.alternate_button.allow_no_selection = False self.consecutive_button.allow_no_selection = False self.options.add_widget(self.alternate_button) self.options.add_widget(self.consecutive_button) self.add_widget(self.options) if self.value == 'alternate': self.alternate_button.state = 'down' elif self.value == 'consecutive': self.consecutive_button.state = 'down' self.alternate_button.bind(on_release=self.alternateButtonPressed) self.consecutive_button.bind(on_release=self.consecutiveButtonPressed)
def draw_filter(self): """Create a list of toggle buttons to allow user to show which buses should be shown on the screen. """ # If we've got no filter then we need to set it up: if self.filters is None: # Clear the previous filter self.ids.bx_filter.clear_widgets() # Get the list of unique bus routes and apply a natural sort. routes = sorted(set([x["route"] for x in self.buses]), key=natural_sort_key) # Create a toggle button for each route and set it as enabled # for now. for route in routes: route_found = False for child in self.ids.bx_filter.children: if (route == child.text): route_found = True if (route_found == False): tb = ToggleButton(text=route, state="down") tb.bind(state=self.toggled) self.ids.bx_filter.add_widget(tb) # Run the "toggled" method now as this updates which buses are shown. self.toggled(None, None)
class SliderulMeu(GridLayout): def __init__(self, **kwargs): super(SliderulMeu, self).__init__(**kwargs) self.cols = 1 self.padding = 150 self.toggle1 = ToggleButton(text="muzica") self.toggle1.background_normal = "on.png" self.toggle1.background_down = "off.png" self.add_widget(self.toggle1) self.arata_volum = Label (text = "volum: 10") self.add_widget(self.arata_volum) self.slide_muzica = Slider(min=0, max=100, value=10) self.slide_muzica.step = 5 self.slide_muzica.orientation="horizontal" # alte optiuni 'vertical' self.add_widget(self.slide_muzica) self.toggle1.bind(on_press=self.dezactiveaza_volum) self.slide_muzica.bind(value=self.valoare_volum) def valoare_volum (self,x,y): '''utilziat pentru a vedea volumul''' self.arata_volum.text = "volum: "+str(int(self.slide_muzica.value)) def dezactiveaza_volum (self,x): '''utilziat pentru a acctiva sau a dezactiva slider-ul''' if (self.toggle1.state == "down") : self.slide_muzica.disabled =True else: self.slide_muzica.disabled =False self.slide_muzica.value = 0
def _create_subpopup(self, instance): ''' shows the sub popup ''' # create the popup content = GridLayout(cols=1, spacing='5dp') scrollview = ScrollView( do_scroll_x=False) scrollcontent = GridLayout(cols=1, spacing='5dp', size_hint=(None, None)) scrollcontent.bind(minimum_height=scrollcontent.setter('height')) self.subpopup = popup = Popup(content=content, title=self.uOption, size_hint=(0.5, 0.9), auto_dismiss=False) #we need to open the popup first to get the metrics popup.open() #Add some space on top content.add_widget(Widget(size_hint_y=None, height=dp(2))) # add all the options uid = str(self.uid) for option in self.aSubOption: state = 'down' if option == self.value else 'normal' oTbtn = ToggleButton(text=option, state=state, group=uid, size=(popup.width, dp(55)), size_hint=(None, None)) oTbtn.bind(on_release=self._set_suboption) scrollcontent.add_widget(oTbtn) # finally, add a cancel button to return on the previous panel scrollview.add_widget(scrollcontent) content.add_widget(scrollview) content.add_widget(SettingSpacer()) oMbtn = cMultiLineButton(text=ReplaceVars('$lvar(5009)'), size=(popup.width, dp(50)),size_hint=(0.9, None), halign='center', valign='middle') oMbtn.bind(on_release=popup.dismiss) content.add_widget(oMbtn)
def makeHeaderLayout(self): layout = self.HeaderLayout layout.clear_widgets() self.btnP = Button(text="Update", size_hint_x=None, width = self.factor*125) self.btnP.bind(on_press = buttonUpdate) layout.add_widget(self.btnP) btnSep = Button(text="", size_hint_x=None, width = self.factor*50) layout.add_widget(btnSep) self.btnLi = ToggleButton(text="List", group='menu', size_hint_x=None, width = self.factor*125, state='down') self.btnLi.bind(on_press = buttonList) layout.add_widget(self.btnLi) self.btnV = ToggleButton(text="VM Launcher", group='menu', size_hint_x=None, width = self.factor*125) self.btnV.bind(on_press = buttonVM) layout.add_widget(self.btnV) self.btnSta = ToggleButton(text="Statistics", group='menu', size_hint_x=None, width = self.factor*125) self.btnSta.bind(on_press = buttonStatistics) layout.add_widget(self.btnSta) self.btnL = ToggleButton(text="Log", group='menu', size_hint_x=None, width = self.factor*125) self.btnL.bind(on_press = buttonLog) layout.add_widget(self.btnL) self.btnS = Button(text="Settings", size_hint_x=None, width = self.factor*125) self.btnS.bind(on_press = buttonSettings) layout.add_widget(self.btnS)
def __init__(self, tabbed_cef_browser, url="", text="", cef_browser=None): super(TabbedCEFBrowserTab, self).__init__(rows=1, size_hint=(None, 1), width=controls_size * 10) self.__tabbed_cef_browser = tabbed_cef_browser self.url = url self.text = text self.__toggle_button = ToggleButton(text=text, group="tabs", font_size=controls_size / 2, size_hint=(1, 1), text_size=(controls_size * 10, controls_size), shorten=True, shorten_from="right", valign="middle", padding_x=5) self.__toggle_button.bind( size=self.__toggle_button.setter("text_size")) self.add_widget(self.__toggle_button) self.__close_button = Button(text="X", background_color=(1, 0, 0, 1), font_size=controls_size / 2, size_hint=(None, 1), width=controls_size) self.__close_button.bind(on_press=self.close) self.__toggle_button.bind(state=self._on_toggle_state) self.bind(text=self._on_text) if cef_browser: self.__cef_browser = cef_browser self.__configure_cef_browser()
def buildToggleBtns(self): layout = GridLayout(cols=4) layout.add_widget(ToggleButton(text="Master", state="down")) layout.add_widget(ToggleButton(text="Expressions")) layout.add_widget(ToggleButton(text="Food")) layout.add_widget(ToggleButton(text="Science")) return layout
def __init__(self, **kwargs): kwargs['background_normal'] = 'media/btn.png' if kwargs['group'] == 'notes': kwargs['background_down'] = 'media/btn_down_g.png' else: kwargs['background_down'] = 'media/btn_down.png' kwargs['border'] = (2,) * 4 if kwargs.get('state') == 'down': kwargs['color'] = COLOR_DOWN else: kwargs['color'] = COLOR_NORMAL if kwargs['group'] == 'notes': kwargs['font_name'] = 'DroidSans-Regular.ttf' kwargs['font_size'] = 15 kwargs['markup'] = False self.rel = kwargs['rel'] del kwargs['rel'] ToggleButton.__init__(self, **kwargs) self.bind(state=state_change)
def editResults(self, *arg): self.shots = Global.shotsFiltered if Global.mapped == False: self.map = [] for shot in self.shots: self.map.append(1) else: self.map = Global.map self.ids.tableAngles.clear_widgets() self.ids.tableAngles.rows = len(self.shots) for i in range(0, len(self.shots)): st = "down" if Global.mapped: if self.map[i] == 0: st = "normal" shot = self.shots[i] theta = round(calc.angle(shot[0])) tog = ToggleButton(text=str(theta), state=st, group=str(i), height=40, size_hint_y=None) tog.bind(state=self.toggleShot) self.ids.tableAngles.add_widget(tog) self.refreshImage()
class Transport(AnchorLayout): btn_play = '' def __init__(self, **kwargs): super(Transport, self).__init__(**kwargs) self.medium = kwargs.get('medium', '') self.anchor_x = 'center' self.anchor_y = 'top' btn_size = "30px" self.btn_play = ToggleButton( size=(btn_size, btn_size), size_hint=(None, None), background_normal='images/play.png', background_down='images/pause.png', border=(0,0,0,0), state='down') self.add_widget(self.btn_play) self.btn_play.bind(on_release=self.medium.toggle_play_status) self.padding = 10 def on_spacebar_pressed(self, *args): self.btn_play.state = 'normal' \ if self.btn_play.state == 'down' else 'down' self.medium.toggle_play_status()
def __init__(self, **kwargs): self.register_event_type('on_seleccion') self.register_event_type('on_salvar') self.register_event_type('on_restaurar') super(LayoutParametro, self).__init__(orientation='horizontal', size_hint=kwargs['size_hint'], pos_hint=kwargs['pos_hint']) self.bot_sel = ToggleButton(text=kwargs['text'], group='parametro') self.add_widget(self.bot_sel) self.bot_sel.bind(on_press=self.__seleccionado) self.txt_valor_act = Label(text='0.0') self.add_widget(self.txt_valor_act) self.txt_valor_sal = Label(text='0.0') self.add_widget(self.txt_valor_sal) self.bot_sal = Button(text='Salvar') self.add_widget(self.bot_sal) self.bot_sal.bind(on_press=self.__salvado) self.bot_res = Button(text='Restaurar') self.add_widget(self.bot_res) self.bot_res.bind(on_press=self.__restaurado) self.bind(valor_act=self.__valor_cambiado) self.bind(valor_sal=self.__valor_cambiado)
def __init__(self): super(GameBoardNextStoneInput, self).__init__("next stone") self.app = App.get_running_app() self.value = self.app.data['game_board']['next_stone'] self.options = BoxLayout(orientation='horizontal', size_hint=[1.0, None], height=20) self.black_button = ToggleButton(text="black", group='game_board_next_stone', font_size=13) self.white_button = ToggleButton(text="white", group='game_board_next_stone', font_size=13) self.black_button.allow_no_selection = False self.white_button.allow_no_selection = False self.options.add_widget(self.black_button) self.options.add_widget(self.white_button) self.add_widget(self.options) if self.value == 'black': self.black_button.state = 'down' elif self.value == 'white': self.white_button.state = 'down' self.black_button.bind(on_release=self.blackButtonPressed) self.white_button.bind(on_release=self.whiteButtonPressed)
class GameBoardModeInput(PanelSettingsInput): def __init__(self): super(GameBoardModeInput, self).__init__("game mode") self.app = App.get_running_app() self.value = self.app.data['game_board']['mode'] self.options = BoxLayout(orientation='horizontal', size_hint=[1.0, None], height=20) self.play_button = ToggleButton(text="play", group='game_board_mode', font_size=13) self.edit_button = ToggleButton(text="edit", group='game_board_mode', font_size=13) self.play_button.allow_no_selection = False self.edit_button.allow_no_selection = False self.options.add_widget(self.play_button) self.options.add_widget(self.edit_button) self.add_widget(self.options) if self.value == 'edit': self.edit_button.state = 'down' elif self.value == 'play': self.play_button.state = 'down' self.play_button.bind(on_release=self.playButtonPressed) self.edit_button.bind(on_release=self.editButtonPressed) def playButtonPressed(self, *largs): self.app.data['game_board']['mode'] = 'play' self.value = 'play' def editButtonPressed(self, *largs): self.app.data['game_board']['mode'] = 'edit' self.value = 'edit'
def buildlist2(self, ip): for row in curs.execute( "SELECT Light_name FROM Lights WHERE IP_address = '" + ip + "'"): ln = row[0] print('building list') self.ids.gridlayout.clear_widgets() for row in curs.execute( "SELECT Light_name FROM Lights WHERE Room='X'"): btn = ToggleButton(id=row[0], text='%s' % row[0], size=(360, 45), size_hint=(None, None)) #create button btn.bind(state=self.lightscallback) self.ids.gridlayout.add_widget(btn) #add to gridlayout btn.state = 'down' btn.state = 'up' self.ids.gridlayout.bind( minimum_height=self.ids.gridlayout.setter('height')) if btn.id == ln: self.ids.gridlayout.remove_widget(btn) curs.execute("DELETE FROM Lights WHERE IP_address = '" + ip + "'") conn.commit() pass else: pass
def crear_botones_cursos(self, ciclo_seleccionado): contenedor_cursos=self.root.ids.contenedor_cursos contenedor_cursos.clear_widgets() lista_cursos_asociados=self.todos_cursos.filter(ciclo_id=ciclo_seleccionado.id) for curso in lista_cursos_asociados: btn_curso=ToggleButton(text=curso.nombre_curso, height=45, group="cursos") btn_curso.bind(on_press=self.on_curso_seleccionado) contenedor_cursos.add_widget(btn_curso)
def crear_botones_modulos(self, curso_seleccionado): contenedor_modulos=self.root.ids.contenedor_modulos contenedor_modulos.clear_widgets() lista_modulos=self.todos_modulos.filter(curso_id=curso_seleccionado.id) for m in lista_modulos: btn_modulo=ToggleButton(text=m.nombre, height=45, group="modulos") btn_modulo.bind(on_press=self.on_modulo_seleccionado) contenedor_modulos.add_widget(btn_modulo)
def create_button(self, dic, line, layout, id, group): line = line.replace('\n', '') dic[line] = 0 btn = ToggleButton(text='%s' % line, group=group) btn.id = id layout.add_widget(btn)
class Light: def __init__(self, lifxlight, rooms): self.lifxlight = lifxlight self.rooms = rooms self.label = self.lifxlight.get_label() self.group = self.lifxlight.get_group_label() Logger.info("Lights: New light %s / %s" % (self.label, self.group)) self.button = ToggleButton(text=self.label) self.button.bind(state=self.callback) def button_state(self): return False if self.button.state == 'normal' else True def callback(self, instance, value): """Ensures that light is set to same state as button""" button_state = False if value == 'normal' else True light_state = self.get_state() if light_state != button_state: # Is light offline? if light_state is None: return self.lifxlight.set_power(button_state) self.rooms.refresh() Logger.debug("Lights: Light is %s, value is %s, get_power is %s" % (self.label, value, self.get_state())) def refresh_light(self): light_state = self.get_state() if light_state is True: self.button.state = 'down' if light_state is False: self.button.state = 'normal' if light_state is None: self.button.state = 'normal' def get_state(self): try: power = self.lifxlight.get_power() except IOError: # Light is offline return None if power in LIFX_LAN_OFF: return False if power in LIFX_LAN_ON: return True return None
def build(self): global sounds,icons sounds,icons=loadData() #showmissingSounds() show = DEFAULT_SHOWTIME global MAX_NBITEMS MAX_NBITEMS = len(icons) g = MemoryLayout(rows=4,items = DEFAULT_NBITEMS, level=show,size_hint=(1,.9)) config = BoxLayout(orientation='horizontal',spacing=10, size_hint=(1,.1)) sound = ToggleButton(text='Sound On', size_hint=(0.1,1)) sound.bind(on_press=MemoryButton.toggleSound) pb = MyPb(max=DEFAULT_NBITEMS, size_hint=(0.7,1),ml=g) score = LabelScore(text="Time: 0 s",size_hint=(0.1,1)) missed = LabelMissed(text="Missed: 0",size_hint=(0.1,1)) config.add_widget(pb) config.add_widget(score) config.add_widget(missed) config.add_widget(sound) g.bind(missed=missed.update) g.bind(elapsed=score.updateTime) g.bind(left=pb.foundAnItem) g.bind(items=pb.newNbItems) playZone = BoxLayout(orientation='vertical') playZone.add_widget(g) playZone.add_widget(config) #select DEFAULT_NBITEMS shuffle(icons) iicons=icons[:DEFAULT_NBITEMS] iicons=iicons+iicons shuffle(iicons) for i in iicons: s = i.split(".png")[0].split(sep)[1] if sounds.has_key(s): aSound = choice(sounds[s]) else: aSound = sounds['default'][0] btn = MemoryButton( text="", filenameIcon=i, filenameSound=aSound, ) g.add_widget(btn) root=FloatLayout() root.add_widget(Image(source='Jungle_Background_-_by-vectorjungle.jpg',allow_stretch=True,keep_ratio=False)) root.add_widget(playZone) Clock.schedule_interval(g.initialCountdown,1) return root
def _create_popup(self, instance): # create the popup content = BoxLayout(orientation='vertical', spacing='5dp') box = GridLayout(cols=1, spacing="5dp") box.bind(minimum_height=box.setter('height')) self.popup = popup = Popup(content=content, title=self.title, size_hint=(None, 1), width='400dp') #popup.height = len(self.options) * dp(55) + dp(150) # add all the options content.add_widget(Widget(size_hint_y=None, height=1)) uid = str(self.uid) for option in self.options: state = 'down' if option == self.value else 'normal' btn = ToggleButton(text=option, state=state, group=uid) btn.bind(on_release=self._set_option) box.add_widget(btn) #box.height = metrics.dp(35) * len(self.options) scroll = ScrollView(pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, size_hint=(1, 1)) scroll.add_widget(box) content.add_widget(scroll) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='OK') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=self.popup.dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # and open the popup ! popup.open()
def build(self): # Title and icon for program self.icon = 'memoIcon.png' self.title = 'Pro Soccer Mem 15' items, level = load_level() global g g = MemoryLayout(rows=4, items=items, level=level, size_hint=(1, .9)) config = BoxLayout(orientation='horizontal', spacing=10, size_hint=(1, .1)) narrate_box = BoxLayout(orientation='horizontal', spacing=10, size_hint=(1, .1)) sound = ToggleButton(text='Sound On', size_hint=(0.15, 1)) sound.bind(on_press=MemoryButton.toggle_sound) pb = MyPb(max=items, size_hint=(0.55, 1), ml=g) timing = LabelTime(text="Time: 0 s", size_hint=(0.15, 1)) score = LabelScore(text="Score: 0 - 0", size_hint=(0.15, 1)) narration = LabelNarrate(text="Welcome to Pro Soccer Mem 15. Loading...", size=(1, 1)) narrate_box.add_widget(narration) config.add_widget(pb) config.add_widget(timing) config.add_widget(score) config.add_widget(sound) g.bind(narration=narration.update) g.bind(score=score.update) g.bind(elapsed=timing.update_time) g.bind(left=pb.found_an_item) g.bind(items=pb.new_nb_items) play_zone = BoxLayout(orientation='vertical') play_zone.add_widget(g) play_zone.add_widget(narrate_box) play_zone.add_widget(config) root = FloatLayout() root.add_widget(Image(source='court.jpg', allow_stretch=True, keep_ratio=False)) root.add_widget(play_zone) # Screen manager global sm sm = ScreenManager() settings_screen = SettingsScreen(name='settings') settings_screen.add_widget(root) sm.add_widget(MenuScreen(name='menu')) sm.add_widget(CreditsScreen(name='credits')) sm.add_widget(settings_screen) return sm
def set_rule_chooser(self): if self.lsystem: name,(axiom,rules,angle) = self.lsystem else: rules = {} self.rule_chooser.clear_widgets() for name in ["axiom"]+sorted(rules.keys()): btn = ToggleButton(text=name, group='rules',size_hint_y=None,height=sp(30)) if name == 'axiom': btn.state = 'down' btn.bind(on_press = self.on_rule_choose) self.rule_chooser.add_widget(btn)
def add_items(self, choices): for choice in choices: btn = ToggleButton(text=choice, size_hint_y=None, height=44) self.add_widget(btn) btn.bind(on_press=self.update) self.division_buttons.append(btn) for i in self.division_buttons: if i in self.current_division: i.state = "down"
def editgroup(self, widget): self.dropdown.clear_widgets() for player in sorted(self.currentplayer.all_zones, key=lambda x: x.player_name): btn = ToggleButton(text='%s' % (player.player_name,), size_hint_y=None, height=60) btn.bind(on_release=partial(self.makegroup, player)) if player in self.currentplayer.group.members: btn.state = "down" self.dropdown.add_widget(btn) self.dropdown.open(widget)
def buildKivyNoteMap(self, toshow, i, notesandrightspeed = None): """ levelstarts = toshow.song.startparts levelends = toshow.song.endparts hands = toshow.song.handparts """ x = toshow.notes[i] btn = KivyNoteMap() btn.build(x) #btn.chord.playstream = self.stream btn.add_widget(btn.chord) btn.chord.bind(on_press=self.adapter.selectBtn) #btn.add_widget(btn.myduration) #btn.add_widget(btn.myvolume) tmp = ToggleButton(text = "levelstart" ) if btn.inchord.pos in self.song.startparts: tmp.state = 'down' self.levelstarts[btn.inchord.pos] = tmp btn.add_widget(tmp) #self.endparts=[] tmp = ToggleButton(text = "levelend" ) if btn.inchord.pos in self.song.endparts: tmp.state = 'down' self.levelends[btn.inchord.pos] = tmp btn.add_widget(tmp) """ tmp = Spinner(text="hand", values = map(str,self.song.handparts)) #tmp = ToggleButton(text = "levelend" ) tmp.text = str(btn.inchord.hand) self.hands[btn.inchord.pos] = tmp btn.add_widget(tmp) """ btn.add_widget(btn.myoffset) #self.widget.add_widget(btn) return [btn]
def mediakraken_find_server_list(self): self.server_list = common_network_mediakraken.com_net_mediakraken_find_server() if self.server_list is not None: for found_server in self.server_list: btn1 = ToggleButton(text=self.server_list[found_server][1], group='mediakraken_server', ) btn1.bind(on_press=partial(self.MediaKraken_Event_Button_Server_Select, found_server)) self.root.ids.mediakraken_server_list_layout.add_widget(btn1) else: # go back to main menu self.root.ids._screen_manager.current = 'Main_Remote'
def filebar(self): layout=BoxLayout(padding='2sp',size_hint=(1,None),height='100sp') layout.orientation='horizontal' files = self.element.files(self.current_ex) for f in files: if f.strip() == self.current_file: button = ToggleButton(text=f,group = self.current_ex,state='down') else: button = ToggleButton(text=f,group = self.current_ex,state='normal') button.bind(on_press=self.update_currentFile) layout.add_widget(button) return layout