def _create_popup(self, instance): # global oORCA # create the popup mod_name, func_name = self.function_string.rsplit('.', 1) mod = importlib.import_module(mod_name) func = getattr(mod, func_name) self.options = func() 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.popup = popup = Popup(content=content, title=self.title, 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.options: state = 'down' if option == self.value else 'normal' btn = ToggleButton(text=option, state=state, group=uid, size=(popup.width, dp(55)), size_hint=(None, None)) btn.bind(on_release=self._set_option) scrollcontent.add_widget(btn) # finally, add a cancel button to return on the previous panel scrollview.add_widget(scrollcontent) content.add_widget(scrollview) content.add_widget(SettingSpacer()) # btn = Button(text='Cancel', size=((oORCA.iAppWidth/2)-sp(25), dp(50)),size_hint=(None, None)) btn = Button(text='Cancel', size=(popup.width, dp(50)), size_hint=(0.9, None)) btn.bind(on_release=popup.dismiss) # popup.bind(on_dismiss=self.action) content.add_widget(btn)
def __init__(self, *args, **kwargs): self.render_context = RenderContext() super(RvitWidget, self).__init__(**kwargs) self.top_buttons = BoxLayout(orientation='horizontal', size_hint=(1.0, None), size=(0, 20), pos_hint={'right': 1.0, 'top': 1.0},) self.title_label = Label() self.top_buttons.add_widget(self.title_label) self.configurable_properties = {} if 'inspect' in dir(self): self.inspect_button = Button(text='inspect', on_press=lambda x: self.inspect(), background_color=rvit.core.WHITE, pos_hint={'x': 0.0, 'top': 1.0}) self.top_buttons.add_widget(self.inspect_button) self.disable_button = ToggleButton(size_hint=(None, None), background_color=rvit.core.RED, size=(20, 20), state='down', ) def enabled_state_changed(inst, value): self.enabled = value == 'down' self.enabled = True self.disable_button.bind(state=enabled_state_changed) self.top_buttons.add_widget(self.disable_button) self.add_widget(self.top_buttons) self.render_context['modelview_mat'] = Matrix().identity() self.render_context['projection_mat'] = Matrix().identity() self.render_context['window_size'] = [float(Window.width), float(Window.height)] self.canvas.before.add(self.render_context) self.update_event = None # self.update_interval.dispatch() # self.on_show_controls prop = self.property('update_interval') # dispatch this property on the button instance prop.dispatch(self)
def __init__(self, **kwargs): super(self.__class__, self).__init__(**kwargs) self.cols = 3 # clock self.clock = Label(text='') self.tick(0) self.add_widget(self.clock) Clock.schedule_interval(self.tick, 60) # calc self.add_widget(Label(text='M97 P1000')) self.calc = Button(text='', font_size=32) self.calc.bind(on_press=self.doM) self.add_widget(self.calc) # stock self.add_widget(Label(text='Заготовка')) self.length = NumInput(text='123', multiline=False, font_size=32, input_type='number') self.length.bind(text=self.on_text) self.add_widget(self.length) self.units = ToggleButton(text='СМ', state='down') self.units.bind(on_press=self.cmmm) self.add_widget(self.units) # detail self.add_widget(Label(text='Деталь')) self.detail = NumInput(text='45', multiline=False, font_size=32, input_type='number') self.detail.bind(text=self.on_text) self.add_widget(self.detail) self.add_widget(Label(text='мм')) # cutter self.add_widget(Label(text='Отрезной')) self.cutter = NumInput(text='4', multiline=False, input_type='number') self.cutter.bind(text=self.on_text) self.add_widget(self.cutter) self.add_widget(Label(text='мм')) # chuck self.add_widget(Label(text='Патрон')) self.chuck = NumInput(text='100', multiline=False, input_type='number') self.chuck.bind(text=self.on_text) self.add_widget(self.chuck) self.add_widget(Label(text='мм')) # default calc self.calculate()
def custom_exposure_added(self, tb): try: self.exposure = str_to_exp(tb.text) if self.exposure not in self.expos + self.user_expos: self.user_expos += [self.exposure] if len(self.user_expos) > 10: self.user_expos = self.user_expos[-10:] self.user_gl.clear_widgets() for e in sorted(self.user_expos): self.user_gl.add_widget(ToggleButton(text=exp_to_str(e), size_hint=(.2, None), group='expos', height=dp(30), on_press=partial(self.exposure_selected, e))) for e in range(11 - len(self.user_expos)): self.user_gl.add_widget(Label(size_hint=(.2, None), height=dp(30))) self.save() except: pass
def build(self): self.icon = 'memoIcon.png' self.title = 'Kivy Memory' global sounds, icons sounds, icons = loadData() #showmissingSounds() global MAX_NBITEMS MAX_NBITEMS = len(icons) items, level = self.loadLevel() g = MemoryLayout(rows=4, items=items, level=level, size_hint=(1, .9)) config = BoxLayout(orientation='horizontal', spacing=10, size_hint=(1, .1)) sound = ToggleButton(text='Sound On', size_hint=(0.15, 1)) sound.bind(on_press=MemoryButton.toggleSound) pb = MyPb(max=items, size_hint=(0.55, 1), ml=g) score = LabelScore(text="Time: 0 s", size_hint=(0.15, 1)) missed = LabelMissed(text="Missed: 0", size_hint=(0.15, 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) 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) Clock.schedule_once(g.startGame, 3) return root
def on_enter(self): if self.hasBeenEntered: pass else: # TODO: RGB OF RED: 237, 24, 32 ::: RGB OF BLUE: 8, 21, 73 # fetch supplies and equipment from xl file sundries = Sundry(join('Sundries.xlsx')) equipment = sundries.get_equipment() # add title button and make list scrollable titleBtnEquipment = Button(text=equipment[0], font_size=findFontSize(18, self), size_hint=(0.8, 0.2), pos_hint={ 'x': 0, 'y': 0.8 }, background_color=(8 / 255, 21 / 255, 73 / 255, 1)) rootEquipment = ScrollView(size_hint=(0.8, 0.8)) layoutForEquipment = GridLayout(cols=1, spacing=1, size_hint=(1, None)) layoutForEquipment.bind( minimum_height=layoutForEquipment.setter('height')) # adds supply buttons to page for i in range(1, len(equipment), 1): btn = ToggleButton(text=equipment[i], font_size=findFontSize(12, self), size_hint_x=titleBtnEquipment.size_hint_x, size_hint_y=None, height=(Window.height / 20), background_normal='QCE-Red.png', background_down='QCE-Blue.png') self.equipment_list.append(btn) layoutForEquipment.add_widget(btn) rootEquipment.add_widget(layoutForEquipment) self.add_widget(rootEquipment) self.add_widget(titleBtnEquipment)
def build_cocktail_buttons(self, menu): for key, recipe in menu.items(): b = ToggleButton(text=recipe.name, size_hint=(1 / MENU_COLS, 1 / MENU_ROWS), halign='center', group='recipe', allow_no_selection=False, on_press=lambda b: self.stage_recipe(b.recipe)) b.recipe = recipe # set text width to 85% of the button width b.bind(width=lambda bt, w: setattr(bt, 'text_size', (w*.85, None))) self.menu_buttons.add_widget(b) self.stage_recipe(self.menu_buttons.children[-1].recipe) self.menu_buttons.children[-1].state = 'down'
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) # Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl1 = ToggleButton(text="LED 1") outputControl1.bind(on_press=press_callback) # Add the UI elements to the layout: layout.add_widget(outputControl1) return layout
def build(self): layout = GridLayout(cols=1, row_force_default=True, row_default_height=40) #title label layout.add_widget(Label(text="[color=#ffffff]music[/color][color=#ff3300]-dl[/color]", font_size="20sp", markup=True)) #add inputs layout.add_widget(urlInput) layout.add_widget(artistInput) layout.add_widget(albumInput) #type select is in a sub layout sub_layout = GridLayout(cols=5) #type select radio buttons labels = ( "mp3", "m4a", "wav", "ogg" ) for i in range(4): btn = ToggleButton(text=labels[i], group="format") btn.bind(on_press=onRadio) if(i == 0): btn.state = "down" sub_layout.add_widget(btn) #add type select sub layout to main layout layout.add_widget(sub_layout) #download button downloadButton = Button(text="Download") downloadButton.bind(on_press=onDownload) layout.add_widget(downloadButton) #button to set filenames as title tags tagButton = Button(text="Confirm File Names as MP3 Titles") tagButton.bind(on_press=onTag) layout.add_widget(tagButton) #bottom copyright label layout.add_widget(Label(text="Created by Daniel Yost - MIT License 2019", font_size="11sp", padding_y="0", markup=True)) return layout
def addControlBar(self): """ Adds bar to top of widget with various controls for that widget. """ self.top_buttons = BoxLayout( orientation='horizontal', size_hint=(1.0, None), size=(0, 20), pos_hint={ 'right': 1.0, 'top': 1.0 }, ) ## create title label self.title_label = Label() self.top_buttons.add_widget(self.title_label) ## create inspection button if 'inspect' in dir(self): self.inspect_button = Button(text='inspect', on_press=lambda x: self.inspect(), background_color=rvit.core.WHITE, pos_hint={ 'x': 0.0, 'top': 1.0 }) self.top_buttons.add_widget(self.inspect_button) ## create disable button self.disable_button = ToggleButton( size_hint=(None, None), background_color=rvit.core.RED, size=(20, 20), state='down', ) def enabled_state_changed(inst, value): self.enabled = value == 'down' self.enabled = True self.disable_button.bind(state=enabled_state_changed) self.top_buttons.add_widget(self.disable_button) ## add all created buttons to layout (i.e. display them all) self.add_widget(self.top_buttons)
def __init__(self, cols, *args, **kwargs): super().__init__(cols=cols, *args, **kwargs) n = cols self.buttons = [] for i in range(n): b = ToggleButton(text=" ", color=(1, 1, 1, 1), background_normal="", background_down="", background_color=HSVtoRGB(color(i, n)), group="my_toggles", allow_no_selection=False) b.idx = i b.bind(state=self.on_state) self.buttons.append(b) self.add_widget(b) self.buttons[0].state = "down" self.which_active = 0
def __init__(self, cm, **kwargs): super(RootWidget, self).__init__(**kwargs) layout = self.ids.light_grid self.cm = cm cm.talk("TOUCH:REGISTER:TOUCH") with layout.canvas.before: #Color(.2,.9,.2,1) #self.rect = Rectangle(size=(800,480), pos=layout.pos) for i in sorted(lights): outputControl = ToggleButton( text=i.title(), font_size=24, ) outputControl.bind(on_press=press_callback) layout.add_widget(outputControl) Clock.schedule_interval(self.update, 0.01) #print(dir(self.ids.carousel)) pass
def __init__(self): super(Config, self).__init__() self.size_hint = (0.8, 0.8) self.title = "Settings" self.name = "default" self.level = "Level 1" layout = FloatLayout() formLayout = BoxLayout(orientation="vertical", size_hint=(0.6, 0.6), pos_hint={ "top": 0.8, "right": 0.8 }) inputLayout = GridLayout(cols=2) buttonLayout = GridLayout(cols=4, size_hint=(1, 0.8)) label1 = Label(text="Name") textBox1 = TextInput(text="Enter dustbin name", multiline=False) textBox1.bind(on_text_validate=self.on_enter) inputLayout.add_widget(label1) inputLayout.add_widget(textBox1) for i in range(1, 5): floor = "Level " + str(i) btn = ToggleButton(text=floor, group="Floors") if self.name == btn.text: btn.state = "down" def setLevel(instance): self.level = floor btn.bind(on_release=setLevel) buttonLayout.add_widget(btn) formLayout.add_widget(inputLayout) formLayout.add_widget(buttonLayout) layout.add_widget(formLayout) with self.canvas: self.add_widget(layout)
def _create_sub_popup(self, instance, loc): content = BoxLayout(orientation='vertical', spacing='5dp', size_hint_y=None, height=500) content.bind(minimum_height=content.setter('height')) self.popup = popup = ScrollablePopup() config = ConfigParser() config.read('mysteryonline.ini') fav_list = str(config.get('other', 'fav_subloc').strip('[]')) fav_list = fav_list.replace("'", "") fav_list = fav_list.split(',') fav_list = [x.strip() for x in fav_list] for option in sorted(self.options): state = 'down' if option in self.value and option in fav_list else 'normal' btn = ToggleButton(text=option, state=state, size_hint_y=None, height=50) self.buttons.append(btn) for subloc in loc.sublocations: if btn.text == loc.name + '_' + subloc: content.add_widget(btn) popup.scroll_lay.add_widget(content) box = BoxLayout(size_hint_y=None, height=dp(50), pos_hint={ 'y': 0, 'x': 0 }) popup.button_lay.add_widget(box) btn = Button(text='Done', size_hint_y=None, height=dp(50)) btn.bind(on_release=self._set_options) box.add_widget(btn) btn = Button(text='Cancel', size_hint_y=None, height=dp(50)) btn.bind(on_release=self._dismiss) box.add_widget(btn) popup.open()
def make_filter_dropdown(self, button, data, init_data, callback): current_buttons = [] current_dropdown = DropDown(dismiss_on_select=False) for tag in data: # When adding widgets, we need to specify the height manually # (disabling the size_hint_y) so the dropdown can calculate # the area it needs. btn = ToggleButton(text='%s' % tag, size_hint_y=None, height=25) if tag in init_data: btn.state = 'down' # for each button, attach a callback that will call the select() method # on the dropdown. We'll pass the text of the button as the data of the # selection. btn.bind(on_release=lambda in_btn: self.update_multiselect_tags( in_btn, current_dropdown, current_buttons, callback)) current_buttons.append(btn) # then add the button inside the dropdown current_dropdown.add_widget(btn) # button.bind(on_press=current_dropdown.open) button.bind(on_release=lambda button_instance: current_dropdown.open( button_instance)) # one last thing, listen for the selection in the dropdown list and # assign the data to the button text. current_dropdown.bind( on_select=lambda instance, x: setattr(button, 'text', x)) if len(init_data) > 0: current_dropdown.select('None') tags_text = self.get_text_from_dropdown_multiselect( current_buttons) if tags_text: current_dropdown.select(tags_text) self.filter_dropdowns[button] = {current_dropdown, callback}
def build(self): layout=BoxLayout() # boxlayout is where widgets are placed adjacent to each other layout.orientation='vertical' # make adjacency of widgets vertical # create OpenCV camera self.cam=cv2.VideoCapture(0) self.cam.set(3,1280) # set resolution of camera self.cam.set(4,720) self.img=Image() # create Toggle Button for pause and play of video stream self.togbut=ToggleButton(text='Pause',group='camstart',state='down',size_hint_y=None,height='48dp',on_press=self.change_state) self.but=Button(text='Stop',size_hint_y=None,height='48dp',on_press=self.stop_stream) layout.add_widget(self.img) layout.add_widget(leb) layout.add_widget(self.togbut) layout.add_widget(self.but) Clock.schedule_interval(self.update,1.0/30) # update for 30fps return layout
def fill_crests(self, list_of_crest_names): """Places the correct crests. Loaded when the screen is called.""" #First we erase the crests that are there already self.crest_box.clear_widgets() self.available_crests = [] ##We read the save in search of the new available crests #list_of_crest_names = g.save.crests #Then add them to the box and to a parallel list that guard the btn objects for name in list_of_crest_names: btn = ToggleButton(group='crests') btn.name = name btn.background_normal = './data/images/crest_' + name + '_no.png' btn.background_down = './data/images/crest_' + name + '.png' self.crest_box.add_widget(btn) self.available_crests.append(btn) #Then we align everything right self.crest_box.size = (len(list_of_crest_names) * 90, 90) if len(list_of_crest_names) == 3: self.scroller.pos = (45, self.pos[1])
def load_file(self, file_path): if not os.path.isdir(file_path): self.load_video_and_audio(file_path) return # title等の変更 self.project_name = path2name(file_path) self.ids['project_select'].text = '> ' + self.project_name Window.set_title(f'MV Editor v{version} - {self.project_name}') self.project = ProjectData(file_path) if self.project.activate: self.ids['project_create'].text = '' self.project.update() else: self.ids['project_create'].text = 'プロジェクト作成' self.ids['project_dirs'].clear_widgets() self.ids['file_stack'].clear_widgets() return _files = os.listdir(self.project.project_path) self.project_path_listdir = [f for f in _files if os.path.isdir(os.path.join(self.project.project_path, f))] self.ids['project_dirs'].clear_widgets() for dir_count, dir_path in enumerate(self.project_path_listdir): btn = ToggleButton(text = dir_path, group = 'listdir', background_normal = self.app_resources_path + 'listdir.png', background_down = self.app_resources_path + 'listdir_down.png', height = 30, size_hint = (1,None), halign = 'left', valign = 'top', text_size = (180, 30-5), on_press = lambda x: self.dir_selected(x, x.text, x.state)) if dir_count == 0: btn.state = 'down' self.ids['project_dirs'].add_widget(btn) self.ids['project_dirs'].parent.width = 200 if len(self.project_path_listdir) > 0: self.load_files(self.project.project_path + '/' + self.project_path_listdir[0]) else: self.load_files(self.project.project_path)
def update_rooms(self): self.ids.roomlayout.clear_widgets() #open json file with open("database1.json","r") as f: data = f.read() f.close() js_dict = json.loads(data) for key in js_dict: btn = ToggleButton(text='%s' % key,size = (400, 40),size_hint=(None,None)) #create button btn.bind(state=self.callback) self.ids.roomlayout.add_widget(btn) #add to roomlayout global btns_down btns_down = [] global lights_down lights_down = []
def on_pre_enter(self, *args): sApp = App.get_running_app() sApp.root.ids.toolbar.title = 'Who pulled, and how well?' self.puller = 'puller_not_set' # print("starting pulling, off: "+str(sApp.current_point.current_sequence().offence)) for player in sApp.current_point.current_sequence().lines[ 1 - sApp.current_point.current_sequence().offence]: pb = ToggleButton(text=player.display_name, group=u'players') pickcallback = partial(self.set_puller, pb, player) pb.bind(on_release=pickcallback) self.ids.LeftBox.add_widget(pb) for action in hierarch.Pull.all_pulls: outcome = MDRaisedButton(text=action, size_hint=(1, 0.25)) outcomecallback = partial(self.set_pull_outcome, outcome) outcome.bind(on_release=outcomecallback) self.ids.RightBox.add_widget(outcome)
def __init__(self, nQubits, **kwargs): super(board, self).__init__(**kwargs) self.cols = int(np.sqrt(nQubits)) self.rows = int(np.sqrt(nQubits)) self.buttons = [[], [], [], [], []] #Holds button objects self.clickStatus = [] for i in range(self.cols * self.rows): self.clickStatus.append(0) for i in range(self.rows): for j in range(self.cols): self.buttons[i].append( ToggleButton(text='{}'.format(i * self.rows + j))) self.add_widget(self.buttons[i][j]) self.buttons[i][j].bind( on_press=partial(self.pressUpdate, i, j))
def build(self): #global function_callback function_callback = LightsView() self.ids.gridlayout2.clear_widgets() if len(btns_down) == 1: try: self.room_name = btns_down[0] for row in curs.execute("SELECT Light_name FROM Lights WHERE Room='" + btns_down[0] + "'"): btn = ToggleButton(text='%s' % row[0],size = (580, 45),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 "cannot execute light names for room" pass else: print "must select a light" pass
def _select(self, dropdown, setup_button): """Set the selected plot""" Logger.debug('PageSelection._select: %s', setup_button.text) self.mainbutton.text = setup_button.text self.pages_widget.clear_widgets() setup = setup_button.data for link in setup_button.data['links']: # So far only dateplots are implemented if link['pagetype'] != 'dateplot': continue codename = setup['codename'] button = ToggleButton(text=link['title'], group=codename, size_hint_y=None, height=50) button.bind(on_release=partial(self._select_page, setup, link)) self.pages_widget.add_widget(button) self.pages_widget.height = len(setup_button.data['links']) * 50
def __init__(self, **kwargs): super(Tela, self).__init__(**kwargs) self.add_widget(ToggleButton( text='Male', group='sex', )) self.add_widget(ToggleButton(text='Female', group='sex', state='down')) self.add_widget(ToggleButton(text='Mixed', group='sex')) self.add_widget(ToggleButton( text='BI', group='sex2', )) self.add_widget(ToggleButton(text='TRA', group='sex2', state='down')) self.add_widget(ToggleButton(text='MUTANTE', group='sex2'))
def __init__(self, user, **kwargs): super(UserToggle, self).__init__(size=(180, 30), size_hint=(None, None), pos_hint={ "right": 1, "top": 1 }, orientation="horizontal", **kwargs) with self.canvas.before: self.rect = Rectangle(source="images/dropdown-dcharc-up.jpg") self.bind(pos=manager.update_rect, size=manager.update_rect) self.user = user self.user_button = ToggleButton( text=user, background_normal="images/dropdown-dcharc-up.jpg", background_down="images/dropdown-lcharc-down.jpg", font_size=12, size=(150, 30), size_hint=(None, None), on_press=self.toggle_priority) self.priority_text = TextInput( text=str(1), size_hint=(None, None), size=(30, 30), background_normal="images/dropdown-lcharc-down.jpg", background_active="images/dropdown-lcharc-down.jpg", foreground_color=[1, 1, 1, 1], cursor_color=[1, 1, 1, 1], input_filter='int', pos_hint={ 'center_x': .5, 'top': 1.01 }, multiline=False) self.priority_label = Label(text='', size_hint=(None, None), size=(30, 30)) self.add_widget(self.user_button) self.add_widget(self.priority_label)
def buildlist(self): 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.initialize) btn.bind(state=self.lightscallback) #store id into database #curs.execute("UPDATE Lights SET ID='" + row[0] + "' WHERE Light_name= '" + row[0] + "'") #conn.commit() #btn.state = 'down' #btn.state = 'normal' self.ids.gridlayout.add_widget(btn) #add to gridlayout self.ids.gridlayout.bind( minimum_height=self.ids.gridlayout.setter('height'))
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 __init__(self, set_clock_screen, pos_hint_y, alarm_nr): self.set_clock_screen = set_clock_screen self.size_hint_y = 0.1 self.pos_hint_y = pos_hint_y self.hour = 0 self.minute = 0 self.activated = False self.alarm_nr = alarm_nr self.time_label = Label(text=self.getPrintTime(self.hour) + ':' + self.getPrintTime(self.minute), font_size='30sp', size_hint=(0.2, self.size_hint_y), pos_hint={ 'x': 0.2, 'y': self.pos_hint_y }) self.activation_toggle = ToggleButton(text='On', group='state', size_hint=(0.1, self.size_hint_y), pos_hint={ 'x': 0.6, 'y': self.pos_hint_y }) self.set_button = Button(text='Set', size_hint=(0.1, self.size_hint_y), pos_hint={ 'x': 0.7, 'y': self.pos_hint_y }) self.set_clock_screen.add_widget(self.time_label) self.set_clock_screen.add_widget(self.activation_toggle) self.set_clock_screen.add_widget(self.set_button) self.set_button.bind(on_press=self.set) self.activation_toggle.bind(on_press=self.toggleEvent) self.load()
def light_defect(self, inst): self.buttons_label.remove_widget(self.test_widgets["Box_optisch"]) # Falls Leuchte defekt # Hinzufügen von Fehler-Knöpfen zur Auswahl des Defekts err_box = BoxLayout(orientation="vertical", size_hint_y=None) self.test_widgets["Fehler_Liste"] = [] for e in self.leuchten["optischeFehler"]: btn = ToggleButton(size_hint_y=None, height=35, text=e) self.test_widgets["Fehler_Liste"].append(btn) err_box.add_widget(btn) self.test_widgets["Auswahl"] = Button(size_hint_y=None, height=35, text="Fehler bestätigen", background_color=(1, 0, 0, 1)) self.test_widgets["Auswahl"].bind(on_release=self.add_defect) self.test_widgets["Box_Error"] = BoxLayout(orientation="horizontal") self.test_widgets["Box_Error"].add_widget(err_box) self.test_widgets["Box_Error"].add_widget(self.test_widgets["Auswahl"]) self.buttons_label.add_widget(self.test_widgets["Box_Error"])
def pulldata(self): try: self.ids.containerr.clear_widgets() self.ids.container_gb.clear_widgets() print("clearwidget") data=newSet().openJson() #print(data) for json_obj in data: if json_obj['is_delete'] == 'false': print('json_obj',json_obj) namaset = json_obj['namaset'] print('namaset', namaset) create_btn = ToggleButton(text=namaset, group="config") create_btn.bind(state=self.on_state) self.ids.containerr.add_widget(create_btn) if len(self.ids.containerr.children) == 0: # handle empty config empty_config_label = Label(text="no config available") self.ids.containerr.add_widget(empty_config_label) except Exception as e: print('[ERROR] chooseSet open JSON',e)