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


Python button.Button方法代码示例

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


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

示例1: build

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def build(self):

            # test with FboFloatLayout or FloatLayout
            # comment/uncomment to test it
            root = FboFloatLayout()
            #root = FloatLayout()

            # this part of creation can be slow. try to optimize the loop a
            # little bit.
            s = 30
            size = (s, s)
            sh = (None, None)
            add = root.add_widget
            print('Creating 5000 widgets...')
            for i in range(5000):
                x = (i % 40) * s
                y = int(i / 40) * s
                add(Button(text=str(i), pos=(x, y), size_hint=sh, size=size))
                if i % 1000 == 1000 - 1:
                    print(5000 - i - 1, 'left...')

            return root 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:24,代码来源:fbowidget.py

示例2: __init__

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def __init__(self, *args, **kwargs):
		super(AddBlockButton, self).__init__(*args, **kwargs)
		self.bind(on_release=self.openPopup)
		box=BoxLayout(padding=10)
		self.Input=TextInput(text="New Block", multiline=False, font_size=18)
		self.Input.bind(on_text_validate=self.addBlock)
		b=Button(text="Add it")
		b.bind(on_release=self.addBlock)	
		box.add_widget(self.Input)
		box.add_widget(b)
		self.addPopup = Popup(title="Add A New Block",
					size_hint=(None,None),
					size=(400,115),
					separator_color=[.9,.4,.2,1],
					background_color=[0,0,0,.6],
					content=box
					) 
开发者ID:the-duck,项目名称:launcher,代码行数:19,代码来源:main.py

示例3: vol_change

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def vol_change(self, value, update=True):
        """Method or handling volume changes."""
        # If the volume has changed
        if self.pl_vol != value:

            # display the change
            value = float(value)
            self.pl_vol = value

            # If we've changed volume, then we need to update the player
            if update:
                self.player.set_volume(self.pl_vol)

            # but if the player changed, then we need to update the slider
            else:
                self.vol = value

    # Button press events to send commands to the player 
开发者ID:elParaguayo,项目名称:RPi-InfoScreen-Kivy,代码行数:20,代码来源:screen.py

示例4: build

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def build(self):
            root = FloatLayout()
            self.sm = sm = ScreenManager(transition=SwapTransition())

            sm.add_widget(Screen(name='test1'))
            sm.add_widget(Screen(name='test2'))

            btn = Button(size_hint=(None, None))
            btn.bind(on_release=self.change_view)

            btn2 = Button(size_hint=(None, None), x=100)
            btn2.bind(on_release=self.remove_screen)

            root.add_widget(sm)
            root.add_widget(btn)
            root.add_widget(btn2)
            return root 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:19,代码来源:screenmanager.py

示例5: build

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def build(self):
        btn1 = Button(text="Start Tests")
        btn1.bind(on_press=self.start_tests)

        btn2 = Button(text="Show Results")
        btn2.bind(on_press=self.btn_pressed)

        buttons = BoxLayout(orientation='horizontal')
        buttons.add_widget(btn1)
        buttons.add_widget(btn2)

        label = Label(text="Test Results")
        labels = BoxLayout(orientation='horizontal')
        labels.add_widget(label)

        layout = BoxLayout(orientation="vertical")
        layout.add_widget(buttons)
        layout.add_widget(labels)

        return layout 
开发者ID:iclab,项目名称:centinel,代码行数:22,代码来源:main.py

示例6: _draw_buttons

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def _draw_buttons(self):
        """
        Encompasses the drawing of buttons onto the card.
        """
        button_layout = BoxLayout(orientation="horizontal", size_hint=(1, 0.2))
        for button in self.buttons:
            b = Button(text=button["label"])
            b.bind(on_press=self._button_click(button["target"]))
            if "text_size" in button:
                b.font_size = button["text_size"]
            else:
                b.font_size = 24
            if "text_color" in button:
                b.color = palette(button["text_color"])
            else:
                b.color = palette("white")
            if "background_color" in button:
                b.background_color = palette(button["background_color"])
            else:
                b.background_color = palette("grey")
            self.button_widgets.append(b)
            button_layout.add_widget(b)
        self.layout.add_widget(button_layout) 
开发者ID:ntoll,项目名称:pypercard,代码行数:25,代码来源:core.py

示例7: __init__

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def __init__(self, **kwargs):
        super(ListItemButton, self).__init__(**kwargs)

        # Set Button bg color to be deselected_color.
        self.background_color = self.deselected_color 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:7,代码来源:listview.py

示例8: build

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def build(self):
        fl = BoxLayout(orientation="vertical")
        a = Button(text="press me", height=40, size_hint_y=None)
        a.bind(on_press=callback)
        nav1 = NavigationToolbar2Kivy(canvas)
        nav2 = NavigationToolbar2Kivy(canvas2)
        fl.add_widget(nav1.actionbar)
        fl.add_widget(canvas)
        fl.add_widget(nav2.actionbar)
        fl.add_widget(canvas2)
        fl.add_widget(a)
        return fl 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:14,代码来源:test_backend.py

示例9: build

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def build(self): 

		# adding GridLayouts in App 
		# Defining number of coloumn 
		# You can use row as well depends on need 
		layout = GridLayout(cols = 2) 

		# 1st row 
		layout.add_widget(Button(text ='Hello 1')) 
		layout.add_widget(Button(text ='World 1')) 

		# 2nd row 
		layout.add_widget(Button(text ='Hello 2')) 
		layout.add_widget(Button(text ='World 2')) 

		# 3rd row 
		layout.add_widget(Button(text ='Hello 3')) 
		layout.add_widget(Button(text ='World 3')) 

		# 4th row 
		layout.add_widget(Button(text ='Hello 4')) 
		layout.add_widget(Button(text ='World 4')) 

		# returning the layout 
		return layout 

# creating object of the App class 
开发者ID:rpotter12,项目名称:spotify-downloader-music-player,代码行数:29,代码来源:kivy.py

示例10: __init__

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def __init__(self,**kwargs):
		super(WordUI, self).__init__(**kwargs)
		self.cols=2
		#adding text label
		self.add_widget(Label(text="insert the words:"))
		#adding text Input
		self.letttersinput = TextInput(multiline=False)
		self.add_widget(self.letttersinput)
		#adding the action button
		self.add_widget(Button(text="Generate", on_press=self.game , pos=(50, 100))) 
开发者ID:HoussemCharf,项目名称:FunUtils,代码行数:12,代码来源:AndroidKivyApp_Letters2Words.py

示例11: __init__

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def __init__(self, **kwargs):
        wpos = self.pos = kwargs.pop("pos")
        try:
            self.create_image = kwargs.pop("create_image")
            super(Note, self).__init__(**kwargs)
        except:
            print(kwargs)         
        self.opacity = 0
        #Show
        anim = Animation(opacity=1.0, duration=0.3)
        anim.start(self)        
        create_image = kwargs.get('create_image', False)
                
        self.request_del = False
        text_editor = TextInput(size = (120, 90))
        close = Button(size = (20, 20), text="x")
        image = Image(source="./data/imgs/background.jpg", allow_stretch=True, keep_ratio=False)

        self.add_widget(image)
        self.add_widget(text_editor)
        self.add_widget(close)
        
        if create_image:         
            image_front = Image(source="./data/imgs/faust_github.jpg", size=(120,70), allow_stretch=True, keep_ratio=False)
            self.add_widget(image_front)

        self.size = (120, 120)
        self.size_hint = (None, None)
        image.size = (120, 120)
        text_editor.pos = (0, 10)
        close.pos = (100, 100)
        self.pos = wpos

        close.bind(on_release=self.close_request) 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:36,代码来源:tour3d.py

示例12: test_emulation

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def test_emulation(self):
        from kivy.uix.button import Button

        self.emulate_file('/root/Pictures/test.py')
        root_widget = self.emulator_area().screen_display.screen.root_widget
        self.assertEqual(isinstance(root_widget, Button), True) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:8,代码来源:test_emulator.py

示例13: test_changeScreen

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def test_changeScreen(self):
        from kivy.uix.button import Button

        self.emulate_file('/root/Pictures/test.py')
        root_widget = self.emulator_area().screen_display.screen.root_widget
        self.assertEqual(isinstance(root_widget, Button), True)

        # then change screen
        screen_display = self.emulator_area().screen_display
        screen_display.screen_name = 'IpadScreen'
        self.assertEqual(isinstance(root_widget, Button), True)

        # change screen again
        screen_display.screen_name = 'IphoneScreen'
        self.assertEqual(isinstance(root_widget, Button), True) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:17,代码来源:test_emulator.py

示例14: __init__

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def __init__(self, data_model, **kwargs):
        super(DropBut, self).__init__(**kwargs)
        self.data_model = data_model
        self.drop_down = DropDown()
        for i in self.types:
            btn = Button(text=i, size_hint_y=None, height=45,
                         background_color=(0.0, 0.5, 1.0, 1.0))
            btn.bind(on_release=lambda b: self.drop_down.select(b.text))
            self.drop_down.add_widget(btn)

        self.bind(on_release=self.drop_down.open)
        self.drop_down.bind(on_select=self.on_formatter_select) 
开发者ID:riptideio,项目名称:modbus-simulator,代码行数:14,代码来源:datamodel.py

示例15: _create_popup

# 需要导入模块: from kivy.uix import button [as 别名]
# 或者: from kivy.uix.button import Button [as 别名]
def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, None),
            size=(popup_width, '250dp'))

        # create the textinput used for numeric input
        self.textinput = textinput = TextInput(
            text=self.value, font_size='24sp', multiline=False,
            size_hint_y=None, height='42sp')
        textinput.bind(on_text_validate=self._validate)
        self.textinput = textinput

        # construct the content, widget are used as a spacer
        content.add_widget(Widget())
        content.add_widget(textinput)
        content.add_widget(Widget())
        content.add_widget(SettingSpacer())

        # 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._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open() 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:35,代码来源:settings.py


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