I'm trying to make a GTK program that brings up other child windows, but I can't seem to get set_transient_for to work.
The window I'm having trouble with is called "about" for now. I am trying to set the window under __init__ as its parent, but when I try to use the "About" menu, I get:
TypeError: argument parent: Expected Gtk.Window, but got __main__.function
Here's how I made the window.
class App(Gtk.Window):
def __init__(self):
## Create window. ##
Gtk.Window.__init__(self, title="Simple Updater")
self.set_border_width(5)
self.set_resizable(False)
I used uimanager to create some menus and packed them in a grid. Here's how I call my about window.
## Menu functions ##
def add_about_actions(self, action_group):
action_group.add_actions([
("About", None, "About"),
("About...", None, "About...", None, None, Windows.About)
])
I created another class for my child windows. Here's where I try to set the parent as window __init__.
class Windows(Gtk.Window):
def About(self):
about = Gtk.Window(title="About")
about.set_border_width(10)
about.set_resizable(False)
about.set_transient_for(__init__)
I also tried:
about.set_transient_for(App.__init__)
And here's how I set up my GTK loop.
top = App()
top.connect("delete-event", Gtk.main_quit)
top.show_all()
Gtk.main()
I've tried to figure out what's going on for several hours now with no luck. Any help would be appreciated.
This is a duplicate question of: GtkDialog mapped without a transient parent
You need to pass the variable holding the main window object.