Python kivy.uix.gridlayout.GridLayout() Examples
The following are 8
code examples of kivy.uix.gridlayout.GridLayout().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.uix.gridlayout
, or try the search function
.
Example #1
Source File: scrollview.py From Tickeys-linux with MIT License | 6 votes |
def build(self): layout1 = GridLayout(cols=4, spacing=10, size_hint=(None, None)) layout1.bind(minimum_height=layout1.setter('height'), minimum_width=layout1.setter('width')) for i in range(40): btn = Button(text=str(i), size_hint=(None, None), size=(200, 100)) layout1.add_widget(btn) scrollview1 = ScrollView(bar_width='2dp') scrollview1.add_widget(layout1) layout2 = GridLayout(cols=4, spacing=10, size_hint=(None, None)) layout2.bind(minimum_height=layout2.setter('height'), minimum_width=layout2.setter('width')) for i in range(40): btn = Button(text=str(i), size_hint=(None, None), size=(200, 100)) layout2.add_widget(btn) scrollview2 = ScrollView(scroll_type=['bars'], bar_width='9dp', scroll_wheel_distance=100) scrollview2.add_widget(layout2) root = GridLayout(cols=2) root.add_widget(scrollview1) root.add_widget(scrollview2) return root
Example #2
Source File: forms.py From kivy-material-ui with MIT License | 6 votes |
def __init__( self, **kargs ) : super( Screen2, self ).__init__( **kargs ) """ ScrollView with a refresh controll... """ self.myscroll = RefreshableScrollView( on_start_reload=self.on_start_reload, root_layout=self.shared_navigation_controller.floating_panel ) self.add_widget( self.myscroll ) """ Loading fake elements... """ temp = GridLayout( size_hint=(1,None), cols=1 ) for n in ['Pull down to reload','A fake error will be raised']+list(range(0,20)) : l = Label( text='Element no '+str(n), height=dp(50), size_hint=(1,None), color=[0,0,0,.8] ) temp.add_widget( l ) temp.height += dp(50) self.myscroll.add_widget( temp )
Example #3
Source File: kivy.py From spotify-downloader-music-player with MIT License | 5 votes |
def build(self): # adding GridLayouts in App # Defining number of coloumn # You can use row as well depends on need layout = GridLayout(cols = 2) # 1st row layout.add_widget(Button(text ='Hello 1')) layout.add_widget(Button(text ='World 1')) # 2nd row layout.add_widget(Button(text ='Hello 2')) layout.add_widget(Button(text ='World 2')) # 3rd row layout.add_widget(Button(text ='Hello 3')) layout.add_widget(Button(text ='World 3')) # 4th row layout.add_widget(Button(text ='Hello 4')) layout.add_widget(Button(text ='World 4')) # returning the layout return layout # creating object of the App class
Example #4
Source File: screen.py From RPi-InfoScreen-Kivy with GNU General Public License v3.0 | 5 votes |
def setup(self): # Get the layout self.config = self.loadLayout() # We'll want to keep a list of all the letter objects self.letters = [] # Create a grid layout that's the right size grid = GridLayout(cols=self.config.COLS) # Loop over the letters for ltr in self.config.LAYOUT: # Create a letter object word = WordClockLetter(text=ltr, size=self.config.SIZE, font_size=self.config.FONTSIZE, colour=self.colour) # add it to our list... grid.add_widget(word) # ...and to the grid layout self.letters.append(word) # Clear the screen self.clear_widgets() # add the clock layout self.add_widget(grid)
Example #5
Source File: scrollview.py From Tickeys-linux with MIT License | 5 votes |
def build(self): layout1 = GridLayout(cols=4, spacing=10, size_hint=(None, None)) layout1.bind(minimum_height=layout1.setter('height'), minimum_width=layout1.setter('width')) for i in range(40): btn = Button(text=str(i), size_hint=(None, None), size=(200, 100)) layout1.add_widget(btn) scrollview1 = ScrollView(bar_width='2dp') scrollview1.add_widget(layout1) layout2 = GridLayout(cols=4, spacing=10, size_hint=(None, None)) layout2.bind(minimum_height=layout2.setter('height'), minimum_width=layout2.setter('width')) for i in range(40): btn = Button(text=str(i), size_hint=(None, None), size=(200, 100)) layout2.add_widget(btn) scrollview2 = ScrollView(scroll_type=['bars'], bar_width='9dp', scroll_wheel_distance=100) scrollview2.add_widget(layout2) root = GridLayout(cols=2) root.add_widget(scrollview1) root.add_widget(scrollview2) return root
Example #6
Source File: screentalks.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def on_enter(self, onsuccess=False): container = self.ids.container if self.from_back: return if len(container.children) > 2: container.remove_widget(container.children[0]) from network import get_data talks = get_data('tracks', onsuccess=onsuccess) gl = None if not talks: return talk_info = talks['0.0.1'][0][self.talkid] self.ids.talk_title.text = talk_info['title'] self.ids.talk_desc.text = talk_info['description'] if 'speaker' in talk_info.keys(): speaker=talk_info['speaker'] if speaker['name']: speaker_details = SpeakerDetails(speaker=speaker) if 'social' in speaker: speaker_social = speaker['social'][0] social_len = len(speaker_social) gl = GridLayout(cols=social_len, size_hint_y=None, padding='2dp', spacing='2dp') import webbrowser for social_acc, social_link in speaker_social.items(): imbt = Factory.ImBut() imbt.source = 'atlas://data/default/' + social_acc.lower() imbt.on_released = partial(webbrowser.open,social_link) gl.add_widget(imbt) speaker_details.add_widget(gl) self.ids.container.add_widget(speaker_details) Factory.Animation(opacity=1, d=.3).start(container) self.ids.scroll.scroll_y = 1
Example #7
Source File: screentalks.py From PyCon-Mobile-App with GNU General Public License v3.0 | 4 votes |
def on_enter(self, onsuccess=False): container = self.ids.container if self.from_back: Factory.Animation(opacity=1, d=.3).start(container) return if len(container.children) > 2: container.remove_widget(container.children[0]) from network import get_data talks = get_data('tracks', onsuccess=onsuccess) gl = None if not talks: return try: talk_info = talks['0.0.1'][0][self.talkid] except KeyError: # no details for this talk exist... # let's go back to previous screen from utils import go_back_in_history go_back_in_history() return self.ids.talk_title.text = talk_info['title'] self.ids.talk_desc.text = talk_info['description'] if 'speaker' in talk_info.keys(): speaker = talk_info['speaker'] if speaker['name']: speaker_details = SpeakerDetails(speaker=speaker) if 'social' in speaker: speaker_social = speaker['social'] items = speaker_social.items() social_len = len(items) gl = GridLayout(cols=social_len, size_hint_y=None, padding='2dp', spacing='2dp') import webbrowser # update data for share button if 'proposal' in speaker_social: self.ids.but_share.data = "Checkout this talk " \ + speaker_social['proposal'] + " by "\ + speaker['name'] # display social buttons for social_acc, social_link in items: imbt = Factory.ImBut() imbt.source = 'atlas://data/default/' + \ social_acc.lower() imbt.on_released = partial( webbrowser.open, social_link) imbt.color = app.base_active_bright[:3] + [.9] gl.add_widget(imbt) speaker_details.add_widget(gl) self.ids.container.add_widget(speaker_details) Factory.Animation(opacity=1, d=.3).start(container) self.ids.scroll.scroll_y = 1
Example #8
Source File: screen.py From RPi-InfoScreen-Kivy with GNU General Public License v3.0 | 4 votes |
def drawScreen(self): """Main method for rendering screen. If there is recording data (live or cached) then is laid out in a scroll view. If not, the user is notified that the backend is unreachable. """ sv = self.ids.myth_scroll sv.clear_widgets() if self.recs: # Create a child widget to hold the recordings. self.sl = GridLayout(cols=1, size_hint=(1, None), spacing=2) self.sl.bind(minimum_height=self.sl.setter('height')) # Loop over the list of recordings. for rec in self.recs: # These are grouped by day so we need a header day = dt.timedelta(0, rec[0]) + EPOCH mrh = MythRecordingHeader(rec_date=day.strftime("%A %d %B")) self.sl.add_widget(mrh) # Then we loop over the recordings scheduled for that day for r in rec[1]: # and add them to the display. mr = MythRecording(rec=r) self.sl.add_widget(mr) sv.add_widget(self.sl) else: lb = Label(text="Backend is unreachable and there is no cached" " information") sv.add_widget(lb)