Example #1
0
 def generate_restart_button(self, *args):
     restart = Button(background_color=get_color_from_hex('EC9449'))
     restart.curve = 25
     set_color(restart, get_color_from_hex('EC9449'))
     restart.image.source = 'assets/images/refresh.png'
     restart.bind(on_press=self.go)
     return restart
 def _update_specific_text_color(self, instance, value):
     if hasattr(self, 'theme_cls'):
         palette = {'Primary': self.theme_cls.primary_palette,
                    'Accent': self.theme_cls.accent_palette
                    }.get(self.background_palette, self.background_palette)
     else:
         palette = {'Primary': 'Blue',
                    'Accent': 'Amber'
                    }.get(self.background_palette, self.background_palette)
     if text_colors[palette].get(self.background_hue):
         color = get_color_from_hex(text_colors[palette]
                                    [self.background_hue])
     else:
         # Some palettes do not have 'A100', 'A200', 'A400', 'A700'
         # In that situation just default to using 100/200/400/700
         hue = self.background_hue[1:]
         color = get_color_from_hex(text_colors[palette][hue])
     secondary_color = color[:]
     # Check for black text (need to adjust opacity)
     if (color[0] + color[1] + color[2]) == 0:
         color[3] = 0.87
         secondary_color[3] = 0.54
     else:
         secondary_color[3] = 0.7
     self.specific_text_color = color
     self.specific_secondary_text_color = secondary_color
Example #3
0
	def set_clearcolor_by_theme_style(self, theme_style):
		if theme_style == 'Light':
			Window.clearcolor = get_color_from_hex(
					colors['Light']['Background'])
		elif theme_style == 'Dark':
			Window.clearcolor = get_color_from_hex(
					colors['Dark']['Background'])
Example #4
0
 def update_canvas(self, *args):
     self.canvas.after.clear()  # TODO mirar si es necesario si no pintamos
     self.canvas.before.clear()
     for p in self.horario.pasadas_widget():
         with self.canvas.before:
             y = self.y + self.height \
                 - p['start']*self.height - p['len']*self.height
             h = p['len']*self.height
             pos = (self.x, y)
             size = (self.width, h)
             if p['task'] == 'Ejecutivo':
                 # color = get_color_from_hex('#FF880088')
                 color = get_color_from_hex('#888888')
             elif p['task'] == 'Ayudante':
                 # color = get_color_from_hex('#CC000088')
                 color = get_color_from_hex('#444444')
             if p['task'] != 'Libre':
                 Color(*color)
                 Rectangle(pos=pos, size=size)
         with self.canvas.after:
             Color(1, 1, 1)
             # Line(rectangle=pos+size)
     with self.canvas.before:
         h = 10
         pos = (self.x,
                self.y + self.height - self.timepos*self.height - h/2)
         size = (self.width, h)
         self.tpc = Color(1, .1, .1, self.alpha)
         # Color(self.alpha, self.alpha, self.alpha, 1)
         self.tp = Rectangle(pos=pos, size=size)
Example #5
0
 def __init__(self, text, **kwargs):
     super(Tile, self).__init__(**kwargs)
     self.font_size = 0.5 * self.width
     self.text = text
     if self.text == 'O':
         self.text_color = get_color_from_hex(colors[3])
     elif self.text == 'X':
         self.text_color == get_color_from_hex(colors[1])
Example #6
0
 def _get_md_bg_color_down(self):
     if self.theme_cls.theme_style == 'Dark':
         c = get_color_from_hex('cccccc')
         c[3] = 0.25
     else:
         c = get_color_from_hex('999999')
         c[3] = 0.4
     return c
Example #7
0
	def _get_icon_color(self, opposite=False):
		theme_style = self._get_theme_style(opposite)
		if theme_style == 'Light':
			color = get_color_from_hex('000000')
			color[3] = .54
		elif theme_style == 'Dark':
			color = get_color_from_hex('FFFFFF')
		return color
Example #8
0
 def _get_icon_color(self, opposite=False):
     theme_style = self._get_theme_style(opposite)
     if theme_style == "Light":
         color = get_color_from_hex("000000")
         color[3] = 0.54
     elif theme_style == "Dark":
         color = get_color_from_hex("FFFFFF")
     return color
Example #9
0
 def generate_sound_button(self, *args):
     sound = Button(background_color=get_color_from_hex('EC9449'))
     sound.curve = 25
     set_color(sound, get_color_from_hex('EC9449'))
     sound.image.source = 'assets/images/sound_%s.png' % (
         SOUND and 'on' or 'off'
     )
     sound.bind(on_press=self.change_sound)
     return sound
Example #10
0
	def _get_disabled_hint_text_color(self, opposite=False):
		theme_style = self._get_theme_style(opposite)
		if theme_style == 'Light':
			color = get_color_from_hex('000000')
			color[3] = .26
		elif theme_style == 'Dark':
			color = get_color_from_hex('FFFFFF')
			color[3] = .30
		return color
Example #11
0
 def go(self,screen):
     if screen=="about":
         cnt=BoxLayout(padding=0,spacing=0)
         lbl=Label(text="  [size=20]pyPuzzle Game[/size]\n\nSimple fun memory game\n\n"
                        "Match simple jelly images\n\nEnter your scores.\n\n"
                        "www.yahyakesenek.com @2016",markup=True)
         cnt.add_widget(lbl)
         modal=ModalView(size_hint=(0.7,0.5),background_color=get_color_from_hex("#ff7373"))
         modal.add_widget(cnt)
         modal.open()
         modal.x=self.root.x-modal.width-10
         anim=Animation(center_x=self.root.center_x,center_y=self.root.center_y,d=2,t="out_expo")
         anim.start(modal)
         return
     if screen=="settings":
         cnt=BoxLayout()
         lbl=Label(text="Set Sound Volume :")
         sld=Slider(max=100,min=0,value=25)
         sld.bind(value=self.value_change)
         cnt.add_widget(lbl);cnt.add_widget(sld)
         modal=ModalView(size_hint=(0.8,0.2),background_color=get_color_from_hex("#ff7373"))
         modal.add_widget(cnt)
         modal.open()
         modal.x=self.root.x+modal.width+10
         anim=Animation(center_x=self.root.center_x,center_y=self.root.center_y,d=2,t="out_expo")
         anim.start(modal)
         self.sld=sld
         return
     if screen=="exit":
         cnt=BoxLayout(size_hint=(0.8,0.5),padding=4,spacing=5)
         lbl=Label(text="[size=35][color=#ae5a41]Quit?[/color][/size]",markup=True)
         btnyes=Button(text="Yes")
         btnno=Button(text="No")
         modal=ModalView(size_hint=(0.8,0.2))
         def quit(inst):
             exit()
         def cancel(inst):
             if modal:
                 modal.dismiss()
                 if self.root.current=="game_screen":
                     self.root.current_screen.newGame()
         btnyes.bind(on_release=quit)
         btnno.bind(on_release=cancel)
         cnt.add_widget(lbl)
         cnt.add_widget(btnyes)
         cnt.add_widget(btnno)
         modal.add_widget(cnt)
         modal.open()
         return
     if screen=="end_screen":
         self.level=1
     self.root.current=screen
     if self.root.current=="main_screen":
         if self.snd.state=="stop":
             self.snd.play()
     else:
         self.snd.stop()
Example #12
0
 def _get_disabled_hint_text_color(self, opposite=False):
     theme_style = self._get_theme_style(opposite)
     if theme_style == "Light":
         color = get_color_from_hex("000000")
         color[3] = 0.26
     elif theme_style == "Dark":
         color = get_color_from_hex("FFFFFF")
         color[3] = 0.30
     return color
Example #13
0
    def __init__(self, dest_manager, **kw):
        super(InField, self).__init__(**kw)

        self.dest_manager = dest_manager
        self.arrow = Arrow(
            start=self,
            color=[.2, .2, .2, .6],
            start_color=get_color_from_hex('#c8282d'),
            end_color=get_color_from_hex('#21a6a5'))
        self.add_widget(self.arrow)
Example #14
0
    def search(self):
        if self.searchFlag:
            return
        self.ids.container.clear_widgets()

        self.ids.by_day.background_color = get_color_from_hex('#5D535E')
        self.ids.by_cat.background_color = get_color_from_hex('#5D535E')
        self.ids.by_search.background_color = get_color_from_hex('#669999')
        self.ids.search_holder.size_hint=(1, 0.07)
        self.ids.search_holder.add_widget(SearchInput(search_text=""))
        self.searchFlag = True
Example #15
0
    def update_label(self, *args):
        capital_label = self.ids['capital_label']
        capital_label.text = self.ids['textbox'].text.upper()

        lower_label = self.ids['lower_label']
        lower_label.text = self.ids['textbox'].text.lower()

        red_label = self.ids['red_label']
        red_label.color = get_color_from_hex('#f4433')

        green_label = self.ids['green_label']
        green_label.color = get_color_from_hex('#1de9b6')

        blue_label = self.ids['blue_label']
        blue_label.color = get_color_from_hex('#03a9f4')
Example #16
0
	def _set_colors(self, *args):
		self._track_color_normal = self.theme_cls.disabled_hint_text_color
		if self.theme_cls.theme_style == 'Dark':
			self._track_color_active = self.theme_cls.primary_color
			self._track_color_active[3] = .5
			self._track_color_disabled = get_color_from_hex('FFFFFF')
			self._track_color_disabled[3] = .1
			self.thumb_color = get_color_from_hex(colors['Grey']['400'])
			self.thumb_color_down = get_color_from_hex(colors[self.theme_cls.primary_palette]['200'])
			self.thumb_color_disabled = get_color_from_hex(colors['Grey']['800'])
		else:
			self._track_color_active = get_color_from_hex(colors[self.theme_cls.primary_palette]['200'])
			self._track_color_active[3] = .5
			self._track_color_disabled = self.theme_cls.disabled_hint_text_color
			self.thumb_color_down = self.theme_cls.primary_color
Example #17
0
	def _set_thumb_color(self, color, alpha=None):
		if len(color) == 2:
			self._thumb_color = get_color_from_hex(colors[color[0]][color[1]])
			if alpha:
				self._thumb_color[3] = alpha
		elif len(color) == 4:
			self._thumb_color = color
Example #18
0
 def generate_score_label(self, *args):
     label = Label(
         text=str(self.get_record()),
         color=get_color_from_hex('5BBEE5'),
         font_size=30)
     label.curve = 25
     return label
Example #19
0
    def __init__(self, **kwargs):
        super(MDFlatButton, self).__init__(**kwargs)
        self._bg_color_down = get_color_from_hex(
            colors[self.theme_cls.theme_style]['FlatButtonDown'])

        Clock.schedule_once(lambda x: self.ids._label.bind(
            texture_size=self.update_width_on_label_texture))
Example #20
0
 def generate_medal_label(self, *args):
     label = Label(
         color=get_color_from_hex('5BBEE5'),
         font_size=30, size_hint=(.7, 1))
     label.curve = 25
     label.image.source = 'assets/images/medal.png'
     return label
Example #21
0
 def _set_bg_color_disabled(self, color, alpha=None):
     if len(color) == 2:
         self._bg_color_disabled = get_color_from_hex(colors[color[0]][color[1]])
         if alpha:
             self._bg_color_disabled[3] = alpha
     elif len(color) == 4:
         self._bg_color_disabled = color
Example #22
0
    def _geojson_part_geometry(self, geometry, properties):
        from kivy.graphics import Mesh, Line, Color
        from kivy.graphics.tesselator import Tesselator, WINDING_ODD, TYPE_POLYGONS
        from kivy.utils import get_color_from_hex
        from kivy.metrics import dp
        tp = geometry["type"]
        graphics = []
        if tp == "Polygon":
            tess = Tesselator()
            for c in geometry["coordinates"]:
                xy = list(self._lonlat_to_xy(c))
                xy = flatten(xy)
                tess.add_contour(xy)

            tess.tesselate(WINDING_ODD, TYPE_POLYGONS)

            color = self._get_color_from(properties.get("color", "FF000088"))
            graphics.append(Color(*color))
            for vertices, indices in tess.meshes:
                graphics.append(Mesh(vertices=vertices,
                                     indices=indices,
                                     mode="triangle_fan"))

        elif tp == "LineString":
            stroke = get_color_from_hex(properties.get("stroke", "#ff000088"))
            stroke_width = dp(properties.get("stroke-width", 2))
            xy = list(self._lonlat_to_xy(geometry["coordinates"]))
            xy = flatten(xy)
            graphics.append(Color(*stroke))
            graphics.append(Line(points=xy, width=stroke_width))

        return graphics
Example #23
0
    def openinfo(self, *args):
        """
        Display element info into pop-up
        """

        boxpop = BoxLayout(orientation='vertical')

        description = Description()
        description.text = self.main.tip_info

        boxpop.add_widget(TitreDescription())
        boxpop.add_widget(description)

        usage = Usage()
        usage.text = self.main.apl_info

        boxpop.add_widget(TitreUsage())
        boxpop.add_widget(usage)
       
        popup = Popup(
            title=self.main.nametext,
            content=boxpop,
            separator_color=get_color_from_hex('42bd3bff'),
            title_size = 20,
            size_hint=(None, None),
            size=(640, 280))
        popup.open()
Example #24
0
    def build_penta(self, *largs):
        self.canvas.clear()
        pw = self.pw
        ph = self.ph
        s = self.string
        if pw == 0 or ph == 0 or s is None:
            return
        with self.canvas:
            Color(1, 1, 1, .1)
            Rectangle(pos=self.pos, size=self.size)

            if self.color is None:
                self.color = get_color_from_hex(penta_colors[self.pentak])

            step = min(self.width / 7, self.height / 7)
            ox, oy = self.pos

            Color(*self.color)
            size = (step, step)
            mx = (self.width - step * 5) / 2.
            my = (self.height - step * 5) / 2.
            ox += mx + (step * (5 - pw)) / 2.
            oy += my + (step * (5 - ph)) / 2.
            for ix in xrange(pw):
                for iy in xrange(ph):
                    if s[iy * pw + ix] != '1':
                        continue
                    x = ix * (step + 1)
                    y = iy * (step + 1)
                    Rectangle(pos=(ox + x, oy + y), size=size)
Example #25
0
    def redraw_widget(self, *args):
        '''Method of redraw this widget.'''

        with self.canvas.before:
            self.canvas.before.clear()
            Color(*get_color_from_hex(self.background_color))
            Rectangle(pos=(self.x, self.y + 1), size=self.size)
Example #26
0
 def __init__(self, filename, viewport, scale):
     super(TileMapWidget, self).__init__()
     self.map = TileMap.load(filename, viewport, scale)
     self.size = (self.map.px_width, self.map.px_height)
     with self.canvas:
         for layer in self.map.layers:
             if hasattr(layer, 'color') and layer.color:
                 c = get_color_from_hex(layer.color)
                 c[-1] = .2
                 Color(*c)
             else:
                 Color(1, 1, 1)
             if not layer.visible:
                 continue
             for cell in layer:
                 if cell is None:
                     continue
                 x = cell.px
                 # OpenGL vs. TMX, y is reversed
                 y = self.map.scaled_height - cell.py - self.map.scaled_tile_height
                 if cell.tile:
                     texture = cell.tile.texture
                     size = cell.px_width, cell.px_height
                     Rectangle(pos=(x, y), texture=texture, size=size, allow_stretch=True)
                 else:
                     Rectangle(pos=(cell.px, cell.py), size=(cell.width, cell.height))
     self.set_focus(0, 0)
Example #27
0
def get_rgba_color(color_tuple):
    color, weight = color_tuple
    try:
        return get_color_from_hex(colors[color][weight])
    except:
        print('Error: ' + color + weight + ' not found, set to default')
        return (1., 1., 1., 1.)
Example #28
0
    def check_update(self, *args):
        release_link = "https://github.com/RedXBeard/kivy-1010/releases/latest"
        try:
            resp = urlopen(release_link)
            current_version = int("".join(resp.url.split("/")[-1].split(".")))
            lbl = Label(
                text="Already in Newest Version", shorten=True,
                strip=True, font_size=14, color=(0, 0, 0, 1))
            if current_version > int("".join(__version__.split('.'))):
                lbl.text = ("Newer Version Released please check\n"
                            "[color=3148F5][i][ref=https://github"
                            ".com/RedXBeard/kivy-1010]Kivy1010"
                            "[/ref][/i][/color]")
                lbl.bind(on_ref_press=self.open_page)

                layout = GridLayout(
                    cols=1, rows=1, spacing=(10, 10), padding=(3, 6, 3, 6))
                layout.add_widget(lbl)

                self.info_popup = Popup(
                    content=layout, size_hint=(None, None), size=(300, 200),
                    title='Kivy 1010', title_color=(0, 0, 0, 1),
                    border=(0, 0, 0, 0), auto_dismiss=True,
                    separator_color=get_color_from_hex('7B8ED4'))
                self.info_popup.open()
        except URLError:
            pass
Example #29
0
    def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, 0.9),
            width=popup_width)

        self.colorpicker = colorpicker = \
            ColorPicker(color=utils.get_color_from_hex(self.value))
        colorpicker.bind(on_color=self._validate)

        self.colorpicker = colorpicker
        content.add_widget(colorpicker)
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open()
Example #30
0
 def __init__(self, gradient=False, line=False, **kwargs):
     super(PipLabel, self).__init__(**kwargs)
     self.font_name = "monofonto.ttf"
     self.font_size = "13sp"
     self.background_color = [1, 1, 1, 0]
     self.color = get_color_from_hex("#64FEB5")
     with self.canvas:
         Color(100 / 256.0, 254 / 256.0, 181 / 256.0)
         if line:
             Line(
                 width=1.3, points=[self.x - 3, self.height + self.y, self.x + self.width + 6, self.height + self.y]
             )
         if gradient:
             aux = 0
             for x in range(1, 9):
                 Color(100 / 256.0, 254 / 256.0, 181 / 256.0, 0.9 - x / 10.0)
                 Line(
                     width=1.3,
                     points=[
                         self.x + self.width + 6,
                         self.height + self.y - aux,
                         self.x + self.width + 6,
                         self.height + self.y - aux - 2,
                     ],
                 )
                 aux += 2
Example #31
0
class MDSwitch(ThemableBehavior, ButtonBehavior, FloatLayout):
    active = BooleanProperty(False)
    """
    Indicates if the switch is active or inactive.

    :attr:`active` is a :class:`~kivy.properties.BooleanProperty`
    and defaults to `False`.
    """

    _thumb_color = ColorProperty(get_color_from_hex(colors["Gray"]["50"]))

    def _get_thumb_color(self):
        return self._thumb_color

    def _set_thumb_color(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color = get_color_from_hex(colors[color[0]][color[1]])
            if alpha:
                self._thumb_color[3] = alpha
        elif len(color) == 4:
            self._thumb_color = color

    thumb_color = AliasProperty(_get_thumb_color,
                                _set_thumb_color,
                                bind=["_thumb_color"])
    """
    Get thumb color ``rgba`` format.

    :attr:`thumb_color` is an :class:`~kivy.properties.AliasProperty`
    and property is readonly.
    """

    _thumb_color_down = ColorProperty([1, 1, 1, 1])

    def _get_thumb_color_down(self):
        return self._thumb_color_down

    def _set_thumb_color_down(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color_down = get_color_from_hex(
                colors[color[0]][color[1]])
            if alpha:
                self._thumb_color_down[3] = alpha
            else:
                self._thumb_color_down[3] = 1
        elif len(color) == 4:
            self._thumb_color_down = color

    _thumb_color_disabled = ColorProperty(
        get_color_from_hex(colors["Gray"]["400"]))

    thumb_color_disabled = get_color_from_hex(colors["Gray"]["800"])
    """
    Get thumb color disabled ``rgba`` format.

    :attr:`thumb_color_disabled` is an :class:`~kivy.properties.AliasProperty`
    and property is readonly.
    """

    def _get_thumb_color_disabled(self):
        return self._thumb_color_disabled

    def _set_thumb_color_disabled(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color_disabled = get_color_from_hex(
                colors[color[0]][color[1]])
            if alpha:
                self._thumb_color_disabled[3] = alpha
        elif len(color) == 4:
            self._thumb_color_disabled = color

    thumb_color_down = AliasProperty(
        _get_thumb_color_disabled,
        _set_thumb_color_disabled,
        bind=["_thumb_color_disabled"],
    )
    """
    Get thumb color down ``rgba`` format.

    :attr:`thumb_color_down` is an :class:`~kivy.properties.AliasProperty`
    and property is readonly.
    """

    theme_thumb_color = OptionProperty("Primary",
                                       options=["Primary", "Custom"])
    """
    Thumb color scheme name

    :attr:`theme_thumb_color` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `Primary`.
    """

    theme_thumb_down_color = OptionProperty("Primary",
                                            options=["Primary", "Custom"])
    """
    Thumb Down color scheme name

    :attr:`theme_thumb_down_color` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `Primary`.
    """

    _track_color_active = ColorProperty([0, 0, 0, 0])
    _track_color_normal = ColorProperty([0, 0, 0, 0])
    _track_color_disabled = ColorProperty([0, 0, 0, 0])
    _thumb_pos = ListProperty([0, 0])

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.theme_cls.bind(
            theme_style=self._set_colors,
            primary_color=self._set_colors,
            primary_palette=self._set_colors,
        )
        self.bind(active=self._update_thumb_pos)
        Clock.schedule_once(self._set_colors)
        self.size_hint = (None, None)
        self.size = (dp(36), dp(48))

    def _set_colors(self, *args):
        self._track_color_normal = self.theme_cls.disabled_hint_text_color
        if self.theme_cls.theme_style == "Dark":

            if self.theme_thumb_down_color == "Primary":
                self._track_color_active = self.theme_cls.primary_color
            else:
                self._track_color_active = self.thumb_color_down

            self._track_color_active[3] = 0.5
            self._track_color_disabled = get_color_from_hex("FFFFFF")
            self._track_color_disabled[3] = 0.1

            if self.theme_thumb_color == "Primary":
                self.thumb_color = get_color_from_hex(colors["Gray"]["400"])

            if self.theme_thumb_down_color == "Primary":
                self.thumb_color_down = get_color_from_hex(
                    colors[self.theme_cls.primary_palette]["200"])
        else:
            if self.theme_thumb_down_color == "Primary":
                self._track_color_active = get_color_from_hex(
                    colors[self.theme_cls.primary_palette]["200"])
            else:
                self._track_color_active = self.thumb_color_down

            self._track_color_active[3] = 0.5
            self._track_color_disabled = self.theme_cls.disabled_hint_text_color

            if self.theme_thumb_down_color == "Primary":
                self.thumb_color_down = self.theme_cls.primary_color

            if self.theme_thumb_color == "Primary":
                self.thumb_color = get_color_from_hex(colors["Gray"]["50"])

    def _update_thumb_pos(self, *args, animation=True):
        if self.active:
            _thumb_pos = (self.width - dp(14), self.height / 2 - dp(12))
        else:
            _thumb_pos = (0, self.height / 2 - dp(12))
        Animation.cancel_all(self, "_thumb_pos")
        if animation:
            Animation(_thumb_pos=_thumb_pos, duration=0.2,
                      t="out_quad").start(self)
        else:
            self._thumb_pos = _thumb_pos

    def on_size(self, *args):
        self._update_thumb_pos(animation=False)
Example #32
0
class RedButton(RoundedButton):
    UNPRESSED_COLOR = StringProperty(get_color_from_hex("#ff000d"))
    PRESSED_COLOR = StringProperty(get_color_from_hex("#be0119"))
Example #33
0
class GreenButton(RoundedButton):
    UNPRESSED_COLOR = StringProperty(get_color_from_hex("#21fc0d"))
    PRESSED_COLOR = StringProperty(get_color_from_hex("#048243"))
    FONT_COLOR = StringProperty(get_color_from_hex("#000000"))
Example #34
0
 def _get_bg_light(self, opposite=False):
     theme_style = self._get_theme_style(opposite)
     if theme_style == "Light":
         return get_color_from_hex(colors["Light"]["CardsDialogs"])
     elif theme_style == "Dark":
         return get_color_from_hex(colors["Dark"]["CardsDialogs"])
Example #35
0
class MDSwitch(ThemableBehavior, ButtonBehavior, FloatLayout):
    active = BooleanProperty(False)

    _thumb_color = ListProperty(get_color_from_hex(colors["Gray"]["50"]))

    def _get_thumb_color(self):
        return self._thumb_color

    def _set_thumb_color(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color = get_color_from_hex(colors[color[0]][color[1]])
            if alpha:
                self._thumb_color[3] = alpha
        elif len(color) == 4:
            self._thumb_color = color

    thumb_color = AliasProperty(_get_thumb_color,
                                _set_thumb_color,
                                bind=["_thumb_color"])

    _thumb_color_down = ListProperty([1, 1, 1, 1])

    def _get_thumb_color_down(self):
        return self._thumb_color_down

    def _set_thumb_color_down(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color_down = get_color_from_hex(
                colors[color[0]][color[1]])
            if alpha:
                self._thumb_color_down[3] = alpha
            else:
                self._thumb_color_down[3] = 1
        elif len(color) == 4:
            self._thumb_color_down = color

    thumb_color_down = AliasProperty(_get_thumb_color_down,
                                     _set_thumb_color_down,
                                     bind=["_thumb_color_down"])

    _thumb_color_disabled = ListProperty(
        get_color_from_hex(colors["Gray"]["400"]))

    thumb_color_disabled = get_color_from_hex(colors["Gray"]["800"])

    def _get_thumb_color_disabled(self):
        return self._thumb_color_disabled

    def _set_thumb_color_disabled(self, color, alpha=None):
        if len(color) == 2:
            self._thumb_color_disabled = get_color_from_hex(
                colors[color[0]][color[1]])
            if alpha:
                self._thumb_color_disabled[3] = alpha
        elif len(color) == 4:
            self._thumb_color_disabled = color

    thumb_color_down = AliasProperty(
        _get_thumb_color_disabled,
        _set_thumb_color_disabled,
        bind=["_thumb_color_disabled"],
    )

    _track_color_active = ListProperty()
    _track_color_normal = ListProperty()
    _track_color_disabled = ListProperty()
    _thumb_pos = ListProperty([0, 0])

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.theme_cls.bind(
            theme_style=self._set_colors,
            primary_color=self._set_colors,
            primary_palette=self._set_colors,
        )
        self._set_colors()

    def _set_colors(self, *args):
        self._track_color_normal = self.theme_cls.disabled_hint_text_color
        if self.theme_cls.theme_style == "Dark":
            self._track_color_active = self.theme_cls.primary_color
            self._track_color_active[3] = 0.5
            self._track_color_disabled = get_color_from_hex("FFFFFF")
            self._track_color_disabled[3] = 0.1
            self.thumb_color = get_color_from_hex(colors["Gray"]["400"])
            self.thumb_color_down = get_color_from_hex(
                colors[self.theme_cls.primary_palette]["200"])
        else:
            self._track_color_active = get_color_from_hex(
                colors[self.theme_cls.primary_palette]["200"])
            self._track_color_active[3] = 0.5
            self._track_color_disabled = self.theme_cls.disabled_hint_text_color
            self.thumb_color_down = self.theme_cls.primary_color

    def on_pos(self, *args):
        if self.active:
            self._thumb_pos = (self.right - dp(12), self.center_y - dp(12))
        else:
            self._thumb_pos = (self.x - dp(12), self.center_y - dp(12))
        self.bind(active=self._update_thumb)

    def _update_thumb(self, *args):
        if self.active:
            Animation.cancel_all(self, "_thumb_pos")
            anim = Animation(
                _thumb_pos=(self.right - dp(12), self.center_y - dp(12)),
                duration=0.2,
                t="out_quad",
            )
        else:
            Animation.cancel_all(self, "_thumb_pos")
            anim = Animation(
                _thumb_pos=(self.x - dp(12), self.center_y - dp(12)),
                duration=0.2,
                t="out_quad",
            )
        anim.start(self)
Example #36
0
import time

from kivy.config import Config
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.uix.textinput import TextInput

Config.set('graphics', 'resizable', False)
Config.set('graphics', 'width', '1280')
Config.set('graphics', 'height', '720')
Config.set('input', 'mouse', 'mouse, multitouch_on_demand')

from kivy.core.window import Window
from kivy.utils import get_color_from_hex

Window.clearcolor = get_color_from_hex("#F2F2F2")

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.filechooser import FileChooserIconView
from kivy.uix.popup import Popup
from hurry.filesize import size, alternative
from layoutComponents import BorderBox, CustomLayout, RoundedButton, CustomTextInput
from layoutComponents import ClientsListUnselectable, ClientsList, FilesList, ReceivedFilesList

from kivy.uix.screenmanager import ScreenManager, Screen

sm = ScreenManager()
Example #37
0
class RoundedButton(Button):
    DISABLED_COLOR = get_color_from_hex("#9e9ea2")
    FONT_COLOR = get_color_from_hex("#ffffff")

    def collide_point(self, x, y):
        return Vector(x, y).distance(self.center) <= self.width / 2
Example #38
0
 def _get_primary_dark(self):
     return get_color_from_hex(
         colors[self.primary_palette][self.primary_dark_hue])
Example #39
0
 def on_release(self):
     if self.kind == 'plus':
         self.text_color = get_color_from_hex('#E74C3C')
     else:
         self.text_color = get_color_from_hex('#3498DB')
Example #40
0
 def _get_accent_light(self):
     return get_color_from_hex(
         colors[self.accent_palette][self.accent_light_hue])
Example #41
0
    def build(self):
        self.box = BoxLayout(orientation='horizontal', spacing=0)
        self.left_box = CustomLayout.CustomLayout(orientation='vertical',
                                                  spacing=10,
                                                  size_hint_x=None,
                                                  width=250)
        self.right_box = BoxLayout(orientation='vertical',
                                   spacing=10,
                                   padding=(20, -15, 10, 20))
        self.name_logo_box = BoxLayout(orientation='horizontal',
                                       spacing=60,
                                       size_hint=(None, None),
                                       height=110)

        self.app_logo = Image(source='resources/logo.png',
                              size_hint=(None, None),
                              size=(100, 100))

        self.client_list_label = Label(
            text="[color=#F2F2F2]File[b]Transfer[/b][/color]",
            font_size="25sp",
            size_hint=(1, None),
            height=90,
            markup=True)

        self.quit_button = Button(
            text="Quit",
            on_press=self.close_and_quit,
            size_hint=(1, .1),
            color=get_color_from_hex("#F2F2F2"),
            background_color=get_color_from_hex("#002140"),
            background_normal='')

        self.connected_clients_label = Label(text="Connected clients:",
                                             font_size="18sp",
                                             size_hint=(1, None),
                                             text_size=(250, 30),
                                             height=30,
                                             markup=True,
                                             halign='left')

        self.build_right_box()

        self.name_logo_box.add_widget(self.app_logo)
        self.name_logo_box.add_widget(self.client_list_label)
        self.connected_clients_label_box.add_widget(
            self.connected_clients_label)
        self.left_box.add_widget(self.name_logo_box)
        self.left_box.add_widget(self.connected_clients_label_box)
        self.left_box.add_widget(self.clients_list_unselectable)
        self.left_box.add_widget(self.quit_button)

        self.box.add_widget(self.left_box)
        self.box.add_widget(self.right_box)

        main_gui = Main_GUI(name="main")
        main_gui.build(self.box)

        self.login_box = CustomLayout.CustomLayout(orientation='vertical',
                                                   spacing=50,
                                                   padding=(0, 0, 0, 180))
        self.login_items_box = BoxLayout(orientation='vertical',
                                         spacing=10,
                                         size_hint=(1, .3))

        self.login_logo_box = BoxLayout(orientation="horizontal",
                                        spacing=0,
                                        size_hint=(1, None))
        self.login_app_logo_box = BoxLayout(size_hint=(.55, None),
                                            padding=(450, 0, 0, 0))

        self.login_app_logo = Image(source='resources/logo.png',
                                    size_hint=(None, None),
                                    height=150)

        self.login_app_logo_label = Label(
            text="[color=#F2F2F2]File[b]Transfer[/b][/color]",
            font_size="40sp",
            size_hint=(1, None),
            text_size=(640, 150),
            valign='middle',
            markup=True)

        self.login_app_logo_box.add_widget(self.login_app_logo)
        self.login_logo_box.add_widget(self.login_app_logo_box)
        self.login_logo_box.add_widget(self.login_app_logo_label)

        self.login_welcome = Label(text="Welcome",
                                   font_size="28sp",
                                   size_hint=(1, None),
                                   markup=True)

        self.login_text_input = CustomTextInput.CustomTextInput(
            on_text_validate=self.login,
            size=(500, 50),
            background_color=get_color_from_hex("#F2F2F2"),
            hint_text="Please insert an username (max of 14 characters long)",
            font_size='18dp')

        self.login_button = RoundedButton.RoundedButton(
            text="Login",
            size=(300, 60),
            font_size=18,
            on_release=self.login,
            color=get_color_from_hex("#F2F2F2"),
            border_radius=[30, 30, 30, 30],
            background_color=get_color_from_hex("#1890ff"))

        self.login_items_box.add_widget(self.login_logo_box)
        self.login_items_box.add_widget(self.login_welcome)
        self.login_items_box.add_widget(self.login_text_input)
        self.login_box.add_widget(self.login_items_box)
        self.login_box.add_widget(self.login_button)

        login_gui = Login_GUI(name="login")
        login_gui.build(self.login_box)

        sm.add_widget(login_gui)
        sm.add_widget(main_gui)

        return sm
Example #42
0
    def build_right_box(self):
        self.title_box = BoxLayout(orientation='horizontal',
                                   spacing=50,
                                   size_hint=(1, None),
                                   padding=(77, 0, 0, 0))

        if self.right_page == 'selected_files':
            first_title = 'Selected files'
            first_ref = 'selected_files'
            second_title = 'Received Files'
            second_ref = 'received_files'

            self.send_files_button = RoundedButton.RoundedButton(
                text="Select destinations",
                size_hint=(None, None),
                size=(170, 50),
                pos_hint={
                    'right': .96
                },
                color=get_color_from_hex("#F2F2F2"),
                background_color=get_color_from_hex("#1890ff"),
                font_size=18,
                border_radius=[5, 5, 5, 5],
                on_release=self.show_destinations_popup).build()

            self.connected_clients_label_box = BorderBox.BorderBox(
                orientation='horizontal',
                size_hint=(1, .1),
                padding=(20, 5, 5, 10),
                final_x=5,
                line_width=1.3).build()

        else:
            first_title = 'Received files'
            first_ref = 'received_files'
            second_title = 'Selected Files'
            second_ref = 'selected_files'

        self.files_list_label = Label(text="[u][b]" + first_title + "[/b][/u]",
                                      font_size=42,
                                      size_hint=(None, None),
                                      height=50,
                                      color=(0, 33 / 255, 64 / 255 / 1),
                                      markup=True)
        self.received_list_label = Label(text="[ref=" + second_ref + "]" +
                                         second_title + "[/ref]",
                                         font_size=42,
                                         size_hint=(None, None),
                                         width=1200,
                                         height=50,
                                         color=(0, 33 / 255, 64 / 255, .5),
                                         markup=True)
        self.received_list_label.bind(on_ref_press=self.select_right_page)

        self.header_box = BorderBox.BorderBox(orientation="horizontal",
                                              spacing=0,
                                              size_hint=(1, None),
                                              padding=(15, 0, 0, 0)).build()
        self.header_box.height = 30

        self.file_name_label = Label(text="Name",
                                     font_size=18,
                                     size_hint=(None, None),
                                     width=662,
                                     height=30,
                                     text_size=(662, None),
                                     halign='left',
                                     color=(0, 0, 0, .75))
        self.file_size_label = Label(text="Size",
                                     font_size=18,
                                     size_hint=(None, None),
                                     width=170,
                                     height=30,
                                     text_size=(100, None),
                                     halign='left',
                                     color=(0, 0, 0, .75))
        self.action_label = Label(text="Action",
                                  font_size=18,
                                  size_hint=(None, None),
                                  width=100,
                                  height=30,
                                  text_size=(100, None),
                                  halign='center',
                                  color=(0, 0, 0, .75))

        self.title_box.add_widget(self.files_list_label)
        self.title_box.add_widget(self.received_list_label)

        self.header_box.add_widget(self.file_name_label)
        self.header_box.add_widget(self.file_size_label)
        self.header_box.add_widget(self.action_label)

        self.right_box.add_widget(self.title_box)
        self.right_box.add_widget(self.header_box)

        if self.right_page == 'selected_files':
            self.right_box.add_widget(self.files_list)
            self.right_box.add_widget(self.send_files_button)
        else:
            self.right_box.add_widget(self.received_files_list)
Example #43
0
 def _get_primary_light(self):
     return get_color_from_hex(
         colors[self.primary_palette][self.primary_light_hue])
Example #44
0
 def _get_accent_dark(self):
     return get_color_from_hex(
         colors[self.accent_palette][self.accent_dark_hue])
Example #45
0
 def on_tb_primary_palette(self, *args):
     """Changing MyToolbar md_bg_color."""
     self.md_bg_color = get_color_from_hex(
         colors[self.tb_primary_palette]["600"])
Example #46
0
 def update_md_bg_color(self, instance, value):
     if self.md_bg_color in self._bg_color_map:
         self.md_bg_color = get_color_from_hex(colors[value]["CardsDialogs"])
Example #47
0
                                         self.config,
                                         data=settings_json.read())

        with open(
                os.path.join(dirname, 'es_gui', 'resources', 'settings',
                             'btm.json'), 'r') as settings_json:
            self.settings.add_json_panel('QuESt BTM',
                                         self.config,
                                         data=settings_json.read())

        self.settings.bind(on_close=sm.settings_screen.dismiss)
        sm.settings_screen.settings_box.add_widget(self.settings)

        return bx

    def on_start(self):
        pass

    def on_stop(self):
        # Signal that the app is about to close
        self.root.stop.set()


if __name__ == '__main__':
    from kivy.core.window import Window

    # Sets window background color
    Window.clearcolor = get_color_from_hex('#FFFFFF')

    QuEStApp().run()
 def _set_hex(self, value):
     self.color = get_color_from_hex(value)[:4]
 def on_color(self, w, val):
     if "#" in val:
         val = "".join(val)
         self.color = get_color_from_hex(val)
     else:
         self.color = val
Example #50
0
    def go_forward(self):
        screen_manager = self.root.ids['screen_manager']
        screen_manager.transition = SlideTransition(direction="right")
        screen_manager.current = 'stopwatch_screen'

    def go_back(self):
        screen_manager = self.root.ids['screen_manager']
        screen_manager.transition = SlideTransition(direction="left")
        screen_manager.current = 'clock_screen'

    def start_stop(self):
        self.root.ids['stopwatch_screen'].ids[
            'start_stop'].text = 'Start' if self.sw_started else 'Stop'
        self.sw_started = not self.sw_started

    def reset(self):
        if self.sw_started:
            self.root.ids['stopwatch_screen'].ids['start_stop'].text = 'Start'
            self.sw_started = False
        self.sw_seconds = 0


if __name__ == "__main__":
    Window.borderless = True
    Window.clearcolor = get_color_from_hex('#101216')
    LabelBase.register(name='Roboto',
                       fn_regular='Roboto-Thin.ttf',
                       fn_bold='Roboto-Medium.ttf')
MainApp().run()
Example #51
0
 def on_style_name(self, *args):
     super(DesignerCodeInput, self).on_style_name(*args)
     self.background_color = get_color_from_hex(self.style.background_color)
     self._trigger_refresh_text()
Example #52
0
 def _get_error_color(self):
     return get_color_from_hex(colors["Red"]["A700"])
 def on_bg_color(self, root, val):
     if "#" in val:
         val = "".join(val)
         self.bg_color = get_color_from_hex(val)
     else:
         self.bg_color = val
Example #54
0
 def _get_bg_normal(self, opposite=False):
     theme_style = self._get_theme_style(opposite)
     if theme_style == "Light":
         return get_color_from_hex(colors["Light"]["Background"])
     elif theme_style == "Dark":
         return get_color_from_hex(colors["Dark"]["Background"])
Example #55
0
class MDCard(
    ThemableBehavior,
    BackgroundColorBehavior,
    RectangularElevationBehavior,
    FocusBehavior,
    BoxLayout,
    RectangularRippleBehavior,
):
    background = StringProperty()
    """
    Background image path.

    :attr:`background` is a :class:`~kivy.properties.StringProperty`
    and defaults to `''`.
    """

    focus_behavior = BooleanProperty(False)
    """
    Using focus when hovering over a card.

    :attr:`focus_behavior` is a :class:`~kivy.properties.BooleanProperty`
    and defaults to `False`.
    """

    ripple_behavior = BooleanProperty(False)
    """
    Use ripple effect for card.

    :attr:`ripple_behavior` is a :class:`~kivy.properties.BooleanProperty`
    and defaults to `False`.
    """

    elevation = NumericProperty(None, allownone=True)
    """
    Elevation value.

    :attr:`elevation` is an :class:`~kivy.properties.NumericProperty`
    and defaults to 1.
    """

    _bg_color_map = (
        get_color_from_hex(colors["Light"]["CardsDialogs"]),
        get_color_from_hex(colors["Dark"]["CardsDialogs"]),
        [1.0, 1.0, 1.0, 0.0],
    )

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.theme_cls.bind(theme_style=self.update_md_bg_color)
        Clock.schedule_once(lambda x: self._on_elevation(self.elevation))
        Clock.schedule_once(
            lambda x: self._on_ripple_behavior(self.ripple_behavior)
        )
        self.update_md_bg_color(self, self.theme_cls.theme_style)

    def update_md_bg_color(self, instance, value):
        if self.md_bg_color in self._bg_color_map:
            self.md_bg_color = get_color_from_hex(colors[value]["CardsDialogs"])

    def on_radius(self, instance, value):
        if self.radius != [0, 0, 0, 0]:
            self.background = f"{images_path}/transparent.png"

    def _on_elevation(self, value):
        if value is None:
            self.elevation = 6
        else:
            self.elevation = value

    def _on_ripple_behavior(self, value):
        self._no_ripple_effect = False if value else True
Example #56
0
class ThemeManager(EventDispatcher):
    primary_palette = OptionProperty("Blue", options=palette)
    """
    The name of the color scheme that the application will use.
    All major `material` components will have the color
    of the specified color theme.

    Available options are: `'Red'`, `'Pink'`, `'Purple'`, `'DeepPurple'`,
    `'Indigo'`, `'Blue'`, `'LightBlue'`, `'Cyan'`, `'Teal'`, `'Green'`,
    `'LightGreen'`, `'Lime'`, `'Yellow'`, `'Amber'`, `'Orange'`, `'DeepOrange'`,
    `'Brown'`, `'Gray'`, `'BlueGray'`.

    To change the color scheme of an application:

    .. code-block:: python

        from kivy.uix.screenmanager import Screen

        from kivymd.app import MDApp
        from kivymd.uix.button import MDRectangleFlatButton


        class MainApp(MDApp):
            def build(self):
                self.theme_cls.primary_palette = "Green"  # "Purple", "Red"

                screen = Screen()
                screen.add_widget(
                    MDRectangleFlatButton(
                        text="Hello, World",
                        pos_hint={"center_x": 0.5, "center_y": 0.5},
                    )
                )
                return screen


        MainApp().run()

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/primary-palette.png

    :attr:`primary_palette` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'Blue'`.
    """

    primary_hue = OptionProperty("500", options=hue)
    """
    The color hue of the application.

    Available options are: `'50'`, `'100'`, `'200'`, `'300'`, `'400'`, `'500'`,
    `'600'`, `'700'`, `'800'`, `'900'`, `'A100'`, `'A200'`, `'A400'`, `'A700'`.

    To change the hue color scheme of an application:

    .. code-block:: python

        from kivy.uix.screenmanager import Screen

        from kivymd.app import MDApp
        from kivymd.uix.button import MDRectangleFlatButton


        class MainApp(MDApp):
            def build(self):
                self.theme_cls.primary_palette = "Green"  # "Purple", "Red"
                self.theme_cls.primary_hue = "200"  # "500"

                screen = Screen()
                screen.add_widget(
                    MDRectangleFlatButton(
                        text="Hello, World",
                        pos_hint={"center_x": 0.5, "center_y": 0.5},
                    )
                )
                return screen


        MainApp().run()

    With a value of ``self.theme_cls.primary_hue = "500"``:

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/primary-palette.png

    With a value of ``self.theme_cls.primary_hue = "200"``:

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/primary-hue.png

    :attr:`primary_hue` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'500'`.
    """

    primary_light_hue = OptionProperty("200", options=hue)
    """
    Hue value for :attr:`primary_light`.

    :attr:`primary_light_hue` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'200'`.
    """

    primary_dark_hue = OptionProperty("700", options=hue)
    """
    Hue value for :attr:`primary_dark`.

    :attr:`primary_light_hue` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'700'`.
    """
    def _get_primary_color(self):
        return get_color_from_hex(
            colors[self.primary_palette][self.primary_hue])

    primary_color = AliasProperty(_get_primary_color,
                                  bind=("primary_palette", "primary_hue"))
    """
    The color of the current application theme in ``rgba`` format.

    :attr:`primary_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value of the current application theme, property is readonly.
    """

    def _get_primary_light(self):
        return get_color_from_hex(
            colors[self.primary_palette][self.primary_light_hue])

    primary_light = AliasProperty(_get_primary_light,
                                  bind=("primary_palette",
                                        "primary_light_hue"))
    """
    Colors of the current application color theme in ``rgba`` format
    (in lighter color).

    .. code-block:: python

        from kivy.lang import Builder

        from kivymd.app import MDApp


        KV = '''
        Screen:

            MDRaisedButton:
                text: "primary_light"
                pos_hint: {"center_x": 0.5, "center_y": 0.7}
                md_bg_color: app.theme_cls.primary_light

            MDRaisedButton:
                text: "primary_color"
                pos_hint: {"center_x": 0.5, "center_y": 0.5}

            MDRaisedButton:
                text: "primary_dark"
                pos_hint: {"center_x": 0.5, "center_y": 0.3}
                md_bg_color: app.theme_cls.primary_dark
        '''


        class MainApp(MDApp):
            def build(self):
                self.theme_cls.primary_palette = "Green"
                return Builder.load_string(KV)


        MainApp().run()

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/primary-colors-light-dark.png
        :align: center

    :attr:`primary_light` is an :class:`~kivy.properties.AliasProperty` that
    returns the value of the current application theme (in lighter color),
    property is readonly.
    """

    def _get_primary_dark(self):
        return get_color_from_hex(
            colors[self.primary_palette][self.primary_dark_hue])

    primary_dark = AliasProperty(_get_primary_dark,
                                 bind=("primary_palette", "primary_dark_hue"))
    """
    Colors of the current application color theme
    in ``rgba`` format (in darker color).

    :attr:`primary_dark` is an :class:`~kivy.properties.AliasProperty` that
    returns the value of the current application theme (in darker color),
    property is readonly.
    """

    accent_palette = OptionProperty("Amber", options=palette)
    """
    The application color palette used for items such as the tab indicator
    in the :attr:`MDTabsBar` class and so on...

    The image below shows the color schemes with the values
    ``self.theme_cls.accent_palette = 'Blue'``, ``Red'`` and​​ ``Yellow'``:

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/accent-palette.png

    :attr:`accent_palette` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'Amber'`.
    """

    accent_hue = OptionProperty("500", options=hue)
    """Similar to :attr:`primary_hue`,
    but returns a value for :attr:`accent_palette`.

    :attr:`accent_hue` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'500'`.
    """

    accent_light_hue = OptionProperty("200", options=hue)
    """
    Hue value for :attr:`accent_light`.

    :attr:`accent_light_hue` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'200'`.
    """

    accent_dark_hue = OptionProperty("700", options=hue)
    """
    Hue value for :attr:`accent_dark`.

    :attr:`accent_dark_hue` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'700'`.
    """

    def _get_accent_color(self):
        return get_color_from_hex(colors[self.accent_palette][self.accent_hue])

    accent_color = AliasProperty(_get_accent_color,
                                 bind=["accent_palette", "accent_hue"])
    """Similar to :attr:`primary_color`,
    but returns a value for :attr:`accent_color`.

    :attr:`accent_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`accent_color`,
    property is readonly.
    """

    def _get_accent_light(self):
        return get_color_from_hex(
            colors[self.accent_palette][self.accent_light_hue])

    accent_light = AliasProperty(_get_accent_light,
                                 bind=["accent_palette", "accent_light_hue"])
    """Similar to :attr:`primary_light`,
    but returns a value for :attr:`accent_light`.

    :attr:`accent_light` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`accent_light`,
    property is readonly.
    """

    def _get_accent_dark(self):
        return get_color_from_hex(
            colors[self.accent_palette][self.accent_dark_hue])

    accent_dark = AliasProperty(_get_accent_dark,
                                bind=["accent_palette", "accent_dark_hue"])
    """Similar to :attr:`primary_dark`,
    but returns a value for :attr:`accent_dark`.

    :attr:`accent_dark` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`accent_dark`,
    property is readonly.
    """

    theme_style = OptionProperty("Light", options=["Light", "Dark"])
    """App theme style.

    .. code-block:: python

        from kivy.uix.screenmanager import Screen

        from kivymd.app import MDApp
        from kivymd.uix.button import MDRectangleFlatButton


        class MainApp(MDApp):
            def build(self):
                self.theme_cls.theme_style = "Dark"  # "Light"

                screen = Screen()
                screen.add_widget(
                    MDRectangleFlatButton(
                        text="Hello, World",
                        pos_hint={"center_x": 0.5, "center_y": 0.5},
                    )
                )
                return screen


        MainApp().run()

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/theme-style.png

    :attr:`theme_style` is an :class:`~kivy.properties.OptionProperty`
    and defaults to `'Light'`.
    """

    def _get_theme_style(self, opposite):
        if opposite:
            return "Light" if self.theme_style == "Dark" else "Dark"
        else:
            return self.theme_style

    def _get_bg_darkest(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            return get_color_from_hex(colors["Light"]["StatusBar"])
        elif theme_style == "Dark":
            return get_color_from_hex(colors["Dark"]["StatusBar"])

    bg_darkest = AliasProperty(_get_bg_darkest, bind=["theme_style"])
    """
    Similar to :attr:`bg_dark`,
    but the color values ​​are a tone lower (darker) than :attr:`bg_dark`.

    .. code-block:: python

        KV = '''
        <Box@BoxLayout>:
            bg: 0, 0, 0, 0

            canvas:
                Color:
                    rgba: root.bg
                Rectangle:
                    pos: self.pos
                    size: self.size

        BoxLayout:

            Box:
                bg: app.theme_cls.bg_light
            Box:
                bg: app.theme_cls.bg_normal
            Box:
                bg: app.theme_cls.bg_dark
            Box:
                bg: app.theme_cls.bg_darkest
        '''

        from kivy.lang import Builder

        from kivymd.app import MDApp


        class MainApp(MDApp):
            def build(self):
                self.theme_cls.theme_style = "Dark"  # "Light"
                return Builder.load_string(KV)


        MainApp().run()

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/bg-normal-dark-darkest.png

    :attr:`bg_darkest` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`bg_darkest`,
    property is readonly.
    """

    def _get_op_bg_darkest(self):
        return self._get_bg_darkest(True)

    opposite_bg_darkest = AliasProperty(_get_op_bg_darkest,
                                        bind=["theme_style"])
    """
    The opposite value of color in the :attr:`bg_darkest`.

    :attr:`opposite_bg_darkest` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`opposite_bg_darkest`,
    property is readonly.
    """

    def _get_bg_dark(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            return get_color_from_hex(colors["Light"]["AppBar"])
        elif theme_style == "Dark":
            return get_color_from_hex(colors["Dark"]["AppBar"])

    bg_dark = AliasProperty(_get_bg_dark, bind=["theme_style"])
    """
    Similar to :attr:`bg_normal`,
    but the color values ​​are one tone lower (darker) than :attr:`bg_normal`.

    :attr:`bg_dark` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`bg_dark`,
    property is readonly.
    """

    def _get_op_bg_dark(self):
        return self._get_bg_dark(True)

    opposite_bg_dark = AliasProperty(_get_op_bg_dark, bind=["theme_style"])
    """
    The opposite value of color in the :attr:`bg_dark`.

    :attr:`opposite_bg_dark` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`opposite_bg_dark`,
    property is readonly.
    """

    def _get_bg_normal(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            return get_color_from_hex(colors["Light"]["Background"])
        elif theme_style == "Dark":
            return get_color_from_hex(colors["Dark"]["Background"])

    bg_normal = AliasProperty(_get_bg_normal, bind=["theme_style"])
    """
    Similar to :attr:`bg_light`,
    but the color values ​​are one tone lower (darker) than :attr:`bg_light`.

    :attr:`bg_normal` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`bg_normal`,
    property is readonly.
    """

    def _get_op_bg_normal(self):
        return self._get_bg_normal(True)

    opposite_bg_normal = AliasProperty(_get_op_bg_normal, bind=["theme_style"])
    """
    The opposite value of color in the :attr:`bg_normal`.

    :attr:`opposite_bg_normal` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`opposite_bg_normal`,
    property is readonly.
    """

    def _get_bg_light(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            return get_color_from_hex(colors["Light"]["CardsDialogs"])
        elif theme_style == "Dark":
            return get_color_from_hex(colors["Dark"]["CardsDialogs"])

    bg_light = AliasProperty(_get_bg_light, bind=["theme_style"])
    """"
    Depending on the style of the theme (`'Dark'` or `'Light`')
    that the application uses, :attr:`bg_light` contains the color value
    in ``rgba`` format for the widgets background.

    :attr:`bg_light` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`bg_light`,
    property is readonly.
    """

    def _get_op_bg_light(self):
        return self._get_bg_light(True)

    opposite_bg_light = AliasProperty(_get_op_bg_light, bind=["theme_style"])
    """
    The opposite value of color in the :attr:`bg_light`.

    :attr:`opposite_bg_light` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`opposite_bg_light`,
    property is readonly.
    """

    def _get_divider_color(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            color = get_color_from_hex("000000")
        elif theme_style == "Dark":
            color = get_color_from_hex("FFFFFF")
        color[3] = 0.12
        return color

    divider_color = AliasProperty(_get_divider_color, bind=["theme_style"])
    """
    Color for dividing lines such as  :class:`~kivymd.uix.card.MDSeparator`.

    :attr:`divider_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`divider_color`,
    property is readonly.
    """

    def _get_op_divider_color(self):
        return self._get_divider_color(True)

    opposite_divider_color = AliasProperty(_get_op_divider_color,
                                           bind=["theme_style"])
    """
    The opposite value of color in the :attr:`divider_color`.

    :attr:`opposite_divider_color` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`opposite_divider_color`,
    property is readonly.
    """

    def _get_text_color(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            color = get_color_from_hex("000000")
            color[3] = 0.87
        elif theme_style == "Dark":
            color = get_color_from_hex("FFFFFF")
        return color

    text_color = AliasProperty(_get_text_color, bind=["theme_style"])
    """
    Color of the text used in the :class:`~kivymd.uix.label.MDLabel`.

    :attr:`text_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`text_color`,
    property is readonly.
    """

    def _get_op_text_color(self):
        return self._get_text_color(True)

    opposite_text_color = AliasProperty(_get_op_text_color,
                                        bind=["theme_style"])
    """
    The opposite value of color in the :attr:`text_color`.

    :attr:`opposite_text_color` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`opposite_text_color`,
    property is readonly.
    """

    def _get_secondary_text_color(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            color = get_color_from_hex("000000")
            color[3] = 0.54
        elif theme_style == "Dark":
            color = get_color_from_hex("FFFFFF")
            color[3] = 0.70
        return color

    secondary_text_color = AliasProperty(_get_secondary_text_color,
                                         bind=["theme_style"])
    """
    The color for the secondary text that is used in classes
    from the module :class:`~kivymd/uix/list.TwoLineListItem`.

    :attr:`secondary_text_color` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`secondary_text_color`,
    property is readonly.
    """

    def _get_op_secondary_text_color(self):
        return self._get_secondary_text_color(True)

    opposite_secondary_text_color = AliasProperty(_get_op_secondary_text_color,
                                                  bind=["theme_style"])
    """
    The opposite value of color in the :attr:`secondary_text_color`.

    :attr:`opposite_secondary_text_color`
    is an :class:`~kivy.properties.AliasProperty` that returns the value
    in ``rgba`` format for :attr:`opposite_secondary_text_color`,
    property is readonly.
    """

    def _get_icon_color(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            color = get_color_from_hex("000000")
            color[3] = 0.54
        elif theme_style == "Dark":
            color = get_color_from_hex("FFFFFF")
        return color

    icon_color = AliasProperty(_get_icon_color, bind=["theme_style"])
    """
    Color of the icon used in the :class:`~kivymd.uix.button.MDIconButton`.

    :attr:`icon_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`icon_color`,
    property is readonly.
    """

    def _get_op_icon_color(self):
        return self._get_icon_color(True)

    opposite_icon_color = AliasProperty(_get_op_icon_color,
                                        bind=["theme_style"])
    """
    The opposite value of color in the :attr:`icon_color`.

    :attr:`opposite_icon_color` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`opposite_icon_color`,
    property is readonly.
    """

    def _get_disabled_hint_text_color(self, opposite=False):
        theme_style = self._get_theme_style(opposite)
        if theme_style == "Light":
            color = get_color_from_hex("000000")
            color[3] = 0.38
        elif theme_style == "Dark":
            color = get_color_from_hex("FFFFFF")
            color[3] = 0.50
        return color

    disabled_hint_text_color = AliasProperty(_get_disabled_hint_text_color,
                                             bind=["theme_style"])
    """
    Color of the disabled text used in the :class:`~kivymd.uix.textfield.MDTextField`.

    :attr:`disabled_hint_text_color`
    is an :class:`~kivy.properties.AliasProperty` that returns the value
    in ``rgba`` format for :attr:`disabled_hint_text_color`,
    property is readonly.
    """

    def _get_op_disabled_hint_text_color(self):
        return self._get_disabled_hint_text_color(True)

    opposite_disabled_hint_text_color = AliasProperty(
        _get_op_disabled_hint_text_color, bind=["theme_style"])
    """
    The opposite value of color in the :attr:`disabled_hint_text_color`.

    :attr:`opposite_disabled_hint_text_color`
    is an :class:`~kivy.properties.AliasProperty` that returns the value
    in ``rgba`` format for :attr:`opposite_disabled_hint_text_color`,
    property is readonly.
    """

    # Hardcoded because muh standard
    def _get_error_color(self):
        return get_color_from_hex(colors["Red"]["A700"])

    error_color = AliasProperty(_get_error_color)
    """
    Color of the error text used
    in the :class:`~kivymd.uix.textfield.MDTextField`.

    :attr:`error_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`error_color`,
    property is readonly.
    """

    def _get_ripple_color(self):
        return self._ripple_color

    def _set_ripple_color(self, value):
        self._ripple_color = value

    _ripple_color = ListProperty(get_color_from_hex(colors["Gray"]["400"]))
    """Private value."""

    ripple_color = AliasProperty(_get_ripple_color,
                                 _set_ripple_color,
                                 bind=["_ripple_color"])
    """
    Color of ripple effects.

    :attr:`ripple_color` is an :class:`~kivy.properties.AliasProperty` that
    returns the value in ``rgba`` format for :attr:`ripple_color`,
    property is readonly.
    """

    def _determine_device_orientation(self, _, window_size):
        if window_size[0] > window_size[1]:
            self.device_orientation = "landscape"
        elif window_size[1] >= window_size[0]:
            self.device_orientation = "portrait"

    device_orientation = StringProperty("")
    """
    Device orientation.

    :attr:`device_orientation` is an :class:`~kivy.properties.StringProperty`.
    """

    def _get_standard_increment(self):
        if DEVICE_TYPE == "mobile":
            if self.device_orientation == "landscape":
                return dp(48)
            else:
                return dp(56)
        else:
            return dp(64)

    standard_increment = AliasProperty(_get_standard_increment,
                                       bind=["device_orientation"])
    """
    Value of standard increment.

    :attr:`standard_increment` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`standard_increment`,
    property is readonly.
    """

    def _get_horizontal_margins(self):
        if DEVICE_TYPE == "mobile":
            return dp(16)
        else:
            return dp(24)

    horizontal_margins = AliasProperty(_get_horizontal_margins)
    """
    Value of horizontal margins.

    :attr:`horizontal_margins` is an :class:`~kivy.properties.AliasProperty`
    that returns the value in ``rgba`` format for :attr:`horizontal_margins`,
    property is readonly.
    """

    def on_theme_style(self, instance, value):
        if (hasattr(App.get_running_app(), "theme_cls")
                and App.get_running_app().theme_cls == self):
            self.set_clearcolor_by_theme_style(value)

    set_clearcolor = BooleanProperty(True)

    def set_clearcolor_by_theme_style(self, theme_style):
        if not self.set_clearcolor:
            return
        if theme_style == "Light":
            Window.clearcolor = get_color_from_hex(
                colors["Light"]["Background"])
        elif theme_style == "Dark":
            Window.clearcolor = get_color_from_hex(
                colors["Dark"]["Background"])

    # font name, size (sp), always caps, letter spacing (sp)
    font_styles = DictProperty({
        "H1": ["RobotoLight", 96, False, -1.5],
        "H2": ["RobotoLight", 60, False, -0.5],
        "H3": ["Roboto", 48, False, 0],
        "H4": ["Roboto", 34, False, 0.25],
        "H5": ["Roboto", 24, False, 0],
        "H6": ["RobotoMedium", 20, False, 0.15],
        "Subtitle1": ["Roboto", 16, False, 0.15],
        "Subtitle2": ["RobotoMedium", 14, False, 0.1],
        "Body1": ["Roboto", 16, False, 0.5],
        "Body2": ["Roboto", 14, False, 0.25],
        "Button": ["RobotoMedium", 14, True, 1.25],
        "Caption": ["Roboto", 12, False, 0.4],
        "Overline": ["Roboto", 10, True, 1.5],
        "Icon": ["Icons", 24, False, 0],
    })
    """
    Data of default font styles.

    Add custom font:

    .. code-block:: python

        KV = '''
        Screen:

            MDLabel:
                text: "JetBrainsMono"
                halign: "center"
                font_style: "JetBrainsMono"
        '''

        from kivy.core.text import LabelBase

        from kivy.lang import Builder

        from kivymd.app import MDApp
        from kivymd.font_definitions import theme_font_styles


        class MainApp(MDApp):
            def build(self):
                LabelBase.register(
                    name="JetBrainsMono",
                    fn_regular="JetBrainsMono-Regular.ttf")

                theme_font_styles.append('JetBrainsMono')
                self.theme_cls.font_styles["JetBrainsMono"] = [
                    "JetBrainsMono",
                    16,
                    False,
                    0.15,
                ]
                return Builder.load_string(KV)


        MainApp().run()

    .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/font-styles.png

    :attr:`font_styles` is an :class:`~kivy.properties.DictProperty`.
    """

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.rec_shadow = Atlas(f"{images_path}rec_shadow.atlas")
        self.rec_st_shadow = Atlas(f"{images_path}rec_st_shadow.atlas")
        self.quad_shadow = Atlas(f"{images_path}quad_shadow.atlas")
        self.round_shadow = Atlas(f"{images_path}round_shadow.atlas")
        Clock.schedule_once(lambda x: self.on_theme_style(0, self.theme_style))
        self._determine_device_orientation(None, Window.size)
        Window.bind(size=self._determine_device_orientation)
Example #57
0
    def send_files(self, obj):
        selected_destinations = ""
        for x in self.destinations_list.viewclass.selected_items:
            selected_destinations += x['text'].split(" - (")[1].replace(
                ')', '') + ";"
        selected_destinations = selected_destinations[0:-1]

        if len(selected_destinations) == 0:
            show = Popup(title="Error",
                         title_size=18,
                         title_align='center',
                         content=Label(text="Select at least 1 destination",
                                       font_size=16),
                         size_hint=(None, None),
                         size=(250, 150),
                         separator_color=get_color_from_hex("#1890ff"),
                         background='resources/background.jpg')

            show.open()
            return

        files_sizes = []
        files_names = []
        for file_info in FilesList.files:
            file_path = file_info[0]
            file = open(file_path, 'rb')

            name = os.path.basename(os.path.normpath(file_path))

            file.seek(0, 2)
            size = file.tell()
            file.seek(0, 0)

            files_sizes.append(size)
            files_names.append(name)

        pre_info = {
            'files_sizes': files_sizes,
            'files_names': files_names,
            'destinations': selected_destinations
        }

        client_socket.send(pickle.dumps(pre_info))

        for file_info in FilesList.files:
            file_path = file_info[0]
            selected_file = open(file_path, 'rb')

            selected_file.seek(0, 2)
            file_size = selected_file.tell()
            selected_file.seek(0, 0)

            sent = 0
            while True:
                if file_size - sent > 65536:
                    buf = selected_file.read(65536)
                else:
                    buf = selected_file.read(file_size - sent)
                if buf:
                    client_socket.send(buf)
                    sent += len(buf)
                else:
                    break

        app.destinations_popup.dismiss()

        file_sent_popup = Popup(title='Uploaded File(s)',
                                title_size=16,
                                title_align='center',
                                size_hint=(None, None),
                                size=(600, 50),
                                pos_hint={
                                    'center_x': .5,
                                    'center_y': .04
                                },
                                separator_color=(0, 0, 0, .8),
                                background='resources/background2.jpg',
                                on_open=self.popup_dismiss)

        file_sent_popup.open()
Example #58
0
 def _get_bg_dark(self, opposite=False):
     theme_style = self._get_theme_style(opposite)
     if theme_style == "Light":
         return get_color_from_hex(colors["Light"]["AppBar"])
     elif theme_style == "Dark":
         return get_color_from_hex(colors["Dark"]["AppBar"])
Example #59
0
from kivy.utils import get_color_from_hex

colors = {
    'main_bcolor': get_color_from_hex('#fcfcfc'),
    'active_bcolor': get_color_from_hex('#fcfcfc'),
    'fbx_active_bcolor': get_color_from_hex('#e5e5ff'),
    'unactive_bcolor': get_color_from_hex('#ececec'),
    'context_menu': get_color_from_hex('#d0e3f6'),
    'context_menu_normal_btn': get_color_from_hex('#8fbae7'),
    'context_menu_active_btn': get_color_from_hex('#d0e3f6'),
    'info_label_background': get_color_from_hex('#FCAE1E'),  #('#d0e3f6'),
    'cursor_color': get_color_from_hex('#282828'),
    'bar_color': get_color_from_hex('#c0c0c4'),
    'progress_color': get_color_from_hex('#60bd4d'),
    'font_color': get_color_from_hex('#5c5c5c'),
    'touched_color': get_color_from_hex('#b9d1ea'),
    'active_window_color': get_color_from_hex('#b9d1ea'),
    'unactive_window_color': get_color_from_hex('#d7e4f2')
}
Example #60
0
import kivy
kivy.require("1.8.0")
from kivy.app import App
from kivy.properties import StringProperty
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.utils import get_color_from_hex
from random import randint
from kivy.core.text import LabelBase
Window.clearcolor = get_color_from_hex('#000000')


class EsimeneLehekulg(Screen):
    pass


class Mang(Screen):
    uus_tegevus = StringProperty()
    popup1 = Popup()
    popup2 = Popup()
    uus_pilt = StringProperty()

    def __init__(self, **kwargs):
        super(Mang, self).__init__(**kwargs)
        f = open('tegevused.txt', 'r')
        k = list(f)
        listike = list(open('tahed.txt'))
        self.uus_pilt = str(listike[randint(0, len(listike)-1)])
        self.uus_tegevus = str('[b]' + k[randint(0, len(k)-1)] + '[/b]')