def on_enter(self): carousel = Carousel(direction='right') # tłumaczenie słowa-połaczenie z layoutem for litera in self.lang["translate"]: litera_tlumaczenie = self.lang["translate"][litera]["translation"] layout = builder.Builder.load_file("learn_layout.kv") carousel.add_widget(layout) slowo = layout.ids.slowo slowo.text = self.lang["translate"][litera]["word"] duza_litera = layout.ids.duza_litera duza_litera.text = litera # Podpięte działania layout.ids.zamien_litere.bind( on_release=action(duza_litera, litera, litera_tlumaczenie) ) # utrzymanie przycisku polub = layout.ids.fav przycisk_ulubione(polub, litera, self.ulubione) # Dźwięk litera_sound = self.lang["translate"][litera]["sound"] layout.ids.play_sound.bind(on_release=play_sound(litera_sound)) self.add_widget(carousel)
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)
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
class CarouselApp(App): def myChange(self, instance, value): print(self.carousel.index) pass def build(self): global page self.count = 0 self.carousel = Carousel(direction='right') self.carousel.bind(on_touch_move=self.myChange) self.carousel.scroll_distance = 1 self.carousel.scroll_timeout = 999 #self.carousel. box = BoxLayout(orientation='vertical', padding=3) self.text = Label(text=page[self.count], pos=(10, 0), width=300, height=100) for i in range(10): source = f'{i}.jpg' self.image = Image(source=source) self.carousel.add_widget(self.image) self.slide = self.carousel.next_slide box.add_widget(self.carousel) box.add_widget(self.text) return box
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 CatreCarusel(self, Buton): # am curatat layoutul self.layout0.clear_widgets() # am adaptat programul din clasa folosind obiecte dar nu merge # setam directia in care vom misca cu mouse-ul imaginile self.carousel = Carousel(direction='right') # setam viteza de miscare self.carousel.anim_move_duration = 1 self.carousel.loop = True self.carousel.size_hint = (0.7, 0.7) self.carousel.pos = (200, 120) self.carousel.add_widget(self.layout0) self.image1 = Image(source="nature1.jpg") self.carousel.add_widget(self.image1) self.image2 = Image(source="nature2.jpg") self.carousel.add_widget(self.image2) self.image3 = Image(source="nature3.jpg") self.carousel.add_widget(self.image3) self.image1 = Image(source="nature4.jpg") self.carousel.add_widget(self.image4) self.eticheta_final = Label(text="Am ajuns la finalul listei!", font_size=30) self.carousel.add_widget(self.eticheta_final) # cream widgetul inapoiButon self.inapoiButon = Button(text="Inapoi", bold=True, background_color=(0, 0, 1, 1)) self.inapoiButon.pos = (200, 100) self.inapoiButon.size_hint = (0.7, 0.1) self.inapoiButon.opacity = 0.7 self.layout0.add_widget(self.inapoiButon) #legam apasarea butonului de intoarcerea la meniul principal self.inapoiButon.bind(on_press=self.Menu)
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
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 __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)
def build(self): carousel = Carousel(direction='right') src = "https://static2.abc.es/media/tecnologia/2019/08/01/[email protected]" image = AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) return carousel
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
def __init__(self, **kwargs): super(MyW, self).__init__(**kwargs) carousel = Carousel(direction='right') for i in range(3): src = "f%d.png" % i image = Factory.AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) self.add_widget(carousel)
def __init__(self): # Create carousel - doesn't work so well in .kv Carousel.__init__(self,direction='right',loop='true',scroll_distance=80,scroll_timeout=100) self.overview = Overview() self.add_widget(self.overview) self.add_widget(Label(text='Hello World2')) self.game = PongGame() self.game.serve_ball() self.add_widget(self.game)
def build(self): carousel = Carousel(direction='bottom') for dato in datos: # print(dato['miniaturas']) image = AsyncImage(source=dato['miniaturas'], allow_stretch=True) carousel.add_widget(image) return carousel
def on_index(self, *args): self.gcount += 1 self.cindex = args[1] if args[1] != 0: MDApp.get_running_app().view.load_to_carousel(args[1]) elif args[1] is None: pass Carousel.on_index(self, *args)
def build(self): carousel = Carousel(direction='right') for item in listOfModels: carousel.add_widget(item) return carousel
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
def test_previous_and_next(n_slides, index, loop, index_of_previous_slide, index_of_next_slide): from kivy.uix.carousel import Carousel from kivy.uix.widget import Widget c = Carousel(loop=loop) for i in range(n_slides): c.add_widget(Widget()) c.index = index p_slide = c.previous_slide assert (p_slide and c.slides.index(p_slide)) == index_of_previous_slide n_slide = c.next_slide assert (n_slide and c.slides.index(n_slide)) == index_of_next_slide
def build(self): global page self.window = FloatLayout() self.carousel = Carousel(direction='right') self.carousel.bind(on_touch_move=self.myChange) self.carousel.scroll_distance = 1 self.carousel.scroll_timeout = 999 self.layout = [] # carousel for i in range(10): self.layout.append( FloatLayout(size_hint=(1, .55), pos_hint={ 'x': 0, 'y': .4 })) source = f'{i}.jpg' self.image = Image(source=source, pos_hint={ 'center_x': .5, 'center_y': .4 }) self.myText = Label(text=page[i], halign='center', valign='top', text_size=[_WIDTH, 100], pos_hint={ 'x': 0, 'y': -.8 }, color='#4B0082') self.layout[i].add_widget(self.image) self.layout[i].add_widget(self.myText) self.carousel.add_widget(self.layout[i]) # window self.btn_next = Button(text='Далее', size_hint=(.455, .08), pos_hint={ 'center_x': .745, 'center_y': .1 }, on_release=self.evt_btn_next) self.btn_pre = Button(text='Назад', size_hint=(.455, .08), pos_hint={ 'center_x': .255, 'center_y': .1 }, on_release=self.evt_btn_pre) self.window.add_widget(self.carousel) self.window.add_widget(self.btn_pre) self.window.add_widget(self.btn_next) return self.window
def __init__(self, **kwargs): # Create carousel - doesn't work so well in .kv Carousel.__init__(self,direction='right',loop='true',scroll_distance=80,scroll_timeout=100,**kwargs) self.config = MyConfig() self.backlight = BacklightFactory.Make(self.config) self.overview = Overview() self.add_widget(self.overview) self.add_widget(Label(text='Hello World2')) self.game = PongGame() self.game.serve_ball() self.add_widget(self.game) self.idle_clock = Clock.schedule_once(self.on_idle, float(self.config.switch_off_time)) Window.bind(on_motion=self.on_motion)
def build(self): carousel = Carousel( direction='right', loop=True, ) for i in range(2): src0 = 'images/city.gif' src1 = 'images/clouds.gif' src2 = 'images/Eve_Online_Battle_01.jpg' image = AsyncImage(source=src2) carousel.add_widget(image) return carousel
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 __init__(self): # Create carousel - doesn't work so well in .kv Carousel.__init__(self, direction='right', loop='true', scroll_distance=80, scroll_timeout=100) self.overview = Overview() self.add_widget(self.overview) self.add_widget(Label(text='Hello World2')) self.game = PongGame() self.game.serve_ball() self.add_widget(self.game)
def _show_carousel(self, log_file): local_recon = '/home/pi/recon' prefix = log_file.split('.', 1)[0] carousel = Carousel(direction='right') for filename in os.listdir(local_recon): if filename.startswith(prefix) and filename.endswith('.png'): src = os.path.join(local_recon, filename) image = Image(source=src, allow_stretch=True, size=(620, 460)) carousel.add_widget(image) popup = Popup(title='Reconstruction Results', content=carousel, size_hint=(None, None), size=(640, 480)) popup.open()
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
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)
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 build(self): # Add carousel # And add the direction of swipe carousel = Carousel(direction='right') # Adding 10 slides for i in range(caroSize): src = "c:/users/' + UNAME + '/Pictures/caro/%d.png" % i # using Asynchronous image image = AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) Clock.schedule_interval(carousel.load_next, Timing) return carousel
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
def build(self): Window.size = (480, 800) Window.fullscreen = False layout = BoxLayout(orientation='vertical') carousel = Carousel(direction='right') layout.add_widget(carousel) b = BackButton(text='Back ', size_hint=(None, None), size=(100, 50)) layout.add_widget(b) # get any files into images directory curdir = dirname(__file__) for filename in glob(join(curdir, 'DCIM', '*')): image = AsyncImage(source=filename, allow_stretch=True) carousel.add_widget(image) return layout
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)
def build(self): labels=App.get_running_app().labels layout=BoxLayout(orientation='vertical') carouselDisplay=CarouselDisplay(height=500, width=500) carousel = Carousel(direction='right', loop=True) for coin in coins: labels[coin]=Factory.Label(text=coin + ' ' + App.get_running_app().stocks.toString(coin)) carousel.add_widget(labels[coin]) Clock.schedule_interval(carousel.load_next, 3) layout.add_widget(carousel) layout.add_widget(carouselDisplay) return layout
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 __init__(self, **kwargs): super(MainScreen, self).__init__(**kwargs) self.orientation = 'vertical' title = TitleBar() self.carousel = Carousel(direction='right', loop=False) self.spacing=10 dico = Dictionary() self.carousel.add_widget(dico) self.m = MainMenu() self.m.convert_button.bind(on_release=self.convert) self.m.dictionary_button.bind(on_release=self.dictionary) self.carousel.add_widget(self.m) self.carousel.load_slide(self.m) self.textEntry = TextEntry() self.textEntry.paragraph_button.bind(on_press=self.convert_paragraph) self.carousel.add_widget(self.textEntry) self.result = ResultEntry() self.result.back.bind(on_press=self.back) self.carousel.add_widget(self.result) self.add_widget(title) self.add_widget(self.carousel)
def __init__(self, **kwargs): super(Photo, self).__init__(**kwargs) self.bl = BoxLayout(orientation="vertical") carousel = Carousel(loop=True) for i in range(3): src = "img/f%d.jpg" % i image = Factory.AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) self.btn = Button(text="Back to menu", on_press=lambda x: set_screen('menu'), size_hint=(1, 0.1)) self.bl.add_widget(carousel) self.bl.add_widget(self.btn) self.add_widget(self.bl)
def Carousel(self, buton): self.layout.clear_widgets() self.carousel = Carousel(direction = 'right') self.carousel.anim_move_duration = 1 self.carousel.loop = True self.carousel.size_hint = (0.7, 0.7) self.carousel.pos = (200, 120) self.layout.add_widget(self.carousel) self.image1 = Image(source = 'E:/PROGRAMMIN/Curs/Pentru examen/fisiere proiect/nature1.jpg') self.carousel.add_widget(self.image1) self.image2 = Image(source= 'E:/PROGRAMMIN/Curs/Pentru examen/fisiere proiect/nature2.jpg') self.carousel.add_widget(self.image2) self.image3 = Image(source = 'E:/PROGRAMMIN/Curs/Pentru examen/fisiere proiect/nature3.jpg') self.carousel.add_widget(self.image3) self.image4 = Image(source = 'E:/PROGRAMMIN/Curs/Pentru examen/fisiere proiect/nature4.jpg') self.carousel.add_widget(self.image4) self.label = Label(text = 'This is the end of the list!', font_size = 30) self.carousel.add_widget(self.label) self.backbutton = Button(text = 'Back', bold = True, background_color = (0, 0, 1, 1)) self.backbutton.pos = (200, 100) self.backbutton.size_hint = (0.7, 0.1) self.layout.add_widget(self.backbutton) self.backbutton.bind(on_press = self.Menu)
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
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 __init__(self, **kwargs): super().__init__(**kwargs) # padding: [padding_left, padding_top, padding_right, padding_bottom] self.padding=("0dp", "50dp", "0dp", "10dp") self.carousel = Carousel(direction='right') #self.carousel.pos_hint = {"top":.9} for i in range(10): src = "https://i.imgur.com/x7WdmHBb.jpg" image = AsyncImage(source=src, allow_stretch=True) self.inner_carousel_layout = MDRelativeLayout() self.prev_btn = MDIconButton(icon="menu-left", user_font_size ="200sp", on_release = lambda x:self.carousel.load_previous(), pos_hint={"center_x":.1, "center_y":.5}) # pos_hint={"left":.2, "y":.5}, self.next_btn = MDIconButton(icon="menu-right", user_font_size ="200sp", on_release = lambda x:self.carousel.load_next(), pos_hint={"center_x":.9, "center_y":.5}) # pos_hint={"right":.8, "y":.5} self.inner_carousel_layout.add_widget(image) self.inner_carousel_layout.add_widget(self.prev_btn) self.inner_carousel_layout.add_widget(self.next_btn) self.carousel.add_widget(self.inner_carousel_layout) self.add_widget(self.carousel)
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 build(self): carousel = Carousel(direction='right') lang = load_lang("lang/rus/config.py") ulubione = pickle.load(open("ulubione.p", "rb")) #ulubione = [] # lang = {"translate": {'а': {'translation': 'a', 'word': 'мама'}, 'б': {'translation': 'b', 'word': 'бумага'}}} #tło with carousel.canvas: Color(1, 1, 1) Rectangle(source="img/tlo.png", pos=carousel.pos, size=Window.size) #tłumaczenie słowa-połaczenie z layoutem for litera in lang["translate"]: litera_tlumaczenie = lang["translate"][litera]["translation"] layout = builder.Builder.load_file("learn_layout.kv") carousel.add_widget(layout) if 'size' in lang["translate"][litera].keys(): duza_litera.font_size = lang["translate"][litera]['size'] slowo = layout.ids.slowo duza_litera = layout.ids.duza_litera duza_litera = layout.ids[ 'duza_litera'] # komenda równoznaczna z komendą powyżej duza_litera.text = litera slowo.text = lang["translate"][litera]["word"] layout.ids.zamien_litere.bind( on_release=action(duza_litera, litera, litera_tlumaczenie)) #utrzymanie przycisku pulub = layout.ids.fav pulub.aktywny = False if litera in ulubione: aktywuj(pulub, True) pulub.bind(on_release=dodaj_ulub(ulubione, litera, pulub, pulub.background_normal, pulub.background_down)) litera_sound = lang["translate"][litera]["sound"] layout.ids.play_sound.bind(on_release=play_sound(litera_sound)) return carousel
def build(self): box = GridLayout(cols=1, padding=50, spacing=10) carousel = Carousel(direction='right') lang = load_lang("lang/rus/config.py") layout_top = builder.Builder.load_file("fon_quiz_layout_top.kv") box.add_widget(layout_top) box.add_widget(carousel) #ulubione = [] # lang = {"translate": {'а': {'translation': 'a', 'word': 'мама'}, 'б': {'translation': 'b', 'word': 'бумага'}}} with carousel.canvas: Color(1, 1, 1) Rectangle(source="img/tlo.png", pos=carousel.pos, size=Window.size) wszystkie_litery_alf = list(lang["translate"].keys()) random.shuffle(wszystkie_litery_alf) for litera in wszystkie_litery_alf: litera_sound = lang["translate"][litera]["sound"] if litera_sound is None: continue litera_tlumaczenie = lang["translate"][litera]["translation"] #layout = builder.Builder.load_file("fon_quiz_layout.kv") #carousel.add_widget(layout) odp_false = (1, 0.2, 0, 0.8) odp_true = (0, 1, 0, 0.8) #odp_A=layout.ids.odp_A #odp_B = layout.ids.odp_B #odp_C = layout.ids.odp_C #odp_D = layout.ids.odp_D #buttons=[odp_A,odp_B,odp_C,odp_D] wszystkie_litery = list(lang["translate"].keys()) wszystkie_litery.remove(litera) wybrane_litery = random.sample(wszystkie_litery, 3) wybrane_litery.append(litera) random.shuffle(wybrane_litery) for Przycisk, wybrana_litera in zip(buttons, wybrane_litery): Przycisk.text = wybrana_litera if litera == wybrana_litera: Przycisk.bind(on_release=action(self, Przycisk, odp_true, buttons, True)) else: Przycisk.bind(on_release=action(self, Przycisk, odp_false, buttons, False)) layout.ids.play_sound.bind(on_release=play_sound(litera_sound)) return carousel
def __init__(self, **kwargs): # Create carousel - doesn't work so well in .kv Carousel.__init__(self, direction='right', loop='true', scroll_distance=80, scroll_timeout=100, **kwargs) self.config = MyConfig() self.backlight = BacklightFactory.Make(self.config) self.overview = Overview() self.add_widget(self.overview) self.add_widget(Label(text='Hello World2')) self.game = PongGame() self.game.serve_ball() self.add_widget(self.game) self.idle_clock = Clock.schedule_once( self.on_idle, float(self.config.switch_off_time)) Window.bind(on_motion=self.on_motion)
def on_enter(self): carousel = Carousel(direction='right') wszystkie_litery_alf = list(self.lang["translate"].keys()) random.shuffle(wszystkie_litery_alf) for litera in wszystkie_litery_alf: litera_sound = self.lang["translate"][litera]["sound"] if litera_sound is None: continue litera_tlumaczenie = self.lang["translate"][litera]["translation"] layout = builder.Builder.load_file("fon_quiz_layout.kv") carousel.add_widget(layout) odp_false=(1,0.2,0,0.8) odp_true = (0, 1, 0, 0.8) odp_A=layout.ids.odp_A odp_B = layout.ids.odp_B odp_C = layout.ids.odp_C odp_D = layout.ids.odp_D buttons=[odp_A,odp_B,odp_C,odp_D] wszystkie_litery = list(self.lang["translate"].keys()) wszystkie_litery.remove(litera) wybrane_litery=random.sample(wszystkie_litery, 3) wybrane_litery.append(litera) random.shuffle(wybrane_litery) layout.score = str(NumericProperty(0)) layout.ids.wynik=layout.score for Przycisk, wybrana_litera in zip(buttons, wybrane_litery): Przycisk.text = wybrana_litera if litera == wybrana_litera: Przycisk.bind(on_release=action(self, Przycisk, odp_true, buttons, layout, True)) else: Przycisk.bind(on_release=action(self, Przycisk, odp_false, buttons, layout, False)) layout.ids.play_sound.bind(on_release= play_sound(litera_sound)) self.add_widget(carousel)
def build(self): carousel = Carousel(direction='right') src = "https://farm8.staticflickr.com/7404/10772400223_244bb727c6_z_d.jpg" image = AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) src = "https://farm6.staticflickr.com/5139/5519598097_e91d45b195_z_d.jpg" image = AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) src = "https://farm3.staticflickr.com/2920/33021716475_4fffb8f11a_z_d.jpg" image = AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) src = "https://farm1.staticflickr.com/271/20147143552_28affd24e7_z_d.jpg" image = AsyncImage(source=src, allow_stretch=True) carousel.add_widget(image) return carousel
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
def buildMembersCarousel(self): #removing the memberscarousel from the main one to rebuild it properly self.main_carousel.remove_widget(self.members_carousel) #refreshing the members carousel by reinitializing it self.members_carousel = Carousel(direction='bottom', loop='True') #either way we add the newly created members_carousel to the main one self.main_carousel.add_widget( widget_builder.buildMembersCarousel(self.members_carousel, self.members, self))
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
def build(self): scroll = ScrollView() grid = GridLayout(cols=1, spacing=1, size_hint_y=None) grid.bind(minimum_height=grid.setter('height')) scroll.add_widget(grid) for r in range(0, 50): bt = Button(text='Slow start ' + str(r), size_hint_y=None, height=cm(2)) grid.add_widget(bt) scroll2 = ScrollView() grid2 = GridLayout(cols=1, spacing=1, size_hint_y=None) grid2.bind(minimum_height=grid2.setter('height')) scroll2.add_widget(grid2) for r in range(50, 100): bt = Button(text="Fast scrolling doesn't work " + str(r), size_hint_y=None, height=cm(2)) grid2.add_widget(bt) carousel = Carousel() carousel.add_widget(scroll) carousel.add_widget(scroll2) return carousel
def build(self): scroll = ScrollView() grid = GridLayout(cols=1, spacing=1, size_hint_y=None) grid.bind(minimum_height=grid.setter('height')) scroll.add_widget(grid) for r in range(0,50): bt = Button(text='Slow start '+str(r), size_hint_y=None, height=cm(2)) grid.add_widget(bt) scroll2 = ScrollView() grid2 = GridLayout(cols=1, spacing=1, size_hint_y=None) grid2.bind(minimum_height=grid2.setter('height')) scroll2.add_widget(grid2) for r in range(50,100): bt = Button(text="Fast scrolling doesn't work "+str(r), size_hint_y=None, height=cm(2)) grid2.add_widget(bt) carousel = Carousel() carousel.add_widget(scroll) carousel.add_widget(scroll2) return carousel
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()
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 init_ui(self): self.carousel = Carousel(direction='right') self.layout = BoxLayout(orientation='vertical') Clock.schedule_interval(self.update_ui, 1.0 / 60.0) self.soundboard = Soundboard() self.soundboard.load() self._init_about_layout() self._init_console_layout() self.carousel.add_widget(self.layout) self.carousel.add_widget(self.console_layout) self.carousel.add_widget(self.about_layout) return self.carousel
def HauptProgramm(self, *args): print 'das ist das Hauptprogramm' self.BilderListeVorlaeufer = [] self.BilderListeVorlaeufer = os.listdir(os.getcwd() + '/pictures') self.Pfade = [] for i in self.BilderListeVorlaeufer: Pfad = os.path.join('pictures', i) self.Pfade.append(Pfad) self.HauptCarousel = Carousel() self.add_widget(self.HauptCarousel) #################################################################################################### ### Erste Seite im HauptCarousel momentan mit den produktbildern self.HauptCarousel.FloatLayout = FloatLayout() self.HauptCarousel.add_widget(self.HauptCarousel.FloatLayout) self.HauptCarousel.FloatLayout.GridLayout = GridLayout(cols=3, pos_hint={'x': 0,'y': 0}, size_hint=[1,0.9]) self.HauptCarousel.FloatLayout.add_widget(self.HauptCarousel.FloatLayout.GridLayout) ## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test')) ## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test2')) for i in range(9): button = Button(background_normal = self.Pfade[i], background_down= 'pictures/bilder_oberflaeche/1361740537_Ball Green_mitHaken.png', mipmap= True) self.HauptCarousel.FloatLayout.GridLayout.add_widget(button) ##################################################################################################### ### 2 Seite im Hauptcarousel mit testbutton zur datei Erstellung self.HauptCarousel2 = BoxLayout(orientation='vertical') self.HauptCarousel.add_widget(self.HauptCarousel2) self.HauptCarousel2.Texteingabe = TextInput(multiline=True) self.HauptCarousel2.add_widget(self.HauptCarousel2.Texteingabe) self.HauptCarousel2.ButtonSchreiben = Button(text="datei schreiben", on_release = self.datenpickeln) self.HauptCarousel2.add_widget(self.HauptCarousel2.ButtonSchreiben) ### 3 Seite im Hauptcarousel momentan mit Datei Auslesefunktion self.HauptCarousel3 = BoxLayout(orientation='vertical') self.HauptCarousel.add_widget(self.HauptCarousel3) self.HauptCarousel3.Textausgabe = TextInput(multiline=True, readonly = True) self.HauptCarousel3.add_widget(self.HauptCarousel3.Textausgabe) self.HauptCarousel3.ButtonLesen = Button(text="datei auslesen", on_release = self.datenentpickeln) self.HauptCarousel3.add_widget(self.HauptCarousel3.ButtonLesen)
def __init__ (self,**kwargs): super (CalStart, self).__init__(**kwargs) box = BoxLayout(size_hint_x=1, size_hint_y=1,padding=10, spacing=10, orientation='vertical') box1 = BoxLayout(size_hint_x=1, size_hint_y=0.5,padding=10, spacing=10, orientation='vertical') box2 = BoxLayout(size_hint_x=1, size_hint_y=0.5,padding=10, spacing=10, orientation='vertical') button_back = Button(text="Back") button_back.bind(on_press= self.change_to_precal) self.button_stream = Button(text="Start Streaming") self.button_stream.bind(on_press= self.bci_begin) 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) self.carousel.add_widget(image) self.label_energy = Label() box2.add_widget(self.carousel) box1.add_widget(self.label_energy) box1.add_widget(self.button_stream) box1.add_widget(button_back) box.add_widget(box2) box.add_widget(box1) self.add_widget(box) self.stream_flag = False Clock.schedule_interval(self.get_energy, 1/20)
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
def build(self): # set the window size Window.size = (800, 480) # load miscellaneous stuff that's in kv language # Builder.load_string(misc) # setup the Carousel such that we can swipe between screens carousel = Carousel(direction='right') # add the homescreen widget to the carousel with the sidebar homescreen = Builder.load_string(homescr + sidebar) carousel.add_widget(homescreen) # add the musicscreen widget to the carousel with the sidebar musicscreen = Builder.load_string(musicscr + sidebar) carousel.add_widget(musicscreen) # add the rearview camera screen widget to the carousel with the sidebar rearviewscreen = Builder.load_string(rearscr + sidebar) carousel.add_widget(rearviewscreen) return carousel
def HauptProgramm(self, *args): print 'das ist das Hauptprogramm' self.BilderListeVorlaeufer = [] self.BilderListeVorlaeufer = os.listdir(os.getcwd() + '/pictures') self.Pfade = [] for i in self.BilderListeVorlaeufer: Pfad = os.path.join('pictures', i) self.Pfade.append(Pfad) self.HauptCarousel = Carousel(scroll_timeout = 100) self.add_widget(self.HauptCarousel) #################################################################################################### ### Erste Seite im HauptCarousel momentan mit den produktbildern self.HauptCarousel.FloatLayout = FloatLayout() self.HauptCarousel.add_widget(self.HauptCarousel.FloatLayout) self.HauptCarousel.FloatLayout.GridLayout = GridLayout(cols=3, pos_hint={'x': 0,'y': 0}, size_hint=[1,0.9]) self.HauptCarousel.FloatLayout.add_widget(self.HauptCarousel.FloatLayout.GridLayout) for i in range(9): button = Button(background_normal = self.Pfade[i], background_down= 'pictures/bilder_oberflaeche/1361740537_Ball Green_mitHaken.png', mipmap= True) self.HauptCarousel.FloatLayout.GridLayout.add_widget(button) ## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test')) ## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test2')) ##################################################################################################### ### 2 Seite im Hauptcarousel mit testbutton zur datei Erstellung ### 2 Page in MainCarousel with testbutton for creating /exporting to a file self.HauptCarousel2 = BoxLayout(orientation='vertical') ###############self.HauptCarousel.add_widget(self.HauptCarousel2) self.HauptCarousel2.Texteingabe = TextInput(multiline=True) self.HauptCarousel2.add_widget(self.HauptCarousel2.Texteingabe) self.HauptCarousel2.ButtonSchreiben = Button(text="datei schreiben", on_release = self.datenpickeln) self.HauptCarousel2.add_widget(self.HauptCarousel2.ButtonSchreiben) ####################################################################### ### 3 Seite im Hauptcarousel momentan mit Datei Auslesefunktion ### 3 Page in MainCarousel atm with functionality to read from file self.HauptCarousel3 = BoxLayout(orientation='vertical') ######################self.HauptCarousel.add_widget(self.HauptCarousel3) self.HauptCarousel3.Textausgabe = TextInput(multiline=True, readonly = True) self.HauptCarousel3.add_widget(self.HauptCarousel3.Textausgabe) self.HauptCarousel3.ButtonLesen = Button(text="datei auslesen", on_release = self.datenentpickeln) self.HauptCarousel3.add_widget(self.HauptCarousel3.ButtonLesen) ####################################################################### ### 4 Seite im Hauptcarousel momentan mit Tischmanager ### 4 Page in Maincarousel atm with some kind of Table Manager BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)] self.CustomLayout = CustomLayout() self.HauptCarousel.add_widget(self.CustomLayout) #self.CustomLayout.TopLabel = Label(text = 'Tisch[sup][color=#098125ff]Organizer[/sup][/b][/color]', markup = True, #halign= 'left', valign= 'top', text_size= self.size, pos_hint={'x':0, 'y': 0}, font_size= '30sp') self.CustomLayout.TopLabel = Label(text = 'Tisch[sup][color=#098125ff]Organizer[/sup][/b][/color]', markup = True, halign= 'left', font_size= '30sp') #self.CustomLayout.add_widget(self.CustomLayout.TopLabel) self.CustomLayout.BoxLayout = BoxLayout (orientation = 'horizontal', size_hint = [1,0.05], pos_hint={'x':0, 'y': 0.95}) self.CustomLayout.add_widget(self.CustomLayout.BoxLayout) self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.TopLabel) ButtonMenu1 = self.DropdownbuttonCreator() self.CustomLayout.BoxLayout.Button1 = ButtonMenu1 ## self.CustomLayout.BoxLayout.Button2 = Button(text = 'Tisch+' , on_release = self.tischhinzufuegen) ## self.CustomLayout.BoxLayout.Button3 = Button(text = 'Spalte+', on_release = self.spaltehinzufuegen) ## self.CustomLayout.BoxLayout.Button4 = Button(text = 'Zeile+', on_release = self.zeilehinzufuegen) self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button1) ## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button2) ## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button3) ## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button4) self.CustomLayoutGridLayout = GridLayout(cols = 3, rows = 4, padding = [20,20], spacing = [30,30], size_hint = [1,0.95], pos_hint={'x':0, 'y': 0}) #cGridLayout = StackLayout(orientation = "tb-lr", padding = [20,20], spacing = [30,30], size_hint = [1,0.9], pos_hint={'x':0, 'y': 0}) self.CustomLayout.add_widget(self.CustomLayoutGridLayout) self.Tischliste = [] Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"] AnzahlTische = 12 Zielwidget = self.CustomLayoutGridLayout self.tischerstellung(Zielwidget,AnzahlTische, Auswahlliste, BackgroundcolorListe)
class LoginScreen(FloatLayout): def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) #gc.disable() self.DropdownObjects = [] self.add_widget(Label(text= "Wilkommen [color=ff3333] [sub] bei der [/sub][/color][color=3333ff][b] Bonierungs[sup][color=#098125ff]App[/sup][/b][/color]", markup = True, pos_hint={'top': 1.2}, font_size='20sp')) self.GridlayoutS1 = GridLayout(cols = 2, size_hint_y = 1/5, pos_hint={'top': 0.6}) self.add_widget(self.GridlayoutS1) self.GridlayoutS1.add_widget(Label(text='User Name')) #, size_hint_x = 0.2, size_hint_y = 0.2)) self.username = TextInput(multiline=False) #, size_hint_x = 0.2, size_hint_y = 0.2) self.username.bind(on_text_validate=self.on_enter) self.GridlayoutS1.add_widget(self.username) self.GridlayoutS1.add_widget(Label(text='password')) #,size_hint_x = 0.2, size_hint_y = 0.2)) self.password = TextInput(password=True, multiline=False) #, size_hint_x = 0.2, size_hint_y = 0.2) self.GridlayoutS1.add_widget(self.password) self.BenutzerListe = {"": ""}; self.add_widget(Button(text='Einloggen', size_hint_y= 1/5, pos_hint={'top': 0.4}, on_release = self.AbfrageLogin)) self.LabelLoginanzeiger = Label(size_hint_y= 1/5) self.add_widget(self.LabelLoginanzeiger) def on_enter(self, instance): print('User pressed enter in', instance) self.password.focus = True def AbfrageLogin(self, widget): Username = self.username.text Passwort = self.password.text if Username in self.BenutzerListe and Passwort == self.BenutzerListe[Username]: self.LabelLoginanzeiger.text = 'Login korrekt' self.clear_widgets() self.HauptProgramm() else: self.LabelLoginanzeiger.text = 'Login inkorrekt' def HauptProgramm(self, *args): print 'das ist das Hauptprogramm' self.BilderListeVorlaeufer = [] self.BilderListeVorlaeufer = os.listdir(os.getcwd() + '/pictures') self.Pfade = [] for i in self.BilderListeVorlaeufer: Pfad = os.path.join('pictures', i) self.Pfade.append(Pfad) self.HauptCarousel = Carousel(scroll_timeout = 100) self.add_widget(self.HauptCarousel) #################################################################################################### ### Erste Seite im HauptCarousel momentan mit den produktbildern self.HauptCarousel.FloatLayout = FloatLayout() self.HauptCarousel.add_widget(self.HauptCarousel.FloatLayout) self.HauptCarousel.FloatLayout.GridLayout = GridLayout(cols=3, pos_hint={'x': 0,'y': 0}, size_hint=[1,0.9]) self.HauptCarousel.FloatLayout.add_widget(self.HauptCarousel.FloatLayout.GridLayout) for i in range(9): button = Button(background_normal = self.Pfade[i], background_down= 'pictures/bilder_oberflaeche/1361740537_Ball Green_mitHaken.png', mipmap= True) self.HauptCarousel.FloatLayout.GridLayout.add_widget(button) ## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test')) ## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test2')) ##################################################################################################### ### 2 Seite im Hauptcarousel mit testbutton zur datei Erstellung ### 2 Page in MainCarousel with testbutton for creating /exporting to a file self.HauptCarousel2 = BoxLayout(orientation='vertical') ###############self.HauptCarousel.add_widget(self.HauptCarousel2) self.HauptCarousel2.Texteingabe = TextInput(multiline=True) self.HauptCarousel2.add_widget(self.HauptCarousel2.Texteingabe) self.HauptCarousel2.ButtonSchreiben = Button(text="datei schreiben", on_release = self.datenpickeln) self.HauptCarousel2.add_widget(self.HauptCarousel2.ButtonSchreiben) ####################################################################### ### 3 Seite im Hauptcarousel momentan mit Datei Auslesefunktion ### 3 Page in MainCarousel atm with functionality to read from file self.HauptCarousel3 = BoxLayout(orientation='vertical') ######################self.HauptCarousel.add_widget(self.HauptCarousel3) self.HauptCarousel3.Textausgabe = TextInput(multiline=True, readonly = True) self.HauptCarousel3.add_widget(self.HauptCarousel3.Textausgabe) self.HauptCarousel3.ButtonLesen = Button(text="datei auslesen", on_release = self.datenentpickeln) self.HauptCarousel3.add_widget(self.HauptCarousel3.ButtonLesen) ####################################################################### ### 4 Seite im Hauptcarousel momentan mit Tischmanager ### 4 Page in Maincarousel atm with some kind of Table Manager BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)] self.CustomLayout = CustomLayout() self.HauptCarousel.add_widget(self.CustomLayout) #self.CustomLayout.TopLabel = Label(text = 'Tisch[sup][color=#098125ff]Organizer[/sup][/b][/color]', markup = True, #halign= 'left', valign= 'top', text_size= self.size, pos_hint={'x':0, 'y': 0}, font_size= '30sp') self.CustomLayout.TopLabel = Label(text = 'Tisch[sup][color=#098125ff]Organizer[/sup][/b][/color]', markup = True, halign= 'left', font_size= '30sp') #self.CustomLayout.add_widget(self.CustomLayout.TopLabel) self.CustomLayout.BoxLayout = BoxLayout (orientation = 'horizontal', size_hint = [1,0.05], pos_hint={'x':0, 'y': 0.95}) self.CustomLayout.add_widget(self.CustomLayout.BoxLayout) self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.TopLabel) ButtonMenu1 = self.DropdownbuttonCreator() self.CustomLayout.BoxLayout.Button1 = ButtonMenu1 ## self.CustomLayout.BoxLayout.Button2 = Button(text = 'Tisch+' , on_release = self.tischhinzufuegen) ## self.CustomLayout.BoxLayout.Button3 = Button(text = 'Spalte+', on_release = self.spaltehinzufuegen) ## self.CustomLayout.BoxLayout.Button4 = Button(text = 'Zeile+', on_release = self.zeilehinzufuegen) self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button1) ## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button2) ## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button3) ## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button4) self.CustomLayoutGridLayout = GridLayout(cols = 3, rows = 4, padding = [20,20], spacing = [30,30], size_hint = [1,0.95], pos_hint={'x':0, 'y': 0}) #cGridLayout = StackLayout(orientation = "tb-lr", padding = [20,20], spacing = [30,30], size_hint = [1,0.9], pos_hint={'x':0, 'y': 0}) self.CustomLayout.add_widget(self.CustomLayoutGridLayout) self.Tischliste = [] Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"] AnzahlTische = 12 Zielwidget = self.CustomLayoutGridLayout self.tischerstellung(Zielwidget,AnzahlTische, Auswahlliste, BackgroundcolorListe) ##################################################################### ### Versuch eines Dropdown Buttons ### Try to implement a dropdown Button, probably better than a Spinner ############################### #### Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"] #### BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)] #### self.dropdownobjects = [] #### for i in range(12): #### TischButtonText = "T " + str(i+1) #### DropdownObjekt = CustomDropDown() #von kovak hinzugefuegt #### DropdownObjektButton = CustomButton(text = TischButtonText, background_color = (201./255.,99./255.,23./255.,1)) #### cGridLayout.add_widget(DropdownObjektButton) #### DropdownObjektButton.bind(on_release=DropdownObjekt.open) #### self.dropdownobjects.append(DropdownObjekt) #von kovak hinzugefuegt #### #### for x in range(len(Auswahlliste)): #### #### DropdownUnterbutton = Button(text=Auswahlliste[x], font_size = 15, size_hint_y=None, height=60, background_color = BackgroundcolorListe[x]) #### DropdownObjekt.add_widget(DropdownUnterbutton) #### #### #print' button', i, 'unterbutton', x #### #### #### #### DropdownObjektButton.text= TischButtonText #### TischButtondict = {'Nummer':(i),'Objekt':DropdownObjektButton} #### self.Tischliste.append(TischButtondict) ## for i in range(12): ## TischButtonText = "T " + str(i+1) ## #TischButton = Button(text=(''), on_release = self.tischmanipulieren) ## TischButton = Spinner(text='', values = ("Bestellung", "Abrechnung", "Best. Aendern", "Bennenen")) ## cGridLayout.add_widget(TischButton) ## TischButton.text= TischButtonText ## TischButtondict = {(i),TischButton} ## self.Tischliste.append(TischButtondict) ## for index, item in enumerate(self.Tischliste): ## print index, item def DropdownbuttonCreator(self): Auswahlliste = ["Tisch +", "Tisch -", "Spalte + ", "Spalte -", "Reihe + ", "Reihe -"] BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(1,0,0,1),(0,1,0,1),(1,0,0,1),(0,1,0,1)] Aktionsliste = [self.tischhinzufuegen, self.tischentfernen, self.spaltehinzufuegen, self.spalteentfernen, self.zeilehinzufuegen, self.zeileentfernen] DropdownObjekt = CustomDropDown() DropdownObjektButton = CustomButton(text = "Menue", #DropdownObjektButton = ToggleButton(text="Menue", size_hint=[1,1], background_color = (0.8, 0.8, 0.00, 1), background_normal='pictures/white2.png', background_down='pictures/white3.png') #self.CustomLayout.add_widget(DropdownObjektButton) DropdownObjektButton.bind(on_release=DropdownObjekt.open) self.DropdownObjects.append(DropdownObjekt) for x in range(len(Auswahlliste)): DropdownUnterbutton = Button(text=Auswahlliste[x], font_size = 15, size_hint_y=None, height=60, background_color = BackgroundcolorListe[x], background_normal='pictures/white2.png', background_down='pictures/white3.png', opacity = 0.8, on_release = Aktionsliste[x]) DropdownObjekt.add_widget(DropdownUnterbutton) ButtonMenu1 = DropdownObjektButton return ButtonMenu1 def tischerstellung (self, Zielwidget, AnzahlTische, Auswahlliste, BackgroundcolorListe): Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"] BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)] Aktionsliste = [self.bestellung, self.abrechnung, self.bestellungaendern, self.tischbenennen] #self.DropdownObjects = [] for i in range(AnzahlTische): if self.Tischliste != []: LetzterTisch = self.Tischliste[-1]['Nummer'] ## print LetzterTisch + 1 else: LetzterTisch = 0 TischNr = str(LetzterTisch+1) TischButtonText = "T " + TischNr DropdownObjekt = CustomDropDown() #von kovak hinzugefuegt #DropdownObjektButton = CustomButton(text = TischButtonText, DropdownObjektButton = ToggleButton(text = TischButtonText, group='Tische', background_normal='pictures/white2.png', background_down='pictures/white4.png', background_color = (0.79, 0.39, 0.09, 0.6)) Zielwidget.add_widget(DropdownObjektButton) DropdownObjektButton.bind(on_release=DropdownObjekt.open) self.DropdownObjects.append(DropdownObjekt) #von kovak hinzugefuegt for x in range(len(Auswahlliste)): DropdownUnterbutton = Button(text=Auswahlliste[x], id = TischNr, #auto_width='False', #width = '200sp', font_size = 15, size_hint_y=None, height=60, background_normal='pictures/white2.png', background_down='pictures/white3.png', background_color = BackgroundcolorListe[x], on_release = Aktionsliste[x]) DropdownObjekt.add_widget(DropdownUnterbutton) #print' button', i, 'unterbutton', x DropdownObjektButton.text= TischButtonText self.TischButtondict = {'Nummer':(LetzterTisch + 1),'Objekt':DropdownObjektButton} self.Tischliste.append(self.TischButtondict) def garbagecollectortracking(self, widget): for i in self.Tischliste: a = i print gc.is_tracked(a) ### function for Editing a Table####################################### #def tischmanipulieren(self, widget): # widget.text = 'mein text' #### function for adding an extra table to layout ########################## def tischhinzufuegen(self, widget): if len(self.Tischliste) >= 1: if hasattr(self, 'CustomLayoutBottomLabel'): self.CustomLayout.remove_widget(self.CustomLayoutBottomLabel) AnzahlTische = 1 Zielwidget = self.CustomLayoutGridLayout Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"] BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)] LetzterTisch = self.Tischliste[-1]['Nummer'] if (self.CustomLayoutGridLayout.cols * self.CustomLayoutGridLayout.rows) <= (LetzterTisch +1): self.CustomLayoutGridLayout.rows = self.CustomLayoutGridLayout.rows + 1 self.tischerstellung(Zielwidget, AnzahlTische, Auswahlliste, BackgroundcolorListe) def tischentfernen(self, widget): self.Warnlabel = 0 if len(self.Tischliste) <= 1: if hasattr(self, 'CustomLayoutBottomLabel'): # obj.attr_name exists. if self.CustomLayoutBottomLabel in self.CustomLayout.children: self.Warnlabel=1 print 'das ist der Letzte Tisch, der kann nicht entfernt werden' if self.Warnlabel == 0: self.CustomLayoutBottomLabel= Label(text='Das ist der Letzte Tisch,\n der kann nicht \n entfernt werden', text_size = self.size) self.CustomLayout.add_widget(self.CustomLayoutBottomLabel) else: Zielwidget = self.CustomLayoutGridLayout Zielwidget.remove_widget(self.Tischliste[-1]['Objekt']) del self.Tischliste[-1] LetzterTisch = self.Tischliste[-1]['Nummer'] print 'die anzahl der Tische ist nun:', LetzterTisch pass #### function for adding a column to layout #################################### def spaltehinzufuegen(self, widget): if self.CustomLayoutGridLayout.cols >= 1: if hasattr(self, 'CustomLayoutBottomLabel'): self.CustomLayout.remove_widget(self.CustomLayoutBottomLabel) self.WarnLabel = 0 self.CustomLayoutGridLayout.cols = self.CustomLayoutGridLayout.cols + 1 print 'Zeile hinzufuegen' def spalteentfernen(self, widget): self.Warnlabel = 0 if self.CustomLayoutGridLayout.cols <= 1: if hasattr(self, 'CustomLayoutBottomLabel'): # obj.attr_name exists. if self.CustomLayoutBottomLabel in self.CustomLayout.children: self.Warnlabel=1 print 'das ist die letzte Tischreihe, sie kann nicht entfernt werden' if self.Warnlabel == 0: self.CustomLayoutBottomLabel= Label(text='Das ist die letzte Tischreihe,\n sie kann nicht \n entfernt werden', text_size = self.size) self.CustomLayout.add_widget(self.CustomLayoutBottomLabel) else: TischanzahlVerbleibend = (self.CustomLayoutGridLayout.cols -1) * self.CustomLayoutGridLayout.rows for i in range(len(self.Tischliste[TischanzahlVerbleibend:])): self.CustomLayoutGridLayout.remove_widget(self.Tischliste[TischanzahlVerbleibend+ i]['Objekt']) del self.Tischliste[TischanzahlVerbleibend:] self.CustomLayoutGridLayout.cols = self.CustomLayoutGridLayout.cols - 1 #### function for adding a row to layout #################################### def zeilehinzufuegen(self, widget): if self.CustomLayoutGridLayout.rows >= 1: if hasattr(self, 'CustomLayoutBottomLabel'): self.CustomLayout.remove_widget(self.CustomLayoutBottomLabel) self.WarnLabel = 0 self.CustomLayoutGridLayout.rows = self.CustomLayoutGridLayout.rows + 1 print 'Zeile hinzufuegen' def zeileentfernen(self, widget): self.Warnlabel = 0 if self.CustomLayoutGridLayout.rows <= 1: if hasattr(self, 'CustomLayoutBottomLabel'): # obj.attr_name exists. if self.CustomLayoutBottomLabel in self.CustomLayout.children: self.Warnlabel=1 print 'das ist die letzte Tischreihe, sie kann nicht entfernt werden' if self.Warnlabel == 0: self.CustomLayoutBottomLabel= Label(text='Das ist die letzte Tischreihe,\n sie kann nicht \n entfernt werden', text_size = self.size) self.CustomLayout.add_widget(self.CustomLayoutBottomLabel) else: TischanzahlVerbleibend = (self.CustomLayoutGridLayout.rows -1) * self.CustomLayoutGridLayout.cols for i in range(len(self.Tischliste[TischanzahlVerbleibend:])): self.CustomLayoutGridLayout.remove_widget(self.Tischliste[TischanzahlVerbleibend+ i]['Objekt']) del self.Tischliste[TischanzahlVerbleibend:] self.CustomLayoutGridLayout.rows = self.CustomLayoutGridLayout.rows - 1 def bestellung(self, widget): TischNr = widget.id PopupFloatLayout = FloatLayout() popup = Popup(title='Bestellung für Tisch ' + str(TischNr), content=PopupFloatLayout,size_hint=(1, 1) ) ButtonExit = Button(text="Exit", pos_hint={'x': 0.8, 'y': 1.005}, size_hint = [0.2,0.065], on_release = popup.dismiss) PopupBoxLayout = BoxLayout(orientation='vertical', size_hint = [1.05, 1]) PopupFloatLayout.add_widget(PopupBoxLayout) ButtonKasse = Button(text='Kasse', size_hint = [1,0.08]) PopupBoxLayout.add_widget(ButtonKasse) HoeheUebrig = PopupFloatLayout.height - sum(child.height for child in PopupFloatLayout.children) print PopupFloatLayout.height print ButtonKasse.height print HoeheUebrig # create a default grid layout with custom width/height ScrollviewGridLayout = GridLayout(cols=1,size_hint=(1, None), spacing = 10) # when we add children to the grid layout, its size doesn't change at # all. we need to ensure that the height will be the minimum required to # contain all the childs. (otherwise, we'll child outside the bounding # box of the childs) ScrollviewGridLayout.bind(minimum_height=ScrollviewGridLayout.setter('height')) # add button into that grid for i in range(30): ScrollViewBoxLayout = BoxLayout(size_hint = [1, None], size_y=50) button1 = Button(text='button1') button2 = Button(text='button2') ButtonBoxLayout = BoxLayout(orientation='vertical') button3_1 = Button(text='+') button3_2 = Button(text='-') ButtonBoxLayout.add_widget(button3_1) ButtonBoxLayout.add_widget(button3_2) button4 = Button(text='button4') ScrollViewBoxLayout.add_widget(button1) ScrollViewBoxLayout.add_widget(button2) ScrollViewBoxLayout.add_widget(ButtonBoxLayout) ScrollViewBoxLayout.add_widget(button4) ## btn = Button(text=str(i), size=(480, 40), ## size_hint=(None, None)) ScrollviewGridLayout.add_widget(ScrollViewBoxLayout) # create a scroll view, with a size < size of the grid PopupScrollView = ScrollView(size_hint=(1, 1), pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, scroll_timeout = 80) PopupScrollView.add_widget(ScrollviewGridLayout) PopupBoxLayout.add_widget(PopupScrollView) ## PopupGridLayout = GridLayout(cols = 4) ## PopupBoxLayout.add_widget(PopupGridLayout) ## button1 = Button(text='button1') ## button2 = Button(text='button2') ## button3 = Button(text='button3') ## button4 = Button(text='button4') ## PopupGridLayout.add_widget(button1) ## PopupGridLayout.add_widget(button2) ## PopupGridLayout.add_widget(button3) ## PopupGridLayout.add_widget(button4) PopupFloatLayout.add_widget(ButtonExit) popup.open() def abrechnung(self, widget): TischNr = widget.id ScreenmanagerPopup = CustomScreenManager() popup = Popup(title='Abrechnung für ' + str(TischNr), content=ScreenmanagerPopup,size_hint=(1, 1) ) popup.open() def bestellungaendern(self, widget): pass def tischbenennen(self, widget): TischNr = widget.id PopupBox1LayoutTischBennenen = BoxLayout(orientation = 'vertical') popup = Popup(title='Tisch Nr. ' + str(TischNr) + 'benennen', content=PopupBox1LayoutTischBennenen, size_hint=(0.75, 0.5)) EingabeTextfeld = TextInput(text='hier Tischbezeichnung eintragen - Funktion muss noch eingebaut werden') PopupBox1LayoutTischBennenen.add_widget(EingabeTextfeld) PopupBoxLayoutTischBenennen = BoxLayout(orientation = 'horizontal', size_hint=(1,1)) ButtonAbbrechenTischBenennen = Button(text="Abbrechen", size_hint=(0.5, 0.5)) ButtonAbbrechenTischBenennen.bind(on_press=popup.dismiss) ButtonOkTischBenennen = Button(text="OK", size_hint=(0.5, 0.5)) ButtonOkTischBenennen.bind(on_press=popup.dismiss) PopupBox1LayoutTischBennenen.add_widget(PopupBoxLayoutTischBenennen) PopupBoxLayoutTischBenennen.add_widget(ButtonAbbrechenTischBenennen) PopupBoxLayoutTischBenennen.add_widget(ButtonOkTischBenennen) #popup.add_widget popup.open() pass #### function for exporting Data to file #################################### def datenpickeln(self, widget): BonListe = self.HauptCarousel2.Texteingabe.text '''function to pickle data to make it ready for sending''' try: with open('bonliste.txt', 'w+b') as BonListeDaten_File: pickle.dump(BonListe, BonListeDaten_File) except IOError as err: print('Dateifehler: ' + str(err)) except pickle.PickleError as perr: print('Pickling Fehler: ' + str(perr)) #### function for importing Data to file #################################### def datenentpickeln(self, widget): with open('bonliste.txt', 'rb') as BonListeDaten_File_entpickelt: BonListeWiederhergestellt = pickle.load(BonListeDaten_File_entpickelt) print 'die entpickelte BinListe ist: ' print BonListeWiederhergestellt BonListe = BonListeWiederhergestellt self.HauptCarousel3.Textausgabe.text = BonListe