本文整理汇总了Python中kivy.uix.stacklayout.StackLayout类的典型用法代码示例。如果您正苦于以下问题:Python StackLayout类的具体用法?Python StackLayout怎么用?Python StackLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StackLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_buses
def draw_buses(self):
"""Adds the buses to the main screen."""
# Clear the screen of any buses.
self.ids.bx_buses.clear_widgets()
# Get a list of just those buses who are included in the filter.
buses = [b for b in self.buses if b["route"] in self.filters]
# Work out the height needed to display all the buses
# (we need this for the StackLayout)
h = (len(buses) * 30)
# Create a StackLayout and ScrollView
sl = StackLayout(orientation="tb-lr", height=h, size_hint=(1, None))
sv = ScrollView(size_hint=(1, 1))
sv.add_widget(sl)
self.ids.bx_buses.add_widget(sv)
# Loop over the buses, create a FinlandArrivals object and add it to the
# StackLayout
for bus in buses:
bs = FinlandArrivals(bus=bus)
if "alert" in(bus):
self.alert = bus["alert"]
sl.add_widget(bs)
示例2: build
def build(self):
s = StackLayout()
p = MyFilechooser(title = 'test')
b = Button(size_hint = (1,0.2))
b.bind(on_press = p.open)
s.add_widget(b)
return s
示例3: build
def build(self):
lay = StackLayout()
btn = Button(text="hello", width=40, height=40)
btn2 = Button(text="sup", width=40, height=40)
lay.add_widget(btn)
lay.add_widget(btn2)
return lay
示例4: DragTab
class DragTab(BoxLayout):
def __init__(self,**kwargs):
super(DragTab,self).__init__(**kwargs)
#Base Layer is a BoxLayout
#right-hand column is StackLayout, lefthand is a vertical box layout
self.Scrollhome=StackLayout(orientation='tb-rl', size_hint=(.3,1))
#self.Scrollhome.add_widget(Button(text='hi'))
self.lefthand=BoxLayout(orientation='vertical', size_hint=(.7,1))
#within lefthand, stats and a series of semesters
self.Planner=GridLayout(size_hint=(1,.9),rows=2, cols=4, spacing=5)
self.slot1=Semester(text=str(semesters[0]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot1)
self.slot2=Semester(text=str(semesters[2]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot2)
self.slot3=Semester(text=str(semesters[4]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot3)
self.slot4=Semester(text=str(semesters[6]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot4)
self.slot5=Semester(text=str(semesters[1]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot5)
self.slot6=Semester(text=str(semesters[3]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot6)
self.slot7=Semester(text=str(semesters[5]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot7)
self.slot8=Semester(text=str(semesters[7]), color=(0, 0, 1., .2))
self.Planner.add_widget(self.slot8)
self.lefthand.add_widget(self.Planner)
self.lefthand.add_widget(Label(size_hint=(1,.1),text= 'We can display statistics here', color=(1,1,1,.3)))
self.add_widget(self.lefthand)
self.add_widget(self.Scrollhome)
for course in catalog:
self.add_Icon(course)
def add_Icon(self, display):
Icon=DragableButton(text=display,size=(100,100),
droppable_zone_objects=[],
bound_zone_objects=[],
drag_opacity=.5,
remove_on_drag=True)
Icon.bound_zone_objects.append(self.Planner)
Icon.bound_zone_objects.append(self.Scrollhome)
Icon.droppable_zone_objects.append(self.slot1.coursehouse)
Icon.droppable_zone_objects.append(self.slot2.coursehouse)
Icon.droppable_zone_objects.append(self.slot3.coursehouse)
Icon.droppable_zone_objects.append(self.slot4.coursehouse)
Icon.droppable_zone_objects.append(self.slot5.coursehouse)
Icon.droppable_zone_objects.append(self.slot6.coursehouse)
Icon.droppable_zone_objects.append(self.slot7.coursehouse)
Icon.droppable_zone_objects.append(self.slot8.coursehouse)
Icon.droppable_zone_objects.append(self.Scrollhome)
self.Scrollhome.add_widget(Icon)
示例5: build
def build(self):
root = StackLayout()
custom_widget1 = MyCustomWidget(id='my_custom_widget')
custom_widget1.status = 'ok'
custom_widget2 = MyCustomWidget(id='my_custom_widget')
custom_widget2.status = 'nope'
root.add_widget(custom_widget1)
root.add_widget(custom_widget2)
return root
示例6: build
def build(self):
oscAPI.init()
main_layout = StackLayout()
for i in range(4):
xy_pad = XyPad(size_hint=(0.5, 0.5))
xy_pad.x_msg = '/fxparam/{0}/value'.format(i*2 + 1)
xy_pad.y_msg = '/fxparam/{0}/value'.format(i*2 + 2)
main_layout.add_widget(xy_pad)
return main_layout
示例7: askInfo
def askInfo(self,requiredInfo):
#the button size is wrong on my laptop but right on the tablet so
close=Button(text='Add')
cancel=Button(text='Cancel')
buttonGrid=GridLayout(cols=2,size_hint_y=.5)
buttonGrid.add_widget(close)
buttonGrid.add_widget(cancel)
content=StackLayout(spacing=5)
valueList=[]#empty list that gets filled with the inputs' getValue functions
for x,y in requiredInfo:
content.add_widget(Label(text=x,size_hint=(None,None),size=(50,32)))
if y.split()[0]=='text': #v if it's length 1, then it isn't a list
tmpWidget=_RetrievableText(len(y.split())-1,multiline=False,size_hint=(None,None),
write_tab=False,size=(100,32))
#^ height 32 bc font size defaults to 10 and y padding defaults to 12
valueList.append(tmpWidget.getValue)
content.add_widget(tmpWidget)
elif y.split()[0]=='int':
tmpWidget=_RetrievableText(len(y.split())-1,multiline=False,input_type='number',
write_tab=False,size_hint=(None,None),size=(100,32))
#^ height 32 bc font size defaults to 10 and y padding defaults to 12
valueList.append(tmpWidget.getValue)
content.add_widget(tmpWidget)
#buttonGrid.height=.5*content.height #size_hint_y=.5 should do this but i guess not
content.add_widget(buttonGrid)
self.askPane=Popup(title='Get Info',content=content,size_hint=(.5,None),
height=1.5*content.height,
auto_dismiss=False,)#on_dismiss=lambda x: self._setInfo(valueList))
close.bind(on_release=lambda x: self._setInfo(valueList,False))#askPane.dismiss)
cancel.bind(on_release=lambda x: self._setInfo(valueList,True))
self.askPane.open()
示例8: test_tb_lr_stacklayout
def test_tb_lr_stacklayout(self):
stacklayout = StackLayout(
orientation='tb-lr',
size=(200, 200),
padding=20,
spacing=10)
widget = Widget(width=100, size_hint=(0.2, 0.4))
stacklayout.add_widget(widget)
stacklayout.do_layout()
self.assertEqual(stacklayout.top - widget.top, 20)
示例9: test_stacklayout_fixed_size
def test_stacklayout_fixed_size(self):
sl = StackLayout()
wgts = [Widget(size=(50, 50), size_hint=(None, None))
for i in range(4)]
for wgt in wgts:
sl.add_widget(wgt)
sl.do_layout()
self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
self.assertEqual(wgts[2].pos, [0, 0])
self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
示例10: test_stacklayout_default
def test_stacklayout_default(self):
# Default orientation is lr-tb.
sl = StackLayout()
wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
for wgt in wgts:
sl.add_widget(wgt)
sl.do_layout()
self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
self.assertEqual(wgts[2].pos, [0, 0])
self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
示例11: LogBox
class LogBox(ScrollView):
_current_selection = 0
def __init__(self, root):
super(LogBox, self).__init__()
self.root = root
self.size_hint = (1, None)
self.height = 150
self.stack = StackLayout()
self.stack.orientation = 'lr-tb'
self.stack.size_hint = (1, None)
self.stack.bind(minimum_height=self.stack.setter('height'))
self.add_widget(self.stack)
def add(self, note):
self.stack.add_widget(LogEntry(note))
def get_entry(self, at):
if at == 0:
return None
if at > len(self.stack.children):
return None
return self.stack.children[len(self.stack.children)-at]
def get_current_entry(self):
return self.get_entry(self.current_selection)
@property
def current_selection(self):
return self._current_selection
@current_selection.setter
def current_selection(self, value):
for child in self.stack.children:
child.color = [1,1,1,1]
if value > len(self.stack.children):
self._current_selection = 0
return
self._current_selection = value
self.stack.children[len(self.stack.children)-value].color = [1,0,0,1]
# We send a KEY ON signal for each note
# only if we are on play mode.
# Reset done status for each note.
if self.root.app.playing:
for note in self.get_current_entry().notes:
note['done'] = False
arduino.send(str.format("+{0}", note['note']))
示例12: __init__
def __init__(self, **kwargs):
StackLayout.__init__(self, **kwargs)
list_item_args_converter = lambda row_index, obj: {
'artist': obj.artist,
'name': obj.name,
'size_hint_y': None,
'height': 25
}
# self.ids.list.item_strings = ["Test 123"]
self.ids.list.adapter = ListAdapter(data=[SampleData("Test Song", "Test Artist")],
template='OverviewEntry',
args_converter=list_item_args_converter)
示例13: __init__
def __init__(self, **kwargs):
super(MagicTab, self).__init__(**kwargs)
self.text = 'Magic'
tab_magic_ui = StackLayout(orientation='tb-lr',
minimum_width=3100,
padding=(5, 5, 0, 0),
spacing=1)
spells = ["Fireball", "Healing Rain", "Taunt", "Holy Light", "Steady Shot",
"Might", "Strike", "Dance"]
for i in range(0, len(spells)):
spell_string = spells[i]
tab_magic_ui.add_widget(Button(text=spell_string,
size_hint=(.2, .1))) # Width of the buttons
self.add_widget(tab_magic_ui)
示例14: build_list
def build_list(self):
self.data_store = JsonStore('./dat.json')
entries = json.loads(self.data_store.get('feeds')['entries'])
entries_count = len(entries)
card_contents = StackLayout(size_hint = [1, 0.0225])
for entry in entries:
self.size_hint[1] += 0.35
card_contents.add_widget(Image(source = './assets/images/talkpython-nowrds.png', size_hint = [0.15,0.4]))
card_contents.add_widget(Label(text=entry['title'],
valign='top',
size_hint=[0.85, 0.4],
text_size= [Window.width * 0.35, None]))
card_contents.add_widget(MyAudioPlayer(source="./assets/audio/043_monitoring_high_performance_python_apps_at_opbeat.mp3",
thumbnail= './assets/images/talkpython.png',
size_hint = [1,0.4],
allow_fullscreen= False
))
#card_contents.add_widget(VideoPlayer(source="./assets/videos/hst_1.mpg", size_hint = [1,0.8]))
self.entry_widgets.append(card_contents)
card_contents = StackLayout(size_hint = [1, 0.0225])
示例15: winPopup
def winPopup(winCondition):
winLayout = StackLayout()
winLabel = Label(text = winCondition, size_hint = (1.0,0.8))
menuBtn = Button(text = 'Main Menu', size_hint = (0.5,0.2))
menuBtn.bind(on_release = mainMenu)
quitBtn = Button(text = 'Quit to Desktop', size_hint = (0.5,0.2))
quitBtn.bind(on_release = ExitFunc)
winLayout.add_widget(winLabel)
winLayout.add_widget(menuBtn)
winLayout.add_widget(quitBtn)
win_popup.content = winLayout