Nick
Nick

Reputation: 59

How to set an icon in Kivy?

I want to set my own icon in my kivy app, but its not working. I have tried both with icon.ico and icon.png.

This is what i have tried:

class MyApp(App):
    def build(self):
        self.icon = 'myicon.png'

and:

from kivy.config import Config
Config.set('kivy','window_icon','icon.ico')

Upvotes: 2

Views: 4208

Answers (1)

Wayne Werner
Wayne Werner

Reputation: 51847

Your icon path needs to be either absolute or relative to your application file. So if your directory structure looks like this:

my_app/
├── app.py
└── things
    └── images
        └── my_icon.png

Then you're going to need

class MyApp:
    def build(self):
        self.icon = r'C:\Users\you\path\to\my_app\things\images\my_icon.png'

Obviously you'll want to replace that with the actual path. You should also be able to have

        self.icon = r'things\images\my_icon.png'

but I'm not sure about that.

Upvotes: 2

Related Questions