本文整理汇总了Python中kivy.uix.screenmanager.Screen.add_widget方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.add_widget方法的具体用法?Python Screen.add_widget怎么用?Python Screen.add_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.screenmanager.Screen
的用法示例。
在下文中一共展示了Screen.add_widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebuild_homescreen
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def rebuild_homescreen(self, mode=None, goto=True):
print 'rebuilding homescreen'
t1 = time()
if mode is None:
mode = self.view_mode
if 'Home' in self.screen_names:
oldhome = self.get_screen('Home')
self.remove_widget(oldhome)
if mode[:6] == 'tablet':
hs = TabletHomeScreen(managedby=self)
else:
hs = HomeScreen(managedby=self)
t2 = time()
print 'made homescreen', t2-t1
hs_screen = Screen(name='Home')
hs_screen.add_widget(hs)
t3 = time()
self.add_widget(hs_screen)
print 'made Screen', t3-t2
self.refresh_open_games()
t4 = time()
print 'refreshed open games', t4-t3
print 'total', t4-t1
if goto:
if self.current == 'Home':
self.make_empty_screen()
self.current = 'emptyscreen'
self.current = 'Home'
示例2: display_settings
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def display_settings(self, settings):
manager = self.manager
if not manager.has_screen('Settings'):
s = Screen(name='Settings')
s.add_widget(settings)
manager.add_widget(s)
manager.switch_and_set_back('Settings')
示例3: rebuild_homescreen
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def rebuild_homescreen(self, mode=None, goto=True):
print "rebuilding homescreen"
t1 = time()
if mode is None:
mode = self.view_mode
if "Home" in self.screen_names:
oldhome = self.get_screen("Home")
self.remove_widget(oldhome)
if mode[:6] == "tablet":
hs = TabletHomeScreen(managedby=self)
else:
hs = HomeScreen(managedby=self)
t2 = time()
print "made homescreen", t2 - t1
hs_screen = Screen(name="Home")
hs_screen.add_widget(hs)
t3 = time()
self.add_widget(hs_screen)
print "made Screen", t3 - t2
self.refresh_open_games()
t4 = time()
print "refreshed open games", t4 - t3
print "total", t4 - t1
if goto:
if self.current == "Home":
self.make_empty_screen()
self.current = "emptyscreen"
self.current = "Home"
示例4: GameApp
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
class GameApp(App):
def __init__(self, **kwargs):
"""
:param kwargs:
:return:
"""
super(GameApp, self).__init__(**kwargs)
self.textures = textures
self.screen_manager = ScreenManager()
self.menu_widget = Menu()
self.menu_screen = Screen(name="Menu")
self.menu_screen.add_widget(self.menu_widget)
self.screen_manager.add_widget(self.menu_screen)
self.game_widget = Level('../resources/test.png', self.textures)
self.game_screen = Screen(name="Game")
self.game_screen.add_widget(self.game_widget)
self.screen_manager.add_widget(self.game_screen)
def build(self):
"""
:return:
"""
self.screen_manager.current = 'Game'
return self.screen_manager
示例5: setup_battle
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def setup_battle(self, dt=None):
self.graphics_widget.remove_widget(self.button_reset)
self.graphics_widget.remove_widget(self.image_score)
self.graphics_widget.remove_widget(self.progress_bar)
if self.level == 11:
graphics_widget = FloatLayout()
image = Image(source = PATH + "end.png", keep_ratio=False, allow_stretch=True,\
size=(SCREEN_WIDTH, SCREEN_HEIGHT), size_hint=(None, None), pos=(0,0))
graphics_widget.add_widget(image)
graphics_widget.add_widget(self.button_reset)
screen = Screen(name="end")
screen.add_widget(graphics_widget)
self.add_widget(screen)
self.current=screen.name
else:
self.get_level_data()
graphics_widget = self.set_background()
screen = Screen(name=str(self.level))
screen.add_widget(graphics_widget)
self.graphics_widget = graphics_widget
self.add_widget(screen)
self.current=screen.name
if self.score_threshold > 0:
self.level_score = - self.score_threshold
else:
self.level_score = 0
self.image_score.set_score(self.level_score)
if self.level < 3:
self.start_battle()
else:
self.schedule(self.start_battle, 0) #WAS 2
self.graphics_widget.add_widget(self.button_reset)
self.graphics_widget.add_widget(self.progress_bar)
self.graphics_widget.add_widget(self.image_score)
示例6: build
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def build(self):
Builder.load_string(textwrap.dedent(
'''
<[email protected]>:
description_a: ''
description_b: ''
text: root.description_a + ' <newline> ' + root.description_b
halign:'center'
size_hint:(1, 0.1)
<MyListView>:
size_hint:(0.5, 0.5)
ListView:
item_strings: [str(index) for index in range(10)]
<OtherNamedScreen>:
GridLayout:
cols: 2
MyListView
ScrollView:
ContainerForButtons:
cols:1
row_default_height:150
size_hint_y: None
'''))
Window.bind(on_keyboard=self.check_what_key_was_pressed)
self.screen_mgr = ScreenManager()
first = Screen(name='First')
self.screen_mgr.add_widget(first)
first.add_widget(Button(text="click me", bind=self.swap_screen))
self.screen_mgr.add_widget(OtherNamedScreen(name='Second'))
return self.screen_mgr
示例7: build
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def build(self):
self.sm = TouchyScreenManager()
for storyline in intro.splitlines():
screen = Screen(name=storyline)
screen.add_widget(Label(text=storyline))
self.sm.add_widget(screen)
return self.sm
示例8: add_page
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def add_page(self, id, name):
screen = Screen()
screen.name = id
page = AudiowallPage()
page.name = name
screen.add_widget(page)
self._sm.add_widget(screen)
self.pages.append(page)
self.pages_label.text = 'Page %i of %i' % (self.active_page, len(self.pages))
示例9: get_more_info
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def get_more_info(self, info):
if not App.get_running_app().root.has_screen(info.memory['sid']):
sc = Screen(name=info.memory['sid'])
m = MoreInfo(info.memory)
sc.add_widget(m)
App.get_running_app().root.add_widget(sc)
self.used_screens.append(info.memory['sid'])
App.get_running_app().root.transition = RiseInTransition()
App.get_running_app().root.current = info.memory['sid']
示例10: enter_state
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def enter_state(self, context=None):
print 'ShowingListsScreen/enter_state'
if not 'Lists' in self.statechart.app.sm.screen_names:
# Convenience references:
self.app = self.statechart.app
view = BoxLayout(orientation='vertical', spacing=10)
toolbar = BoxLayout(size_hint=(1.0, None), height=50)
label = Label(text='Lists', color=[.8, .8, .8, .8], bold=True)
toolbar.add_widget(label)
button = Button(text='Search')
button.bind(on_press=self.go_to_search)
toolbar.add_widget(button)
button = Button(text='Data')
button.bind(on_press=self.go_to_data)
toolbar.add_widget(button)
button = Button(text='Detail')
button.bind(on_press=self.go_to_detail)
toolbar.add_widget(button)
view.add_widget(toolbar)
lists_view = GridLayout(cols=3, size_hint=(1.0, 1.0))
lists_view.add_widget(ListView(
adapter=self.statechart.fruit_categories_dict_adapter,
size_hint=(.2, 1.0)))
lists_view.add_widget(ListView(
adapter=self.statechart.fruits_dict_adapter,
size_hint=(.2, 1.0)))
selected_fruit = \
self.statechart.fruits_dict_adapter.selection[0].text
self.detail_view = FruitDetailView(fruit_name=selected_fruit,
size_hint=(.6, 1.0))
lists_view.add_widget(self.detail_view)
view.add_widget(lists_view)
self.create_adapter_bindings()
screen = Screen(name='Lists')
screen.add_widget(view)
self.app.sm.add_widget(screen)
if self.app.sm.current != 'Lists':
self.app.sm.current = 'Lists'
示例11: build
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def build(self):
self.py=ScreenManager()
for i in range(4):
p=Screen(name="pncr%d" % i)
p.add_widget(Label(text="Pencere %d" % i))
self.py.add_widget(p)
self.py.current = 'pncr2'
Clock.schedule_interval(self.pencereDegistir, 2)
return self.py
示例12: open_help
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def open_help(self):
if self.has_screen('Info Page'):
self.switch_and_set_back('Info Page')
else:
fileh = open('README.rst','r')
readme = fileh.read()
fileh.close()
infoscreen = Screen(name='Info Page')
infoscreen.add_widget(InfoPage(infotext=readme))
self.add_widget(infoscreen)
self.switch_and_set_back('Info Page')
示例13: open_help
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def open_help(self):
if self.has_screen("Info Page"):
self.switch_and_set_back("Info Page")
else:
fileh = open("README.rst", "r")
readme = fileh.read()
fileh.close()
infoscreen = Screen(name="Info Page")
infoscreen.add_widget(InfoPage(infotext=readme))
self.add_widget(infoscreen)
self.switch_and_set_back("Info Page")
示例14: build
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def build(self):
config = self.config
root = Screen()
self.sm = sm = ScreenManager()
sm.add_widget(MainScreen(name='main',background=self.bg))
sm.add_widget(PinScreen(name='pin',background=self.bg))
sm.add_widget(AlarmScreen(name='alarm',background=self.bg))
sm.add_widget(ImageScreen(name='image',background=self.bg))
root.add_widget(sm)
return root
示例15: build
# 需要导入模块: from kivy.uix.screenmanager import Screen [as 别名]
# 或者: from kivy.uix.screenmanager.Screen import add_widget [as 别名]
def build(self):
self.parent = ScreenManager()
screen = Screen(name="List")
self.parent.add_widget(screen)
sync_list = self.create_sync_list()
screen.add_widget(sync_list)
new_sync = self.create_new_sync()
new_sync_screen = Screen(name="New")
new_sync_screen.add_widget(new_sync)
self.parent.add_widget(new_sync_screen)
return self.parent