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>?
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="org.me.my_app")
self.win = Gtk.Window(title="Hi")
self.win.add(Gtk.Label(label="Look at the app name at the panel"))
def do_startup(self):
Gtk.Application.do_startup(self)
GLib.set_application_name("MyApp")
self.win.set_application(self)
self.win.show_all()
def do_activate(self):
Gtk.Application.do_activate(self)
app = App()
app.run()
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.
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.