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


Python screenmanager.Screen方法代码示例

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


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

示例1: test_card_screen_with_background_colour

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def test_card_screen_with_background_colour():
    """
    If a background colour is set for the card, ensure this is correctly
    configured for the layout associated with the card's screen.
    """
    mock_screen_manager = mock.MagicMock()
    data_store = {"foo": "bar"}
    card = Card("title", background="red")
    mock_layout = mock.MagicMock()
    with mock.patch(
        "pypercard.core.BoxLayout", return_value=mock_layout
    ), mock.patch("pypercard.core.Screen"), mock.patch(
        "pypercard.core.Color"
    ) as mock_colour, mock.patch(
        "pypercard.core.Rectangle"
    ) as mock_rectangle:
        card.screen(mock_screen_manager, data_store)
        mock_layout.bind.assert_called_once_with(
            size=card._update_rect, pos=card._update_rect
        )
        mock_colour.assert_called_once_with(1.0, 0.0, 0.0, 1.0)  # "red"
        mock_rectangle.assert_called_once_with(
            size=mock_layout.size, pos=mock_layout.pos
        )
        assert card.rect == mock_rectangle() 
开发者ID:ntoll,项目名称:pypercard,代码行数:27,代码来源:test_core.py

示例2: test_card_screen_with_background_image

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def test_card_screen_with_background_image():
    """
    If a background image is set for the card, ensure this is correctly
    configured for the layout associated with the card's screen.
    """
    mock_screen_manager = mock.MagicMock()
    data_store = {"foo": "bar"}
    card = Card("title", background="image.png")
    mock_layout = mock.MagicMock()
    with mock.patch(
        "pypercard.core.BoxLayout", return_value=mock_layout
    ), mock.patch("pypercard.core.Screen"), mock.patch(
        "pypercard.core.Rectangle"
    ) as mock_rectangle:
        card.screen(mock_screen_manager, data_store)
        mock_rectangle.assert_called_once_with(
            source="image.png", size=mock_layout.size, pos=mock_layout.pos
        ) 
开发者ID:ntoll,项目名称:pypercard,代码行数:20,代码来源:test_core.py

示例3: add_widget

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def add_widget(self, widget, title=''):
        if len(self.children) > 1:
            tab = TerminalTab()
            tab.text=title
            tab.name=title
            tab.bind(state=self.tab_state)
            self.tab_container.add_widget(tab)
            Clock.schedule_once(lambda dt: setattr(tab, 'state', 'down'))
            screen = Screen(name=title)
            screen.add_widget(widget)
            self.manager.add_widget(screen)
        else:
            super(TerminalSpace, self).add_widget(widget) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:15,代码来源:__init__.py

示例4: add_widget

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def add_widget(self, widget):
        screen = Screen()
        screen.add_widget(widget)
        super(EmulatorScreens, self).add_widget(screen) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:6,代码来源:__init__.py

示例5: add_widget

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def add_widget(self, widget, **kwargs):
        if widget is self._progress:
            super(FileChooser, self).add_widget(widget, **kwargs)
        elif hasattr(widget, 'VIEWNAME'):
            name = widget.VIEWNAME + 'view'
            screen = Screen(name=name)
            widget.controller = self
            screen.add_widget(widget)
            self.manager.add_widget(screen)

            self.trigger_update_view()
        else:
            raise ValueError(
                'widget must be a FileChooserLayout,'
                ' not %s' % type(widget).__name__) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:17,代码来源:filechooser.py

示例6: add_widget_to_window

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def add_widget_to_window(self,ins,type,id):
		if id=='resource_tree':
			self.ids.resource_tree.add_widget(ins)
		elif type=='processing':
			screen=Screen(name=id)
			screen.add_widget(ins)
			self.ids.processing_screens.add_widget(screen)
			self.add_munu_button(id)
		elif type=='display':
			screen=Screen(name=id)
			screen.add_widget(ins)
			self.ids.display_screens.add_widget(screen) 
开发者ID:deepdiy,项目名称:deepdiy,代码行数:14,代码来源:widget_mgr.py

示例7: test_card_screen_empty

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def test_card_screen_empty():
    """
    Ensure a relatively empty card results in the expected Screen object and
    the passed in ScreenManager instance and data_store is set for the card.
    """
    mock_screen_manager = mock.MagicMock()
    data_store = {"foo": "bar"}
    card = Card("title")
    result = card.screen(mock_screen_manager, data_store)
    assert card.screen_manager == mock_screen_manager
    assert card.data_store == data_store
    assert isinstance(result, Screen) 
开发者ID:ntoll,项目名称:pypercard,代码行数:14,代码来源:test_core.py

示例8: screen

# 需要导入模块: from kivy.uix import screenmanager [as 别名]
# 或者: from kivy.uix.screenmanager import Screen [as 别名]
def screen(self, screen_manager, data_store):
        """
        Return a screen instance containing all the necessary UI items that
        have been associated with the expected event handlers.

        :param kivy.uix.screenmanager.ScreenManager screen_manager: The UI
            stack of screens which controls which card is to be displayed.
        :param dict data_store: A dictionary containing application state.
        :return: A graphical representation of the card.
        """
        # References to app related objects.
        self.screen_manager = screen_manager
        self.data_store = data_store
        # The Kivy Screen instance used to draw the UI.
        screen = Screen(name=self.title)
        # Bind event handlers to life-cycle events.
        screen.bind(on_enter=self._enter)
        screen.bind(on_pre_enter=self._pre_enter)
        screen.bind(on_pre_leave=self._leave)
        # The main layout that defines how UI elements are drawn.
        self.layout = BoxLayout(orientation="vertical")
        screen.add_widget(self.layout)
        # The sound player for this card.
        self.player = None
        # Text font size for the Screen instance.
        self.font_size = "{}sp".format(self.text_size)
        if self.form:
            self._draw_form()
        elif self.text:
            self._draw_text()
        else:
            # For padding purposes.
            self.layout.add_widget(Label(text=" "))
        if self.sound:
            self.player = SoundLoader.load(self.sound)
            self.player.loop = self.sound_repeat
        if self.background:
            self.layout.bind(size=self._update_rect, pos=self._update_rect)
            with self.layout.canvas.before:
                if isinstance(self.background, tuple):
                    Color(*self.background)
                    self.rect = Rectangle(
                        size=self.layout.size, pos=self.layout.pos
                    )
                else:
                    self.rect = Rectangle(
                        source=self.background,
                        size=self.layout.size,
                        pos=self.layout.pos,
                    )
        if self.buttons:
            self._draw_buttons()
        return screen 
开发者ID:ntoll,项目名称:pypercard,代码行数:55,代码来源:core.py


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