PyGObject: FileChooserDialog and transient parent

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PyGObject: FileChooserDialog and transient parent

Gtk+ - Apps Dev mailing list
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

<<a href="https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/FileChooserDialog.html#Gtk.FileChooserDialog">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()
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: PyGObject: FileChooserDialog and transient parent

Gtk+ - Apps Dev mailing list
Hi;

On Sun, 12 Aug 2018 at 12:33, c.buhtz--- via gtk-app-devel-list <
[hidden email]> wrote:

> 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
>
> <
> <a href="https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/FileChooserDialog.html#Gtk.FileChooserDialog">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.
>

The documentation for Python/GObject bindings is generated from the
introspection data, which is in turn generated from comments and
annotations inside the C code.

The C code comes with C examples, because writing examples in Python, Perl,
JavaScript, whatever inside the C documentation would be odd, and could not
be validated in any way by the C developers.

Yes, it would be nice if we had a translation layer for introspected
languages using the documentation inside the generated data; it's been a
request for a long time, but nobody has shown up to do the work.

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)
>

The properties are inherited from the GtkFileChooserDialog class, so you'll
have to look at the hierarchy of the type, namely:

 - GtkWidget
 - GtkWindow
 - GtkDialog

The transient parent is provided by the transient-for property on GtkWindow:


https://developer.gnome.org/gtk3/stable/GtkWindow.html#GtkWindow--transient-for

or:


<a href="http://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Window.html#Gtk.Window.props.transient_for">http://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Window.html#Gtk.Window.props.transient_for

In any case, it would be good to file this as an issue against pygobject:

  https://gitlab.gnome.org/GNOME/pygobject/issues/new

Documentation doesn't magically improve by itself, and issues are how
projects can work on improving it, as long as they provide actionable items
and goals.

Ciao,
 Emmanuele.

--
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list