PyGObject: FileChooserDialog and transient parent



Below you see a minimal working example using Gtk.FileChooserNative as
a file-open dialog. While running with Python 3.6.6 I recieve
this warning message

"GtkDialog mapped without a transient parent. This is discouraged."

I understand the logic behind it but can not find a solution BECAUSE
the docu is IMO inusfficient. Please see

<https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/FileChooserDialog.html#Gtk.FileChooserDialog>

This docu is about PyGObject which is Python, isn't it!? But there is C
code in the example. Also with my C experience this doesn't help.

What IMO is missing in that documentation and what would help me to
understand and solve the problem by myself without contacting the list
or issue tracker is
 - Description of the Constructor or new()
 - all possible parameters accepted by this constructor (I have no idea
   where and how to put a parent to it)
 - I minimal Python3 example describing how this dialog should be used.
   What I mean is using run() after construction, get_filename() and a
   destroy() at the end.

This is the MWE

#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk


class MainWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.connect("delete-event", Gtk.main_quit)
        self.set_default_size(300, 200)

        dlg = Gtk.FileChooserNative(
                title='Title',
                action=Gtk.FileChooserAction.OPEN
                )
        dlg.run()
        dlg.destroy()

win = MainWindow()
win.show_all()
Gtk.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]