當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。