本文整理汇总了Python中kivy.uix.anchorlayout.AnchorLayout.add_widget方法的典型用法代码示例。如果您正苦于以下问题:Python AnchorLayout.add_widget方法的具体用法?Python AnchorLayout.add_widget怎么用?Python AnchorLayout.add_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.anchorlayout.AnchorLayout
的用法示例。
在下文中一共展示了AnchorLayout.add_widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def build(self):
Builder.load_file('screens/login.kv')
Builder.load_file('screens/home.kv')
Builder.load_file('screens/scenarios.kv')
Builder.load_file('main.kv')
self.body.add_widget(Login(LoginMenu, 'loginmenu', None, name = 'login'))
self.body.add_widget(Home(HomeMenu, 'homemenu', None, name = 'home'))
self.body.add_widget(Scenarios(ScenariosMenu, 'scenariosmenu', 'home', name = 'scenarios'))
self.body.add_widget(NewScenario(NewScenarioMenu, 'newscenariomenu', 'scenarios', name = 'newscenario'))
self.body.current = 'login'
self.menu.height = '48dp'
self.menu.size_hint_y = None
self.use_kivy_settings = False
self.settings_cls = SettingsWithSidebar
screen = AnchorLayout(anchor_x='right', anchor_y='top')
screen.add_widget(self.body)
screen.add_widget(self.menu)
# screen = BoxLayout(orientation='vertical')
# screen.add_widget(self.menu)
# screen.add_widget(self.body)
return screen
示例2: HelpMenu
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def HelpMenu(instance):
window = instance.parent.parent
window.clear_widgets()
textLayout = AnchorLayout(anchor_x='center', anchor_y='center')
buttonLayout = AnchorLayout(anchor_x='right', anchor_y='top', padding=5)
btn = Button(text='Main Menu', background_color=(0.2,0.32,1.8,1), size_hint=(0.1,0.1))
btn.bind(on_press=clickSoundPlay)
btn.bind(on_release=mainMenu)
DescObjLabel = Label(text='[b]Description[/b]\n\nQuarto is a game played by two players on a 4x4,'
'16 space board. There are 16 different pieces that can be constructed\n in any combination of '
'four characteristics (Size, Color, Shape, Hole) in an attempt to win the game.\n\n[b]Objective[/b]'
'\n\nTo win the game a line of pieces with matching characteristics (Four big pieces, four little, '
'four dark, four light, four with a hole,\nor four without a hole) must be constructed. '
'These pieces can be layed out horizontally, vertically, or diagonally.\n\n'
'[b]Gameplay[/b]\n\nPlayers move alternatively, placing one piece on the board at a time. '
'Note that once a piece has been placed on the board it \ncannot be moved again. '
'Perhaps the most unique aspect of Quarto is that the choice of the piece to be placed on the board\n'
'is not decided by the player placing the piece, but by the opponent. Each turn consists of two actions:\n\n'
' [b]1.[/b] Place the piece given by the opponent on the board.\n\n [b]2.[/b] Give the opponent the '
'piece to be played on the next move\n\nTo start the game the player needs only to select the piece for '
'his opponent to play.', markup=True)
textLayout.add_widget(DescObjLabel)
buttonLayout.add_widget(btn)
window.add_widget(textLayout)
window.add_widget(buttonLayout)
示例3: HomePage
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
class HomePage(PageBase):
"""HomePage of the App.
This is the first page that the user will see."""
def __init__(self, app):
"""Constructor"""
# Call the base.
super(HomePage, self).__init__(app)
# Load the backend
self.backend = SpecialBackend(FlatfileBackend())
# Create a body manually, overriding the default.
self.body = AnchorLayout(anchor_x='center', anchor_y='center')
stack_layout = StackLayout(size_hint=(0.95, 0.6))
self.body.add_widget(stack_layout)
text_layout = BoxLayout(anchor_x='left', anchor_y='center', size_hint=(0.8, None))
text_layout.height = '35px'
stack_layout.add_widget(text_layout)
def on_enter(sender):
self._on_search(sender, self.query.text)
self.query = TextInput(text='', multiline=False, hint_text='Type here...')
self.query.bind(on_text_validate=on_enter)
text_layout.add_widget(self.query)
button_layout = BoxLayout(anchor_x='right', anchor_y='center', size_hint=(0.2, None))
button_layout.height = '35px'
stack_layout.add_widget(button_layout)
def on_search_press(sender):
self._on_search(self.query, self.query.text)
search = Button(text='Search!')
search.width = '50px'
search.bind(on_press=on_search_press)
button_layout.add_widget(search)
self.search_results = RichPage.get_page(app, [self], self.backend, 'search')
def on_category_press(sender):
RichPage.get_page(app, [self], self.backend, 'categories').show(self)
self.hide()
category = Button(text='Categories', size_hint=(None, None), height='35px')
category.width = '100px'
category.bind(on_press=on_category_press)
self.body.add_widget(category)
def _on_search(self, sender, value):
"""Called when the user trys to search."""
query = value
self.query.text = ''
self.backend.cached_search(query)
self.search_results.reload()
self.hide()
self.search_results.show(self)
示例4: MainScreen
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
class MainScreen(Screen):
buttons = {'main':['alarm']}
settings = commonFunc.getYaml('settings')
def __init__(self, **kwargs):
self.bgImage = kwargs['background']
super(MainScreen, self).__init__(**kwargs)
def on_enter(self):
grid = GridLayout()
self.grid2 = AnchorLayout()
self.bg = ImgButton(size=(800,480)) #CONFIG
self.bg.source = self.bgImage.image()
self.bg.bind(on_press=partial(app.change_view,'main'))
self.grid2.add_widget(self.bg)
for btn in self.buttons[self.name]:
button = MainButton(text=btn,pos=getPos())
button.bind(on_press=partial(app.change_view,btn,''))
grid.add_widget(button)
self.add_widget(self.grid2)
self.add_widget(grid)
Clock.schedule_interval(self.callback,self.settings['timeOut']) #CONFIG
def on_leave(self):
Clock.unschedule(self.callback)
self.remove_widget(self.grid2)
def callback(self,instalnce):
self.bg.source=self.bgImage.nextImage()
示例5: add_meaning_full
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def add_meaning_full(self, row):
"""
Add a meaning row on the GUI to let the user add his own meaning
:param instance:
:return:
"""
self.found_numb += 1
self.counter += 1
bl = BoxLayoutH50(id='bl'+str(self.found_numb))
al = AnchorLayout(anchor_x='center', anchor_y='center', size_hint_x=0.05, size_hint_y=None, height=self.app.row_height)
al.add_widget(IconButtonDel(id='btn'+str(self.found_numb), on_press=self.remove_line))
bl.add_widget(al)
al2 = AnchorLayout(anchor_x='center', anchor_y='center', size_hint_x=0.05, size_hint_y=None, height=self.app.row_height)
btn_ref = IconButtonRefresh(id='btn_ref'+str(self.found_numb))
btn_ref.bind(on_press=self.update_wiki)
al2.add_widget(btn_ref)
bl.add_widget(al2)
bl.add_widget(TextInputH50(id='found', text=row.found, size_hint_x=0.25))
bl.add_widget(TextInputH50(id='url'+str(self.found_numb), text=row.url, size_hint_x=0.3))
if row.disambiguation_url == 1:
bl.add_widget(CheckBoxH50(id='dis'+str(self.found_numb), size_hint_x=0.15, active=True))
else:
bl.add_widget(CheckBoxH50(id='dis'+str(self.found_numb), size_hint_x=0.15))
bl.add_widget(CheckBoxH50(id='approved'+str(self.found_numb), size_hint_x=0.1, active=True))
bl.add_widget(CheckBoxH50(id='chosen'+str(self.found_numb), group='chosen', size_hint_x=0.1))
self.grid_row.add_widget(bl)
示例6: handle_waitready
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def handle_waitready(self, message):
self.container.clear_widgets()
btn = Label(label='En attente...', cls=['pentabtn', 'ready'],
size=(200, 100))
anchor = AnchorLayout(size=self.container.size)
anchor.add_widget(btn)
self.container.add_widget(anchor)
示例7: build
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def build(self):
global root
root = BoxLayout(orientation="vertical")
#some art/whatsoever
root.add_widget(Label(text="Whirl it Away"))
#enable Facebook
fb = Button(text="Login to Facebook")
fb.bind(on_press = self.login_facebook)
root.add_widget(fb)
#enable Twitter
twit = Button(text="Login to Twitter")
twit.bind(on_press = self.login_twitter)
root.add_widget(twit)
login_button_area = AnchorLayout(anchor_x = 'right', anchor_y='bottom')
login_button = Button(text="Let's go")
login_button.bind(on_press = self.login)
login_button_area.add_widget(login_button)
root.add_widget(login_button_area)
return root
示例8: add_meaning_empty
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def add_meaning_empty(self, instance):
"""
Add a meaning row on the GUI to let the user add his own meaning
:param instance:
:return:
"""
self.grid_row.remove_widget(self.addmore)
self.found_numb += 1
self.counter += 1
bl = BoxLayoutH50(id='bl'+str(self.found_numb))
al = AnchorLayout(anchor_x='center', anchor_y='center', size_hint_x=0.05, size_hint_y=None, height=self.app.row_height)
al.add_widget(IconButtonDel(id='btn'+str(self.found_numb), on_press=self.remove_line))
bl.add_widget(al)
bl.add_widget(TextInputH50(id='found'+str(self.found_numb), text='', size_hint_x=0.3))
bl.add_widget(TextInputH50(id='url'+str(self.found_numb), text='', size_hint_x=0.3))
bl.add_widget(CheckBoxH50(id='dis'+str(self.found_numb), size_hint_x=0.15))
bl.add_widget(CheckBoxH50(id='approved'+str(self.found_numb), size_hint_x=0.1))
if self.found_numb == 1:
bl.add_widget(CheckBoxH50(id='chosen'+str(self.found_numb),
group='chosen', size_hint_x=0.1, active=True))
else:
bl.add_widget(CheckBoxH50(id='chosen'+str(self.found_numb),
group='chosen', size_hint_x=0.1))
self.grid_row.add_widget(bl)
self.grid_row.add_widget(self.addmore)
示例9: __init__
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def __init__(self, **kwargs):
super(viewDayPopup, self).__init__(**kwargs)
box = BoxLayout(orientation='vertical', spacing=10)
get_input_box = BoxLayout(size_hint=(1, None), height=30)
self.day_input = TextInput(multiline=False)
self.month_input = TextInput(multiline=False)
self.year_input = TextInput(multiline=False)
day_lbl = Label(text='Ngày')
month_lbl = Label(text='Tháng')
year_lbl = Label(text='Năm')
submit_btn = Button(text='OK', size_hint=(.2, 1), halign='center')
anchor_submit_layout = AnchorLayout(anchor_x='center')
anchor_submit_layout.add_widget(submit_btn)
get_input_box.add_widget(day_lbl)
get_input_box.add_widget(self.day_input)
get_input_box.add_widget(month_lbl)
get_input_box.add_widget(self.month_input)
get_input_box.add_widget(year_lbl)
get_input_box.add_widget(self.year_input)
box.add_widget(get_input_box)
box.add_widget(anchor_submit_layout)
self.add_widget(box)
self.day_input.focus = True
self.day_input.bind(on_text_validate=self.dayValidate)
self.month_input.bind(on_text_validate=self.monthValidate)
self.year_input.bind(on_text_validate=self.yearValidate)
submit_btn.bind(on_release=self.update)
示例10: build
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def build(self):
self.root = NavigationDrawer()
self.root.side_panel_opacity = 0
self.root.separator_image_width = sp(0)
menu = BoxLayout(orientation='vertical')
resetButton = Factory.GreenButton(text='New Game')
settingsButton = Factory.OrangeButton(text='Settings')
helpButton = Factory.PurpleButton(text='Help')
menu.add_widget(resetButton)
menu.add_widget(settingsButton)
menu.add_widget(helpButton)
resetButton.bind(on_press=self.reset)
self.root.add_widget(menu)
content = AnchorLayout(anchor_x='right', anchor_y='bottom', paddind=sp(5))
toggleButton = IconButton (icon="atlas://img/icon/iconatlas/icon-menu", size_hint=(.15, .1),
background_normal='atlas://img/button/buttonatlas/red',
background_down='atlas://img/button/buttonatlas/orange')
toggleButton.bind(on_press=lambda j: self.root.toggle_state())
content.add_widget(sm)
content.add_widget(toggleButton)
self.root.add_widget(content)
sm.current = 'titleScreen'
return self.root
示例11: set_layout
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def set_layout(self):
#anchor_left = AnchorLayout(anchor_x='left', anchor_y='bottom')
boxlayout1 = BoxLayout(orientation='horizontal', size_hint=(None, None), size=(Window.width, '%sdp' % self._height)) #, size=('350dp', 0))
button_menu = Button(size_hint=(None, None), size=('127dp', '51dp'), border=(0, 0, 0, 0),
background_normal='resources/interface/menu.png',
background_down='resources/interface/menu-pressed.png',
background_disabled_normal='resources/interface/menu.png',
background_color=(1, 1, 1, 1),
on_release=self.go_to_menu
)
self.button_menu = button_menu
#button_save = Button(size_hint=(None, None), size=('132dp', '57dp'), border=(0, 0, 0, 0),
# background_normal='resources/interface/save.png',
# background_down='resources/interface/save-pressed.png',
# background_color=(1, 1, 1, 1))
button_play = Button(size_hint=(None, None), size=('68dp', '51dp'), border=(0, 0, 0, 0),
background_normal='resources/interface/pause.png',
background_down='resources/interface/pause-pressed.png',
background_disabled_normal='resources/interface/pause.png',
on_release=GameContext.game.pause,
background_color=(1, 1, 1, 1))
boxlayout1.add_widget(button_menu)
#boxlayout1.add_widget(button_save)
boxlayout1.add_widget(button_play)
self.button_play = button_play
self.button_play.set_paused = self.set_paused
self.button_play.set_resumed = self.set_resumed
#anchor_left.add_widget(boxlayout1)
anchor_center = AnchorLayout(anchor_x='center', anchor_y="bottom", size_hint=(1, 1))
#size=(Window.width, '%sdp' % self._height))
steps = Label(text="STEPS:0", font_size="31dp", font_name=FONT_NAME) #, font_name="resources/Intro.ttf")
self.steps = steps
anchor_center.add_widget(steps)
boxlayout1.add_widget(anchor_center)
#anchor_right = AnchorLayout(anchor_x='right', anchor_y="bottom", size_hint=(None, None),
# size=(Window.width, '%sdp' % self._height))
boxlayout2 = BoxLayout(orientation='horizontal', size_hint=(None, 1), size=('120dp', 0))
button_trees = Button(size_hint=(None, None), size=('68dp', '57dp'), border=(0, 0, 0, 0),
background_normal='resources/interface/trees.png',
background_down='resources/interface/trees.png',
background_disabled_normal='resources/interface/trees_press.png',
background_color=(1, 1, 1, 1),
on_release=GameContext.game.switch_to_plant_tree
)
number_of_trees = Label(text='x5', font_size="31dp", font_name=FONT_NAME)
boxlayout2.add_widget(button_trees)
boxlayout2.add_widget(number_of_trees)
self.button_trees = button_trees
self.number_of_trees = number_of_trees
boxlayout1.add_widget(boxlayout2)
self.add_widget(boxlayout1)
示例12: _greeting
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def _greeting(dt):
anchor = AnchorLayout(anchor_x='center', anchor_y='center', size=(Window.width, Window.height))
label = Label(text='TAP TO START', font_size='50dp', bold=True, font_name=FONT_NAME)
anchor.add_widget(label)
anchor.bind(on_touch_up=self.close_greeting)
self.greeting_msg = anchor
self.add_widget(self.greeting_msg)
示例13: test_anchorlayout_default
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def test_anchorlayout_default(self):
from kivy.uix.anchorlayout import AnchorLayout
r = self.render
b = self.box
layout = AnchorLayout()
layout.add_widget(b(1, 0, 0))
r(layout)
示例14: handleGoal
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def handleGoal(self):
def go_next_callback(instance):
self.popup.dismiss()
main.switchLevel()
return False
if self.isToolOnGoal and self.isPersonOnGoal:
if self.activeTool.isGoal and self.activePerson.isGoal:
print "FINISHED? ",isFinished
while not isFinished: #notwendig, weil sonst 2 mal aufgerufen (touch_events feuern alle 2 mal)
global isFinished
isFinished = True
btnBGSource = ''
if currentLevel <= len(levels)-1:
btnBGSource = unichr(61518)
else:
btnBGSource = unichr(61470)
box = AnchorLayout(size_hint=(1, 1), anchor_x= "right", anchor_y= "bottom")
btn = Button(font_size=100, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0.7])
btn.bind(on_press=go_next_callback)
#vid = Video(source=self.levelInfos[levelProps[3]], play=True)
#box.add_widget(vid)
#instead of laggy video insert just an image
img = Image(source=self.levelInfos[levelProps[3]])
img.allow_stretch = True
box.add_widget(img)
imgBtn = Button(font_size=60, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0], size_hint= (0.15, 0.15))
imgBtn.bind(on_press=go_next_callback)
box.add_widget(imgBtn)
def end_of_vid(video, eos):
logging.info("endofvid")
#video.play=False #not working on android...
box.add_widget(btn)
#video.unload() #not working on android...
#logging.info("video unloaded")
def showit():
print "showing video popup"
self.popup.open()
if self.winSound:
self.winSound.play()
#vid.bind(loaded=lambda foo,bar: showit())
#vid.bind(eos=lambda video,eos:end_of_vid(video,eos))
self.popup = Popup(content=box,size_hint=(0.8, 0.7),auto_dismiss=False)
self.hidePopupTitle(self.popup)
showit()
Clock.schedule_once(lambda wumpe:box.add_widget(btn), 8)
示例15: show_accordion
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import add_widget [as 别名]
def show_accordion(self):
root = Accordion()
for x in xrange(5):
item = AccordionItem(title='Title %d' % x)
item.add_widget(Label(text='Very big content\n' * 10))
root.add_widget(item)
col = AnchorLayout()
col.add_widget(root)
return col