本文整理汇总了Python中kivy.uix.gridlayout.GridLayout方法的典型用法代码示例。如果您正苦于以下问题:Python gridlayout.GridLayout方法的具体用法?Python gridlayout.GridLayout怎么用?Python gridlayout.GridLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.gridlayout
的用法示例。
在下文中一共展示了gridlayout.GridLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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 )
示例2: build
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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
示例3: setup
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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)
示例4: drawScreen
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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)
示例5: build
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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
示例6: on_enter
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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
示例7: on_enter
# 需要导入模块: from kivy.uix import gridlayout [as 别名]
# 或者: from kivy.uix.gridlayout import GridLayout [as 别名]
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