GTK4PythonTutorial icon indicating copy to clipboard operation
GTK4PythonTutorial copied to clipboard

'gi.repository.Gtk' object has no attribute 'FileDialog' error

Open kirby-kirby opened this issue 2 years ago • 2 comments

Things are going along hunky-dory in this rather nice tutorial until I hit the 'Adding a file chooser' section. I then see the error mentioned in the title. Below is the snippet with the pre and post couple of lines. What am I missing other than the "FileDialog attribiute"? Thanks.

        self.open_button.connect('clicked', self.hello)
        self.open_button.set_icon_name("document-open-symbolic")

        self.open_dialog = Gtk.FileDialog.new()
        self.open_dialog.set_title("Select a File")

    def show_open_dialog(self, button):
        self.open_dialog(self, None, self.open_dialog_open_callback)

kirby-kirby avatar Dec 15 '23 11:12 kirby-kirby

FileDialog is actually new and was introduced in the recent GTK 4.10. Your distro is likely still using an older version of GTK. You can instead use the older FileChooserDialog. An older version of my tutorial used this. Maybe I was too hasty to remove it. You can refer to the removed section of my tutorial here.

Taiko2k avatar Dec 15 '23 12:12 Taiko2k

On 12/15/23 07:55, James wrote:

FileDialog https://docs.gtk.org/gtk4/class.FileDialog.html is actually new and was introduced in the recent GTK 4.10. Your distro is likely still using an older version of GTK. You can instead use the older

Yes indeed! FC37 (upgrade scheduled for holidays) uses 4.8.3. Aside from my fumblefingers, things work splendidly now.

Thank you for your quick response and for your wonderful tutorial!

kirby-kirby avatar Dec 15 '23 13:12 kirby-kirby