本文整理汇总了Python中kivy.loader.Loader类的典型用法代码示例。如果您正苦于以下问题:Python Loader类的具体用法?Python Loader怎么用?Python Loader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Loader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: request_coins
def request_coins(self, instance, *tmp):
"""
формирует зпрос по http монет
:param instance:
:param largs:
:return:
"""
coins_layout = self.root.ids.coins_layout
coins_scroll_view = self.root.ids.coins_scroll_view
post_data = {'what': instance.name, 'type': instance.gettype()}
self.coins = self.send_http_post('/euro/what', post_data)
if self.coins is not None:
if Loader.pool is not None: # если что то было в овчерди на загрузку,отключаем
Loader.stop()
coins_layout.clear_widgets() # удаляем все что было вставлено
coins_scroll_view.scroll_y = 1 # скроллер на начало
coins_scroll_view.height = self.root.height
height = 0
while self.coins:
view_coin = CoinViewFactory.factory(instance=instance, coin=self.coins.pop(0))
coins_layout.add_widget(view_coin)
height += view_coin.height
if coins_scroll_view.height + 2*view_coin.height < height:
break
示例2: on_start
def on_start(self):
Logger.debug("%s: on_start %s" % (APP, datetime.now()))
from kivy.core.window import Window
Window.bind(on_keyboard=self.on_keypress)
if platform == 'android':
android.map_key(android.KEYCODE_BACK, 1001)
import android.activity as python_activity
python_activity.bind(on_new_intent=self.on_new_intent)
self.on_new_intent(activity.getIntent())
self.server_url = self.config.get('general', 'server_url')
self.root.bind(
on_touch_down=lambda *a: setattr(self, 'delay_image_loading', True),
on_touch_up=lambda *a: setattr(self, 'delay_image_loading', False))
imagedir = ImageDir(server_url=self.server_url)
wp = 'with_previous'
imagedir.bind(
on_navigate_top=lambda *a: setattr(self.root, wp, False),
on_navigate_down=lambda *a: setattr(self.root, wp, True),
on_img_selected=self.load_carousel,
path=lambda w,v: setattr(self.root, 'title', v),
on_loading_start=lambda *a: setattr(self.root, 'loading', True),
on_loading_stop=lambda *a: setattr(self.root, 'loading', False))
self.imagedir = imagedir
self.root.container.add_widget(imagedir)
self.root.bind(on_touch_down=lambda *a: Loader.pause(),
on_touch_up=lambda *a: Loader.resume())
Loader.max_upload_per_frame = 1 # Maximize interactivity
示例3: reload
def reload(self):
if Loader:
source = self.source
if not self.is_uri(source):
source = resource_find(source)
Loader.remove_from_cache(source)
super(AsyncImage, self).reload()
示例4: _clear_loader
def _clear_loader(self, *largs):
Loader.stop()
self.carousel.clear_widgets()
self.loadnum = 0
self.image = []
self.pb.value = 0
self.ltext.text = "total: "
# now load
Clock.schedule_once(self._load_values,0.2)
示例5: __init__
def __init__(self, **kwargs):
super(gfsViewerApp, self).__init__(**kwargs)
self.carousel = Carousel(direction='right',anim_move_duration=0.1, anim_type='in_out_sine',loop='false')
self.active_region = "M-Europa"
self.active_value = "3h Niederschlag"
self.last_df = 0
self.image = []
self.limit = 0
self.pb = ""
self.src = ""
Loader.start()
示例6: __init__
def __init__(self, **kwargs):
super(Tweet, self).__init__(**kwargs)
contentContainer = self.ids['content_container']
self.profPic = self.ids['profile_image']
profPicLoader = Loader.image(kwargs["profile_image"])
profPicLoader.bind(on_load=self._image_loaded)
userName = self.ids['user_name']
userName.text = kwargs["user_name"] + " " + "[size=19][color=075981]" + " @"+kwargs["screen_name"] + " - " + to_friendly_time(kwargs["created_at"]) + "[/color][/size]"
userName.markup = True
tweetText = self.ids['tweet_text']
tweetText.text = kwargs["text"]
self.linkButton = self.ids['link_button']
urls = kwargs['urls']
if len(urls)>0:
self.link = urls[0]["url"]
if self.link[:15] != "http://youtu.be":
self.add_hyperlinks(tweetText, urls)
self.linkButton.bind(on_release = self.on_ref_pressed_btn)
self.trgHeight = self.height
if len(kwargs["media"]) > 0:
self.addImageCont = self.ids['additional_image_cont']
self.addImage = self.ids['additional_image']
self.addImageBtn = self.ids['additional_image_button']
self.image_url = kwargs["media"][0]['url']
addImageLoader = Loader.image(self.image_url)
addImageLoader.bind(on_load=self._add_image_loaded)
self.addImageCont.height = 300
self.fullHeight = int(kwargs["media"][0]['lrg_height'])
self.trgHeight += self.addImageCont.height
self.height = 0
self.opacity = 0
#anim = Animation(height = self.trgHeight, opacity = 1, duration = self.animDur)
#anim.start(self)
self.height = self.trgHeight
self.opacity = 1
示例7: on_source
def on_source(self, instance, value):
if not value:
self.texture = None
self._coreimage = None
else:
filename = resource_find(value)
self._coreimage = image = Loader.image(filename)
image.bind(on_load=self.on_source_load)
self.texture = image.texture
示例8: __init__
def __init__(self, poolsize=TILESERVER_POOLSIZE):
self.cache_path = join(dirname(__file__), 'cache', self.provider_name)
if not isdir(self.cache_path):
makedirs(self.cache_path)
black = Loader.image(join('documents','black.png'))
#Loader._loading_image = black
self.q_in = deque()
self.q_out = deque()
self.q_count = 0
self.c_in = Condition()
self.workers = []
self.poolsize = poolsize
self.uniqid = 1
self.want_close = False
self.available_maptype = dict(roadmap='Roadmap')
self.hcsvnt = Loader.image(join('documents','hcsvnt.png'))
示例9: on_source
def on_source(self, instance, value):
if not value:
self.texture = None
self._coreimage = None
else:
if not self.is_uri(value):
value = resource_find(value)
self._coreimage = image = Loader.image(value)
image.bind(on_load=self.on_source_load)
image.bind(on_texture=self._on_tex_change)
self.texture = image.texture
示例10: get_cover
def get_cover(self):
data_folder = App.get_running_app().config.get('Server', 'storagedir')
cover_file = '%s/%s.png'%(data_folder,str(self.comic_id_number))
try:
if os.path.isfile(cover_file):
return str(cover_file)
else:
proxyImage = Loader.image(self.thumb_url,nocache=True)
proxyImage.bind(on_load=partial(self._proxy_loaded))
return self.thumb_url
except:
Logger.critical('Something bad happened in loading cover')
示例11: __init__
def __init__(self, objective, position, level_max, integrated=True, url=None):
"""
Initialize the indicator
:param objective: a table of different objectives
:param position: the position of the indicator
:param level_max: the max number of objectives
"""
Widget.__init__(self)
self.objective = objective
self.progress = 0
self.level = 0
self.countdown = objective
self.level_max = level_max
self.integrated = integrated
self.position = position
self.url = url
btn_new_image = Button(text="Ajout d'images", size=[200, 50])
btn_new_image.pos = (position[0] - btn_new_image.width / 2, position[1])
btn_new_image.bind(on_press=self.callback)
if not self.integrated:
self.pb = ProgressBar(max=self.objective, value=self.progress, size=[200, 0])
self.pb2 = ProgressBar(max=self.objective, value=self.progress, size=[200, 0])
self.pb3 = ProgressBar(max=self.objective, value=self.progress, size=[200, 0])
self.pb.pos = (position[0] - self.pb.width / 2, position[1] + btn_new_image.height)
self.pb2.pos = (position[0] - self.pb.width / 2, position[1] + btn_new_image.height + 2)
self.pb3.pos = (position[0] - self.pb.width / 2, position[1] + btn_new_image.height + 5)
elif self.integrated and self.countdown >= 0:
from kivy.uix.image import Image
from kivy.loader import Loader
proxyImage = Loader.image(str(self.url))
proxyImage.bind(on_load=self._image_loaded)
self.pb = Image()
self.pb.pos = (position[0] - self.pb.width / 2, position[1] + btn_new_image.height)
self.position = (position[0] - self.pb.width / 2, position[1] + btn_new_image.height)
with self.canvas:
Color(1, 1, 1, 1)
Rectangle(texture=self.pb.texture,
size=(self.pb.width, self.pb.height * (1 - (float(self.progress) / float(self.objective)))),
pos=(
self.position[0], self.position[1] + self.pb.height * (self.progress / self.objective)))
Color(0, 0, 0, 1)
Rectangle(size=(self.pb.width, self.pb.height * (1 - (float(self.progress) / float(self.objective)))),
pos=self.pb.pos)
self.add_widget(btn_new_image)
if not self.integrated:
self.add_widget(self.pb)
self.add_widget(self.pb2)
self.add_widget(self.pb3)
示例12: _load_source
def _load_source(self, *args):
source = self.source
if not source:
if self._coreimage is not None:
self._coreimage.unbind(on_texture=self._on_tex_change)
self.texture = None
self._coreimage = None
else:
if not self.is_uri(source):
source = resource_find(source)
self._coreimage = image = Loader.image(source, nocache=self.nocache, mipmap=self.mipmap)
image.bind(on_load=self._on_source_load)
image.bind(on_texture=self._on_tex_change)
self.texture = image.texture
示例13: loadImage
def loadImage(self, filename, onload=None):
self.filename = filename
if filename != None:
self.onLoadCallback = onload
proxyImage = Loader.image(filename)
# this is totally stupid behaviour of Kivy
# the docs suggest to bind proxy image's on_load method to a callback
# to indicate when image is loaded. However, when image is already
# in the cache the callback won't be called. My first thought was
# that it was a threading issue, because the bindind might have happened
# after the callback was initiated, but it seems that indeed the method is just not called.
if proxyImage.loaded == False:
proxyImage.bind(on_load=self._image_loaded)
else:
self._image_loaded(proxyImage)
示例14: _load_next
def _load_next(self,*largs):
if (self.loadnum < self.limit):
# for some reason to many events where fired, so ignore
# calls that don't have a unique timestamp
if (len(largs) >0 ):
if self.last_df == largs[0]:
ignore = True
else:
ignore = False
self.last_df = largs[0]
else:
ignore = False
if not ignore:
#gif images make trouble, conversion happens on server
src = self.src % \
( regions[self.active_region], ((self.loadnum +1) * self.steps), values.index(self.active_value) + 1)
proxyImage = Loader.image(src)
# we already have that image in cache
if proxyImage.loaded:
self.image.append(Image())
self.image[self.loadnum].texture = proxyImage.image.texture
self.carousel.add_widget(self.image[self.loadnum])
self.loadnum = self.loadnum + 1
self._load_next()
# load image in background.
else:
proxyImage.bind(on_load=self._image_loaded)
self.image.append(Image())
self.image[self.loadnum].texture = proxyImage.image.texture
self.carousel.add_widget(self.image[self.loadnum])
#update widget..
self.carousel.canvas.ask_update()
# update progress bar
self.pb.value = (self.loadnum) / float(self.limit) * 100
self.ltext.text = "total: + %dh" % ((self.loadnum) * self.steps)
示例15: load_comic_screen
def load_comic_screen(self, comicstream_number):
m_win_x = Window.width
m_win_y = Window.height
carousel = self.ids.comicscreenid.ids['my_carousel']
carousel.clear_widgets()
Logger.debug(str(comicstream_number))
page_count = 22
comicstream_number = int(self.ids['txt1'].text)
id = '96'
# cscomic = CsComic(comicstream_number)
base_url = App.get_running_app().config.get('Server', 'url')
base_dir = 'comic_page_images'
scroll = ScrollView( size_hint=(1,1), do_scroll_x=True, do_scroll_y=False,id='page_thumb_scroll')
self.pop = Popup(id='page_pop',title='Pages', content=scroll, pos_hint ={'y': .0001},size_hint = (1,.33))
grid = GridLayout(rows=1, size_hint=(None,None),spacing=5,padding_horizontal=5,id='outtergrd')
grid.bind(minimum_width=grid.setter('width'))
for i in range(0, page_count):
src_full = "%s/comic/%d/page/%d?max_height=1200#.jpg" % (base_url, comicstream_number, i)
src_thumb = "%s/comic/%d/page/%d?max_height=200#.jpg" % (base_url, comicstream_number, i)
comic_page_image = ComicImage(src=src_full, _index=i,nocache=False,keep_ratio=False,allow_stretch=True,id='pi_'+str(i),
size_hint = (1,1),size=self.size
)
proxyImage = Loader.image(src_full)
scatter = ComicScatter(do_rotation=False, do_scale=False,do_translation_x=False,id='comic_scatter'+str(i),
scale_min=1, scale_max=2, size_hint=(None,None), size = (m_win_x,m_win_y),
)
scatter.add_widget(comic_page_image)
carousel.add_widget(scatter)
c_index = len(carousel.slides)
comic_page_image.car_index = c_index
scatter.parent.bind(pos=self.setter('pos'))
scatter.parent.bind(size=self.setter('size'))
proxyImage.bind(on_load=partial(comic_page_image._image_downloaded, grid,comicstream_number))
#Build the popup scroll of page buttons
scroll.add_widget(grid)