KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

Allow external Icon in MDIcon

Open kengoon opened this issue 3 years ago • 20 comments

Description of the Feature

Making The MDIcon accept an external icon(using another font file) will really be nice. Most times I have to edit the source code so that I can use an external Icon file. I think making it more dynamic will really be great so that developers can use their own custom icons

Also one might be wondering, why is this necessary, since MDIcon is a child of MDLabel, icons can be changed through the text property. The problem still remains that the markup, and text properties of MDIcon are not exposed to other widgets that needs it, like the MDIconButton, MDFlatIconButton ..... and the rest

kengoon avatar Jun 10 '21 14:06 kengoon

@kengoon MD icon use material design icons. There are 5956 of these icons. I think this is more than enough. If you need to use your own icon, you can specify the source parameter with the path to the desired icon file:

MDIconButton:
    icon: "data/logo/kivy-icon-256.png"

HeaTTheatR avatar Aug 11 '21 11:08 HeaTTheatR

@HeaTTheatR I actually meant .ttf and .otf files, not images. And yes they might be more than enough but it still limited to a specific design, I might want an icon that is more light and not bold or thick or even a little bit slant. Exposing that feature gives a sense of power to the developer to choose whatever kind of icon they want

kengoon avatar Aug 11 '21 15:08 kengoon

@kengoon I don't see any point in this...

HeaTTheatR avatar Aug 11 '21 16:08 HeaTTheatR

@HeaTTheatR I simply mean expose the markup property to use external .ttf files

kengoon avatar Aug 11 '21 16:08 kengoon

@kengoon You can use your own fonts in labels anyway.

HeaTTheatR avatar Aug 11 '21 16:08 HeaTTheatR

@kengoon You can do the same - https://github.com/kivymd/KivyMD/blob/master/kivymd/uix/label.py#L249

HeaTTheatR avatar Aug 11 '21 16:08 HeaTTheatR

@HeaTTheatR But can't use it in Buttons that include icons because the markup is not exposed

kengoon avatar Aug 11 '21 16:08 kengoon

@kengoon I really don't see the point with new icons. There are more than enough of them in material font.

HeaTTheatR avatar Aug 11 '21 16:08 HeaTTheatR

@HeaTTheatR yes but the style or shape of the icon might not be exactly what some developer needs. Well if the point is not convincing, then the feature can be tossed aside.

kengoon avatar Aug 11 '21 16:08 kengoon

@kengoon I really don't see the point with new icons. There are more than enough of them in material font.

In my app, I also need more icons, for example the ones in: https://github.com/nationalparkservice/symbol-library

I ended up manually modifying the kivy icon font to include extra icons for the app

vitoller avatar Aug 31 '21 17:08 vitoller

@HeaTTheatR: Would reopening this be feasible? For free-as-in-beer apps, KivyMD's builtin support for the standard 5,956 Material Design icons is indeed impressive. For commercial apps with custom branding needs, though, it'd be even more impressive if KivyMD eventually let us customize icon fonts a bit more readily.

Let's admit that manually patching kivymd/icon_definitions.py is cumbersome, fragile, and a pain point when upgrading KivyMD. We can do better, right? Still, a working solution already exists – so this is probably low-priority with respect to more pressing issues and feature requests.

Thanks as always for the tremendous volunteerism, @HeaTTheatR and fellow KivyMD teamsters! :hugs:

leycec avatar May 06 '22 05:05 leycec

Thanks so much, @HeaTTheatR. You :rock:!

Unrelatedly: I just realized you live in Луганськ, deep within the occupied territories of eastern Ukraine. It's unbelievable that you're giving 0-hour turnaround on GitHub issues from one of the hottest hot spots in the world. That's just how Ukranian open-source volunteers roll, right? Still... please be safe IRL. My thoughts for you and your family during this wild (but hopefully brief) interregnum in human history.

leycec avatar May 06 '22 06:05 leycec

@leycec I'm not from Ukraine. And not from Kiev. I am from Lugansk (Lugansk People Respublic).

HeaTTheatR avatar May 06 '22 07:05 HeaTTheatR

Absolutely, bro. I know. It's likely Ukraine will regain Луганськ at some point this or next year, given current gains along the eastern front. Moreover, the rest of the world still considers Луганськ (along with the other occupied territories) to be Ukranian. Annnnnnnway – politics, eh? The point is: please be safe.

This summer's gonna be a real rough ride for everyone in the disputed zone. Do you have any ejection plans, just in case? Hundreds of thousands of IT specialists have already fled the Russian Federation. GitHub itself is already suspending accounts of Russian devs at sanctioned companies, which increasingly is all of them.

And... I kinda feel like I just inserted my finger into the light socket. I'll quietly show myself the door. Meanwhile, thanks so much for reopening this and your continual efforts on this utterly phenomenal piece of open-source Kivy kit. So much :heart_eyes:!

leycec avatar May 06 '22 07:05 leycec

@leycec Ukraine will cease to exist as a state very soon. And I, as a resident of Donbass, hate Ukraine.

HeaTTheatR avatar May 06 '22 07:05 HeaTTheatR

@leycec What successes of Ukraine are you talking about? Your media are lying to you - Ukraine as a state and on the military front is almost completely destroyed.

HeaTTheatR avatar May 06 '22 07:05 HeaTTheatR

I suggest closing this issue, because there is no point in it. Here is an example of using custom icons.

from kivy.lang import Builder
from kivymd.app import MDApp

KV = '''
Screen:
    MDLabel:
        id: lbl
        font_name: "aaron.ttf"
        text: "\007a"
        halign: 'center'
        color: 1, 0, 1, 1
        font_size: sp(70)
        markup: True
'''


class MainApp(MDApp):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.screen = Builder.load_string(KV)

    def build(self):
        return self.screen


MainApp().run()

aaron font unicode preview font soft

Neizvestnyj avatar Jun 06 '22 11:06 Neizvestnyj

@Neizvestnyj I don't think you get the point. You are only pointing to MDLabel, but the issue is pointing to all kivymd widget using MDIcon for example MDFlatIconButton, MDIconButton etc... how would you add external icon to those kind of widget without trying to change some codes in the kivymd source code

kengoon avatar Jun 06 '22 11:06 kengoon

@Neizvestnyj I don't think you get the point. You are only pointing to MDLabel, but the issue is pointing to all kivymd widget using MDIcon for example MDFlatIconButton, MDIconButton etc... how would you add external icon to those kind of widget without trying to change some codes in the kivymd source code

I would just create my own class so as not to interfere with the work of kivymd, since kivymd is a material design library, and my own fonts do not relate to it in any way. For example, in my application I have created classes for many buttons based on kivymd (it's easy enough to do in python)

Neizvestnyj avatar Jun 06 '22 12:06 Neizvestnyj

@Neizvestnyj that is re-inventing the wheel, when there is already made similar widget. The best option is to improve it

kengoon avatar Jun 10 '22 13:06 kengoon

Fix in master branch.

HeaTTheatR avatar Aug 26 '22 05:08 HeaTTheatR