本文整理汇总了Python中kivy.uix.carousel.Carousel.add_widget方法的典型用法代码示例。如果您正苦于以下问题:Python Carousel.add_widget方法的具体用法?Python Carousel.add_widget怎么用?Python Carousel.add_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.carousel.Carousel
的用法示例。
在下文中一共展示了Carousel.add_widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
carousel = Carousel(direction='right')
for i in range(10):
src = "http://placehold.it/480x270.png&text=slide-%d&.png" % i
image = AsyncImage(source=src, allow_stretch=True)
carousel.add_widget(image)
return carousel
示例2: DeckCatalogScreen
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
class DeckCatalogScreen(Screen):
"""Provide a means of exploring and purchasing available decks."""
catalog = ObjectProperty()
def __init__(self, **kwargs):
Screen.__init__(self, **kwargs)
self.carousel = Carousel(direction="right")
standard = self.catalog["Lovers & Spies Deck"]
self.carousel.add_widget(DeckDisplay(deck=standard, purchased=True))
for deck in self.catalog:
if deck == standard: continue
purchased = self.catalog.purchased(deck) is not None
self.carousel.add_widget(DeckDisplay(deck=deck, purchased=purchased))
main = BoxLayout(orientation="vertical")
main.add_widget(ActionBar())
main.add_widget(self.carousel)
self.add_widget(main)
def update(self):
for slide in self.carousel.slides:
if slide.deck.base_filename == "Standard":
continue
slide.purchased = self.catalog.purchased(slide.deck) is not None
示例3: __init__
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def __init__(self, **kwargs):
super(screenLayout, self).__init__(**kwargs)
#buttons
larrow = Button(background_normal='arrows/scroll-left.png',
background_down='arrows/scroll-left-hit.png',
size_hint = (0.06,0.1),
pos_hint={'x':0, 'y':.5},
)
rarrow = Button(background_normal='arrows/scroll-right.png',
background_down='arrows/scroll-right-hit.png',
size_hint = (0.06,0.1),
pos_hint={'x':0.93, 'y':.5}
)
#carousel gallery
root = Carousel(loop='true')
for i in range(1,5):
src = "images/%d.png" % i
images = Image(source=src,
pos_hint = {'x':0.15,'y':0.25},
size_hint= (0.7,0.7),
allow_stretch=True)
root.add_widget(images)
self.add_widget(root)
self.add_widget(larrow)
self.add_widget(rarrow)
示例4: __init__
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def __init__(self, **kwargs):
Screen.__init__(self, **kwargs)
main = BoxLayout(orientation="vertical")
main.add_widget(ActionBar(size_hint=(1, .125)))
carousel = Carousel(direction='right')
layout = GridLayout(rows=2)
i, c = 0, 0
for card in self.definition.cards(App.get_running_app().achievements,
use_blocks=False):
color = (1, 1, 1, 1)
if str(card) in self.definition.blocked_cards:
color = (.5, 0, 0, 1)
layout.add_widget(CardSelect(card=card,
color=color,
callback=self._card_detail,
args=(card,)))
i += 1
c += 1
if i == 10:
carousel.add_widget(layout)
layout = GridLayout(rows=2)
i = 0
if c < 50 + len(self.definition.specials):
layout.add_widget(CardSelect(card=self.LOCKED_CARD))
carousel.add_widget(layout)
main.add_widget(carousel)
self.add_widget(main)
示例5: CarouCntrl
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
class CarouCntrl(Widget):
# root
def __init__(self):
super(CarouCntrl, self).__init__()
# init screens
self.home_screen = HomeScreen(name='home')
self.settings_screen = SettingsScreen(name='settings')
# self.draw_screen = DrawScreen(name='draw')
# init carousel
self.carousel = Carousel(direction='right', loop=True)
# add widgets to carousel
# for i in range(3):
# self.carousel.add_widget(self.home_screen)
self.carousel.add_widget(self.home_screen)
self.carousel.add_widget(self.settings_screen)
# self.carousel.add_widget(self.draw_screen)
# start getting data from OWM
self.owm_link = OWMLink(self)
self.owm_thread = threading.Thread(target=self.owm_link.run, args=())
self.owm_thread.start()
def shutdown(self):
self.owm_link.keep_running = False
示例6: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
carousel = Carousel(direction="right", loop="true")
for i in range(1, 5):
src = "images/%d.jpg" % i
image = Image(source=src, pos=(400, 100), size=(400, 400))
carousel.add_widget(image)
return carousel
示例7: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
#define the carousel
carousel = Carousel(direction='right',loop='true')
filenames = [filename for filename in os.listdir('.') if filename.endswith('.jpg') or filename.endswith('.jpeg')]
for imagefile in filenames:
#load pictures from images folder
imgsize = PILImage.open(imagefile).size
image = Image(source=imagefile,pos=(0,0), size=imgsize)
carousel.add_widget(image)
return carousel
示例8: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
root = self.root
# get any files into images directory
curdir = dirname(__file__)
carousel = Carousel(direction='right', loop='True')
#replace file_name with the directory where your pictures are located
for filename in glob(join(curdir, 'file_name', '*')):
image = Factory.AsyncImage(source=filename, allow_stretch=True)
carousel.add_widget(image)
return carousel
示例9: __init__
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def __init__(self, **kwargs):
kwargs['orientation'] = 'vertical'
super(GraphView, self).__init__(**kwargs)
self.graph_list = [CostPlot(),
VolumePlot(),
DistancePlot(),
EfficiencyPlot()]
graph_carousel = Carousel(direction='right')
for i in range(len(self.graph_list)):
graph_carousel.add_widget(self.graph_list[i].graph)
self.add_widget(graph_carousel)
示例10: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
carousel = Carousel(direction="right")
for i in range(10):
layout = BoxLayout(orientation="vertical")
image1 = AsyncImage(source=("http://placehold.it/480x270.png&text=slide-%d&.png" % i), allow_stretch=True)
image2 = AsyncImage(
source=("http://placehold.it/480x270.png&text=slide-%d&.png" % (i + 1)), allow_stretch=True
)
layout.add_widget(image1)
layout.add_widget(Label(text="Image %d" % i, font_size=30))
layout.add_widget(image2)
layout.add_widget(Label(text="Second Image %d" % (i + 1), font_size=30))
carousel.add_widget(layout)
return carousel
示例11: btn_stats_state
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def btn_stats_state(self, instance, value):
print "btn2", instance, value
if value == 'down':
gg = self.ayevent.get_all_stats_graph()
carousel = Carousel(direction='right', loop=True)
for g in gg:
print g
image = Factory.AsyncImage(source=g, allow_stretch=True)
carousel.add_widget(image)
self._stats_removed = self.mainw.children[0]
self.mainw.remove_widget(self._stats_removed)
self.mainw.add_widget(carousel, 0)
elif value == 'normal':
self.mainw.remove_widget(self.mainw.children[0])
self.mainw.add_widget(self._stats_removed)
示例12: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
global katy
katy=self.config.get('ustawienia', 'miarakatowa')
root = Carousel(direction = 'right', loop=False, anim_move_duration=0.4)
#self.settings_cls = SettingsWithSidebar
kar = ObjectProperty()
kar= MenuRoot()
kar1=Biegun()
kar2=AzymutDlugosc()
kar3=PolePowierzchni()
kar4=WciecieLiniowe()
karTab=[kar,kar1,kar2,kar3,kar4]
for x in range(5):
klas=karTab[x]
root.add_widget(klas)
return root_widget
示例13: Example1
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
class Example1(App):
def build(self):
self.additional_init()
self.carousel = Carousel(
direction='right',
loop=True)
for src in k.filenames:
image = Factory.AsyncImage(source=src, allow_stretch=True)
self.carousel.add_widget(image)
return self.carousel
def additional_init(self):
self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text')
self._keyboard.bind(on_key_down=self._on_keyboard_down)
def _keyboard_closed(self):
print('My keyboard have been closed!')
self._keyboard.unbind(on_key_down=self._on_keyboard_down)
self._keyboard = None
def _print_debug(self, keycode, text, modifiers):
print('The key', keycode, 'have been pressed')
print(' - text is %r' % text)
print(' - modifiers are %r' % modifiers)
def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
self._print_debug(keycode, text, modifiers)
# If we hit escape, release the keyboard
k = keycode[1]
if k == 'escape':
keyboard.release()
if k == 'right':
self.carousel.load_next()
pass
if k == 'left':
self.carousel.load_previous()
pass
return True
示例14: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
# define the carousel
carousel = Carousel(direction="right")
carousel.anim_move_duration = 1
carousel.padding = 40
carousel.loop = True
image1 = Image(source="nature1.jpg")
carousel.add_widget(image1)
image2 = Image(source="nature2.jpg")
carousel.add_widget(image2)
image3 = Image(source="nature3.jpg")
carousel.add_widget(image3)
image4 = Image(source="nature4.jpg")
carousel.add_widget(image4)
eticheta = Label(text="Am ajuns la finalul listei!", font_size=40)
carousel.add_widget(eticheta)
return carousel
示例15: build
# 需要导入模块: from kivy.uix.carousel import Carousel [as 别名]
# 或者: from kivy.uix.carousel.Carousel import add_widget [as 别名]
def build(self):
"""Return the Kivy carousel of gallery images when the app is run."""
try:
exhibit.show_gallery()
except exhibit.GalleryError:
print "Number of input images is not equal to number of effects."
return
output_dir = "output-images"
input_dir = "source-images"
carousel = Carousel(direction="right")
source = ["alf.png", "hug.png", "sad.jpg", "jegermeister.jpg"]
for filename in source:
original_image = AsyncImage(source=(os.path.join(input_dir, filename)), allow_stretch=True)
carousel.add_widget(original_image)
new_image = AsyncImage(source=(os.path.join(output_dir, filename)), allow_stretch=True)
carousel.add_widget(new_image)
return carousel