本文整理汇总了Python中kivy.uix.anchorlayout.AnchorLayout类的典型用法代码示例。如果您正苦于以下问题:Python AnchorLayout类的具体用法?Python AnchorLayout怎么用?Python AnchorLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AnchorLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
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: build
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
示例3: __init__
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)
示例4: create_gui
def create_gui(self, w=None):
#layout superior
self.lay_up = AnchorLayout(anchor_x='center',
anchor_y='top',
padding=5)
self.nickname = ngTextInput(size_hint=(None,None),
size=(300,50),
pos=(500,100),
text=self.nick)
self.nickname.bind(on_enter=self.on_nickenter)
self.lay_up.add_widget(self.nickname)
self.add_widget(self.lay_up)
#layout inferior derecha
self.lay_rightbottom = AnchorLayout(anchor_x='right',
anchor_y='bottom',
padding=0)
self.txt_puntos = Label(text='Puntos: ',
size_hint=(None,None),
size=(300,50))
self.lay_rightbottom.add_widget(self.txt_puntos)
self.add_widget(self.lay_rightbottom)
#layoutprincipal, aqui va el chat y lo que vaya del otro lado que no sean las cartas
self.lay_main = BoxLayout()
self.add_widget(self.lay_main)
#listbox con gente conectada
self.people = ListBox(size_hint_x=.35, widget_cls=Button)
self.lay_main.add_widget(self.people )
#CREAR PARTIDA
self.btn_crearpartida = Button(size_hint=(None,None),
size=(200,60),
text='Crear partida')
self.btn_crearpartida.center = (Window.center[0], 70)
self.btn_crearpartida.bind(on_press=self.on_crearpartida)
self.lay_main.add_widget(self.btn_crearpartida)
#JUGAR
self.btn_jugar = Button(size_hint=(None,None),
size=(200,60),
text='Jugar')
self.btn_jugar.center = (Window.center[0], 140)
self.btn_jugar.bind(on_press=self.on_jugar)
self.lay_main.add_widget(self.btn_jugar)
#obtener la lista de dispositivos para jugar
Request(action=self.server + '/conquian/get_devices.php',
callback=self.on_devices,
data=urllib.urlencode({'devID':self.devID})
)
#crear tarjetas
self.create_cards()
示例5: HomePage
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)
示例6: MainScreen
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()
示例7: handle_waitready
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)
示例8: build
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
示例9: add_meaning_empty
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)
示例10: set_layout
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)
示例11: set_list
def set_list(self):
#Get all image file name in Images Craft Bottles
first_list = []
second_list = []
if self.query_result is None:
i = 0
for name in os.listdir('./images/bottles/'):
if i%2 == 0:
first_list.append(name)
else:
second_list.append(name)
i = i + 1
#get all Items
else:
i = 0
for name in self.query_result:
if i%2 == 0:
first_list.append(name+'.jpg')
else:
second_list.append(name+'.jpg')
i = i + 1
# Clear widget first
self.scroll_view_one.clear_widgets()
self.scroll_view_two.clear_widgets()
self.remove_widget(self.scroll_view_one)
self.remove_widget(self.scroll_view_two)
#First Horizontal Scrollable View
grid_one_layout = GridLayout(cols=len(first_list), spacing=10, size_hint_x=None)
#Make sure the height is such that there is something to scroll.
grid_one_layout.bind(minimum_width=grid_one_layout.setter('width'))
for file_name in first_list:
anchor_one_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=240, width=200, anchor_x='center', anchor_y='bottom')
btn = Button(text=file_name, color=[0,0,0,0], size_hint_y=None, size_hint_x=None, height=240, width=200, background_color=[1,1,1,1], background_normal='images/bottles/{f_name}'.format(f_name=file_name))
btn.bind(on_press=self.on_item_click)
beer_name = file_name[:-4]
label = Label(text=beer_name, color=[0,0,0,1], italic=True, font_size='12dp', size_hint=(None, None), height=30, width=anchor_one_layout.width, halign='center', pos_hint={'x':0,'y':0})
anchor_one_layout.add_widget(btn)
anchor_one_layout.add_widget(label)
grid_one_layout.add_widget(anchor_one_layout)
self.scroll_view_one.add_widget(grid_one_layout)
self.add_widget(self.scroll_view_one)
#First Horizontal Scrollable View
grid_two_layout = GridLayout(cols=len(second_list), spacing=10, size_hint_x=None)
#Make sure the height is such that there is something to scroll.
grid_two_layout.bind(minimum_width=grid_two_layout.setter('width'))
for file_name in second_list:
anchor_two_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=240, width=200, anchor_x='center', anchor_y='bottom')
btn = Button(text=file_name, color=[0,0,0,0], size_hint_y=None, size_hint_x=None, height=240, width=200, background_color=[1,1,1,1], background_normal='images/bottles/{f_name}'.format(f_name=file_name))
btn.bind(on_press=self.on_item_click)
beer_name = file_name[:-4]
label = Label(text=beer_name, color=[0,0,0,1], italic=True, font_size='12dp', size_hint=(None, None), height=30, width=anchor_two_layout.width, halign='center', pos_hint={'x':0,'y':0})
anchor_two_layout.add_widget(btn)
anchor_two_layout.add_widget(label)
grid_two_layout.add_widget(anchor_two_layout)
self.scroll_view_two.add_widget(grid_two_layout)
self.add_widget(self.scroll_view_two)
示例12: _greeting
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
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: show_accordion
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
示例15: create_and_add_widgets
def create_and_add_widgets(self, screen_label=''):
main_label = AndCatLabel(text='AndCat',
size_hint=(1.0, None,),
height=50)
logo_container = AnchorLayout(anchor_x='right')
logo_img = Image(source='logo.png', size_hint=(None, None,), width=50, height=50)
logo_container.add_widget(logo_img)
self.add_widget(main_label)
self.add_widget(logo_container)