A RecentChooserDialog provides selection of recently opened documents from a dialog.


The RecentChooserDialog can be constructed using the following:

recentchooserdialog = Gtk.RecentChooserDialog(manager, (buttons))

Setting the manager parameter to a RecentManager object allows for increase control over the content of the RecentChooserDialog. Finally, the buttons parameter should be a tuple of buttons which are to be displayed on the dialog.


A RecentManager is not required to be added if only basic functions of the RecentChooserWidget are required. The RecentManager simply provides more options on working with files.


Once the RecentChooserDialog has been created, use the following to run and then destroy the widget:

GTK+ will loop in the .run() method until it receives a response, upon which any code that needs to be run is executed (for example, responding to the users request). After completion, the .destroy() method will remove the RecentChooserDialog.

A title can be set on the RecentChooserDialog with:


To ensure the dialog is positioned correctly over the parent window, it is recommended to set parent with:



The commonly used signals of a RecentChooserDialog are:

"response" (dialog, response_id)
"close" (dialog)

The "close" event occurs when the user presses the Escape button on the keyboard, or the Gtk.ResponseType.CLOSE response is met. Alternatively, "response" can be emitted when anything happens within the RecentChooserDialog. Both events emit the RecentChooserDialog object with the function, however the "response" signal also emits a response_id value of the event that occurred within the RecentChooserDialog.


Below is an example of a RecentChooserDialog:

#!/usr/bin/env python3

from gi.repository import Gtk

class RecentChooserDialog(Gtk.RecentChooserDialog):
    def __init__(self):
        self.set_default_size(250, -1)
        self.add_button('Cancel', Gtk.ResponseType.CANCEL)
        self.add_button('OK', Gtk.ResponseType.OK)
        self.connect('response', self.on_response)

    def on_response(self, recentchooserdialog, response):
        if response == Gtk.ResponseType.OK:
            item = recentchooserdialog.get_current_item()

            if item:
                print('Item selected:')
                print('Name:\t %s' % (item.get_display_name()))
                print('URI:\t %s' % (item.get_uri()))

dialog = RecentChooserDialog()

Download: RecentChooserDialog