本文整理匯總了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')
示例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)
示例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
示例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
示例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)
示例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
示例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)
示例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)
示例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)
示例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
示例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
示例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)
示例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)
示例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)
示例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'))