How to set an application's name?

My app while run from source shows <filename>.py. How can I avoid it and set a proper name? I tried this GLib.set_application_name but it didn’t work. Do I have to use Desktop files to do that, or shall I change my filename from <filename>.py to <appname>?

Minimal working example
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import GLib, Gtk

class App(Gtk.Application):
    def __init__(self):
        super().__init__(application_id="") = Gtk.Window(title="Hi")"Look at the app name at the panel"))
    def do_startup(self):
    def do_activate(self):

app = App()
1 Like

No reply from anyone so far?

You don’t need a desktop file. Are you creating a Gtk.Application instance? Can you post a minimal example that fails?

1 Like

Yep I’m creating a Gtk.Application instance. I’ve edited the question to include source and a screenshot

How do you know it hasn’t worked? Where are you looking at the app name?

See the name in the panel at the top of the screen in the screenshot, next to Places. I’m guessing that the app with focus is the Python app, not Kate.

1 Like

Are you running it though a debugger?

Nope. Just normal execution.

Yea,, is my app, the app with focus.

Yes, that is where an application’s name and icon come from.

If there is no .desktop file or we fail to match it to the window, then we create a “fake app” with fallbacks so that components like the app menu, alt-tab or the dash still can display something.

But it’s really just that: a fallback. Please don’t try to game the system by making the app fallback show up nicer, provide a .desktop file that allows it to properly integrate with the system.

If you want your users to be able to launch your application normally by clicking its icon, or add it as favorite to the dash, then you will need a .desktop file anyway.

1 Like

Thanks for that. Expected the use of Desktop files here.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.