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


Python Window.add_widget方法代码示例

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


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

示例1: add_widget

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def add_widget(self, widget):
        if len(self.children) == 0:
            super(NavigationDrawer, self).add_widget(widget)
            self._side_panel = widget
        elif len(self.children) == 1:
            super(NavigationDrawer, self).add_widget(widget)
            self._main_panel = widget
        elif len(self.children) == 2:
            super(NavigationDrawer, self).add_widget(widget)
            self._join_image = widget
        elif self.side_panel is None:
            self._side_panel.add_widget(widget)
            self.side_panel = widget
        elif self.main_panel is None:
            self._main_panel.add_widget(widget)
            self.main_panel = widget
        else:
            raise NavigationDrawerException(
                'Can\'t add more than two widgets'
                'directly to NavigationDrawer') 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:22,代码来源:__init__.py

示例2: on_path

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def on_path(self, path):
        path_list = path.split('/')

        self._dir_selector.clear_widgets()
        for i in path_list:
            if i:
                btn = Factory.DirButton_(size_hint=(None,1), text=str(i))

                btn.bind(on_release=partial(self._go_dir_with_btn, btn))

                if btn.width <= btn.texture_size[0]:
                    btn.width = btn.texture_size[0]+10

                self._dir_selector.add_widget(btn)
        else:
            if i:
                self.ids.dir_scroll.scroll_to(btn) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:19,代码来源:__init__.py

示例3: display_settings

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def display_settings(self, settings):
        '''.. versionadded:: 1.8.0

        Display the settings panel. By default, the panel is drawn directly
        on top of the window. You can define other behaviour by overriding
        this method, such as adding it to a ScreenManager or Popup.

        You should return True if the display is successful, otherwise False.

        :Parameters:
            `settings`: :class:`~kivy.uix.settings.Settings`
                You can modify this object in order to modify the settings
                display.

        '''
        win = self._app_window
        if not win:
            raise Exception('No windows are set on the application, you cannot'
                            ' open settings yet.')
        if settings not in win.children:
            win.add_widget(settings)
            return True
        return False 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:25,代码来源:app.py

示例4: open

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def open(self, *largs):
        '''Show the view window from the :attr:`attach_to` widget. If set, it
        will attach to the nearest window. If the widget is not attached to any
        window, the view will attach to the global
        :class:`~kivy.core.window.Window`.
        '''
        if self._window is not None:
            Logger.warning('ModalView: you can only open once.')
            return self
        # search window
        self._window = self._search_window()
        if not self._window:
            Logger.warning('ModalView: cannot open view, no window found.')
            return self
        self._window.add_widget(self)
        self._window.bind(
            on_resize=self._align_center,
            on_keyboard=self._handle_keyboard)
        self.center = self._window.center
        self.bind(size=self._update_center)
        a = Animation(_anim_alpha=1., d=self._anim_duration)
        a.bind(on_complete=lambda *x: self.dispatch('on_open'))
        a.start(self)
        return self 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:26,代码来源:modalview.py

示例5: __init__

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def __init__(self, **kwargs):
        """ On this initializer the connection has to check whether the
        connection is being made forward or backwards. """
        super().__init__(**kwargs)
        if self.start:
            self.forward = True
            # The value is repeated for correctness sake
            self.bez_start, self.bez_end = [self.start.center] * 2
            with self.canvas.before:
                Color(*self.color)
                self.lin = Line(bezier=self.bez_start * 4, width=1.5)
            self._bind_pin(self.start)
        else:
            self.forward = False
            self.bez_start, self.bez_end = [self.end.center] * 2
            with self.canvas.before:
                Color(*self.color)
                self.lin = Line(bezier=self.bez_end * 4, width=1.5)
            self._bind_pin(self.end)
        self.warned = False
        self.info = Factory.Info(pos=self.bez_start)
        Window.add_widget(self.info) 
开发者ID:AlvarBer,项目名称:Persimmon,代码行数:24,代码来源:connection.py

示例6: on_touch_down

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def on_touch_down(self, touch: MotionEvent) -> bool:
        """ On touch down on connection means we are modifying an already
            existing connection, not creating a new one. """
        # TODO: remove start check?
        if self.start and self.start.collide_point(*touch.pos):
            self.forward = False
            # Remove start edge
            self._unbind_pin(self.start)
            self.start.on_connection_delete(self)
            self.start = None
            # This signals that we are dragging a connection
            touch.ud['cur_line'] = self
            Window.add_widget(self.info)
            return True
        elif self.end and self.end.collide_point(*touch.pos):
            # Same as before but with the other edge
            self.forward = True
            self._unbind_pin(self.end)
            self.end.on_connection_delete(self)
            self.end = None
            touch.ud['cur_line'] = self
            Window.add_widget(self.info)
            return True
        else:
            return False 
开发者ID:AlvarBer,项目名称:Persimmon,代码行数:27,代码来源:connection.py

示例7: open

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def open(self, *largs):
		Window.add_widget(self)
		Clock.schedule_once(lambda x: self.display_menu(largs[0]), -1) 
开发者ID:kivymd,项目名称:KivyMD,代码行数:5,代码来源:menu.py

示例8: bind_to_window_if_requested

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def bind_to_window_if_requested(self, _):
		if self.bind_to_window:
			Window.add_widget(self) 
开发者ID:kivymd,项目名称:KivyMD,代码行数:5,代码来源:slidingpanel.py

示例9: begin

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def begin(self):
		if self.button_text == '':
			self.remove_widget(self.ids['_button'])
		else:
			self.ids['_spacer'].width = dp(16) if \
				DEVICE_TYPE == "mobile" else dp(40)
			self.padding_right = dp(16)
		Window.add_widget(self)
		anim = Animation(y=0, duration=.3, t='out_quad')
		anim.start(self)
		Clock.schedule_once(lambda dt: self.die(), self.duration) 
开发者ID:kivymd,项目名称:KivyMD,代码行数:13,代码来源:snackbar.py

示例10: set_side_panel

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def set_side_panel(self, widget):
        '''Removes any existing side panel widgets, and replaces them with the
        argument `widget`.
        '''
        # Clear existing side panel entries
        if len(self._side_panel.children) > 0:
            for child in self._side_panel.children:
                self._side_panel.remove(child)
        # Set new side panel
        self._side_panel.add_widget(widget)
        self.side_panel = widget 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:13,代码来源:__init__.py

示例11: set_main_panel

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def set_main_panel(self, widget):
        '''Removes any existing main panel widgets, and replaces them with the
        argument `widget`.
        '''
        # Clear existing side panel entries
        if len(self._main_panel.children) > 0:
            for child in self._main_panel.children:
                self._main_panel.remove(child)
        # Set new side panel
        self._main_panel.add_widget(widget)
        self.main_panel = widget 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:13,代码来源:__init__.py

示例12: on_mode

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def on_mode(self, *args):
        if hasattr(self, 'save_widget') and \
                self.save_widget in self.ids.saving_container.children:
               self.ids.saving_container.remove_widget(self.save_widget)
        if hasattr(self, 'folder_btn') and \
            self.folder_btn in self.ids.saving_container.children:
            self.ids.saving_container.remove_widget(self.folder_btn)

        if self.mode == 'save_file':
            self.ids.title.text = 'Save file'
            if not hasattr(self, 'save_widget'):
                self.save_widget = Factory.SaveWidget_()
                self.save_widget.ids.input.bind(on_text_validate=self.handle_saving)
                func = lambda *args: self.handle_saving(self.save_widget.ids.input)
                self.save_widget.ids.save_btn.bind(on_release=func)
            self.ids.saving_container.add_widget(self.save_widget)

        else:
            if self.mode == 'open_file':
                self.ids.title.text = 'Open file'

            elif self.mode == 'choose_dir':
                self.ids.title.text = 'Open folder'

                if not hasattr(self, 'folder_btn'):
                    self.folder_btn = Factory.DirButton_(text='Select')
                    self.folder_btn.bind(on_release=self.folder_selected)
                self.ids.saving_container.add_widget(self.folder_btn) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:30,代码来源:__init__.py

示例13: handle_bubble

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def handle_bubble(self, btn):
        if self.new_bub in Window.children:
            Window.remove_widget(self.new_bub)
        else:
            self.new_bub.pos = (btn.x - (self.new_bub.width-btn.width), btn.y - self.new_bub.height)
            Window.add_widget(self.new_bub) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:8,代码来源:__init__.py

示例14: open

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def open(self):
        if self not in Window.children:
            set_auto_mouse_position(self)
            Window.add_widget(self) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:6,代码来源:rightclick_drop.py

示例15: open

# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import add_widget [as 别名]
def open(self,code_input):
        self.code_input=code_input
        self.ids.input.focus=True
        if not self.parent:
            Window.add_widget(self)
            self.top = code_input.top
            self.right= code_input.right
            code_input.bind(top=self.setter('top'))
            code_input.bind(right=self.setter('right')) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:11,代码来源:code_find.py


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