Пример #1
0
    def build(self, func):

        root = BoxLayout(orientation='vertical',
                         padding='5dp',
                         size_hint=(1, None))
        root.size_y = '100dp'
        with root.canvas:
            Color(.88, .88, .88)
            Rectangle(pos=root.pos, size=root.size)
        b0 = BoxLayout()
        a1 = AnchorLayout(size_hint=(1, 1))
        # короткое имя
        btn = Button(size_hint=(1, 1),
                     text='Add ' + self.short,
                     on_press=func,
                     id=self.short)
        a1.add_widget(btn)

        # содержит картинку
        a2 = AnchorLayout(anchor_x='right', anchor_y='center')
        i1 = Image(size_hint=(None, None),
                   source=paths.images + 'flags/{}.png'.format(self.short))
        i1.width = '60dp'
        i1.height = '60dp'
        a2.add_widget(i1)
        b0.add_widget(a1)
        b0.add_widget(a2)

        root.add_widget(b0)

        return root
Пример #2
0
    def addImage(self, filename):
	image = Image(source=filename)
	image.size_hint = None, None
	image.width = metrics.sp(120)
	image.height = metrics.sp(120)
	self.add_widget(image)
	return
Пример #3
0
    def build(self, convert):
        root = BoxLayout(orientation='vertical',
                         padding='5dp',
                         size_hint=(1, None),
                         id='root')
        root.size_y = '100dp'
        with root.canvas:
            Color(.88, .88, .88)
            Rectangle(pos=root.pos, size=root.size)

        # содержит картинку
        b0 = BoxLayout(id='box_root', padding='30dp',
                       spacing='10dp')  # size_hint=(1, 1),
        ai = AnchorLayout(size_hint=(.3, 1))
        i1 = Image(size_hint=(None, None),
                   source=paths.images +
                   'flags/{}.png'.format(self.item.short))
        i1.width = '60dp'
        i1.height = '60dp'

        ai.add_widget(i1)
        b0.add_widget(ai)

        # содержит ввод и корткое имя
        # короткое имя
        a1 = AnchorLayout(size_hint=(.1, 1))
        l1 = Label(color=(0, 0, 0, 1), font_size='20dp', text=self.item.short)
        a1.add_widget(l1)

        b0.add_widget(a1)

        # ввод
        a_inp = AnchorLayout(size_hint=(1, .8), id='anchor_input')
        inp = LimInput(size_hint=(1, None),
                       id=self.item.short,
                       write_tab=False,
                       multiline=False)
        inp.height = '30dp'
        inp.make_convert = convert
        a_inp.add_widget(inp)
        b0.add_widget(a_inp)

        root.add_widget(b0)

        a2 = AnchorLayout(anchor_x='center', padding='30dp')

        l2 = Label(size_hint=(None, None),
                   color=(0, 0, 0, 1),
                   font_size='20dp',
                   text=self.item.name)
        a2.add_widget(l2)

        root.add_widget(a2)

        root.input = inp

        return root
Пример #4
0
    def build(self):
        root = BoxLayout(orientation='vertical',
                         padding='5dp',
                         size_hint=(1, None))
        root.size_y = '100dp'
        with root.canvas:
            Color(.88, .88, .88)
            Rectangle(pos=root.pos, size=root.size)

        b = BoxLayout(size_hint=(1, .9))
        i1 = Image(size_hint=(None, None),
                   source=paths.images + 'res/{}.svg'.format(self.item.name))
        i1.width = '55dp'
        i1.height = '55dp'

        b.add_widget(i1)

        # полное имя и цена
        a1 = AnchorLayout()
        l1 = Label(color=(0, 0, 0, 1), font_size='20dp', text=self.item.name)
        a1.add_widget(l1)

        # короткое имя
        a2 = AnchorLayout()
        l2 = Label(color=(0, 0, 0, 1),
                   font_size='20dp',
                   text='{0:.2f}'.format(self.item.rate) + '$')
        a2.add_widget(l2)

        b1 = BoxLayout(spacing='30dp', padding='20dp')
        b1.add_widget(a1)
        b1.add_widget(a2)

        a3 = AnchorLayout()
        l3 = Label(color=(0, 0, 0, 1),
                   font_size='20dp',
                   text='price for 100 gr')
        a3.add_widget(l3)

        a4 = AnchorLayout(size_hint=(1, .19), anchor_x='right')
        l4 = Label(size_hint=(None, None),
                   text=str(self.item.date),
                   color=(0, 0, 0, 1))
        a4.add_widget(l4)

        b2 = BoxLayout(spacing='30dp', padding='20dp')
        b2.add_widget(a3)
        b2.add_widget(a4)

        g0 = GridLayout(spacing='30dp', padding='20dp', rows=2)
        g0.add_widget(b1)
        g0.add_widget(b2)

        b.add_widget(g0)
        root.add_widget(b)

        return root
Пример #5
0
 def build(self):
     self.title = "Blackjack"
     self.parent = Widget()  
     sm = ScreenManager()
     
     
     # set up the screens
     
     #splashcreen
     self.ss = Screen(name = 'splash_screen')
     splashmenu = SplashScreen()
     splashmenu.buildUp()
     self.ss.add_widget(splashmenu)
     
     #main menu
     self.mm = Screen(name = 'main_menu')
     self.mainmenu = MainMenu()
     self.mainmenu.buildUp()
     self.mm.add_widget(self.mainmenu)
     
     #add the logo to mainmenu and splashscreen
     logo = Image(source = 'images/logo.png')
     logo.width = Window.width/2
     logo.height = Window.height/2
     logo.x = Window.width/2 - (logo.width-logo.width*.05)
     logo.y = (Window.height/2 - logo.width/2)
     self.mm.add_widget(logo)
    
  
     #game screen
     
     self.gs = Game(name = 'game')
     
   
     
     #Add screens to screen manager
     sm.add_widget(self.ss)
     sm.add_widget(self.mm)
     sm.add_widget(self.gs)
     
     sm.current = 'main_menu'
     
     def check_screen_change(obj):
         if(self.mainmenu.buttonText == 'Play'):
             sm.current = 'game'
             self.gs.start_round()
             
             
     self.mainmenu.bind(on_button_release = check_screen_change)
     
     return sm
    def __init__(self, height: int, **kwargs):
        super(TopBar, self).__init__(**kwargs)
        topBack = Image()
        topBack.color = [0, 0, 0, 1]
        topBack.width = Window.size[0]
        topBack.height = height
        self.add_widget(topBack)

        self.__grid = GridLayout()
        self.__grid.cols = 10
        self.__grid.rows = 1
        self.__grid.width = Window.size[0]
        self.__grid.height = height
        self.add_widget(self.__grid)
    def __init__(self, height: int, backCallback: callable, homeCallback: callable, **kwargs):
        super(BottomBar, self).__init__(**kwargs)

        bottomBack = Image()
        bottomBack.color = [0, 0, 0, 1]
        bottomBack.width = Window.size[0]
        bottomBack.height = height
        self.add_widget(bottomBack)

        btnGrid = GridLayout()
        btnGrid.cols = 5
        btnGrid.rows = 1
        btnGrid.width = Window.size[0]
        btnGrid.height = height
        self.add_widget(btnGrid)

        btnBack = Button(text="Back")
        btnBack.bind(on_press=lambda instance: backCallback())
        btnGrid.add_widget(btnBack, 0)

        btnHome = Button(text="Home")
        btnHome.bind(on_press=lambda instance: homeCallback())
        btnGrid.add_widget(btnHome, 1)
Пример #8
0
    def __init__(self, sound, audio_engine, nb_steps, track_source,
                 steps_left_align, **kwargs):
        super(TrackWidget, self).__init__(**kwargs)

        self.audio_engine = audio_engine
        self.sound = sound
        self.track_source = track_source

        sound_and_separtor_layout = BoxLayout()
        sound_and_separtor_layout.size_hint_x = None
        sound_and_separtor_layout.width = steps_left_align
        self.add_widget(sound_and_separtor_layout)

        sound_button = TrackSoundButton()
        sound_button.text = sound.displayname
        sound_button.on_press = self.on_sound_button_press
        sound_and_separtor_layout.add_widget(sound_button)

        # separateur
        separator_image = Image(source="images/track_separator.png")
        separator_image.size_hint_x = None
        separator_image.width = dp(15)
        sound_and_separtor_layout.add_widget(separator_image)

        # self.track_source = audio_engine.create_track(sound.samples, 120)
        self.step_buttons = []
        self.nb_steps = nb_steps
        for i in range(0, nb_steps):
            step_button = TrackStepButton()
            if int(i / 4) % 2 == 0:
                step_button.background_normal = "images/step_normal1.png"
            else:
                step_button.background_normal = "images/step_normal2.png"
            step_button.bind(state=self.on_step_button_state)
            self.step_buttons.append(step_button)
            self.add_widget(step_button)
Пример #9
0
    def build(self):
        root = BoxLayout(orientation='vertical',
                         padding='5dp',
                         size_hint=(1, None))
        root.size_y = '100dp'
        with root.canvas:
            Color(.88, .88, .88)
            Rectangle(pos=root.pos, size=root.size)

        b = BoxLayout(size_hint=(1, 1))
        ai = BoxLayout()
        i1 = Image(size_hint=(None, None),
                   source=paths.images +
                   'flags/{}.png'.format(self.item.short))
        ai.add_widget(i1)
        i1.width = '90dp'
        i1.height = '90dp'

        b.add_widget(ai)

        g = BoxLayout(spacing='30dp', orientation='vertical')

        a1 = AnchorLayout()
        l1 = Label(color=(0, 0, 0, 1),
                   font_size='20dp',
                   text=(self.item.short + ' ' + str(self.item.rate[0]) + ' ' +
                         self.item.symbol + ' – ' +
                         '{0:.2f}'.format(self.item.rate[1]) + ' Br'))
        a1.add_widget(l1)

        a2 = AnchorLayout()
        l2 = Label(color=(0, 0, 0, 1), font_size='20dp', text=self.item.name)
        a2.add_widget(l2)

        g.add_widget(a1)
        g.add_widget(a2)
        b.add_widget(g)

        root.star = Button(size_hint=(None, None))
        root.star.width = '80dp'
        root.star.height = '80dp'

        root.star.on_press = self.fav
        # star.background_down = 'images\\appIcons\\star.png'
        if self.item.fav_s:
            s = paths.images + 'appIcons/starT.png'
        else:
            s = paths.images + 'appIcons/star.png'
        root.star.background_normal = s

        self.star = root.star
        b.add_widget(root.star)
        root.add_widget(b)

        a3 = AnchorLayout(anchor_x='center')
        l3 = Label(size_hint=(None, .1),
                   text=str(self.item.date),
                   color=(0, 0, 0, 1))
        a3.add_widget(l3)
        g.add_widget(a3)

        return root
Пример #10
0
    def entered(self):
        grid = self.children[0].children[0]
        grid.clear_widgets()

        self.books = []
        self.book_filepaths = [
            helper.get_resources_path() + "/books/" + b
            for b in os.listdir(helper.get_resources_path() + "/books/")
        ]
        self.titles = []
        if self.book_filepaths == []:
            grid.add_widget(Label(text="No books found :("))

        n = 0
        for b in self.book_filepaths:
            n += 1
            if n % 2 == 0:
                grid.height = 200 + n * 200

        n = 0
        for b in self.book_filepaths:
            n += 1

            button = Button(on_press=self.goto_read)
            button.size_hint = (None, None)
            button.size = (200, 200)
            self.children[0].children[0].add_widget(button)

            layout = BoxLayout()
            button.add_widget(layout)
            x = ((1 - (n % 2)) * 240) + 70
            y = grid.height - ((((n - 1) / 2) -
                                (((n - 1) / 2) % 1)) * 240) - 250
            layout.pos = (x, y)
            layout.size = button.size
            layout.orientation = "vertical"

            self.book_filename = b.split("/")[-1].split(".")[0]
            book = EPUBEE(b)
            cover = book.get_cover()

            if cover != "":
                cover_path = helper.get_app_path(
                ) + APP_NAME + "/covers/" + self.book_filename + ".jpeg"
                cover.save(cover_path)
                self.books.append(book)

                img = Image(source=cover_path)
                img.size_hint_x = None
                img.width = 100
                img.height = 100

            if len(book.title) > 18:
                text = book.title[:15] + "..."
            else:
                text = book.title
            self.titles.append(text)

            lbl = Label(text=text,
                        color=[.5, .5, .5, 1],
                        size_hint=(None, None),
                        pos=(button.pos[0], button.pos[1]))
            if cover != "":
                layout.add_widget(img)
                print("adding")

            layout.add_widget(lbl)
Пример #11
0
    def show_startup(self):
        startPop = Popup(title='Help',
                         auto_dismiss=True,
                         size_hint=(0.9, 0.4),
                         separator_color=(0, 0, 1, 1),
                         title_align='center',
                         title_color=(1, 1, 1, 1),
                         title_size='16sp',
                         title_font='fonts/Fcarbim.ttf')

        layStart = GridLayout(cols=2, spacing=10)
        but_playNextCards = Image(source='icons/PlayDown.png')
        but_playNextCards.size_hint = (None, 1)
        but_playNextCards.width = '40dp'

        lbl_playNextCards = Label(text=' Play current cards')
        lbl_playNextCards.halign = 'left'
        lbl_playNextCards.valign = 'middle'
        lbl_playNextCards.bind(size=lbl_playNextCards.setter('text_size'))

        but_startGame = Image(source='icons/ShuffleCardsDown.png')
        but_startGame.size_hint = (None, 1)
        but_startGame.width = '40dp'

        lbl_startGame = Label(text=' Start new game')
        lbl_startGame.halign = 'left'
        lbl_startGame.valign = 'middle'
        lbl_startGame.bind(size=lbl_startGame.setter('text_size'))

        but_duration = Image(source='icons/noofcards.png')
        but_duration.size_hint = (None, 1)
        but_duration.width = '40dp'

        lbl_duration = Label(text=' How many cards to play')
        lbl_duration.halign = 'left'
        lbl_duration.valign = 'middle'
        lbl_duration.bind(size=lbl_duration.setter('text_size'))

        but_background = Image(source='icons/but_backofcards.png')
        but_background.size_hint = (None, 1)
        but_background.width = '40dp'

        lbl_background = Label(text=' Change the background')
        lbl_background.halign = 'left'
        lbl_background.valign = 'middle'
        lbl_background.bind(size=lbl_background.setter('text_size'))

        but_exit = Image(source='icons/Exit.png')
        but_exit.size_hint = (None, 1)
        but_exit.width = '40dp'

        lbl_exit = Label(text=' Exit game')
        lbl_exit.halign = 'left'
        lbl_exit.valign = 'middle'
        lbl_exit.bind(size=lbl_exit.setter('text_size'))

        layStart.add_widget(but_playNextCards)
        layStart.add_widget(lbl_playNextCards)
        layStart.add_widget(but_startGame)
        layStart.add_widget(lbl_startGame)
        layStart.add_widget(but_duration)
        layStart.add_widget(lbl_duration)
        layStart.add_widget(but_background)
        layStart.add_widget(lbl_background)
        layStart.add_widget(but_exit)
        layStart.add_widget(lbl_exit)
        startPop.add_widget(layStart)
        startPop.open()
Пример #12
0
    def build(self):
        root = BoxLayout(orientation='vertical',
                         padding='5dp',
                         size_hint=(1, None))
        root.size_y = '100dp'
        with root.canvas:
            Color(.88, .88, .88)
            Rectangle(pos=root.pos, size=root.size)

        b = BoxLayout(size_hint=(1, 1))
        ai = BoxLayout(size_hint=(.3, 1))
        i1 = Image(size_hint=(None, None),
                   source=paths.images +
                   'crypts/{}.svg'.format(self.item.short))
        i1.width = '60dp'
        i1.height = '60dp'
        ai.add_widget(i1)

        b.add_widget(ai)

        g1 = BoxLayout(spacing='40dp', padding='40dp')

        # полное имя
        a1 = AnchorLayout(anchor_x='left', anchor_y='center', padding='10dp')
        l1 = Label(size_hint=(None, None),
                   color=(0, 0, 0, 1),
                   font_size='20dp',
                   text=self.item.name)
        l1.valign = 'middle'
        l1.halign = 'left'
        a1.add_widget(l1)
        # цена
        a3 = AnchorLayout(anchor_x='right', anchor_y='center', padding='10dp')
        l3 = Label(size_hint=(None, None),
                   color=(0, 0, 0, 1),
                   font_size='20dp',
                   text='{0:.2f}'.format(self.item.rate) + '$')
        l3.valign = 'middle'
        l3.halign = 'right'
        a3.add_widget(l3)

        g1.add_widget(a1)
        g1.add_widget(a3)

        g2 = BoxLayout(spacing='40dp', padding='40dp')
        # короткое имя
        a2 = AnchorLayout(anchor_x='left', anchor_y='center', padding='10dp')
        l2 = Label(size_hint=(None, None),
                   color=(0, 0, 0, 1),
                   font_size='20dp',
                   text=self.item.short)
        l2.valign = 'middle'
        l2.halign = 'left'
        a2.add_widget(l2)
        g2.add_widget(a2)

        a4 = AnchorLayout(anchor_x='right', anchor_y='center', padding='10dp')
        l4 = Label(size_hint=(None, None),
                   text=str(self.item.date),
                   color=(0, 0, 0, 1))
        l4.valign = 'middle'
        l4.halign = 'left'
        a4.add_widget(l4)
        g2.add_widget(a4)

        b0 = BoxLayout(spacing='40dp', orientation='vertical')

        b0.add_widget(g1)
        b0.add_widget(g2)
        b.add_widget(b0)
        root.add_widget(b)

        return root