当前位置: 首页>>代码示例>>Python>>正文


Python CheckBox.bind方法代码示例

本文整理汇总了Python中kivy.uix.checkbox.CheckBox.bind方法的典型用法代码示例。如果您正苦于以下问题:Python CheckBox.bind方法的具体用法?Python CheckBox.bind怎么用?Python CheckBox.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.uix.checkbox.CheckBox的用法示例。


在下文中一共展示了CheckBox.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RootWidget

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
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')
开发者ID:AtsushiSakai,项目名称:kivy_samples,代码行数:30,代码来源:main.py

示例2: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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
开发者ID:xros,项目名称:kivy_practice,代码行数:30,代码来源:button_copied.py

示例3: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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
开发者ID:btchip,项目名称:electrum,代码行数:27,代码来源:choice_dialog.py

示例4: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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
开发者ID:ahmedbodi,项目名称:electrum,代码行数:33,代码来源:choice_dialog.py

示例5: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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)  
开发者ID:rechner,项目名称:ieee754converter,代码行数:31,代码来源:main.py

示例6: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
    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)
开发者ID:sidzi,项目名称:NewsBroadCaster,代码行数:59,代码来源:run.py

示例7: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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)
开发者ID:yahyakesenek,项目名称:Mitm-Tool,代码行数:12,代码来源:main.py

示例8: ActionCheckButton

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
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
开发者ID:5y,项目名称:kivy-designer,代码行数:57,代码来源:actioncheckbutton.py

示例9: buildCenterMenu

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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)
开发者ID:dworak,项目名称:SWD2014,代码行数:15,代码来源:main.py

示例10: agregar

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
	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
开发者ID:jefree,项目名称:SimPlanOS,代码行数:17,代码来源:tablas.py

示例11: show_plugins

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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)
开发者ID:Gamecredits-Universe,项目名称:Gamecredits-electrum-client,代码行数:17,代码来源:main_window.py

示例12: getCellChk

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
 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
开发者ID:jlermauip,项目名称:uip-prog3,代码行数:17,代码来源:Parcial1.py

示例13: build2

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
	def build2(self):
		textinput = TextInput(text='Type the broadcast message here', multiline=False)
		textinput.bind(on_text_validate=self.broadcast_now)
		root.add_widget(textinput)
		
		enable_fb = AnchorLayout(anchor_x = 'right', anchor_y='bottom')
		box1 = BoxLayout(orientation="vertical")
		tick_fb = Label(text="fb")
		box1.add_widget(tick_fb)
		post_to_facebook = CheckBox()
		post_to_facebook.bind(active=self.on_facebook_active)
		box1.add_widget(post_to_facebook)
		enable_fb.add_widget(box1)
		
		enable_twit = AnchorLayout(anchor_x = 'right', anchor_y='bottom')
		box1 = BoxLayout(orientation="vertical")
		tick_fb = Label(text="twtr")
		box1.add_widget(tick_fb)
		post_to_facebook = CheckBox()
		post_to_facebook.bind(active=self.on_twitter_active)
		box1.add_widget(post_to_facebook)
		enable_twit.add_widget(box1)
		
		post_root = BoxLayout(orientation="horizontal")
		post_root.add_widget(enable_fb)
		post_root.add_widget(enable_twit)
		root.add_widget(post_root)
		
		button = Button(text="Submit")
		button.bind(on_press = self.broadcast_now)
		root.add_widget(button)
		
		#Facebook posts
		posts = BoxLayout(orientation="horizontal")
		fb_posts = BoxLayout(orientation="vertical")
		fb_posts_header = Label(text="Status Messages")
		fb_posts.add_widget(fb_posts_header)
		fb_posts.add_widget(self.build3(fb_posts))
		posts.add_widget(fb_posts)
		
		#Twitter posts
		twit_posts = BoxLayout(orientation="vertical")
		twit_posts_header = Label(text="Tweets")
		twit_posts.add_widget(twit_posts_header)
		twit_posts.add_widget(self.build4())
		posts.add_widget(twit_posts)
		
		root.add_widget(posts)
开发者ID:roy09,项目名称:Whirl-it-Away,代码行数:50,代码来源:main.py

示例14: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
    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]))
开发者ID:t0mAI,项目名称:Projects,代码行数:18,代码来源:testmain.py

示例15: __init__

# 需要导入模块: from kivy.uix.checkbox import CheckBox [as 别名]
# 或者: from kivy.uix.checkbox.CheckBox import bind [as 别名]
    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
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:19,代码来源:dashboardview.py


注:本文中的kivy.uix.checkbox.CheckBox.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。