本文整理汇总了Python中kivy.uix.stacklayout.StackLayout方法的典型用法代码示例。如果您正苦于以下问题:Python stacklayout.StackLayout方法的具体用法?Python stacklayout.StackLayout怎么用?Python stacklayout.StackLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.stacklayout
的用法示例。
在下文中一共展示了stacklayout.StackLayout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_buses
# 需要导入模块: from kivy.uix import stacklayout [as 别名]
# 或者: from kivy.uix.stacklayout import StackLayout [as 别名]
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: draw_buses
# 需要导入模块: from kivy.uix import stacklayout [as 别名]
# 或者: from kivy.uix.stacklayout import StackLayout [as 别名]
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 LondonBus object and add it to the
# StackLayout
for bus in buses:
bs = LondonBus(bus=bus)
sl.add_widget(bs)
示例3: createStack
# 需要导入模块: from kivy.uix import stacklayout [as 别名]
# 或者: from kivy.uix.stacklayout import StackLayout [as 别名]
def createStack(self):
"""Works out how to display the league matches.
Layout depends on the number of matches found.
"""
matches = self.leagueobject.LeagueMatches
x = len(matches)
# Single column, no scrolling
if x <= 10:
self.spacer = True
w = 1
scroll = False
self.h = 42 * x
# Dual columns, no scrolling
elif x <= 20:
self.spacer = False
w = 0.5
scroll = False
self.h = round(x/2.0) * 42
# Dual columns, scrolling
else:
self.spacer = False
w = 0.5
scroll = True
self.h = round(x/2.0) * 42
# Create a stack layout
stack = StackLayout(orientation="tb-lr",
size_hint_y=None,
height=self.h)
stack.bind(minimum_height=stack.setter('height'))
# Add the league matches to it.
for l in matches:
lg = LeagueGame(match=l, size_hint=(w, None))
stack.add_widget(lg)
# Create a scroll view
scroll = ScrollView(size_hint=(1, 1))
scroll.add_widget(stack)
return scroll
示例4: getTrains
# 需要导入模块: from kivy.uix import stacklayout [as 别名]
# 或者: from kivy.uix.stacklayout import StackLayout [as 别名]
def getTrains(self, *args):
# Try loading the train data but handle any failure gracefully.
try:
trains = NR.lookup(self.frm, self.to)
except:
trains = None
# If we've got trains then we need to set up the screen
if trains:
# Get rid of the previous widgets.
self.clear_widgets()
# Add a box layout
self.bx = BoxLayout(orientation="vertical")
# Show the name of the train route
self.bx.add_widget(Label(text=self.desc, size_hint_y=0.2))
# Add headers for the trains
self.bx.add_widget(TrainDetail(train=self.headers,
bg=[0.2, 0.2, 0.2, 1]))
# Create a StackLayout in case we need to scroll over the trains.
self.stck = StackLayout(orientation="tb-lr", size_hint_y=0.8)
self.bx.add_widget(self.stck)
# Loop over the trains
for train in trains:
# Create a TrainDetail widget and add it to the StackLayout
trn = TrainDetail(train=train)
self.stck.add_widget(trn)
# Get rid of the Loading label (if it's there)
try:
self.remove_widget(self.ids.load_label)
except ReferenceError:
pass
self.add_widget(self.bx)
# Set the next update for 5 mins later
self.nextupdate = time.time() + 300
self.timer = Clock.schedule_once(self.getTrains, 300)
# No trains so let the user know.
else:
self.clear_widgets()
errorm = ("Error getting train data.\nPlease check that you are "
"connected to the internet and\nthat you have entered "
"valid station names.")
lb = Label(text=errorm)
self.add_widget(lb)