def build(self): root = RootWidget() c = CustomLayout() root.add_widget(c) c.add_widget( AsyncImage( source= "F:/Photos/Favourite personalities/FB_IMG_1566583215036.jpg", size_hint=(1, .5), pos_hint={ 'center_x': .5, 'center_y': .5 })) root.add_widget( AsyncImage( source= 'F:/Photos/Favourite personalities/FB_IMG_1570087505868.jpg')) c = CustomLayout() c.add_widget( AsyncImage( source= "F:/Photos/Favourite personalities/FB_IMG_1571324704011.jpg", size_hint=(1, .5), pos_hint={ 'center_x': .5, 'center_y': .5 })) root.add_widget(c) return root
def generate_image(image_url, part_uid, connected, lock=None): if lock is not None: lock.acquire() if image_url == "locallystored": if os.path.isfile( str(Path.home()) + "/Barnyard-2/" + part_uid + ".jpg"): path = str(Path.home()) + "/Barnyard-2/" + part_uid + ".jpg" return_value = AsyncImage(source=path) else: path = str(Path.home()) + "/Barnyard-2/" + part_uid + ".png" return_value = AsyncImage(source=path) elif connected: return_value = AsyncImage(source=image_url) else: # Offline mode: get downloaded image on hdd path = str(Path.home() ) + "/Barnyard-2/" + "downloaded_" + part_uid + ".png" print(path) return_value = AsyncImage(source=path) if lock is not None: lock.release() return return_value
def build(self): root = RootWidget() c = CustomLayout() root.add_widget(c) c.add_widget( AsyncImage(source="./Q版野餐.jpg", size_hint=(1, .5), pos_hint={ 'center_x': .5, 'center_y': .5 })) root.add_widget( AsyncImage(source='./P_主頁示意圖.jpg') ) #http://www.stuffistumbledupon.com/wp-content/uploads/2012/05/Have-you-seen-this-dog-because-its-awesome-meme-puppy-doggy.jpg')) c = CustomLayout() c.add_widget( AsyncImage( source= "http://www.stuffistumbledupon.com/wp-content/uploads/2012/04/Get-a-Girlfriend-Meme-empty-wallet.jpg", size_hint=(1, .5), pos_hint={ 'center_x': .5, 'center_y': .5 })) root.add_widget(c) return root
def build(self): root = RootWidget() c = CustomLayout() root.add_widget(c) c.add_widget( AsyncImage( source= "http://www.znh.tw/rapa/wp-content/uploads/2016/02/11080927_1604252076479061_6424375858444252074_n-540x600.jpg", size_hint=(1, .5), pos_hint={ 'center_x': .5, 'center_y': .5 })) root.add_widget( AsyncImage( source= 'http://www.znh.tw/rapa/wp-content/uploads/2016/02/11080927_1604252076479061_6424375858444252074_n-540x600.jpg' )) c = CustomLayout() c.add_widget( AsyncImage( source= "http://www.znh.tw/rapa/wp-content/uploads/2016/02/11080927_1604252076479061_6424375858444252074_n-540x600.jpg", size_hint=(1, .5), pos_hint={ 'center_x': .5, 'center_y': .5 })) root.add_widget(c) return root
def __init__(self): super(Condiciones, self).__init__() self.flag = 1 self.DI = AsyncImage(size_hint=(1, 10), source=resource_path('img/Dirichlet.png')) self.NE = AsyncImage(size_hint=(1, 10), source=resource_path('img/Neumann.png')) self.add_widget(self.DI)
def create_recipe(self): content = self.manager.children[0].children[-1].children[0].children[0] if self.recipe_info['name'] in PreviewScreenBoxLayout.favorites: FavoriteButton.status = FavoriteButton.fav else: FavoriteButton.status = FavoriteButton.not_fav self.manager.children[0].children[-1].children[-1].children[ -2].children[0].source = FavoriteButton.status content.children[-1].height = 300 content.children[-1].children[0].clear_widgets() content.children[-1].children[0].add_widget( AsyncImage( source= f'img/img_for_recipes/{self.recipe_info["img_folder_name"]}')) content.children[-1].children[0].add_widget( AsyncImage( source= f'img/img_for_recipes/1_{self.recipe_info["img_folder_name"]}') ) content.children[-1].children[0].add_widget( AsyncImage( source= f'img/img_for_recipes/2_{self.recipe_info["img_folder_name"]}') ) content.children[-2].text = self.recipe_info['name'] content.children[-4].text = self.recipe_info['history'] content.children[-4].text_size = [Window.width, None] content.children[-4].texture_update() content.children[-4].size = content.children[-4].texture_size content.children[-4].texture_update() text_instr = 'Инструкция к приготовлению:\n\n' + self.recipe_info[ 'instruction'] text_instr = text_instr.replace(r'<\n>', '\n') content.children[-6].text = text_instr content.children[-6].text_size = [Window.width, None] content.children[-6].texture_update() content.children[-6].size = content.children[-6].texture_size content.children[-6].texture_update() content.children[-8].text = self.recipe_info['advice'] content.children[-8].text_size = [Window.width, None] content.children[-8].texture_update() content.children[-8].size = content.children[-8].texture_size content.children[-8].texture_update() content.height = sum(x.height for x in content.children)
def build(self): #img = Image(source='boo.jpg') img = AsyncImage( source= 'https://inteng-storage.s3.amazonaws.com/img/iea/y5wWnBlP6X/sizes/ai-main_resize_md.jpg' ) return img
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
def build(self): layout = GridLayout(cols=2, row_force_default=True, row_default_height=40) #layout = BoxLayout(orientation="vertical", spacing=10, padding=40) label = Label(text=" This is a Universal App", font_size="28sp", bold=True, color=(0, 0, 0, 1), italic=True) button = Button( text="Print this", font_size="20sp", size_hint=(0.2, 0.2), pos_hint={ 'center_x': 0.8, "center_y": 0.8 }, on_press=self.printpress, on_release=self.printrelease, ) img = AsyncImage( source="http://cdn3.sbnation.com/assets/3786371/DOGE-12.jpg") message = TextInput(text="Enter you message here") layout.add_widget(label) layout.add_widget(button) layout.add_widget(img) layout.add_widget(message) return layout
def list_files(self, name): print('display thread') self.ids.grid.clear_widgets() self.ids.spinner.active = True url = 'http://point3hub.com/mcroni/albums/' try: r = requests.get(url) except requests.packages.urllib3.exceptions.ProtocolError: print('cant connect') self.ids.spinner.active = False img = AsyncImage(source='network.png', keep_ratio=False, allow_stretch=True) self.ids.grid.add_widget(img) else: r = requests.get(url) data = r.text soup = BeautifulSoup(data, 'html.parser') for link in soup.find_all('a'): if link.get('href').endswith('.jpg'): self.passed.append(link.get('href')) self.ids.spinner.active = False # print(self.passed) for pic in self.passed: src = 'http://point3hub.com/mcroni/albums/{}'.format(pic) print(src) # self.p.append(src) self.album = SM(source=str(src)) self.ids.grid.clear_widgets() self.ids.grid.add_widget(self.album) self.ids.spinner.active = False
def get_weather(self, _, current=True): if current: w = YahooWeater("torun") current_weather = w.get_current_weather() print current_weather data_box = BoxLayout(orientation='vertical', size_hint=(None, None)) self.date_lbl = Label(text="Data pomiaru: " + current_weather['date']) data_box.add_widget(self.date_lbl) weather_box = BoxLayout(orientation='horizontal', size_hint=(None, 1)) self.weather_img = AsyncImage(source=current_weather['img']) weather_box.add_widget(self.weather_img) self.weather_text = Label(text=current_weather['text']) weather_box.add_widget(self.weather_text) data_box.add_widget(weather_box) self.current_temp = Label(text="Aktualna temperatura: {}°C".format(current_weather['temp'])) data_box.add_widget(self.current_temp) self.max_temp = Label(text="Maksymalna temperatura: {}°C".format(current_weather['high'])) data_box.add_widget(self.max_temp) self.min_temp = Label(text="Minimalna temperatura: {}°C".format(current_weather['low'])) data_box.add_widget(self.min_temp) self.data_anchor.add_widget(data_box) else: pass
def load_zipimage(self, source, frames): # keep running the test until loaded (or timeout) maxfps = self.maxfps timeout = 30 * maxfps # load ZIP with images named: 000.png, 001.png, ... image = AsyncImage( source=source, anim_delay=0.0333333333333333 ) image.test_loaded = False self.render(image) # bind to 'on_load' because there are various # steps where the image is (re)loaded, but # the event is triggered only at the end image.bind(on_load=lambda *_, **__: setattr( image, 'test_loaded', True )) while timeout and not image.test_loaded: self.advance_frames(1) timeout -= 1 proxyimg = image._coreimage self.assertTrue(proxyimg.anim_available) self.assertEqual(len(proxyimg.image.textures), frames) return image
def select_all_tasks(self, conn): """This method performs a select all SQL statment and populates the BoxLayout With the Button, Label and AsyncPicture widgets.""" cur = conn.cursor( ) #create sqlite cursor object allowing sql statements to be executed cur.execute("SELECT * FROM manga_list") db_list = cur.fetchall( ) #creates list of manga_list table allowing for loop to run and populate the BoxLayout for row in db_list: """Label widget generated with font 30px and markup property. The markup allows the func. populate_delete_row to run when label is pressed""" lbl = Label(text='[ref=' ']' + row[1] + '[/ref]', id=row[1], font_size=30, markup=True, on_ref_press=self.populate_delete_row) pic = AsyncImage( source='images/' + row[3] ) #picture widgetmade with image address given by user located in col 3 btn = Button(text='OPEN WEBPAGE', size_hint_y=None, id=row[2]) #button widget btn.bind( on_release=self.open_url ) #gives btn widget action to run open_url method when pressed #The below is used to place the newly declared widgets onto the BoxLayout self.ids.grid.add_widget(lbl) self.ids.grid.add_widget(pic) self.ids.grid.add_widget(btn)
def setUID(self, UID): data = pd.read_csv('res/Multidata User Info1.csv') heartRate_data = data[data.UID == int(UID)] x_axis = heartRate_data.TimeStamp y_axis = heartRate_data.HR ax = sns.lineplot(x_axis, y_axis) plt.xticks(rotation=90) plt.show() ax.get_figure().savefig("res/heartRate_data.png") self.image = AsyncImage(source="res/heartRate_data.png", allow_stretch=True) self.add_widget(self.image) self.back_button = Button(text="Back", on_press=self.Back_callBack, size_hint=(0.25, 0.25), pos_hint={ 'top ': 1, 'center_x': 0.5 }) self.add_widget(self.back_button)
def nextPhoto(self): global currentAlbum #first set the new photo pm.current = pm.next() currentPhoto = int(pm.current[6:]) #then remove the old one the if statement for when this function is accidentally called to early #if currentPhoto != 1: pm.remove_widget(pm.get_screen('photo_' + str(currentPhoto - 1))) #then if the whole album isn't loaded: if currentPhoto + int(config['photo_screen'] ['buffer']) - 2 < getPhotoCount(currentAlbum): photoScreen = Screen( name='photo_' + str(currentPhoto + int(config['photo_screen']['buffer']) - 1)) #add the photo to the screen photoScreen.add_widget( AsyncImage(source=urlList['photo_url'][ str(currentAlbum) + '-' + str(currentPhoto + int(config['photo_screen']['buffer']) - 1)][1:-1].replace(' ', '%20'), allow_stretch=True)) #add the screen to the screenmanager pm.add_widget(photoScreen)
def setUID(self, UID): data = pd.read_csv('res/Multidata User Info1.csv') step_data = data[data.UID == int(UID)] #print(sleep_data) x_axis = step_data.TimeStamp y_axis = step_data.Steps #print(x_axis) #print(y_axis) #plt.figure(sigsize=(10,10)) ax = sns.lineplot(x_axis, y_axis) #ax.set_xticklables(rotation=90) plt.xticks(rotation=90) plt.show() ax.get_figure().savefig("res/step_data.png") self.image = AsyncImage(source="res/step_data.png", allow_stretch=True) self.add_widget(self.image) self.back_button = Button(text="Back", on_press=self.Back_callBack, size_hint=(0.25, 0.25), pos_hint={ 'top ': 1, 'center_x': 0.5 }) self.add_widget(self.back_button)
def __init__(self, **kwargs): super().__init__(**kwargs) self.orientation = 'vertical' self.add_widget(nav()) Box1 = BoxLayout(orientation='vertical', padding=[10, -125, 10, 35]) Box1.add_widget( Label(text="HealthCare (For Doctors)", font_size='30sp')) Box2 = BoxLayout(padding=[50, -175, 50, 35]) carousel = Carousel(direction='right') for i in range(1, 5): src = "res/%s.jpg" % str(i) image = AsyncImage(source=src, allow_stretch=False) carousel.add_widget(image) carousel.loop = True Clock.schedule_interval(carousel.load_next, 2) Box2.add_widget(carousel) Grid2 = GridLayout(cols=2, size_hint=(1.0, 0.1), padding=[50, -20, 50, 20], spacing=20, row_default_height=30, row_force_default=True) Login = Button(text='Login', on_press=self.Login_Callback) Signup = Button(text='SignUp', on_press=self.Signup_Callback) Grid2.add_widget(Login) Grid2.add_widget(Signup) self.add_widget(Box1) self.add_widget(Box2) self.add_widget(Grid2)
def load_new_image(self, url): self.ans_button = self.url_ans_dict.get(url) self.add_widget(AsyncImage(source=url)) self.bottom_layout = FloatLayout(size=(600, 600)) self.ans_1 = Button(text=self.ans_button[0], background_color=(0.1, 0.5, 0.3, 1), size_hint=(0.2, 0.2), pos_hint={ 'x': 0.3, 'y': 0.5 }) buttoncallback = lambda *args: self.ans_correct_callback(url, *args) self.ans_1.bind(on_press=buttoncallback) self.bottom_layout.add_widget(self.ans_1) self.ans_2 = Button(text=self.ans_button[1], background_color=(0.1, 0.5, 0.3, 1), size_hint=(0.2, 0.2), pos_hint={ 'x': 0.5, 'y': 0.5 }) self.ans_2.bind(on_press=buttoncallback) self.bottom_layout.add_widget(self.ans_2) self.add_widget(self.bottom_layout)
def __init__(self,getData,**kwargs): super(ProfileActivity,self).__init__(**kwargs) infoBlock = GridLayout(cols = 1,spacing = 10) imagePlace = FloatLayout(size_hint = [1,None], height = 150) imagePlace.add_widget(AsyncImage(pos_hint = {"center_x":.5,"center_y":.5}, source = getData["avatar"])) infoBlock.add_widget(imagePlace) infoBlock.add_widget(Label(text = getData["login"], color = COLOR["LIGHT"]["MAIN_COLOR"],size_hint_y = None, height = 10)) infoBlock.add_widget(InfoPlate(str(getData["reputation"]))) infoBlock.add_widget(InfoPlate(str(getData["helpNum"]))) list = ScrollView() layoutList = GridLayout(cols = 1, size_hint_y = None) layoutList.bind(minimum_height = layoutList.setter('height')) layoutList.add_widget(infoBlock) list.add_widget(layoutList) self.add_widget(list)
def on_pre_enter(self, *args): Manager.list_from_database.clear() try: for self.row in database.view(): Manager.list_from_database.append(self.row) except: print('Database is empty!') print(Manager.list_from_database) self.Scroll_content = self.ids.scroll_view self.layout = GridLayout(cols=1, spacing=5, size_hint_y=2) self.layout.bind(minimum_height=self.layout.setter('height')) for self.item in Manager.list_from_database: self.current_file_path = self.item[2] self.title = self.item[1] self.btn = Button(text=self.title, font_size=8, size_hint=(.2, .05), background_color=(1.0, 0.0, 0.0, 1.0)) self.image = AsyncImage( source=self.item[3], size_hint=(.4, .2), ) self.btn.bind(on_press=(self.call_back)) # print(self.item[2]) self.layout.add_widget(self.image) self.layout.add_widget(self.btn) self.Scroll_content.clear_widgets() self.Scroll_content.add_widget(self.layout)
def on_index(self, instance, value): if self.media: if isinstance(self.media, Video): self.media.play = False self.media = None value = value % len(self.item.medias) media = self.item.medias[value] name, ext = splitext(media) ext = ext[1:].lower() # convert media url to local media path (all medias are already downloaded) from museolib.utils import no_url media = join(self.parent.parent.parent.parent.app.expo_dir, 'otherfiles', no_url(media)) if not isfile(media): print " ### Oops, this media is not downloaded !" try: if ext in ('mp3', 'ogg', 'flac', 'wav'): w = Label(text="It's a song : " + media) if not isfile(media): w = Label(text="Song not downloaded.") elif ext in ('avi', 'mkv', 'mp4', 'ogv', 'mpg', 'mpeg', 'dv'): w = Video(source=media, play=True) else: w = AsyncImage(source=media) except: w = Label(text='Unable to read that media') self.content.clear_widgets() self.content.add_widget(w) self.media = w
def nextAlbum(self): global currentAlbum currentAlbum += 1 if currentAlbum > 2: #maak een albumcount functie currentAlbum = 1 logging.info("Loading photo album " + str(currentAlbum)) #remove all screens/ photos from the manager, ugly but works for removedScreen in pm.screen_names: pm.remove_widget(pm.get_screen(removedScreen)) #Initialise the first 3 photos for i in range(int(config['photo_screen']['buffer'])): photoScreen = Screen(name='photo_' + str(i + 1)) #add the photo to the screen photoScreen.add_widget( AsyncImage( source=urlList['photo_url'][str(currentAlbum) + '-' + str(i + 1)][1:-1].replace( ' ', '%20'), allow_stretch=True)) #add the screen to the screenmanager pm.add_widget(photoScreen) timeLog('load photo', "Photo album loaded", "stop")
def load_images(self, *args): with self.canvas: for x in range(0, 2): for y in range(0, 2): source="http://b.tile.openstreetmap.org/1/%s/%s.png" % (x, y) r = 256 / self.scale AsyncImage(source=source, mipmap=False, allow_stretch=True, pos=(x*256 , (1-y)*256), size=(r, r))
def __init__(self): super(Ensamblaje, self).__init__() self.i = 1 self.MG = AsyncImage(size_hint=(1, 10), source=resource_path('img/Ensamblaje' + str(self.i) + '.png')) self.add_widget(self.MG)
def test_reload_asyncimage(self): from kivy.resources import resource_find from kivy.uix.image import AsyncImage temp_dir = mkdtemp() event = Event() image = AsyncImage() image.bind(on_load=lambda *args, **kwargs: event.set()) fn = resource_find('data/logo/kivy-icon-16.png') source = join(temp_dir, 'source.png') copyfile(fn, source) event.clear() image.source = source self.wait_for_event_or_timeout(event) self.render(image, framecount=2) self.assertEqual(image.texture_size, [16, 16]) remove(source) fn = resource_find('data/logo/kivy-icon-32.png') copyfile(fn, source) event.clear() image.reload() self.wait_for_event_or_timeout(event) self.render(image, framecount=2) self.assertEqual(image.texture_size, [32, 32]) remove(source) rmtree(temp_dir)
def __init__(self, title='', duration='', thumbnail='', source_videos=None, source_audios=None, **kwargs): super(YoutubeDisplayLayout, self).__init__(**kwargs) info_box = BoxLayout(orientation='vertical') self.source_videos = source_videos self.source_audios = source_audios self.title = TextInput( text=title ) # text input canvas clear when its removed, make an error self.duration = Label(text=str(duration)) info_box.add_widget(self.title) info_box.add_widget(self.duration) self.thumbnail = AsyncImage(source=thumbnail, size_hint=(.2, 1)) self.add_widget(self.thumbnail) self.add_widget(info_box) self.register_event_type('on_click') with self.canvas.before: self.color = Color(rgba=(0, 0, 0, 0)) self.rect = Rectangle(size=self.size, pos=self.pos) self.bind(pos=self.updateRect, size=self.updateRect)
def processions(self, string): ### in or out of your backpack if(self.busy): return if(string == 'in'): self.sm.current = 'Your_Processions' self.processionsbox = [] for i in range(len(self.processions_list)): ### item_name(pk) -> idx(index) if(self.processions_list[i]['item_name'] <= 11): idx = self.processions_list[i]['item_name'] - 1 else: idx = self.processions_list[i]['item_name'] - 2 self.processionsbox.append(BoxLayout(orientation = 'vertical')) self.processionsbox[i].add_widget(AsyncImage(source = self.url_image[idx])) #self.processionsbox[i].add_widget(btn[i]) self.processionsbox[i].add_widget(Label(text_size = (.4 * self.root.width, None), font_name = chinese_ch, font_size = 30, text = self.product_list[idx]['name'] + ' $' + str(self.product_list[idx]['price']) + '\nI have : ' + str(self.processions_list[i]['item_quantity']))) self.root.ids.id_processionsgrid.add_widget(self.processionsbox[i]) return if(string == 'out'): self.sm.current = 'P_coin_exchange' for i in range(len(self.processions_list)): self.root.ids.id_processionsgrid.remove_widget(self.processionsbox[i]) return
class TestApp(App): i = 0 img = AsyncImage(size_hint=(1, 0.9), source=src[i], keep_ratio=False) img.source = src[2] def alert(self, msg): popup = Popup(title='Hi', content=Label(text=msg), size_hint=(0.5, .2)) popup.open() def press(self, btn): if btn.id == '1' and self.i < (len(src) - 1): self.i += 1 self.img.source = src[self.i] elif btn.id == '2' and self.i > 0: self.i -= 1 self.img.source = src[self.i] elif btn.id == '3': self.img.allow_stretch = btn.state == 'down' elif btn.id == '4': self.img.keep_ratio = btn.state == 'down' def build(self): layout = BoxLayout(orientation='vertical') btns = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) btns.add_widget(Button(text='>>>', id='1', on_press=self.press)) btns.add_widget(Button(text='<<<', id='2', on_press=self.press)) btns.add_widget( ToggleButton(text='Stretch', id='3', on_press=self.press)) btns.add_widget(ToggleButton(text='Ratio', id='4', on_press=self.press)) layout.add_widget(self.img) layout.add_widget(btns) return layout
def associate_tag(self, instance): for entry in self._entry_list: self._box_layout.remove_widget(entry) self._box_layout.remove_widget(self._tag_association_button) for text_box_label in self._text_box_labels: self._box_layout.remove_widget(text_box_label) if self._part_info.uid is None: self._association_label_image = AsyncImage(source=os.getcwd() + "/tap.png") self._association_label = Label( text="Tap an NFC tag now to associate") self._box_layout.add_widget(self._association_label_image) self._box_layout.add_widget(self._association_label) _thread.start_new_thread(self._get_next_nfc_tag_uid, ()) else: try: uid_sheet_info_modifier = UidSheetInfoModifier() except: # No connection... Use CSV Backup uid_sheet_info_modifier = UidCsvInfoModifier() self._update_part_info() uid_sheet_info_modifier.add_part(self._part_info) self.go_back()
def __init__(self, imageSource, title, videoID): super(VideoItem, self).__init__() #store video data self.id = videoID self.title = title self.actualSongImage = imageSource self.orientation = 'horizontal' #place image and title on screen imag = AnchorLayout(anchor_x='center') ttl = AnchorLayout(anchor_x='right', anchor_y='bottom') toPlaylist = AnchorLayout(anchor_x='right', anchor_y='top', size_hint=(.1, .1)) #add button to add song to playlist toPlaylist.add_widget(Button(text='+', on_press=self.showBuuble)) img = AsyncImage(source=imageSource) btn = Button(background_color=(0, 0, 0, 0)) btn.bind(on_press=self.playSong) imag.add_widget(btn) imag.add_widget(img) ttl.add_widget( Label(bold=True, font_size='22sp', text=title, text_size=(200, None))) #add all widgets self.add_widget(imag) self.add_widget(ttl) self.add_widget(toPlaylist) self.bubbleClicked = False