當前位置: 首頁>>代碼示例>>Python>>正文


Python stacklayout.StackLayout方法代碼示例

本文整理匯總了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) 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:27,代碼來源:screen.py

示例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) 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:25,代碼來源:screen.py

示例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 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:48,代碼來源:screen.py

示例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) 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:55,代碼來源:screen.py


注:本文中的kivy.uix.stacklayout.StackLayout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。