def texture_update(self, *largs): '''Force texture recreation with the current Label properties. After this function call, the :attr:`texture` and :attr:`texture_size` will be updated in this order. ''' self.texture = None if (not self._label.text or (self.halign[-1] == 'y' or self.strip) and not self._label.text.strip()): self.texture_size = (0, 0) else: mrkup = self._label.__class__ is CoreMarkupLabel if mrkup: text = self._label.text # we must strip here, otherwise, if the last line is empty, # markup will retain the last empty line since it only strips # line by line within markup if self.halign[-1] == 'y' or self.strip: text = text.strip() self._label.text = ''.join(('[color=', get_hex_from_color(self.color), ']', text, '[/color]')) self._label.refresh() # force the rendering to get the references if self._label.texture: self._label.texture.bind() self._label.text = text self.refs = self._label.refs self.anchors = self._label.anchors else: self._label.refresh() texture = self._label.texture if texture is not None: self.texture = self._label.texture self.texture_size = list(self.texture.size)
def texture_update(self, *largs): '''Force texture recreation with the current Label properties. After this function call, the :data:`texture` and :data:`texture_size` will be updated in this order. ''' self.texture = None if self._label.text.strip() == '': self.texture_size = (0, 0) else: mrkup = self._label.__class__ is CoreMarkupLabel if mrkup: text = self._label.text self._label.text = ''.join(('[color=', get_hex_from_color(self.color), ']', text, '[/color]')) self._label.refresh() # force the rendering to get the references if self._label.texture: self._label.texture.bind() self._label.text = text self.refs = self._label.refs self.anchors = self._label.anchors else: self._label.refresh() texture = self._label.texture if texture is not None: self.texture = self._label.texture self.texture_size = list(self.texture.size)
def delete_project(self, card, project, open_dialog=True, *args): """ Deletes selected project when delete project button is pressed :param card: ProjectCard() :param project: str :param open_dialog: bool :param args: button args :return: None """ # create the delete dialog if not created if not card.delete_dialog: card.delete_dialog = MDDialog( title=f"[color=%s]Are you sure?[/color]" % get_hex_from_color(self.app.theme_cls.text_color), type="custom", content_cls=DeleteDialogContent( new_text=utils.data[project]['title']), buttons=[ MDFlatButton(text="CANCEL", text_color=self.app.theme_cls.text_color, on_release=partial(self.close_delete_dialog, card)), MDRaisedButton(text="DELETE", text_color=self.app.theme_cls.primary_color, on_release=partial(self.confirm_delete, card, project)) ]) if open_dialog: card.delete_dialog.set_normal_height() card.delete_dialog.open()
def UpdateWidget(self): if not self.uDestVar == u"": h = GetVar(self.uDestVar + u"_h") s = GetVar(self.uDestVar + u"_s") v = GetVar(self.uDestVar + u"_v") if h != "": h = ToFloat(h) / 256 s = ToFloat(s) / 256 v = ToFloat(v) / 256 r, g, b = hsv_to_rgb(h, s, v) else: r = GetVar(self.uDestVar + u"_r") g = GetVar(self.uDestVar + u"_g") b = GetVar(self.uDestVar + u"_b") if r == "": print GetColorFromHex(GetVar(self.uDestVar)) oColor = GetColorFromHex(GetVar(self.uDestVar)) if len(oColor) == 0: oColor = Color(1, 1, 1, 1) else: r, g, b, a = GetColorFromHex(GetVar(self.uDestVar)) if r != "": sHexColor = get_hex_from_color((r, g, b)) self.oObjectColorPicker.hex_color = sHexColor
def on_open(self): with open( LICENSE_PATH, encoding="utf-8", ) as license: self.ids.text_label.text = license.read().format( COLOR=get_hex_from_color(self.theme_cls.primary_color))
def set_style(self, style_switch, dialog_object): # global files if style_switch.active: self.active_style = "Dark" else: self.active_style = "Light" self.cancel_button.theme_text_color = "Primary" self.app.theme_cls.theme_style = self.active_style dialog_object.title = f"[color=%s]Change project appearance[/color]" \ % get_hex_from_color(App.get_running_app().theme_cls.text_color) for banner in utils.bottom_banners: banner.md_bg_color = get_color_from_hex(colors[App.get_running_app().theme_cls.theme_style]["CardsDialogs"]) # there is a chance that the file is no longer in the viewer widget try: for file in utils.files: file.color = self.app.theme_cls.text_color except ReferenceError: pass # update all the checkbox colors in the todo_lists if self.app.theme_cls.theme_style == "Dark": checkbox_color = [1, 1, 1, 0.7] else: checkbox_color = [0, 0, 0, 0.54] for checkbox in utils.todo_checkboxes: if not checkbox.item_checkbox.active: checkbox.item_checkbox.color = checkbox_color for card in utils.project_cards: card.update_colors()
def show_about(self, *args): self.nav_drawer.toggle_nav_drawer() self.screen.ids.about.ids.label.text = \ ( u'[size=20][b]{name}[/b][/size]\n\n' u'[b]Version:[/b] {version}\n' u'[b]License:[/b] {license}\n\n' u'[size=20][b]Developer[/b][/size]\n\n' u'[ref={site}]' u'[color={link_color}]{author}[/color][/ref]\n' u'{mail}\n\n' u'[b]Source code:[/b] ' u'[ref={repo}]' u'[color={link_color}]GitHub[/color][/ref]').format( name=__projectname__, version=__version__, license=__copyright__, author=__author__, site=__site__, mail=__mail__, repo=__repo__, link_color=get_hex_from_color(self.theme_cls.primary_color) ) self.manager.current = 'about' self.screen.ids.action_bar.left_action_items = \ [['chevron-left', lambda x: self.back_screen(27)]]
def on_foreground_color(self, instance, text_color): if not self.use_text_color: self.use_text_color = True return self.text_color = get_hex_from_color(text_color) self.use_text_color = False self.foreground_color = (1, 1, 1, .999) self._trigger_refresh_text()
def on_open(self): with open( ABOUT_PATH, encoding="utf-8", ) as about: self.ids.text_label.text = about.read().format( COLOR=get_hex_from_color(self.theme_cls.primary_color)) self.ids.text_label.markup = True
def __init__(self, **kwargs): super().__init__(**kwargs) self.menu_items = [{ "viewclass": "MDMenuItem", "text": "Example item %d" % i, "callback": self.callback_for_menu_items, } for i in range(15)] self.Window = Window #examen articulos self.articulosCarrito = [] #region variables globales login self.loginEmail = None self.loginPwd = None # Default class instances. self.manager = None self.md_app_bar = None self.instance_menu_demo_apps = None self.instance_menu_source_code = None self.md_theme_picker = None self.long_dialog = None self.input_dialog = None self.alert_dialog = None self.ok_cancel_dialog = None self.long_dialog = None self.dialog = None self.user_card = None self.bs_menu_1 = None self.bs_menu_2 = None self.popup_screen = None self.my_snackbar = None self.dialog_load_kv_files = None self.create_stack_floating_buttons = False self.manager_open = False self.cards_created = False self._interval = 0 self.tick = 0 self.x = 0 self.y = 25 self.file_source_code = "" self.hex_primary_color = get_hex_from_color( self.theme_cls.primary_color) self.previous_text = ( f"Welcome to the application [b][color={self.hex_primary_color}]" f"GiftCard[/color][/b].\n by [b]" f"[color={self.hex_primary_color}]KivyMD[/color][/b] ") self.previous_text_end = ( f"this is a modific design to practical use\n\n" f"Author - [b][color={self.hex_primary_color}]" f"Roberto Lorenzo Aguilar Maldonado[/color][/b]\n") self.demo_apps_list = ["Shop Window"] self.list_name_icons = list(md_icons.keys())[0:15] Window.bind(on_keyboard=self.events)
def setHouse(self, houseNo): """ Sets 'h' characters for each house, or "HOTEL" word for a hotel """ self.clear_widgets() for letter in "HOTEL" if houseNo == 5 else 'h' * houseNo: label = Label( text="[color=%s]%s[/color]" % (get_hex_from_color(self.inverseColor(self.fieldColor)), letter), font_size=self.getHouseSize(), markup=True) self.add_widget(label)
def __init__(self, comic_obj=None, **kwargs): super(ReadingListComicImage, self).__init__(**kwargs) list_menu_items = [ "Open This Comic", "Mark as Read", "Mark as UnRead", # "Download Comic", ] self.menu_items = [] for item in list_menu_items: a_menu_item = { "viewclass": "MDMenuItem", "text": f"[color=#000000]{item}[/color]", "callback": self.callback_for_menu_items, } self.menu_items.append(a_menu_item) self.app = App.get_running_app() self.comic_obj = comic_obj # self.img_color = (.89, .15, .21, 5) self.UserCurrentPage = comic_obj.UserCurrentPage self.PageRead = comic_obj.UserLastPageRead if self.comic_obj.local_file != "": self.has_localfile = True if self.comic_obj.UserLastPageRead == self.comic_obj.PageCount - 1: # self.img_color = (.89, .15, .21, 5) self.is_read = True # txt_color = get_hex_from_color((.89, .15, .21, 1)) txt_color = get_hex_from_color((1, 1, 1, 1)) else: txt_color = get_hex_from_color((1, 1, 1, 1)) self.is_read = False strtxt = f"{self.comic_obj.Series} #{self.comic_obj.Number}" self.text = f"[color={txt_color}]{strtxt}[/color]" self._comic_object = self.comic_obj if self.comic_obj.UserLastPageRead == 0: self.percent_read = 0 else: self.percent_read = round( self.comic_obj.UserLastPageRead / (comic_obj.PageCount - 1) * 100 ) self.page_count_text = f"{self.percent_read}%"
def texture_update(self, *largs): """Force texture recreation with the current Label properties. After this function call, the :attr:`texture` and :attr:`texture_size` will be updated in this order. """ mrkup = self._label.__class__ is CoreMarkupLabel self.texture = None if not self._label.text or (self.halign == "justify" or self.strip) and not self._label.text.strip(): self.texture_size = (0, 0) if mrkup: self.refs, self._label._refs = {}, {} self.anchors, self._label._anchors = {}, {} else: if mrkup: text = self.text # we must strip here, otherwise, if the last line is empty, # markup will retain the last empty line since it only strips # line by line within markup if self.halign == "justify" or self.strip: text = text.strip() self._label.text = "".join( ( "[color=", get_hex_from_color(self.disabled_color if self.disabled else self.color), "]", text, "[/color]", ) ) self._label.refresh() # force the rendering to get the references if self._label.texture: self._label.texture.bind() self.refs = self._label.refs self.anchors = self._label.anchors else: self._label.refresh() texture = self._label.texture if texture is not None: self.texture = self._label.texture self.texture_size = list(self.texture.size)
def __init__(self, **kwargs): self.formatter = BBCodeFormatter() self.lexer = lexers.PythonLexer() self.text_color = '#000000' self._label_cached = Label() self.use_text_color = True super(CodeInput, self).__init__(**kwargs) self._line_options = kw = self._get_line_options() self._label_cached = Label(**kw) # use text_color as foreground color text_color = kwargs.get('foreground_color') if text_color: self.text_color = get_hex_from_color(text_color) # set foreground to white to allow text colors to show # use text_color as the default color in bbcodes self.use_text_color = False self.foreground_color = [1, 1, 1, .999] if not kwargs.get('background_color'): self.background_color = [.9, .92, .92, 1]
def __init__(self, **kwargs): stylename = kwargs.get("style_name", "default") style = kwargs["style"] if "style" in kwargs else styles.get_style_by_name(stylename) self.formatter = BBCodeFormatter(style=style) self.lexer = lexers.PythonLexer() self.text_color = "#000000" self._label_cached = Label() self.use_text_color = True super(CodeInput, self).__init__(**kwargs) self._line_options = kw = self._get_line_options() self._label_cached = Label(**kw) # use text_color as foreground color text_color = kwargs.get("foreground_color") if text_color: self.text_color = get_hex_from_color(text_color) # set foreground to white to allow text colors to show # use text_color as the default color in bbcodes self.use_text_color = False self.foreground_color = [1, 1, 1, 0.999] if not kwargs.get("background_color"): self.background_color = [0.9, 0.92, 0.92, 1]