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


Python floatlayout.FloatLayout方法代碼示例

本文整理匯總了Python中kivy.uix.floatlayout.FloatLayout方法的典型用法代碼示例。如果您正苦於以下問題:Python floatlayout.FloatLayout方法的具體用法?Python floatlayout.FloatLayout怎麽用?Python floatlayout.FloatLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kivy.uix.floatlayout的用法示例。


在下文中一共展示了floatlayout.FloatLayout方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def build(self):

            # test with FboFloatLayout or FloatLayout
            # comment/uncomment to test it
            root = FboFloatLayout()
            #root = FloatLayout()

            # this part of creation can be slow. try to optimize the loop a
            # little bit.
            s = 30
            size = (s, s)
            sh = (None, None)
            add = root.add_widget
            print('Creating 5000 widgets...')
            for i in range(5000):
                x = (i % 40) * s
                y = int(i / 40) * s
                add(Button(text=str(i), pos=(x, y), size_hint=sh, size=size))
                if i % 1000 == 1000 - 1:
                    print(5000 - i - 1, 'left...')

            return root 
開發者ID:kpiorno,項目名稱:kivy3dgui,代碼行數:24,代碼來源:fbowidget.py

示例2: build

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def build(self):
            root = FloatLayout()
            self.sm = sm = ScreenManager(transition=SwapTransition())

            sm.add_widget(Screen(name='test1'))
            sm.add_widget(Screen(name='test2'))

            btn = Button(size_hint=(None, None))
            btn.bind(on_release=self.change_view)

            btn2 = Button(size_hint=(None, None), x=100)
            btn2.bind(on_release=self.remove_screen)

            root.add_widget(sm)
            root.add_widget(btn)
            root.add_widget(btn2)
            return root 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:19,代碼來源:screenmanager.py

示例3: build

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def build(self):
        EventLoop.ensure_window()
        layout = FloatLayout()
        if self.figure:
            self.figure.size_hint_y = 0.9
            layout.add_widget(self.figure)
        if self.toolbar:
            self.toolbar.size_hint_y = 0.1
            layout.add_widget(self.toolbar)
        return layout 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:12,代碼來源:backend_kivyagg.py

示例4: __init__

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def __init__(self, **kw):
        self.content = FloatLayout()
        super(ScatterLayout, self).__init__(**kw)
        if self.content.size != self.size:
            self.content.size = self.size
        super(ScatterLayout, self).add_widget(self.content)
        self.bind(size=self.update_size) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:9,代碼來源:scatterlayout.py

示例5: build

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def build(self):
            root = FloatLayout()
            bx = BoxLayout()
            bx.add_widget(Button())
            bx.add_widget(Button())
            bx2 = BoxLayout()
            bx2.add_widget(Button())
            bx2.add_widget(Button())
            bx2.add_widget(Button())
            spl = Splitter(
                size_hint=(1, .25),
                pos_hint = {'top': 1},
                sizable_from = 'bottom')
            spl1 = Splitter(
                sizable_from='left',
                size_hint=(None, 1), width=90)
            spl1.add_widget(Button())
            bx.add_widget(spl1)
            spl.add_widget(bx)

            spl2 = Splitter(size_hint=(.25, 1))
            spl2.add_widget(bx2)
            spl2.sizable_from = 'right'
            root.add_widget(spl)
            root.add_widget(spl2)
            return root 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:28,代碼來源:splitter.py

示例6: build

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def build(self):
            main_widget = Builder.load_string("""
#:import MDRaisedButton kivymd.button.MDRaisedButton
#:import MDThemePicker kivymd.theme_picker.MDThemePicker
FloatLayout:
    MDRaisedButton:
        size_hint: None, None
        pos_hint: {'center_x': .5, 'center_y': .5}
        size: 3 * dp(48), dp(48)
        center_x: self.parent.center_x
        text: 'Open theme picker'
        on_release: MDThemePicker().open()
        opposite_colors: True
""")
            return main_widget 
開發者ID:kiok46,項目名稱:Blogs-Posts-Tutorials,代碼行數:17,代碼來源:theme_picker.py

示例7: build

# 需要導入模塊: from kivy.uix import floatlayout [as 別名]
# 或者: from kivy.uix.floatlayout import FloatLayout [as 別名]
def build(self):

        data_dir = getattr(self, 'user_data_dir') #get a writable path to save our score
        self.store = JsonStore(join(data_dir, 'score.json')) # create a JsonScore file in the available location

        if(not self.store.exists('score')): # if there is no file, we need to save the best score as 1
            self.store.put('score', best=1)

        if platform() == 'android': # if we are on Android, we can initialize the ADs service
            revmob.start_session('54c247f420e1fb71091ad44a')

        self.screens = {} # list of app screens
        self.screens['menu'] = MenuScreen(self) #self the MainApp instance, so others objects can change the screen
        self.screens['game'] = GameScreen(self)
        self.root = FloatLayout()

        self.open_screen('menu')

        self.sound = SoundLoader.load('res/background.mp3') # open the background music
        # kivy support music loop, but it was not working on Android. I coded in a different way to fix it
        # but if fixed, we can just set the loop to True and call the play(), so it'll auto repeat
        # self.sound.loop = True It # was not working on android, so I wrote the following code:
        self.sound.play() # play the sound
        Clock.schedule_interval(self.check_sound, 1) #every second force the music to be playing

        return self.root

    # play the sound 
開發者ID:aron-bordin,項目名稱:Kivy-Tutorials,代碼行數:30,代碼來源:main.py


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