def _bind_radio_menu(self, layout): button_pool = layout.ids[LayoutIds.radio_labels] radio_select_buttons = dict() radios = radio_types.radio_choices() for radio in radios: radio_layout = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) radio_label = Label(text=radio_types.pretty_name(radio), size_hint=(0.9, 1), font_size=dp(11), halign='left') radio_checkbox = CheckBox(size_hint=(0.1, 1)) radio_checkbox.active = radio == radio_types.DEFAULT radio_label.bind(size=radio_label.setter('text_size')) radio_layout.add_widget(radio_label) radio_layout.add_widget(radio_checkbox) radio_select_buttons[radio] = radio_checkbox button_pool.add_widget(radio_layout) self._async_wrapper.radio_buttons = radio_select_buttons create_button = layout.ids[LayoutIds.create_radio_plugs] create_button.bind(on_press=self._async_wrapper.radio_generator)
def __init__(self, **kwargs): super(CompsPopupView, self).__init__() self.versions = kwargs['versions'] self.cols = len(self.versions) self.create_label("Group 1") self.create_button_labels() self.group1_buttons = [] for version in self.versions: checkbox = CheckBox() self.group1_buttons.append(checkbox) self.add_widget(checkbox) self.create_label("Group 2") self.create_button_labels() self.group2_buttons = [] for version in self.versions: checkbox = CheckBox() self.group2_buttons.append(checkbox) self.add_widget(checkbox) self.add_button = Button(text="Add Comparison") self.add_widget(self.add_button) self.eval_button = Button(text="Evaluate") self.add_widget(self.eval_button) self.close_button = Button(text="Close") self.add_widget(self.close_button) self.comps = [] self.main_view = None self.popup = None self.filename = "default.txt"
def gen_list(self, specialized=None): self.list.clear_widgets() self.specialized = specialized # Denylist content if specialized == None: self.denylist = db.get_denylist() else: self.denylist = specialized self.ui_to_item = {} if len(self.denylist.items) > 5: self.list.height = 100 * len(self.denylist.items) def on_checkbox_active(checkbox, value): item = self.ui_to_item[checkbox] keywords = ", ".join(item.keywords) if value: item.active = True else: item.active = False for item in self.denylist.items: checkbox = CheckBox(active=item.active) self.ui_to_item[checkbox] = item checkbox.bind(active=on_checkbox_active) self.list.add_widget(checkbox) keywords = Label(text=", ".join(item.keywords), font_size=20) self.list.add_widget(keywords) remove = Button(text="Remove", font_size=20) self.ui_to_item[remove] = item remove.bind(on_press=self.remove_item) self.list.add_widget(remove)
def __init__(self, screen, **kwargs): super(SpeachRepeatTest, self).__init__(screen, **kwargs) self.desc = "Opakování" self.instruction = "TENTO TEST ZPRACOVÁVÁ TESTUJÍCÍ!\nŘekněte: „Přečtu vám větu a Vy jí po mně zopakujete \npřesně tak slovo od slova jak jsem jí řekl.“" self.instruction_audio = "sounds/ins6-1.mp3" self.test_field = GridLayout(cols=3, size_hint=(.8, .5), row_force_default=True, row_default_height=70, pos_hint={"x": .1}) self.sent_1 = Label( text=u"Pouze vím, že je to Jan, kdo má dnes pomáhat.", font_size="55px") self.sent_1_chb = CheckBox(size_hint_x=None, width=20) self.sent_2 = Label( text=u"Když jsou v místnosti psi, kočka se vždy schová pod gauč.", font_size="55px") self.sent_2_chb = CheckBox(size_hint_x=None, width=20) self.sent_1_chb.bind(active=partial(self.checkbox_callback, self)) self.sent_2_chb.bind(active=partial(self.checkbox_callback, self)) with self.canvas.before: Color(0, 0, 0, 1) self.rec = Rectangle(size=Window.size)
def __init__(self,**kwargs): super(Medicine,self).__init__(**kwargs) self.active_checkboxes = [] self.checkboxeslist = [] self.scrollsize = fullapp.size[0]*0.86,fullapp.size[1]*0.57 self.scrollpos = fullapp.size[0]*0.07,fullapp.size[1]*0.34 self.canvas.add(Rectangle(size=fullapp.size,pos=fullapp.pos,source="MainBackgroundWhiter.png")) self.add_widget(MenuButton()) rect = Rectangle(size=(fullapp.size[0],fullapp.size[1]*0.236),pos=fullapp.pos,source='FrontForScroll.png') self.canvas.add(rect) self.canvas.add(Color(0.5,0.5,0.5,1)) self.canvas.add(Rectangle(size=self.scrollsize,pos=self.scrollpos)) MedScroll = ScrollView() MedScroll.size_hint = (None,None) MedScroll.size = self.scrollsize MedScroll.pos = self.scrollpos MedBox = Widget() MedBox.size_of_drug = (self.scrollsize[0],fullapp.size[1]*0.1) MedBox.spacing = fullapp.size[1]*0.01 MedBox.size = (self.scrollsize[0],(MedBox.spacing+MedBox.size_of_drug[1])*len(IlnessBase.Medicine)-MedBox.spacing) MedBox.size_hint_y = None for i in range(len(IlnessBase.Medicine)): text = Label(color=(1,1,1,1),markup=True) text.text = IlnessBase.Medicine[i][:IlnessBase.Medicine[i].find(':')] + ' ' + '[i][size=11][color=272727]' + 'ATX num ' + IlnessBase.Medicine[i][IlnessBase.Medicine[i].find(':')+1:] + '[/i][/size][/color]' text.text_size = MedBox.size_of_drug text.text_size[0] -= MedBox.size_of_drug[1] text.halign = 'left' text.valign = 'middle' text.pos = (MedBox.size_of_drug[0]/4.3,i*(MedBox.spacing+MedBox.size_of_drug[1])-MedBox.size_of_drug[1]/2) b = Button(size=MedBox.size_of_drug,pos=(0,i*(MedBox.spacing+MedBox.size_of_drug[1]))) b.bind(on_press=self.on_button) b.add_widget(text) checkbox = CheckBox(size=(MedBox.size_of_drug[1],MedBox.size_of_drug[1]),pos = (MedBox.size_of_drug[0]-MedBox.size_of_drug[1],i*(MedBox.spacing+MedBox.size_of_drug[1]))) checkbox.num = i checkbox.bind(active=self.on_checkbox) b.add_widget(checkbox) self.checkboxeslist.append(checkbox) b.ATXNum = IlnessBase.Medicine[i][IlnessBase.Medicine[i].find(':')+1:] MedBox.add_widget(b) TopLabel = Label(bold=True,size_hint=(None,None),text='check prep:',font_size=fullapp.size[1]*0.036,color = (0,0,0,1),pos = (fullapp.size[0]*0.34,fullapp.size[1]*0.85)) self.SomeWidget = Widget(pos=(0,0),size_hint=(None,None),size = fullapp.size) CancelButton = Button(text = 'exit',font_size=fullapp.size[1]*0.022,size_hint=(None,None),size=(MedBox.size_of_drug[0]/2.01,fullapp.size[1]*0.05), pos = (self.scrollpos[0],self.scrollpos[1]-fullapp.size[1]*0.05-1),background_color = (0.3,0.3,0.9,1),on_press=self.on_cancel) OkButton = Button(text = 'chose',font_size=fullapp.size[1]*0.022,size_hint=(None,None),size=(MedBox.size_of_drug[0]/2.01,fullapp.size[1]*0.05), pos = (self.scrollpos[0]+MedBox.size_of_drug[0]/2+1,self.scrollpos[1]-fullapp.size[1]*0.05-1),background_color = (0.3,0.3,0.9,1),on_press=self.on_choose) self.SomeWidget.add_widget(CancelButton) self.SomeWidget.add_widget(OkButton) self.SomeWidget.opacity=0 MedScroll.add_widget(MedBox) self.add_widget(self.SomeWidget) self.add_widget(MedScroll) self.add_widget(TopLabel)
def mirror_options(self, inst): main_box = BoxLayout(orientation='vertical') full_img_box = BoxLayout(padding=10,size_hint_y=.3) sp = Label(text='',size_hint_x=.2) lbl = Label(text='Mirror Full Image',size_hint_x=.1) mirror_full_check = CheckBox(state='down',size_hint_x=.1) sp1 = Label(text='',size_hint_x=.2) full_img_box.add_widget(sp) full_img_box.add_widget(lbl) full_img_box.add_widget(mirror_full_check) full_img_box.add_widget(sp1) mirror_direction_box = BoxLayout(padding=20,size_hint_y=.6) mirror_left_lbl = Label(text='Mirror Left',size_hint_x=.1) mirror_left_check = CheckBox(state='down',size_hint_x=.1,group='direction') mirror_right_lbl = Label(text='Mirror Right',size_hint_x=.1) mirror_right_check = CheckBox(size_hint_x=.1,group='direction') mirror_direction_box.add_widget(mirror_left_lbl) mirror_direction_box.add_widget(mirror_left_check) mirror_direction_box.add_widget(mirror_right_lbl) mirror_direction_box.add_widget(mirror_right_check) submit = Button(text='Submit',size_hint_y=None,height=30) main_box.add_widget(full_img_box) main_box.add_widget(mirror_direction_box) main_box.add_widget(submit) popup = Popup(size_hint=(.8,None),height=250,title='Mirror Image Options',content=main_box) submit.bind(on_release=lambda x: self.mirror_image(popup,mirror_full_check,mirror_left_check,mirror_right_check)) popup.open()
def build(self): #UIの構築等 args = sys.argv self.src = cv2.imread(args[1], cv2.IMREAD_GRAYSCALE) if self.src is None: return -1 self.src = cv2.flip(self.src, 0) # ButtonやSlider等は基本size_hintでサイズ比率を指定(絶対値の時はNoneでsize=) # Imageに後で画像を描く self.kvImage1 = Image(size_hint=(1.0, 0.9)) # Layoutを作ってadd_widgetで順次モノを置いていく(並びは置いた順) kvBoxLayout1 = BoxLayout(orientation='vertical') kvBoxLayout1.add_widget(self.kvImage1) # 複数行に何か並べる場合はGridLayoutの方が楽そう kvGridLayout1 = GridLayout(cols=2, size_hint=(1.0, 0.1)) kvCheckBox1Label = Label(text='Sobel', halign='right') self.kvCheckBox1 = CheckBox(group='method', active=True) self.kvCheckBox1.bind(active=self.on_checkbox_active) kvCheckBox2Label = Label(text='Canny', halign='right') self.kvCheckBox2 = CheckBox(group='method') self.kvCheckBox2.bind(active=self.on_checkbox_active) kvGridLayout1.add_widget(kvCheckBox1Label) kvGridLayout1.add_widget(self.kvCheckBox1) kvGridLayout1.add_widget(kvCheckBox2Label) kvGridLayout1.add_widget(self.kvCheckBox2) kvBoxLayout1.add_widget(kvGridLayout1) self.process() return kvBoxLayout1
def __init__(self, **kwargs): super().__init__(**kwargs) self.scr1 = Screen(name="None") self.layout = GridLayout(cols=3) self.layout.add_widget(Label(text='')) self.layout.add_widget(Label(text='Мужской')) self.layout.add_widget(Label(text='Женский')) self.layout.add_widget(Label(text='Пол')) self.check_box_male = CheckBox(active=False) self.check_box_male.bind(active=self.check) self.layout.add_widget(self.check_box_male) self.check_box_female = CheckBox(active=False) self.check_box_female.bind(active=self.check) self.layout.add_widget(self.check_box_female) self.layout.add_widget(Label(text='Имя')) self.username = TextInput(multiline=False) self.layout.add_widget(self.username) self.layout.add_widget(Label(text='')) self.but = Button(text="sumbit", on_press=self.redirect) self.layout.add_widget(self.but) self.scr1.add_widget(self.layout) sm.add_widget(self.scr1)
def build(self): self.title = 'Feu de signalisation' # Selection de la ville du feu (et la ville de l'eau alors? lolilol) city = BoxLayout(orientation='horizontal') city.add_widget(Label(text='Feu')) cities = ('Bruxelles', 'Gent', 'Namur') #---------- liste deroulante ---------- city.add_widget(Spinner(values=cities)) # Activation ou non du feu activation = BoxLayout(orientation='horizontal') #---------- case a cocher ---------- activation.add_widget(CheckBox()) activation.add_widget(Label(text='Activer le feu')) # Choix de l'etat du feu (rouge, orange ou vert) state = BoxLayout(orientation='horizontal') #---------- bouton radio ---------- state.add_widget(CheckBox(group='state')) state.add_widget(Label(text='Rouge')) state.add_widget(CheckBox(group='state')) state.add_widget(Label(text='Orange')) state.add_widget(CheckBox(group='state')) state.add_widget(Label(text='Vert')) #Composant principal box = BoxLayout(orientation='vertical') box.add_widget(city) box.add_widget(activation) box.add_widget(state) return box
def __init__(self, **kwargs): self.title = 'Result' self.value = '' self.size_hint = (None, None) padding = Window.width / 70 self.content = GridLayout( cols=1, size_hint_x=1, padding=(padding, 0), row_force_default=True, row_default_height=60 ) super().__init__(size=(Window.width-70, Window.height-70), **kwargs) self.open() self.result = TextInput(multiline=False, write_tab=False, size_hint=(1, None), width=220, height=40) self.content.add_widget(self.result) self.info = Label(text='') self.content.add_widget(self.info) row = GridLayout(cols=4, size_hint_y=None, height=40) self.show = CheckBox(size_hint=(None, None), width=60, height=40) self.show.bind(active=self.check_show) row.add_widget(self.show) row.show_label = Label(text='Show', size_hint=(None, None), width=36, height=40) row.add_widget(row.show_label) row.add_widget(Label(text='', size_hint=(1, None), height=40)) self.btn_close = Button(text='Ok', size_hint=(None,None), size=(70,40)) self.btn_close.bind(on_press=self.btn_close_handler) row.add_widget(self.btn_close) self.content.add_widget(row)
def __init__(self, label, layout, initial=False): self._label = label self._is_active = initial check_box = CheckBox(active=initial) layout.add_widget(Label(text=label, color=[0, 0, 0, 1])) layout.add_widget(check_box) check_box.bind(active=self._on_click)
def next_label(self): global list_tasks global list_completed global check_ref_box global whole_box lay = BoxLayout(orientation='vertical', size=self.size, size_hint=(1, .4), pos_hint={ 'center_x': .4, 'center_y': .5 }) lay.clear_widgets() for i, task in enumerate(list_tasks): layout = BoxLayout(orientation="horizontal", size_hint=(.5, 1), pos_hint={ 'center_x': .5, 'center_y': .5 }) check_ref_box.append(layout) check = CheckBox() self.check_ref[f'checkbox_{i}'] = [check, task] check.bind(active=lambda checkid, checkval: on_checkbox_active( self.check_ref)) layout.add_widget(check) layout.add_widget(Label(text=task, color=(1, 1, 1, 1))) lay.add_widget(layout) self.add_widget(lay) event_3 = Clock.create_trigger(self.speaker_end, timeout=1, interval=False) event_3() whole_box = lay
def __init__(self, **kwargs): self.text = kwargs.pop('text', 'None') self.network = kwargs.pop('network', 'None') self.active_list = kwargs.pop('active_list', 'None') self.full_name = kwargs.pop('full_name', 'None') self.check = kwargs.pop('check') self.is_station = kwargs.pop('is_station') super(MyNodeNetwork, self).__init__(**kwargs) self.orientation = 'horizontal' # make height reasonable self.size_hint_y = None self.height = dp(25) # make the parts of the node # align text of label to the right side for Channel because of alignment of the checkboxes if self.check: self.label = Label(text=self.text, size_hint_x=0.2, halign="right") else: self.label = Label(text=self.text, size_hint_x=0.2, halign="center") self.label.bind(size=self.label.setter('text_size')) self.add_widget(self.label) if self.check: self.checkbox = CheckBox(size_hint_x=0.1, color=(1, 1, 1, 3.5)) # alpha=3.5 to make it more visible self.add_widget(self.checkbox) self.checkbox.bind(active=self.on_checkbox_active)
def type_sort(self, *_): self.tpopup = Popup(title="sorteren", width=Window.size[0] * 0.4, size_hint_x=None) layout = GridLayout(cols=1) select_layout = GridLayout(cols=2) select_layout.add_widget(Label(text="alles", font_size=38)) self._type_checkboxes = [ CheckBox(group="select_type", size_hint_x=0.4, active=True) ] select_layout.add_widget(self._type_checkboxes[-1]) for type in ["gerechten", "dranken", "divers", "dessert"]: select_layout.add_widget(Label(text=type, font_size=38)) self._type_checkboxes.append( CheckBox(group="select_type", size_hint_x=0.4)) select_layout.add_widget(self._type_checkboxes[-1]) layout.add_widget(select_layout) knop = Button(text="select", width=Window.size[0] * .75, font_size=22, size_hint_y=0.25) knop.bind(on_press=self.type_selected) layout.add_widget(knop) self.tpopup.add_widget(layout) self.tpopup.open()
def __init__(self, screen, **kwargs): super(OrientationTest, self).__init__(screen, **kwargs) self.test_field = GridLayout(rows=2, size_hint_y=.3, pos_hint={"y": .2}) self.instruction = "TESTO TEST ZPRACOVVÁVÁ TESTUJÍCÍ!!!\nZeptejte se: Kolikátého je\nDoplňující otázky: Řekněte mi, jaký je rok, \nměsíc, přesné datum a den v týdnu?\nNyní mi řekněte název tohoto místa a města, \nve kterém jsme." self.labels = [ Label(text="Datum"), Label(text="Měsíc"), Label(text="Rok"), Label(text="Den"), Label(text="Místo"), Label(text="Město") ] self.ch_boxes = {} for label in self.labels: chb = CheckBox() chb.bind(active=partial(self.checkbox_callback, self)) self.ch_boxes[label] = chb with self.canvas.before: Color(0, 0, 0, 1) self.rec = Rectangle(size=Window.size)
def setup_variable(self, ioc_root, label_text, description, use_checkbox): self.my_label_text = label_text if use_checkbox: b = CheckBox() b.size_hint = (0.35, 1) if self.my_down: b.bind(on_release = self.on_checkbox_modified) self.add_widget(b) self.my_checkbox = b self.my_text = None else: t = Button(text = '', markup = True, halign="center", valign="center") t.size_hint = (0.35, 1) t.bind(size=t.setter('text_size')) t.background_color = [0 , 0, 0, 0] if self.my_down: t.bind(on_release = self.my_create_popup) self.add_widget(t) self.my_text = t self.my_checkbox = None self.my_label.text = '[size=16]' + label_text + '[/size]' self.my_description.text = '[size=14][color=909090]' + description + '[/color][/size]'
def checkboxPrompt(self, question, answer=False, cb=None): "As a text box based question, with optional default answer. If user confirm, call cb." t = CheckBox(active=True) def cbr_yes(*a): cb(t.active) self.dialog.dismiss() def cbr_no(*a): cb(None) self.dialog.dismiss() self.dialog = MDDialog( type="custom", title=question, content_cls=t, buttons=[ Button(text="Accept", on_press=cbr_yes), Button(text="Cancel", on_press=cbr_no), ], ) self.dialog.height = (0.8, 0.8) t.active = answer self.dialog.open()
def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) #self.cols = 3 # 3 columns self.rows = 4 # 4 rows self.add_widget(Label(text='User Name')) # add widget label : content User Name self.username = TextInput(multiline=False) # no multiline text input support self.add_widget(self.username) # add 'username' textinput self.add_widget(Label(text='Pass Word')) # add widget label : content User Name self.password = TextInput(multiline=False, password=True) #password auto-hidden self.add_widget(self.password) self.btn1 = Button(text='Login', fontsize=14) # add login button self.add_widget(self.btn1) self.btn2 = Button(text='Sign up', fontsize=14) # add Sign up button self.add_widget(self.btn2) def on_checkbox_active(checkbox, value): ''' Once checkbox's state is changed. if checked, then pass "True" to on_checkbox_active if not, then pass "False" to on_checkbox_active ''' if value: pass else: pass checkbox = CheckBox() checkbox.bind(active=on_checkbox_active) #checked , then dispatch to on_checkbox_active self.add_widget(checkbox) # add check box to remember password
def __init__(self, value=True, on_change=None, **kwargs): super().__init__(**kwargs) w = CheckBox(active=value) if callable(on_change): w.bind(active=on_change) self.field = w self.ids['layout'].add_widget(w)
def __init__(self, last_screen, **kwargs): super(Screen, self).__init__(**kwargs) # Back Button def back_callback(self): sm.current = last_screen backButton = Button(text='back', size_hint_y=None, height=70) backButton.bind(on_press=back_callback) # Display output checkbox def change_output(self, value): global output if value: output = 5 else: output = 4 row = GridLayout(cols=2, size_hint_y=None, height=70) checkbox = CheckBox() checkbox.bind(active=change_output) row.add_widget(Label(text='Video2HDMI')) row.add_widget(checkbox) # Settings grid screen = GridLayout(rows=4) screen.add_widget(row) # Finally add back button screen.add_widget(backButton) self.add_widget(screen)
def __init__(self, **kwargs): barsize = kwargs.pop('n', 1) self.value = "0" * barsize self.orientation = 'vertical' self.color = kwargs.pop('color', (0.2, 0.2, 0.2, 0.5)) self.callback = kwargs.pop('callback', lambda: None) self.height = 70 self.padding = 10 self.spacing = 10 self.size_hint = (1, None) super(ToggleBar, self).__init__(**kwargs) self.checkboxes = [] box = BoxLayout(orientation='horizontal') box.size_hint = (1, 0.6) for n in range(barsize): checkbox = CheckBox(size_hint=(1.0/barsize, 0.70)) checkbox.bind(active=self.checkbox_toggle) box.add_widget(checkbox) self.checkboxes.append(checkbox) if 'label' in kwargs: self.label = Label(text=kwargs['label'], markup=True, size_hint=(1, 0.3)) self.add_widget(self.label) self.add_widget(box) self.value_label = Label(text="0"*barsize) self.value_label.size_hint = (1, 0.3) self.add_widget(self.value_label)
def getPadWidget(self): cbKeyScreen = CheckBox(size_hint=(.1, .1), pos=(20, Window.size[1] - 100)) cbKeyScreen.bind(active=self.on_changeSettings) self.root = cbKeyScreen return cbKeyScreen
def __init__(self, screen, **kwargs): super(AbstractionTest, self).__init__(screen, **kwargs) self.instruction = "TENTO TEST ZPRACOVÁVÁ TESTUJÍCÍ!\nZačněte příkladem: Řekněte mi, co mají společného pomeranč a banán.\nNyní mi řekněte, co mají společného vlak a bicykl ?\nNyní mi řekněte, co mají společného hodinky a pravítko?" self.test_field = GridLayout(cols=2, pos_hint={ "x": .3, "y": .25 }, size_hint=(.25, .25)) self.vlak_bycikl_lb = Label(text="vlak - bicykl", width=50, size_hint=(None, .1)) self.hodinky_pravitka_lb = Label(text="hodinky - pravítka", width=50, size_hint=(None, .1)) self.vlak_bycikl_chb = CheckBox() self.hodinky_pravitka_chb = CheckBox() self.vlak_bycikl_chb.bind(active=partial(self.checkbox_callback, self)) self.hodinky_pravitka_chb.bind( active=partial(self.checkbox_callback, self)) with self.canvas.before: Color(0, 0, 0, 1) self.rec = Rectangle(size=Window.size)
def build(self): #UIの構築等 args = sys.argv self.src = cv2.imread(args[1], cv2.IMREAD_GRAYSCALE) if self.src is None: return -1 self.src = cv2.flip(self.src, 0) # ButtonやSlider等は基本size_hintでサイズ比率を指定(絶対値の時はNoneでsize=) # Imageに後で画像を描く self.kvImage1 = Image(size_hint=(1.0, 0.9)) # Layoutを作ってadd_widgetで順次モノを置いていく(並びは置いた順) kvBoxLayout1 = BoxLayout(orientation='vertical') kvBoxLayout1.add_widget(self.kvImage1) # 複数行に何か並べる場合はGridLayoutの方が楽そう kvGridLayout1 = GridLayout(cols = 2, size_hint=(1.0, 0.1)) kvCheckBox1Label = Label(text = 'Sobel', halign='right') self.kvCheckBox1 = CheckBox(group = 'method', active= True) self.kvCheckBox1.bind(active = self.on_checkbox_active) kvCheckBox2Label = Label(text = 'Canny', halign='right') self.kvCheckBox2 = CheckBox(group = 'method') self.kvCheckBox2.bind(active = self.on_checkbox_active) kvGridLayout1.add_widget(kvCheckBox1Label) kvGridLayout1.add_widget(self.kvCheckBox1) kvGridLayout1.add_widget(kvCheckBox2Label) kvGridLayout1.add_widget(self.kvCheckBox2) kvBoxLayout1.add_widget(kvGridLayout1) self.process() return kvBoxLayout1
class RootWidget(GridLayout): def __init__(self, **kwargs): super(RootWidget, self).__init__(cols=2) self.label=Label(text="Check 1") self.add_widget(self.label) self.checkbox = CheckBox() self.checkbox.bind(active=self.on_checkbox_active) self.add_widget(self.checkbox) self.label=Label(text="Check 2") self.add_widget(self.label) checkbox1 = CheckBox() self.add_widget(checkbox1) self.label=Label(text="Check 3") self.add_widget(self.label) checkbox3 = CheckBox() self.add_widget(checkbox3) def on_checkbox_active(self, checkbox, value): if value: print('The checkbox', checkbox, 'is active') else: print('The checkbox', checkbox, 'is inactive')
def display_scene(self, x): layout = StackLayout(orientation='tb-lr') if (x == 2): main = Label(text='WAVE MIXER', size_hint=(1, 0.03), color=(1, 0, 0, 1), background_color=(1, 0, 0, 1)) else: main = Label(text='', size_hint=(1, 0.03), color=(1, 0, 0, 1), background_color=(1, 0, 0, 1)) label1 = Label(text='File '+str(x), size_hint=(1, 0.1)) select1 = Button(text='Select file', size_hint=(1, 0.05), background_color=(1, 0, 0, 1)) select1.bind(on_press=self.selectSound1) bt1 = Button(text='Play file', size_hint=(1, 0.05), background_color=(1, 0, 0, 1)) bt1.bind(on_press=self.callback) stop1 = Button(text='Stop Playing', size_hint=(1, 0.05), background_color=(1, 0, 0, 1)) stop1.bind(on_press=self.stopf1) label2 = Label(text='Amplitude', size_hint=(1, 0.1)) label3 = Label(text='Time Shift', size_hint=(1, 0.1)) label4 = Label(text='Time Scaling', size_hint=(1, 0.1)) self.flag1 = 0 self.flag2 = 0 self.flag3 = 0 self.s1 = Slider(min=0.0, max=5.0, value=1.0, size_hint=(0.8, 0.02), background_color=(1, 0, 0, 1)) self.s2 = Slider(min=-1.0, max=1.0, value=0.5, size_hint=(0.8, 0.02)) self.s3 = Slider(min=0.0, max=8.0, value=2.0, size_hint=(0.8, 0.02)) self.c1 = CheckBox(size_hint=(0.8, 0.05)) self.c2 = CheckBox(size_hint=(0.8, 0.05)) self.c3 = CheckBox(size_hint=(0.8, 0.05)) label5 = Label(text='Time Reversal', size_hint=(1, 0.02)) label6 = Label(text='Select for modulation', size_hint=(1, 0.02)) label7 = Label(text='Select for mixing', size_hint=(1, 0.02)) self.c1.bind(active=self.on_checkbox_active1) self.c2.bind(active=self.on_checkbox_active2) self.c3.bind(active=self.on_checkbox_active3) layout.add_widget(main) layout.add_widget(label1) layout.add_widget(select1) layout.add_widget(bt1) layout.add_widget(stop1) layout.add_widget(label2) layout.add_widget(self.s1) layout.add_widget(label3) layout.add_widget(self.s2) layout.add_widget(label4) layout.add_widget(self.s3) layout.add_widget(self.c1) layout.add_widget(label5) layout.add_widget(self.c2) layout.add_widget(label6) layout.add_widget(self.c3) layout.add_widget(label7) self.s1.bind(value=self.update_value1) self.s2.bind(value=self.update_value2) self.s3.bind(value=self.update_value3) self.lay1.add_widget(layout)
def display_scene2(self, x): layout2 = StackLayout(orientation='tb-lr') if (x == 2): main = Label(text='WAVE MIXER', size_hint=(1, 0.03), color=(1, 0, 0, 1)) else: main = Label(text='', size_hint=(1, 0.03), color=(1, 0, 0, 1), background_color=(1, 0, 0, 1)) label21 = Label(text='File '+str(x), size_hint=(1, 0.1)) bt21 = Button(text='Play file', size_hint=(1, 0.05), background_color=(1, 0, 0, 1)) bt21.bind(on_press=self.callback2) stop3 = Button(text='Stop Playing', size_hint=(1, 0.05), background_color=(1, 0, 0, 1)) stop3.bind(on_press=self.stopf3) select3 = Button(text='Select file', size_hint=(1, 0.05), background_color=(1, 0, 0, 1)) select3.bind(on_press=self.selectSound3) label22 = Label(text='Amplitude', size_hint=(1, 0.1)) label23 = Label(text='Time Shift', size_hint=(1, 0.1)) label24 = Label(text='Time Scaling', size_hint=(1, 0.1)) self.flag21 = 0 self.flag22 = 0 self.flag23 = 0 self.s21 = Slider(min=0.0, max=5.0, value=1.0, size_hint=(0.8, 0.02), background_color=(1, 0, 0, 1)) self.s22 = Slider(min=-1.0, max=1.0, value=0.5, size_hint=(0.8, 0.02)) self.s23 = Slider(min=0.0, max=8.0, value=2.0, size_hint=(0.8, 0.02)) self.c21 = CheckBox(size_hint=(0.8, 0.05)) self.c22 = CheckBox(size_hint=(0.8, 0.05)) self.c23 = CheckBox(size_hint=(0.8, 0.05)) label25 = Label(text='Time Reversal', size_hint=(1, 0.02)) label26 = Label(text='Select for modulation', size_hint=(1, 0.02)) label27 = Label(text='Select for mixing', size_hint=(1, 0.02)) self.c21.bind(active=self.on_checkbox2_active1) self.c22.bind(active=self.on_checkbox2_active2) self.c23.bind(active=self.on_checkbox2_active3) layout2.add_widget(main) layout2.add_widget(label21) layout2.add_widget(select3) layout2.add_widget(bt21) layout2.add_widget(stop3) layout2.add_widget(label22) layout2.add_widget(self.s21) layout2.add_widget(label23) layout2.add_widget(self.s22) layout2.add_widget(label24) layout2.add_widget(self.s23) layout2.add_widget(self.c21) layout2.add_widget(label25) layout2.add_widget(self.c22) layout2.add_widget(label26) layout2.add_widget(self.c23) layout2.add_widget(label27) self.s21.bind(value=self.update2_value1) self.s22.bind(value=self.update2_value2) self.s23.bind(value=self.update2_value3) self.lay1.add_widget(layout2)
def load(self, path, filename): print(filename, filename[0][-4:]) if (os.path.isdir(filename[0])): self.progressLen = 0 self.popup.title = 'Grr Humanos! , selecione um ARQUIVO CSV! ' self.popup.open() mythread = threading.Thread(target=self.waitTime) mythread.start() elif ('.csv' in filename[0][-4:]): self.ids.text_input.text = filename[0].split('/')[-1] self.pathCSV = '/'.join(filename[0].split('/')[1:-1]) self.df = pd.read_csv(filename[0], delimiter=';') self.fileName = filename[0] # selectColumnLabel = Label() self.ids.labelFineTuningScreenSelectId.text = self.listofLabelText[ 0] # self.ids.boxLayoutFineTuningScreenSelectId.add_widget(selectColumnLabel) listOfCheckBox_Ids = {} for idxRM, wgtRM in self.listOf_Columns_Elements_TO_Select_Ids.items( ): self.remove_widget(wgtRM) for headerValues in self.df.columns.values: print(headerValues) newBox = BoxLayout() newLabel = Label() newCheckBox = CheckBox() self.listOf_Columns_Elements_TO_Select_Ids[ "CheckBox_" + str(headerValues)] = newCheckBox newLabel.text = headerValues newCheckBox.group = 'SelectColumnGroup' newCheckBox.color = (1, 1, 1, 1) self.listOfLabel_Select_CheckBoxs.append(headerValues) newBox.add_widget(newLabel) newBox.add_widget(newCheckBox) self.ids.boxLayoutFineTuningScreenSelectId.add_widget(newBox) self.ids.boxLayoutFineTuningScreenSelectId.disabled = False self.ids.boxLayoutFineTuningScreenRunId.disabled = False self.ids.boxLayoutFineTuningScreenExtractClassesId.disabled = True else: self.progressLen = 0 self.popup.title = 'Por Odin! Eu pedi um CSV! ' self.popup.open() mythread = threading.Thread(target=self.waitTime) mythread.start() self.dismiss_popup()
def __init__(self, groupt): super(yesOrNoBox, self).__init__() self.cols = 2 self.rows = 2 self.add_widget(Label(text="Y")) self.add_widget(Label(text="N")) self.add_widget(CheckBox(group=groupt)) self.add_widget(CheckBox(group=groupt))
def __init__(self, **kwargs): super().__init__() for tool in CHECKBOXTOOLS: label = Label(text=tool, halign="left",valign="middle", text_size=(200, 20)) checkbox = CheckBox(color=(0,100,50,1)) checkbox.fbind("state", self.checkbox_operation, hackFunc=CHECKBOXTOOLS[tool], funcName=tool) self.add_widget(label) self.add_widget(checkbox)
def __init__(self, **kwargs): super(Test_input, self).__init__(**kwargs) self.cols = 1 self.text = Label(text='un label') self.add_widget(self.text) self.checkbox = CheckBox(text="Bifeaza-ma!") self.add_widget (self.checkbox) self.checkbox.bind(active=self.Ruleaza_la_activare)
def generate_config(self): def update(conf): def real_update(_, value): if conf == "DELTA": try: value = int(value) except ValueError: value = -1 CONFIG[conf] = value return real_update def toggle_auto(_, active): CONFIG["AUTO_OPEN"] = True if active else "" def save(*_): content = json.dumps(CONFIG) with open("config.json", "w+") as f: f.write(content) self.stop() if self.gps: time.sleep(2) plyer.gps.stop() while not self.config['ADRESSE']: time.sleep(1) layout = BoxLayout(orientation='vertical') for x in CONFIG: if x == "AUTO_OPEN": continue val = CONFIG[x] or x textinput = TextInput( text=(val.replace("VILLEN", "VILLE DE NAISSANCE").replace( "CPPPP", "Code Postal")), multiline=False, ) textinput.bind(text=update(x)) layout.add_widget(textinput) auto_open = BoxLayout(orientation="horizontal") auto_open.add_widget(Label(text="Open pdf automatically")) open_checkbox = CheckBox() open_checkbox.bind(active=toggle_auto) auto_open.add_widget(open_checkbox) layout.add_widget(auto_open) layout.add_widget(Button(text="sport", on_press=self.make_pdf)) layout.add_widget(Button(text="courses", on_press=self.make_pdf)) layout.add_widget(Button(text="feu", on_press=self.make_pdf)) layout.add_widget( Button(text=""" Never get back to this screen and generate both automatically when I open the app (Will use current settings... Advice: Double-check) """, on_press=save)) return layout
def __init__(self, **kwargs): global recflag recflag = False global text text = None super(CasterGUI, self).__init__(**kwargs) version_info = Label(text="NewsBcaster v0.1", font_size=20, size_hint=(1, 0.5), pos_hint={"center_x": 0.5, "center_y": 0.95}) start_button = Button(text="Start Broadcast", background_color=(0, 1, .5, 1), size_hint=(.25, .10), pos_hint={"center_x": 0.25, "center_y": 0.85}) start_button.bind(on_press=lambda x: self.callback_start()) stop_button = Button(text="Stop Broadcast", background_color=(1, 0.1, 0.1, 1), size_hint=(.25, 0.10), pos_hint={"center_x": 0.75, "center_y": 0.85}) stop_button.bind(on_press=lambda x: self.callback_stop()) path_to_video = TextInput(text="lmao.mp4", multiline=False, size_hint=(.60, 0.10), pos_hint={"center_x": .40, "center_y": .70}) upload_video = Button(text="Upload Video", background_color=(0, 1, 1, 1), size_hint=(.20, .10), pos_hint={"center_x": 0.80, "center_y": 0.70}) overlay_text = TextInput(text="Headlines Go Here", multiline=True, size_hint=(.60, 0.10), pos_hint={"center_x": .40, "center_y": .15}) upload_video.bind(on_press=lambda x: self.callback_upload(path_to_video.text, overlay_text.text)) add_overlay = Button(text="Add Overlay", background_color=(1, 1, 1, 1), size_hint=(.20, 0.10), pos_hint={"center_x": 0.80, "center_y": 0.15}) # video_previewer = Video(source="lmao.mp4", state='play', size_hint=(.32, 0.20), # pos_hint={"center_x": 0.50, "center_y": 0.50}) record_start = Button(text="Audio Recording", background_color=(0.9, 0.4, 0.1, 1), size_hint=(.20, .10), pos_hint={"center_x": 0.75, "center_y": 0.30}) checkbox = CheckBox(size_hint=(.10, .10), pos_hint={"center_x": 0.50, "center_y": 0.30}) checkbox.bind(active=on_checkbox_active) fetch_headlines = Button(text="Fetch Headlines", background_color=(0.9, 0.4, 0.1, 1), size_hint=(.20, .10), pos_hint={"center_x": 0.25, "center_y": 0.30}) fetch_headlines.bind(on_press=lambda x: self.fetch_start()) record_start.bind(on_press=lambda x: self.rec_start()) stop_button.bind(on_press=lambda x: self.rec_start()) for widgets in [version_info, start_button, stop_button, add_overlay, path_to_video, overlay_text, upload_video, record_start, fetch_headlines, checkbox]: self.add_widget(widgets)
def analysis(self, *latgs): self.clear_widgets() label = Button(text=' Checklist ', background_normal='bottone3.png', size_hint=(0.31, 0.14), bold=True, font_size='20sp', color=(1, 1, 1, .9), valign='top', pos_hint={ 'center_x': .5, 'center_y': .92 }) pict = Image(source='./logo.png', size_hint=(1, .16), pos_hint={ 'center_x': .68, 'center_y': .92 }) self.add_widget(label) self.add_widget(pict) label1 = Label( text= 'Assembled Device \n\nSample Added \n\nBL Substrate Added \n\nCartridge inserted', color=(1, 1, 1, .9), font_size='15sp', pos_hint={ 'center_x': .24, 'center_y': .56 }) checkbox = CheckBox(pos_hint={'center_x': .10, 'center_y': .61}) checkbox1 = CheckBox(pos_hint={'center_x': .10, 'center_y': .51}) checkbox.bind(active=self.on_checkbox_active) button4 = Button(text='Acquire', background_normal='bottone3.png', size_hint=(0.21, 0.11), bold=True, font_size='20sp', pos_hint={ 'center_x': .5, 'center_y': .1 }) self.add_widget(button4) button4.bind(on_press=self.camerabutton) self.add_widget(label1) self.add_widget(checkbox1) self.add_widget(checkbox) button1 = Button(text='Home', background_normal='bottone3.png', size_hint=(0.11, 0.10), pos_hint={ 'center_x': .1, 'center_y': .1 }) button1.bind(on_press=self.start) self.add_widget(button1)
def add_checkbox(self): checkbox_grid = GridLayout(cols=2, row_force_default=True, row_default_height=40) checkbox = CheckBox(size_hint_x=None, width=50) checkbox_grid.add_widget(checkbox) checkbox.bind(active=self.on_checkbox_active) checkbox_grid.add_widget( Label(text='Whisper', size_hint_x=None, width=50)) self.box_lay.add_widget(checkbox_grid)
def __init__(self, *args, **kwargs): super(File, self).__init__(**kwargs) self.name = args[0] self.path = args[1] self.mode, self.ino, self.dev, self.nlink, self.fuid, self.gid, self.fsize, self.atime, self.mtime, self.ctime = os.stat( self.path + "\\" + self.name) self.check = CheckBox() self.check.bind(active=self.on_checkbox_active) self.add_widget(self.check) self.add_widget(Label(text=self.name))
def __init__(self, name, app=None, *args, **kwargs): self.service = Service(name) self.app = app super(ServiceItem, self).__init__() process_row = BoxLayout(height=30, size_hint_y=None) run_process_check = CheckBox() run_process_check.bind(active=self.toggle_process) process_row.add_widget(run_process_check) process_row.add_widget(Label(text=str(name))) self.add_widget(process_row)
def __init__(self,**kwargs): super(StartWindow,self).__init__(**kwargs) inters=self.get_interfaces("ls /sys/class/net") self.iface="eth0" for iface in inters: lbl=Label(text=iface) cbok=CheckBox(group="face") cbok.bind(active=partial(self.set_interface,iface)) self.ids["interfaces"].add_widget(lbl) self.ids["interfaces"].add_widget(cbok)
class ActionCheckButton(ActionItem, BoxLayout): '''ActionCheckButton is a check button displaying text with a checkbox ''' checkbox = ObjectProperty(None) '''Instance of :class:`~kivy.uix.checkbox.CheckBox`. :data:`checkbox` is a :class:`~kivy.properties.StringProperty` ''' text = StringProperty('Check Button') '''text which is displayed by ActionCheckButton. :data:`text` is a :class:`~kivy.properties.StringProperty` ''' cont_menu = ObjectProperty(None) __events__ = ('on_active',) def __init__(self, **kwargs): super(ActionCheckButton, self).__init__(**kwargs) self._label = Label() self.checkbox = CheckBox(active=True) self.checkbox.size_hint_x = None self.checkbox.x = self.x + 2 self.checkbox.width = '20sp' BoxLayout.add_widget(self, self.checkbox) BoxLayout.add_widget(self, self._label) self._label.valign = 'middle' self._label.text = self.text self.checkbox.bind(active=partial(self.dispatch, 'on_active')) Clock.schedule_once(self._label_setup, 0) def _label_setup(self, dt): '''To setup text_size of _label ''' self._label.text_size = (self.minimum_width - self.checkbox.width - 4, self._label.size[1]) def on_touch_down(self, touch): '''Override of its parent's on_touch_down, used to reverse the state of CheckBox. ''' if not self.disabled and self.collide_point(*touch.pos): self.checkbox.active = not self.checkbox.active self.cont_menu.dismiss() def on_active(self, *args): '''Default handler for 'on_active' event. ''' pass def on_text(self, instance, value): '''Used to set the text of label ''' self._label.text = value
def getPropertyEditors(self, skin): """ get all the controls for editing the extra properties of this control. The list of controls that is returned, our bound to this object (changes will be stored in the skin object) :param skin: json object :return: a list of kivy controls that can be used for editing the properties for the skin. """ items = [] grd = GridLayout(cols=2) grd.bind(minimum_height = grd.setter('height')) grd.size_hint = (1, None) chk = CheckBox(active=sm.getVar(skin, self.asset, "show_label", False), height='28dp', size_hint=(1, None)) chk.bind(active=self.on_show_labelChanged) lbl = Label(text='show label', height='28dp', size_hint=(1, None), halign='right') lbl.bind(size = lbl.setter('text_size')) grd.add_widget(lbl) grd.add_widget(chk) chk = CheckBox(active=sm.getVar(skin, self.asset, "show_marker", False), height='28dp', size_hint=(1, None)) chk.bind(active=self.on_show_markerChanged) lbl = Label(text='show marker', height='28dp', size_hint=(1, None), halign='right') lbl.bind(size = lbl.setter('text_size')) grd.add_widget(lbl) grd.add_widget(chk) chk = CheckBox(active=sm.getVar(skin, self.asset, "send_on_release", False), height='28dp', size_hint=(1, None)) chk.bind(active=self.on_send_on_release_Changed) lbl = Label(text='send on release', height='28dp', size_hint=(1, None), halign='right') lbl.bind(size = lbl.setter('text_size')) grd.add_widget(lbl) grd.add_widget(chk) items.append(grd) return items
def buildCenterMenu(self, wrapper, rebuild=False): if(rebuild): wrapper.clear_widgets() numberOfItems = len(self.sharedInstance.data.temp) if self.sharedInstance.data.temp else 0 for i in range(0, numberOfItems): checkbox = CheckBox(active=True) checkbox.bind(active=app.checkBoxCallback) self.checkBoxesPlotBind[checkbox] = self.graphScreen.getGraph().plots[i] labelText = self.sharedInstance.data.temp[i] if self.sharedInstance.data.temp else "Nazwa atrybutu" label = Label(text=labelText, halign = "right",width=100, col_default_width=20, col_force_default=True) wrapper.add_widget(label) wrapper.add_widget(checkbox)
def agregar(self, nombre): box = BoxLayout() bloqueado = CheckBox(active= False) bloqueado.bind(active= lambda inst, valor : self.recursos[nombre].bloquear(valor)) usado = Label(text="-") box.add_widget(Label(text=nombre)) box.add_widget(usado) box.add_widget(bloqueado) self.add_widget(box) self.visores[nombre] = usado
def show_plugins(self, plugins_list): def on_checkbox_active(cb, value): self.plugins.toggle_enabled(self.electrum_config, cb.name) for item in self.plugins.descriptions: if 'kivy' not in item.get('available_for', []): continue name = item.get('name') label = Label(text=item.get('fullname')) plugins_list.add_widget(label) cb = CheckBox() cb.name = name p = self.plugins.get(name) cb.active = (p is not None) and p.is_enabled() cb.bind(active=on_checkbox_active) plugins_list.add_widget(cb)
def __init__(self, **kwargs): super(CategoryChecklist, self).__init__(**kwargs) self.cols = 4 with conn: c = conn.cursor() c.execute("SELECT DISTINCT Category FROM Inventory") part = c.fetchall() for i in part: check = CheckBox(group='categories') check.id = i[0] check.bind(active=self.on_checkbox_active) print(check.id) self.add_widget(check) self.add_widget(Label(text=i[0]))
def test_tb_lr_stacklayout(self): from kivy.uix.checkbox import CheckBox a = CheckBox(allow_no_selection=False, group='check') b = CheckBox(allow_no_selection=False, group='check') a.active = True self.assertTrue(a.active) self.assertEqual(a.state, 'down') self.assertFalse(b.active) self.assertEqual(b.state, 'normal') b.active = True self.assertTrue(b.active) self.assertEqual(b.state, 'down') self.assertFalse(a.active) self.assertEqual(a.state, 'normal') a.state = 'down' self.assertTrue(a.active) self.assertEqual(a.state, 'down') self.assertFalse(b.active) self.assertEqual(b.state, 'normal') b.state = 'down' self.assertTrue(b.active) self.assertEqual(b.state, 'down') self.assertFalse(a.active) self.assertEqual(a.state, 'normal') b.state = 'normal' self.assertFalse(a.active) self.assertEqual(a.state, 'normal') self.assertFalse(b.active) self.assertEqual(b.state, 'normal') b.state = 'down' self.assertTrue(b.active) self.assertEqual(b.state, 'down') self.assertFalse(a.active) self.assertEqual(a.state, 'normal') b.active = False self.assertFalse(a.active) self.assertEqual(a.state, 'normal') self.assertFalse(b.active) self.assertEqual(b.state, 'normal')
def __init__(self, settings, dashboard_factory, **kwargs): super(DashboardScreenPreferences, self).__init__(**kwargs) self._settings = settings current_screens = self._settings.userPrefs.get_dashboard_screens() screen_keys = dashboard_factory.available_dashboards for key in screen_keys: [name, image] = dashboard_factory.get_dashboard_preview_image_path(key) checkbox = CheckBox() checkbox.active = True if key in current_screens else False checkbox.bind(active=lambda i, v, k=key:self._screen_selected(k, v)) screen_item = DashboardScreenItem() screen_item.add_widget(checkbox) screen_item.add_widget(FieldLabel(text=name)) screen_item.add_widget(Image(source=image)) self.ids.grid.add_widget(screen_item) self._current_screens = current_screens
def __init__(self, title, choices, key, callback): Factory.Popup.__init__(self) if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items()): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def __init__(self, title, choices, key, callback, keep_choice_order=False): Factory.Popup.__init__(self) print(choices, type(choices)) if keep_choice_order: orig_index = {choice: i for (i, choice) in enumerate(choices)} sort_key = lambda x: orig_index[x[0]] else: sort_key = lambda x: x if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items(), key=sort_key): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def update_list(self): for cx in self.ids.table_fields.children[:]: self.ids.table_fields.remove_widget(cx) for header in (_("Selection"), _("Name"), _("Type"), _("Not"), _("PK"), _("AI")): self.ids.table_fields.add_widget(Label(text=header, size_hint_y=0.1)) for f in self.fields: rb=CheckBox() rb.group='selection' self.ids.table_fields.add_widget(rb) self.ids.table_fields.add_widget(Label(text=f[0])) self.ids.table_fields.add_widget(Label(text= f[1])) self.ids.table_fields.add_widget(Label(text= '√' if f[2] else '')) self.ids.table_fields.add_widget(Label(text= '√' if f[3] else '')) self.ids.table_fields.add_widget(Label(text= '√' if f[4] else ''))
def _displayHeatmapGenerationPopup(self, press): print "Building Heatmap Generation Box" self.progressPopupDescription = Label(text = "Generating Heatmaps can take a long time. \nAre you sure you want to do this?") self.heatmapButton = Button(text="Generate") self.heatmapButton.bind(on_press=self._generateHeatmap) checkbox = CheckBox() checkbox.bind(active=self._on_checkbox_active) cancelButton = Button(text="Cancel") layout = BoxLayout(orientation='vertical') layout.add_widget(self.progressPopupDescription) layout.add_widget(self.heatmapButton) layout.add_widget(checkbox) layout.add_widget(cancelButton) layout.add_widget(self.progressBar) popup = Popup(title="Heatmap", content = layout, size_hint=(None, None), size = (400,400)) cancelButton.bind(on_press = lambda widget:self._cancelHeatmapGeneration(popup)) popup.open() self.heatmapPopup = popup print "Heatmap Generation Box Generated"
def _get_body(self): if self.dont_show_value is None: return self._message else: pnl = BoxLayout(orientation='vertical') pnl.add_widget(self._message) pnl_cbx = BoxLayout( size_hint_y=None, height=metrics.dp(35), spacing=5) cbx = CheckBox( active=self.dont_show_value, size_hint_x=None, width=metrics.dp(50)) cbx.bind(active=self.setter('dont_show_value')) pnl_cbx.add_widget(cbx) pnl_cbx.add_widget( LabelEx(text=self.dont_show_text, halign='left')) pnl.add_widget(pnl_cbx) return pnl
class Test_input(GridLayout): def __init__(self, **kwargs): super(Test_input, self).__init__(**kwargs) self.cols = 1 self.text = Label(text='un label') self.add_widget(self.text) self.checkbox = CheckBox(text="Bifeaza-ma!") self.add_widget (self.checkbox) self.checkbox.bind(active=self.Ruleaza_la_activare) def Ruleaza_la_activare(self ,value ,instance): global check1 print value print instance if (check1 %2 == 0) : print('Checkbox este activ') else: print('Checkbox este inactiv') check1 += 1
def __init__(self, **kwargs): super( _player_type_box, self ).__init__( orientation = "horizontal", **kwargs) self.type = 0 # 0 is Human, 1 is PC if 'type' in kwargs: self.type = kwargs['type'] group_name = "type" + str( _player_type_box._index ) human_cb = CheckBox( group=group_name, active=self.type == 0, size_hint=(0.1, 1) ) human_cb.bind( active = self.set_human ) pc_cb = CheckBox( group=group_name, active=self.type == 1, size_hint=(0.1, 1) ) self.add_widget( human_cb ) self.add_widget( Label( text="Human", font_size=13 ) ) self.add_widget( pc_cb ) self.add_widget( Label( text="PC", font_size=13 ) ) _player_type_box._index += 1
def __init__(self, **kwargs): super(Test_input, self).__init__(**kwargs) self.cols = 1 self.text = Label(text='un label') self.add_widget(self.text) self.checkbox1 = CheckBox(text="1",group = "test") self.add_widget (self.checkbox1) self.checkbox2 = CheckBox() self.checkbox2.group = "test" self.add_widget (self.checkbox2) self.checkbox1.bind(active=self.Ruleaza_la_activare)
def show(self, streams): self.clear() index = 0 indexHeaderLabel = Label(text='Stream') activeHeaderLabel = Label(text='Active') speedHeaderLabel = Label(text='Particle speed') self.add_widget(indexHeaderLabel) self.add_widget(activeHeaderLabel) self.add_widget(speedHeaderLabel) for stream in streams: Logger.debug("Got stream: " + str(stream)) streamIndexLabel = Label(text=str(index), size_hint=(self.col1Width, self.rowHeight)) activeCheckbox = CheckBox(active=stream.get_active()) activeCheckbox.bind(active=partial(self.on_active_change, stream)) particleSpeedCheckBox = CheckBox(active=True) particleSpeedCheckBox.bind(active=partial(self.on_particle_speed_change, stream)) self.add_widget(streamIndexLabel) self.add_widget(activeCheckbox) self.add_widget(particleSpeedCheckBox) index = index + 1 self.popup.open()
class CvImg(App): def build(self): #UIの構築等 args = sys.argv self.src = cv2.imread(args[1], cv2.IMREAD_GRAYSCALE) if self.src is None: return -1 self.src = cv2.flip(self.src, 0) # ButtonやSlider等は基本size_hintでサイズ比率を指定(絶対値の時はNoneでsize=) # Imageに後で画像を描く self.kvImage1 = Image(size_hint=(1.0, 0.9)) # Layoutを作ってadd_widgetで順次モノを置いていく(並びは置いた順) kvBoxLayout1 = BoxLayout(orientation='vertical') kvBoxLayout1.add_widget(self.kvImage1) # 複数行に何か並べる場合はGridLayoutの方が楽そう kvGridLayout1 = GridLayout(cols = 2, size_hint=(1.0, 0.1)) kvCheckBox1Label = Label(text = 'Sobel', halign='right') self.kvCheckBox1 = CheckBox(group = 'method', active= True) self.kvCheckBox1.bind(active = self.on_checkbox_active) kvCheckBox2Label = Label(text = 'Canny', halign='right') self.kvCheckBox2 = CheckBox(group = 'method') self.kvCheckBox2.bind(active = self.on_checkbox_active) kvGridLayout1.add_widget(kvCheckBox1Label) kvGridLayout1.add_widget(self.kvCheckBox1) kvGridLayout1.add_widget(kvCheckBox2Label) kvGridLayout1.add_widget(self.kvCheckBox2) kvBoxLayout1.add_widget(kvGridLayout1) self.process() return kvBoxLayout1 def on_checkbox_active(self, checkbox, value): self.process() def process(self): if (self.kvCheckBox1.active): dst = cv2.Sobel(self.src, cv2.CV_8U, 1, 0, ksize = 5) else: dst = cv2.Canny(self.src, 100, 200) kvImage1Texture = Texture.create(size=(dst.shape[1], dst.shape[0]), colorfmt='bgr') kvImage1Texture.blit_buffer(cv2.merge((dst, dst, dst)).tostring(), colorfmt='bgr', bufferfmt='ubyte') self.kvImage1.texture = kvImage1Texture
def __init__(self, **kwargs): super(ActionCheckButton, self).__init__(**kwargs) self._label = Label() self.checkbox = CheckBox(active=True) self.checkbox.size_hint_x = None self.checkbox.x = self.x + 2 self.checkbox.width = '20sp' BoxLayout.add_widget(self, self.checkbox) BoxLayout.add_widget(self, self._label) self._label.valign = 'middle' self._label.text = self.text self.checkbox.bind(active=partial(self.dispatch, 'on_active')) Clock.schedule_once(self._label_setup, 0)
def getCellChk(self,fila,columna,Activo,Disabled = False,Size=200,Tipo="chk"): """Funcion que devuelve una celda completa para manejo de checkbox""" cell = GridRow() cell.id = "row{0}_col{1}".format(fila,columna) cell.size = [Size,40] cchk=CheckBox() cchk.id=Tipo cchk.active=Activo cchk.disabled=Disabled cchk.background_checkbox_disabled_down='atlas://data/images/defaulttheme/checkbox_on' cchk.text_size=cell.size if Tipo == "borrar": cchk.bind(active=self.borradoCkick) cell.add_widget(cchk) return cell
def __init__(self, **kwargs): barsize = kwargs.pop('n', 1) self.value = "0" * barsize self.orientation = 'vertical' self.color = kwargs.pop('color', (0.2, 0.2, 0.2, 0.5)) self.callback = kwargs.pop('callback', lambda: None) self.height = 70 self.padding = 10 self.spacing = 10 self.size_hint = (1, None) super(ToggleBar, self).__init__(**kwargs) self.checkboxes = [] master_box = BoxLayout(orientation='vertical') box = BoxLayout(orientation='horizontal') box.size_hint = (1, 0.6) for n in range(barsize): checkbox = CheckBox(size_hint=(1.0/barsize, 0.70)) checkbox.bind(active=self.checkbox_toggle) self.checkboxes.append(checkbox) #If bit position is divisible by the breaking point, add a new row: if ((n + 1) % kwargs['breakpoint']) == 0: box.add_widget(checkbox) master_box.add_widget(box) box = BoxLayout(orientation='horizontal') box.size_hint = (1, 0.6) else: box.add_widget(checkbox) if 'label' in kwargs: self.label = Label(text=kwargs['label'], markup=True, size_hint=(1, 0.3)) self.add_widget(self.label) self.add_widget(master_box) self.value_label = Label(text="0"*barsize) self.value_label.size_hint = (1, 0.3) self.add_widget(self.value_label)