class Columns(GridLayout): def __init__(self, text, **kwargs): super(Columns, self).__init__(size_hint_x=1, rows=2) self.current_block = 0 self.carousel = Carousel(direction='right', size_hint_x=1, size_hint_y=1) self.carousel.bind(index=self.update_title) self.title_label = Label(font_name=FONT, markup=True, font_size=30, size_hint_y=0.1) self.update_content(text) def update_title(self, *kwargs): if len(kwargs) > 0: self.current_block = kwargs[1] or 0 title = emphasize_part(self.word.string, idx=self.current_block) etymology_str = (' ({})'.format( emphasize_part(self.word.etymology, idx=self.current_block)) if self.word.etymology else '') title += etymology_str self.title_label.text = title def analyze(self, text): self.word = Word(text, compute_etymology=True) self.blocks = self.word.get_blocks_for_selected_meaning() def update_content(self, text): self.clear_widgets() self.carousel.clear_widgets() self.analyze(text) self.update_title() for block in self.blocks: words = DbUtil().get_words_with_block(block, exclude=self.word) self.carousel.add_widget(BlockColumn(block, words)) self.add_widget(self.title_label) self.add_widget(self.carousel)
class ViewSpellScreen(MyScreen): def __init__(self, **kwargs): super(ViewSpellScreen, self).__init__(**kwargs) self.carousel = Carousel() self.content_box.add_widget(self.carousel) self.bind(on_pre_enter= self.prepare_yourself) def prepare_yourself(self,i=0): self.carousel.clear_widgets() for spell in App.get_running_app().root.current_list: self.carousel.add_widget(spell['view_spell_card']) position = App.get_running_app().root.current_position self.carousel.index = position
class KivyAllComicsGui(Screen): def __init__(self, comicBooks, **kwargs): # make sure we aren't overriding any important functionality super(KivyAllComicsGui, self).__init__(**kwargs) self.carrusel = Carousel(direction='right') self.carrusel.orientation = 'vertical' self.carrusel.size_hint = (1, 1) self.listaComicBooks = comicBooks self.panel = GridLayout(cols=1) self.thumbnailWidth=160 self.thumbnailHeight = 280 print(Window.size) self.cantidadColumnas = int(Window.width/self.thumbnailWidth) self.cantidadFilas = int(Window.height/self.thumbnailHeight) print(self.cantidadColumnas) print(self.cantidadFilas) self.searchText = TextInput(text='Buscar comic', multiline=False) self.searchText.size_hint_y = None self.searchText.size[1] = 30 panelBusqueda = GridLayout(cols=self.cantidadColumnas) panelBusqueda.add_widget(self.searchText) self.btn = Button(text = "buscar") self.btn.size_hint = (0.1, None) self.btn.size = (32, 32) # self.btn.background_normal = "Better Search.png" panelBusqueda.add_widget(self.btn) self.btn.bind(on_press=self.evntBtnBuscar) panelBusqueda.size_hint_y = None self.panel.add_widget(panelBusqueda) self.panel.add_widget(self.carrusel) self.add_widget(self.panel) self.__loadComicBooks__() self.indice = 0 def __tbuscar__(self): t = Thread(self.buscar()) t.start() def evntBtnBuscar(self,evnt): self.__tbuscar__() def buscar(self): comicBooks = KivyComicBooks() comicBooks.list(('%'+self.searchText.text+'%',), 'path like ?') self.listaComicBooks = comicBooks.listaConsulta self.indice=0 self.__loadComicBooks__() def __updateCarrusell__(self,args): ##for comicBook in self.listaComicBooks: if (self.indice>=len(self.listaComicBooks)): Clock.unschedule(self.hiloCargaThumnails) return False comicBook = self.listaComicBooks[self.indice] if not (self.indice % (self.cantidadColumnas * self.cantidadFilas) == 0): # print("agregando a panel") # print(comicBook.path) self.panelx4.add_widget(KivySmallComicGui(comicBook)) else: # print("creando panel y agregando a carusel") self.panelx4 = GridLayout(cols=self.cantidadColumnas) self.panelx4.add_widget(KivySmallComicGui(comicBook)) self.carrusel.add_widget(self.panelx4) self.indice += 1 def __loadComicBooks__(self): self.indice = 0 self.carrusel.clear_widgets() self.panelx4 = GridLayout(cols=self.cantidadColumnas) self.hiloCargaThumnails = Clock.schedule_interval(self.__updateCarrusell__, 0.1)
class Build_CloudWatch_Remote ( App ): Period_Buttons = [] Period_End_Buttons = [] Period_Value = 24 Period_End_Value = 0 def __init__(self, **kwargs): super(Build_CloudWatch_Remote, self).__init__(**kwargs) Window.bind(on_key_down=self.on_keyboard_down) # Window.size = (1280, 800) # Automatically size widget images to fit screen real estate horizontal_size, vertical_size = Window.size # print ("h:", horizontal_size, "v:", vertical_size) for widget_descriptor in widget_descriptor_list: widget_descriptor["width"] = horizontal_size if (cw_remote_duplex_layout): widget_descriptor["height"] = int(round(vertical_size * 0.475)) else: widget_descriptor["height"] = int(round(vertical_size * 2 * 0.475)) def build(self): Get_CloudWatch_Graphs() self.CloudWatch_Remote = BoxLayout(orientation='vertical') self.Control_Bar = BoxLayout(orientation='horizontal', size_hint=(1, 0.05)) # self.Begin_Time_Slider = \ # Slider_Extended(min=-24, max=-1, value=-24, step=1, size_hint=(0.40, 1)) # self.Begin_Time_Slider.bind(value=self.on_begin_time_value_change) # self.Begin_Time_Slider.bind(on_release=self.update) # self.Begin_Time_Label = \ # Label(text=(str(int(round(self.Begin_Time_Slider.value))) + "H"), # size_hint=(0.05, 1)) self.Period_Label = Label(text=(str(self.Period_Value) + "H"), size_hint=(0.05, 1)) # self.Control_Bar.add_widget(self.Begin_Time_Label) self.Control_Bar.add_widget(self.Period_Label) # self.Control_Bar.add_widget(self.Begin_Time_Slider) for button_idx, button_value in enumerate([120, 96, 72, 48, 24, 20, 16, 12, 8, 6, 5, 4, 3, 2, 1]): period_button = Button(text=str(button_value)) period_button.font_size = 14 period_button.size_hint = (0.0375, 1) period_button.bind(on_press=partial(self.on_set_period, button_idx, button_value)) self.Period_Buttons.append(period_button) self.Control_Bar.add_widget(period_button) button_refresh = Button(text="Refresh", size_hint=(0.075, 1)) button_refresh.font_size = 14 button_refresh.bind(on_press=self.update) self.Control_Bar.add_widget(button_refresh) for button_idx, button_value in enumerate([-72, -48, -36, -24, -12, -10, -8, -6, -5, -4, -3, -2, -1, 0]): # -96, end_button = Button(text=str(button_value)) end_button.font_size = 14 end_button.size_hint = (0.0375, 1) end_button.bind(on_press=partial(self.on_set_period_end, button_idx, button_value)) self.Period_End_Buttons.append(end_button) self.Control_Bar.add_widget(end_button) # self.End_Time_Slider = \ # Slider_Extended(min=-23, max=0, value=0, step=1, size_hint=(0.40, 1)) # self.End_Time_Slider.bind(value=self.on_end_time_value_change) # self.End_Time_Slider.bind(on_release=self.update) # self.End_Time_Label = \ # Label(text=(str(int(round(self.End_Time_Slider.value))) + "H"), # size_hint=(0.05, 1)) self.Period_End_Label = Label(text=(str(self.Period_End_Value) + "H"), size_hint=(0.05, 1)) # self.Control_Bar.add_widget(self.End_Time_Slider) # self.Control_Bar.add_widget(self.End_Time_Label) self.Control_Bar.add_widget(self.Period_End_Label) if (cw_remote_duplex_layout): self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Lower_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Upper_Widget_Box.add_widget(Image(texture=ci_widget_image_list[0].texture)) self.Lower_Widget_Box.add_widget(Image(texture=ci_widget_image_list[1].texture)) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Lower_Widget_Box) elif (len(widget_descriptor_list) > 1): self.Carousel_Widget = Carousel(direction='bottom') for ci_widget_image in ci_widget_image_list: self.Carousel_Widget.add_widget(Image(texture=ci_widget_image.texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Carousel_Widget) else: self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, (2 * 0.475))) self.Upper_Widget_Box.add_widget(Image(texture=ci_widget_image_list[0].texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) if (cw_remote_refresh_interval_seconds >= 1): Clock.schedule_interval(self.update, cw_remote_refresh_interval_seconds) return self.CloudWatch_Remote def on_set_period(self, button_index, button_value, *args): self.Period_Value = button_value self.Period_Label.text = str(self.Period_Value) + "H" self.update_period_start_end() def on_set_period_end(self, button_index, button_value, *args): self.Period_End_Value = button_value self.Period_End_Label.text = str(self.Period_End_Value) + "H" self.update_period_start_end() def update_period_start_end(self): for widget_descriptor in widget_descriptor_list: widget_descriptor["start"] = "-PT" + str(abs(self.Period_Value) + abs(self.Period_End_Value)) + "H" widget_descriptor["end"] = "-PT" + str(abs(self.Period_End_Value)) + "H" self.update() # def on_begin_time_value_change(self, instance, begin_value, *args): # relative_start_time_value = int(round(begin_value)) # if (relative_start_time_value >= int(round(self.End_Time_Slider.value))): # relative_start_time_value = int(round(self.End_Time_Slider.value)) - 1 # self.Begin_Time_Slider.value = relative_start_time_value # for widget_descriptor in widget_descriptor_list: # widget_descriptor["start"] = "-PT" + str(abs(relative_start_time_value)) + "H" # self.Begin_Time_Label.text = str(relative_start_time_value) + "H" # # def on_end_time_value_change(self, instance, end_value, *args): # relative_end_time_value = int(round(end_value)) # if (relative_end_time_value <= int(round(self.Begin_Time_Slider.value))): # relative_end_time_value = int(round(self.Begin_Time_Slider.value)) + 1 # self.End_Time_Slider.value = relative_end_time_value # for widget_descriptor in widget_descriptor_list: # widget_descriptor["end"] = "-PT" + str(abs(relative_end_time_value)) + "H" # self.End_Time_Label.text = str(relative_end_time_value) + "H" def update(self, *args): Get_CloudWatch_Graphs() if (cw_remote_duplex_layout): self.Upper_Widget_Box.clear_widgets() self.Upper_Widget_Box.add_widget(Image(texture=ci_widget_image_list[0].texture)) self.Lower_Widget_Box.clear_widgets() self.Lower_Widget_Box.add_widget(Image(texture=ci_widget_image_list[1].texture)) elif (len(widget_descriptor_list) > 1): self.Carousel_Widget.clear_widgets() for ci_widget_image in ci_widget_image_list: self.Carousel_Widget.add_widget(Image(texture=ci_widget_image.texture)) else: self.Upper_Widget_Box.clear_widgets() self.Upper_Widget_Box.add_widget(Image(texture=ci_widget_image_list[0].texture)) self.CloudWatch_Remote.canvas.ask_update() def on_keyboard_down(self, instance, keyboard, keycode, text, modifiers): # print("\nThe key", keycode, "have been pressed") # print(" - text is %r" % text) # print(" - modifiers are %r" % modifiers) # Support keyboard control of carousel on OS-X if ((keycode == 81) or (keycode == 79)): self.Carousel_Widget.load_next() elif ((keycode == 82) or (keycode == 80)): self.Carousel_Widget.load_previous()
class Build_CloudWatch_Remote(App): def __init__(self, **kwargs): super(Build_CloudWatch_Remote, self).__init__(**kwargs) Window.bind(on_key_down=self.on_keyboard_down) # Window.size = (1280, 800) # Automatically size widget images to fit screen real estate horizontal_size, vertical_size = Window.size # print ("h:", horizontal_size, "v:", vertical_size) for widget_descriptor in widget_descriptor_list: widget_descriptor["width"] = horizontal_size if (cw_remote_duplex_layout): widget_descriptor["height"] = int(round(vertical_size * 0.475)) else: widget_descriptor["height"] = int( round(vertical_size * 2 * 0.475)) def build(self): Get_CloudWatch_Graphs() self.CloudWatch_Remote = BoxLayout(orientation='vertical') self.Control_Bar = BoxLayout(orientation='horizontal', size_hint=(1, 0.05)) self.Begin_Time_Slider = \ Slider_Extended(min=-24, max=-1, value=-24, step=1, size_hint=(0.40, 1)) self.Begin_Time_Slider.bind(value=self.on_begin_time_value_change) self.Begin_Time_Slider.bind(on_release=self.update) self.Begin_Time_Label = \ Label(text=(str(int(round(self.Begin_Time_Slider.value))) + "H"), size_hint=(0.05, 1)) self.Control_Bar.add_widget(self.Begin_Time_Label) self.Control_Bar.add_widget(self.Begin_Time_Slider) button_refresh = Button(text="Refresh", size_hint=(0.1, 1)) button_refresh.bind(on_press=self.update) self.Control_Bar.add_widget(button_refresh) self.End_Time_Slider = \ Slider_Extended(min=-23, max=0, value=0, step=1, size_hint=(0.40, 1)) self.End_Time_Slider.bind(value=self.on_end_time_value_change) self.End_Time_Slider.bind(on_release=self.update) self.End_Time_Label = \ Label(text=(str(int(round(self.End_Time_Slider.value))) + "H"), size_hint=(0.05, 1)) self.Control_Bar.add_widget(self.End_Time_Slider) self.Control_Bar.add_widget(self.End_Time_Label) if (cw_remote_duplex_layout): self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Lower_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Upper_Widget_Box.add_widget( Image(texture=ci_widget_image_list[0].texture)) self.Lower_Widget_Box.add_widget( Image(texture=ci_widget_image_list[1].texture)) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Lower_Widget_Box) elif (len(widget_descriptor_list) > 1): self.Carousel_Widget = Carousel(direction='bottom') for ci_widget_image in ci_widget_image_list: self.Carousel_Widget.add_widget( Image(texture=ci_widget_image.texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Carousel_Widget) else: self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, (2 * 0.475))) self.Upper_Widget_Box.add_widget( Image(texture=ci_widget_image_list[0].texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) if (cw_remote_refresh_interval_seconds >= 1): Clock.schedule_interval(self.update, cw_remote_refresh_interval_seconds) return self.CloudWatch_Remote def on_begin_time_value_change(self, instance, begin_value, *args): relative_start_time_value = int(round(begin_value)) if (relative_start_time_value >= int(round( self.End_Time_Slider.value))): relative_start_time_value = int(round( self.End_Time_Slider.value)) - 1 self.Begin_Time_Slider.value = relative_start_time_value for widget_descriptor in widget_descriptor_list: widget_descriptor["start"] = "-PT" + str( abs(relative_start_time_value)) + "H" self.Begin_Time_Label.text = str(relative_start_time_value) + "H" def on_end_time_value_change(self, instance, end_value, *args): relative_end_time_value = int(round(end_value)) if (relative_end_time_value <= int(round( self.Begin_Time_Slider.value))): relative_end_time_value = int(round( self.Begin_Time_Slider.value)) + 1 self.End_Time_Slider.value = relative_end_time_value for widget_descriptor in widget_descriptor_list: widget_descriptor["end"] = "-PT" + str( abs(relative_end_time_value)) + "H" self.End_Time_Label.text = str(relative_end_time_value) + "H" def update(self, *args): Get_CloudWatch_Graphs() if (cw_remote_duplex_layout): self.Upper_Widget_Box.clear_widgets() self.Upper_Widget_Box.add_widget( Image(texture=ci_widget_image_list[0].texture)) self.Lower_Widget_Box.clear_widgets() self.Lower_Widget_Box.add_widget( Image(texture=ci_widget_image_list[1].texture)) elif (len(widget_descriptor_list) > 1): self.Carousel_Widget.clear_widgets() for ci_widget_image in ci_widget_image_list: self.Carousel_Widget.add_widget( Image(texture=ci_widget_image.texture)) else: self.Upper_Widget_Box.clear_widgets() self.Upper_Widget_Box.add_widget( Image(texture=ci_widget_image_list[0].texture)) self.CloudWatch_Remote.canvas.ask_update() def on_keyboard_down(self, instance, keyboard, keycode, text, modifiers): # print("\nThe key", keycode, "have been pressed") # print(" - text is %r" % text) # print(" - modifiers are %r" % modifiers) # Support keyboard control of carousel on OS-X if ((keycode == 81) or (keycode == 79)): self.Carousel_Widget.load_next() elif ((keycode == 82) or (keycode == 80)): self.Carousel_Widget.load_previous()
class gfsViewerApp(App): global values global regions #init App class 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() # Loader-complete callback (for some reason AsyncImage got stuck # when fed with to many request at once, so images get loaded here # on after the other.. def _image_loaded(self, proxyImage): if proxyImage.image.texture: if len(self.image) > self.loadnum: self.image[self.loadnum].texture = proxyImage.image.texture if (self.loadnum < self.limit): self.loadnum = self.loadnum + 1 self._load_next() self.carousel.canvas.ask_update() # load next image 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) def _load_values(self,*largs): if (len(largs) > 0 and self.last_df != 0): if self.last_df == largs[0]: ignore = True else: ignore = False self.last_df = largs[0] else: ignore = False # for some reason to many events where fired, so ignore # calls that don't have a unique timestamp if not ignore: if self.active_region == "M-Europa": self.steps = 3 self.limit = 60 else: self.steps = 6 self.limit = 30 if self.active_region in ["M-Europa","Europa"]: self.src = "http://m.ash.to/gfsViewer/imgloader.php?file=R%s%02d%d.gif&type=.png" else: self.src = "http://www.wetterzentrale.de/pics/R%s%02d%d.png" self.loadnum = 0 self.image = [] self.last_df = 0 self._load_next(*largs) 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) # new value selected callback def _on_value_select(self,x): self.carousel.clear_widgets() Clock.schedule_once(self._clear_loader) setattr(self.value_button, 'text', x) self.active_value = x # region select callback def _on_region_select(self,x): setattr(self.region_button, 'text', x) self.active_region = x self._on_value_select(self.active_value) # build layout and app def build(self): self.icon = 'data/icon-s.png' self.layout = BoxLayout(orientation='vertical') ab = ActionBar(size_hint=(1,0.08), height="48dp") av = ActionView() av.add_widget(ActionPrevious(title=appTitle,with_previous=False, app_icon=self.icon)) ab.add_widget(av) self.layout.add_widget(ab) #region_dropdown = DropDown() # disable drop-down options for the moment. # needs more work (also different value selectors) #for i in regions: # btn = Button(text=i, size_hint_y=None, height="48dp") # btn.bind(on_release=lambda btn: region_dropdown.select(btn.text)) # region_dropdown.add_widget(btn) # region_dropdown.bind(on_select=lambda instance, x: self._on_region_select(x)) self.region_button = Button(text=self.active_region, size_hint_y=None, height="48dp") #self.region_button.bind(on_release=region_dropdown.open) self.layout.add_widget(self.region_button) value_dropdown = DropDown() for i in range(len(values)): btn = Button(text=values[i], size_hint_y=None, height="48dp") btn.bind(on_release=lambda btn: value_dropdown.select(btn.text)) value_dropdown.add_widget(btn) value_dropdown.bind(on_select=lambda instance, x: self._on_value_select(x)) self.value_button = Button(text=self.active_value, size_hint_y=None, height="48dp") self.value_button.bind(on_release=value_dropdown.open) self.layout.add_widget(self.value_button) self.layout.add_widget(self.carousel) self.pb = ProgressBar(max=100,value=50, size_hint=(1,0.08),height=48) self.layout.add_widget(self.pb) self.ltext = Label(text='', size_hint_y=None,height="12dp",font_size="10dp") self.layout.add_widget(self.ltext) self._on_value_select(self.active_value) return self.layout
class KivyVisor(ModalView): MODO_NORMAL = 1 MODO_AJUSTADO_ALTURA = 2 MODO_AJUSTADO_ANCHO = 3 def __init__(self, comicBook, **kwargs): super(KivyVisor, self).__init__(**kwargs) self.modoVisualizacion = KivyVisor.MODO_NORMAL self.carrusel = Carousel() self.bind(on_touch_down=self.on_touch) self.comic = comicBook self.comic.openCbFile() self.matrizTransfPagina = None self.listaPaginas = [] self.__loadComicBooks__() self.carrusel.bind(index=self.carruselSlide) self.add_widget(self.carrusel) def __updateCarrusell__(self, args): imagenPagina = self.comic.getImagePage() imagenPagina.size = imagenPagina.texture_size imagenPagina.size_hint = (None, None) imagenPagina.size_hint = (None, None) imagenPagina.keep_ratio = True scrollView = ScrollView() scrollView.add_widget(imagenPagina) self.carrusel.add_widget(scrollView) self.listaPaginas.append(imagenPagina) if not self.comic.gotoNextPage(): Clock.unschedule(self.hiloCargaThumnails) return False def __loadComicBooks__(self): self.carrusel.clear_widgets() self.hiloCargaThumnails = Clock.schedule_interval( self.__updateCarrusell__, 1) def carruselSlide(self, args, args2): self.carrusel.current_slide.scroll_y = 1 self.carrusel.next_slide.scroll_y = 1 # if scatter.transform!=self.matrizTransfPagina: # scatter.apply_transform(self.matrizTransfPagina) def on_transform_with_touch(self, touch, args): print(touch.scale) for slide in self.carrusel.slides: if slide != touch: slide.scale = touch.scale slide.pos = touch.pos # slide.apply_transform(touch.transform) # self.matrizTransfPagina = touch.transform def on_sizeWindow(self, arg1, arg2, arg3): self.__refreshPage__() def on_motion(self, etype, motionevent, other): if other.is_mouse_scrolling: if other.button == 'scrolldown': self.scatter.y -= 10 if other.button == 'scrollup': self.scatter.y += 10 else: # print(self.scatter.pos) print("pos imagen :{}".format(self.imagenPagina.pos)) print("tamaƱo scatter :{}".format(self.scatter.size)) # help(other) # print(motionevent) # print(other) # print("Capturan scroll") def on_touch(self, obj, event): ''' vamos a capturar eventos en estas zonas ************************* *1* *0* *2* *** *** *** * * * * * * * * *3* *4* * * * * * * * * * * *** *** *5* *6* ************************* :param widget: :param event: :return: ''' #zona1 = ((0, Window.width * 0.1), (Window.height, (Window.height - Window.height * 0.1))) #zona2 = ((Window.width - Window.width * 0.1, Window.width), (Window.height, (Window.height - Window.height * 0.1))) zona0 = ((Window.width * 0.5 - Window.width * 0.1, Window.width * 0.5 + Window.width * 0.1), (Window.height - Window.height * 0.1, Window.height)) zona3 = ((0, Window.width * 0.1), (Window.height * 0.1 + Window.height * 0.5, Window.height * -0.1 + Window.height * 0.5)) zona4 = ((Window.width - Window.width * 0.1, Window.width), (Window.height * 0.1 + Window.height * 0.5, Window.height * -0.1 + Window.height * 0.5)) if (zona0[0][0] < event.pos[0] and event.pos[0] < zona0[0][1]) and ( zona0[1][0] < event.pos[1] and event.pos[1] < zona0[1][1]): box = GridLayout(cols=5) botonAncho = Button(text="Ancho") botonAncho.bind(on_press=self.ancho) box.add_widget(botonAncho) botonAjustarAlto = Button(text="Alto") botonAjustarAlto.bind(on_press=self.ajustarAlto) box.add_widget(botonAjustarAlto) botonCentrado = Button(text="normal") botonCentrado.bind(on_press=self.sinAjuste) box.add_widget(botonCentrado) botonRotar = Button(text="Rotar") botonRotar.bind(on_press=self.rotar) box.add_widget(botonRotar) p = Popup(title='Comic View popup', size_hint=(None, None), size=(400, 150)) p.add_widget(box) p.open() def __refreshPage__(self): pass def ancho(self, event): self.modoVisualizacion = KivyVisor.MODO_AJUSTADO_ANCHO for imagen in self.listaPaginas: if imagen.image_ratio < 1: imagen.width = Window.width imagen.height = Window.width / (imagen.image_ratio) else: imagen.width = Window.width imagen.height = Window.width * (imagen.image_ratio) for scroll in self.carrusel.slides: self.carrusel.current_slide.scroll_y = 0.5 def ajustarAlto(self, event): self.modoVisualizacion = KivyVisor.MODO_AJUSTADO_ALTURA for imagen in self.listaPaginas: if imagen.image_ratio < 1: imagen.width = Window.height / (imagen.image_ratio) imagen.height = Window.height else: imagen.width = Window.height * (imagen.image_ratio) imagen.height = Window.height for scroll in self.carrusel.slides: self.carrusel.current_slide.scroll_x = 0 def rotar(self, event): print(self.carrusel.current_slide.size) print(self.listaPaginas[self.carrusel.index].pos) self.listaPaginas[self.carrusel.index].pos[0] += 1 def sinAjuste(self, event): self.listaPaginas[self.carrusel.index].height = self.listaPaginas[ self.carrusel.index].originalHeight self.listaPaginas[self.carrusel.index].width = self.listaPaginas[ self.carrusel.index].originalWidth
class KivyAllSeriesGui(Screen): BUSCAR_VINE = 1 BUSCAR_LOCAL = 2 def __init__(self, series, **kwargs): # make sure we aren't overriding any important functionality super(KivyAllSeriesGui, self).__init__(**kwargs) self.carrusel = Carousel(direction='right') self.carrusel.orientation = 'vertical' self.carrusel.size_hint = (1, 1) self.listaSeries = series self.panel = GridLayout(cols=1) self.thumbnailWidth = 160 self.thumbnailHeight = 280 print(Window.size) self.cantidadColumnas = int(Window.width / self.thumbnailWidth) self.cantidadFilas = int(Window.height / self.thumbnailHeight) print(self.cantidadColumnas) print(self.cantidadFilas) self.searchText = TextInput(text='', multiline=False) self.searchText.size_hint = (0.8, None) self.searchText.size = (0, 30) panelBusqueda = GridLayout(cols=4) panelBusqueda.add_widget(self.searchText) self.btnVine = Button(text="Vine", size_hint=(0.1, None), size=(0, 30)) self.btnLocal = Button(text="Local", size_hint=(0.1, None), size=(0, 30)) self.btnSalir = Button(text="Salir", size_hint=(0.1, None), size=(0, 30)) panelBusqueda.add_widget(self.btnVine) panelBusqueda.add_widget(self.btnLocal) panelBusqueda.add_widget(self.btnSalir) self.btnVine.bind(on_press=self.evntBtnBuscarVine) self.btnLocal.bind(on_press=self.evntBtnBuscarLocal) self.btnLocal.bind(on_press=self.evntBtnBuscarSalir) panelBusqueda.size_hint_y = None self.panel.add_widget(panelBusqueda) self.panel.add_widget(self.carrusel) self.add_widget(self.panel) self.__loadSeries__() self.indice = 0 def evntBtnBuscarSalir(self, evnt): pass def evntBtnBuscarVine(self, evnt): self.__tbuscar__(KivyAllSeriesGui.BUSCAR_VINE) def evntBtnBuscarLocal(self, evnt): self.__tbuscar__(KivyAllSeriesGui.BUSCAR_LOCAL) def __tbuscar__(self, dondeBuscar): t = Thread(self.buscar(dondeBuscar)) t.start() def buscar(self, dondeBuscar): series = Series.Series() if dondeBuscar == KivyAllSeriesGui.BUSCAR_VINE: series.searchInComicVine(self.searchText.text) self.listaSeries = series.listaComicVineSearch self.indice = 0 elif dondeBuscar == KivyAllSeriesGui.BUSCAR_LOCAL: self.listaSeries = series.getList( ("%" + self.searchText.text + "%", ), "name like ?") self.indice = 0 self.__loadSeries__() def __loadSeries__(self): self.carrusel.clear_widgets() panelx4 = GridLayout(cols=self.cantidadColumnas) indice = 0 for serie in self.listaSeries: if not (indice % (self.cantidadColumnas * self.cantidadFilas) == 0): print("agregando a panel") print(serie.nombre) self.panelx4.add_widget(KivySmallSerieGui(serie)) else: print("creando panel y agregando a carusel") self.panelx4 = GridLayout(cols=self.cantidadColumnas) self.panelx4.add_widget(KivySmallSerieGui(serie)) self.carrusel.add_widget(self.panelx4) indice += 1