當前位置: 首頁>>代碼示例>>Python>>正文


Python togglebutton.ToggleButton方法代碼示例

本文整理匯總了Python中kivy.uix.togglebutton.ToggleButton方法的典型用法代碼示例。如果您正苦於以下問題:Python togglebutton.ToggleButton方法的具體用法?Python togglebutton.ToggleButton怎麽用?Python togglebutton.ToggleButton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kivy.uix.togglebutton的用法示例。


在下文中一共展示了togglebutton.ToggleButton方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: draw_filter

# 需要導入模塊: from kivy.uix import togglebutton [as 別名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 別名]
def draw_filter(self):
        """Create a list of toggle buttons to allow user to show which buses
           should be shown on the screen.
        """
        # If we've got no filter then we need to set it up:
        if self.filters is None:

            # Clear the previous filter
            self.ids.bx_filter.clear_widgets()

            # Get the list of unique bus routes and apply a natural sort.
            routes = sorted(set([x["route"] for x in self.buses]),
                            key=natural_sort_key)

            # Create a toggle button for each route and set it as enabled
            # for now.
            for route in routes:
                tb = ToggleButton(text=route, state="down")
                tb.bind(state=self.toggled)
                self.ids.bx_filter.add_widget(tb)

        # Run the "toggled" method now as this updates which buses are shown.
        self.toggled(None, None) 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:25,代碼來源:screen.py

示例2: _heading

# 需要導入模塊: from kivy.uix import togglebutton [as 別名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 別名]
def _heading(game, view):
    heading = Label(font_name='DroidSans-Regular.ttf', font_size=18,
                    color=HEADING_COLOR, markup=False)
    heading.pos = (ANIM_TOGGLE_SIZE, 500 - PADDING)
    heading.size = (960 - ANIM_TOGGLE_SIZE * 2, HEIGHT)
    view.add_widget(heading)

    def state_change(btn, state):
        game.set_animooted(state == 'down')

    anim_toggle = ToggleButton(background_normal='media/chkbox.png',
                               background_down='media/chkbox_a.png',
                               border=(0, 0, 0, 20), font_size=15,
                               text='Display Animations', state='down',
                               color=HEADING_COLOR, markup=False)
    anim_toggle.pos = (965 - ANIM_TOGGLE_SIZE, 510 - PADDING)
    anim_toggle.size = (ANIM_TOGGLE_SIZE, 30)
    anim_toggle.bind(state=state_change)
    view.add_widget(anim_toggle)

    game._heading = heading
    game.update_heading() 
開發者ID:mvasilkov,項目名稱:kivy-2014,代碼行數:24,代碼來源:ui.py

示例3: draw_filter

# 需要導入模塊: from kivy.uix import togglebutton [as 別名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 別名]
def draw_filter(self):
        """Create a list of toggle buttons to allow user to show which buses
           should be shown on the screen.
        """
        # If we've got no filter then we need to set it up:
        if self.filters is None:

            # Clear the previous filter
            self.ids.bx_filter.clear_widgets()

        # Get the list of unique bus routes and apply a natural sort.
        routes = sorted(set([x["route"] for x in self.buses]),
                        key=natural_sort_key)

        # Create a toggle button for each route and set it as enabled
        # for now.
        for route in routes:
            route_found=False
            for child in self.ids.bx_filter.children:
                if (route == child.text):
                    route_found = True
            if (route_found == False):
                tb = ToggleButton(text=route, state="down")
                tb.bind(state=self.toggled)
                self.ids.bx_filter.add_widget(tb)

        # Run the "toggled" method now as this updates which buses are shown.
        self.toggled(None, None) 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:30,代碼來源:screen.py

示例4: _create_popup

# 需要導入模塊: from kivy.uix import togglebutton [as 別名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 別名]
def _create_popup(self, instance):
        # create the popup
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            content=content, title=self.title, size_hint=(None, None),
            size=(popup_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)
            content.add_widget(btn)

        # finally, add a cancel button to return on the previous panel
        content.add_widget(SettingSpacer())
        btn = Button(text='Cancel', size_hint_y=None, height=dp(50))
        btn.bind(on_release=popup.dismiss)
        content.add_widget(btn)

        # and open the popup !
        popup.open() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:28,代碼來源:settings.py

示例5: _draw_form

# 需要導入模塊: from kivy.uix import togglebutton [as 別名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 別名]
def _draw_form(self):
        """
        Encompasses the drawing of a form with a textual label onto the card.
        """
        inner_layout = BoxLayout(orientation="vertical")
        label_layout = BoxLayout(orientation="vertical", size_hint=(1, 0.2))
        self.form_label = Label(
            text=self.text, font_size=self.font_size, markup=True
        )
        self.form_label.color = list(self.text_color)
        self.form_label.valign = "top"
        self.form_label.halign = "left"
        label_layout.add_widget(self.form_label)
        form_layout = BoxLayout(orientation="vertical")
        form_layout.padding = 10
        filler = None
        if self.form == Inputs.TEXTBOX:
            self.textbox = TextInput(text="", multiline=False)
            self.textbox.font_size = self.font_size
            form_layout.size_hint = (1, 0.2)
            form_layout.add_widget(self.textbox)
            filler = BoxLayout(orientation="vertical", size_hint=(1, 0.6))
        elif self.form == Inputs.TEXTAREA:
            self.textarea = TextInput(text="")
            self.textarea.font_size = self.font_size
            form_layout.add_widget(self.textarea)
        elif self.form == Inputs.MULTICHOICE:
            self.multichoice = []
            for item in self.options:
                button = ToggleButton(text=item)
                button.font_size = self.font_size
                form_layout.add_widget(button)
                self.multichoice.append(button)
        elif self.form == Inputs.SELECT:
            self.select = []
            for item in self.options:
                button = ToggleButton(text=item, group=self.title)
                button.font_size = self.font_size
                form_layout.add_widget(button)
                self.select.append(button)
        elif self.form == Inputs.SLIDER:
            min_val = self.options[0]
            max_val = self.options[1]
            if len(self.options) == 3:
                step = self.options[2]
            else:
                step = 1
            self.slider = Slider(
                value_track=True, min=min_val, max=max_val, step=step
            )
            self.slider_label = Label(text="0", font_size=64)
            self.slider.bind(value=self._slider_change)
            form_layout.add_widget(self.slider)
            form_layout.add_widget(self.slider_label)
        inner_layout.add_widget(label_layout)
        inner_layout.add_widget(form_layout)
        if filler:
            inner_layout.add_widget(filler)
        self.layout.add_widget(inner_layout) 
開發者ID:ntoll,項目名稱:pypercard,代碼行數:61,代碼來源:core.py


注:本文中的kivy.uix.togglebutton.ToggleButton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。