本文整理汇总了Python中kivy.loader.Loader.image方法的典型用法代码示例。如果您正苦于以下问题:Python Loader.image方法的具体用法?Python Loader.image怎么用?Python Loader.image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.loader.Loader
的用法示例。
在下文中一共展示了Loader.image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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
示例2: on_source
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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
示例3: __init__
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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'))
示例4: on_source
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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
示例5: get_cover
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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')
示例6: __init__
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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)
示例7: _load_source
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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
示例8: loadImage
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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)
示例9: _load_next
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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)
示例10: load_comic_screen
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
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)
示例11: reload_desktop
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
def reload_desktop( self , *args ) :
"""
:param args:
:return:
"""
if self._ev.isSet() :
sys.exit( 1 )
try :
desktop = Loader.image( self.url , nocache=True )
desktop.bind( on_load=self.desktop_loaded )
except Exception as e :
self._clock_event.cancel()
self._logger.error( 'reload_desktop ' + str( e ))
self.root.ids.desktop.source = './img/stop.png'
sys.exit( 1 )
示例12: __init__
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
def __init__(self, identifier, image, pos, parent, support, lvl):
"""
Initialize an animal
:param identifier: the id of the animal
:param image: the path of the image for the animal
:param pos: the square where the scatter can be randomly placed
"""
self.support = support
self.scale_min=1
self.scale_max=3.
self.src_image = image
from kivy.graphics.texture import Texture
self.texture = Texture.create(size=(100, 100))
size = 100 * 100 * 3
buf = [0 for x in range(size)]
buf = b''.join(map(chr, buf))
self.texture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')
if self.src_image is not None:
from kivy.uix.image import Image
from kivy.loader import Loader
proxy_image = Loader.image(str(self.src_image))
proxy_image.bind(on_load=self._image_loaded)
self.image = Image()
self.locked = False
self.lvl = lvl
self.size_image=self.size[0]-10,self.size[1]-10
self.pos_center = self.pos[0]+5, self.pos[1]+5
Scatter.__init__(self)
if self.support == "table":
self.center = [randint(200, pos[0]), randint(200, pos[1])]
else:
self.center = pos[0], pos[1]
self.rotation = randint(0, 360)
self.identifier = identifier
self.current_user = None
示例13: __init__
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
def __init__(self, poolsize=TILESERVER_POOLSIZE, **kwargs):
self.register_event_type('on_dirty')
super(TileServer, self).__init__(**kwargs)
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'))
self.hcsvnt.bind(on_load=self.set_dirty)
示例14: _load_source
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
def _load_source(self, *args):
source = self.source
file_name = '.' + urlparse(self.source).path
if os.path.isfile(file_name):
source = file_name
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,
anim_delay=self.anim_delay)
image.bind(on_load=self._on_source_load)
image.bind(on_texture=self._on_tex_change)
self.texture = image.texture
示例15: process_message
# 需要导入模块: from kivy.loader import Loader [as 别名]
# 或者: from kivy.loader.Loader import image [as 别名]
def process_message(self, server_msg):
"""
Process network message from server
"""
json_message = json.loads(server_msg.decode())
try:
if json_message['Type'] != "Image":
common_global.es_inst.com_elastic_index('info', {"Got Message": server_msg})
else:
common_global.es_inst.com_elastic_index('info', {"Got Image Message":
json_message['Subtype'],
'uuid':
json_message['UUID']})
except:
common_global.es_inst.com_elastic_index('info', {"full record": server_msg})
common_global.es_inst.com_elastic_index('info', {"len total": len(server_msg)})
# determine message type and work to be done
if json_message['Type'] == "Ident":
# Send a uuid for this connection. This way same installs can be copied, etc.
# and not run into each other.
self.send_twisted_message_thread(json.dumps({'Type': 'Ident',
'UUID': str(uuid.uuid4()),
'Platform': platform.node()}))
# start up the image refresh since we have a connection
Clock.schedule_interval(self.main_image_refresh, 5.0)
elif json_message['Type'] == 'Play': # direct file play
video_source_dir = json_message['Data']
# TODO - load real mapping
share_mapping = (
('/mediakraken/mnt/', '/home/spoot/zfsspoo/Media/'),)
if share_mapping is not None:
for mapping in share_mapping:
video_source_dir = video_source_dir.replace(mapping[0], mapping[1])
if os.path.exists(video_source_dir):
# direct play it
self.mpv_process = subprocess.Popen(
split('mpv --no-config --fullscreen --ontop --no-osc --no-osd-bar --aid=2',
'--audio-spdif=ac3,dts,dts-hd,truehd,eac3 --audio-device=pulse',
'--hwdec=auto --input-ipc-server ./mk_mpv.sock \"'
+ video_source_dir + '\"'))
self.mpv_connection = common_network_mpv.CommonNetMPVSocat()
elif json_message['Type'] == "Image":
common_global.es_inst.com_elastic_index('info', {'stuff': "here for movie refresh"})
if json_message['Image Media Type'] == "Demo":
f = open("./image_demo", "w")
f.write(str(base64.b64decode(json_message['Data'])))
f.close()
self.demo_media_id = json_message['UUID']
if self.first_image_demo == False:
common_global.es_inst.com_elastic_index('info', {'stuff': 'boom'})
self.root.ids.main_home_demo_image.reload()
common_global.es_inst.com_elastic_index('info', {'stuff': 'boom2'})
else:
common_global.es_inst.com_elastic_index('info', {'stuff': 'wha2'})
proxy_image_demo = Loader.image("./image_demo")
proxy_image_demo.bind(
on_load=self._image_loaded_home_demo)
self.first_image_demo = False
elif json_message['Type'] == "MPV":
# sends the data message direct as a command to local running mpv
self.mpv_connection.execute(json_message['Data'])
else:
common_global.es_inst.com_elastic_index('error', {'stuff': "unknown message type"})