Taiko2k / GTK4PythonTutorial

GTK4 + Python tutorial with code examples
446 stars 33 forks source link

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

Open kirby-kirby opened 9 months ago

kirby-kirby commented 9 months ago

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)
Taiko2k commented 9 months ago

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.

kirby-kirby commented 9 months ago

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!