Gtk.AppChooserDialog
Gtk.AppChooserDialog — An application chooser dialog
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Bin
╰── Gtk.Window
╰── Gtk.Dialog
╰── Gtk.AppChooserDialog
Functions:
- new
(parent:Gtk.Window=None, flags:Gtk.DialogFlags, file:Gio.File) -> Gtk.Widget
- new_for_content_type
(parent:Gtk.Window=None, flags:Gtk.DialogFlags, content_type:str) -> Gtk.Widget
- get_widget
(self) -> Gtk.Widget
- set_heading
(self, heading:str)
- get_heading
(self) -> str
Description:
Gtk.AppChooserDialog
shows a Gtk.AppChooserWidget inside a GtkDialog.
Note that Gtk.AppChooserDialog
does not have any interesting methods of its own. Instead, you should get the embedded Gtk.AppChooserWidget using Gtk.AppChooserDialog::get_widget()
and call its methods if the generic Gtk.AppChooser interface is not sufficient for your needs.
To set the heading that is shown above the Gtk.AppChooserWidget, use Gtk.AppChooserDialog::set_heading()
.
- Example of Gtk.AppChooserDialog:
def on_button_clicked(self, button):
dialog = Gtk.AppChooserDialog(parent=self, content_type="image/png")
dialog.set_heading("This is AppChooserDialog")
dialog.connect("response", self.on_response)
dialog.run()
def on_response(self, dialog, response):
if response == Gtk.ResponseType.OK:
app_info = dialog.get_app_info()
name = app_info.get_display_name()
description = app_info.get_description()
print("Name:\t\t%s" % (name))
print("Description:\t%s" % (description))
dialog.destroy()
Function Details:
new()
new (parent:Gtk.Window=None, flags:Gtk.DialogFlags, file:Gio.File) -> Gtk.Widget
Creates a new Gtk.AppChooserDialog
for the provided GFile,to allow the user to select an application for it.
Returns: a newly created Gtk.AppChooserDialog
Since: 3.0
new_for_content_type()
new_for_content_type (parent:Gtk.Window=None, flags:Gtk.DialogFlags, content_type:str) -> Gtk.Widget
Creates a new Gtk.AppChooserDialog
for the provided content type,to allow the user to select an application for it.
Returns: a newly created Gtk.AppChooserDialog
Since: 3.0
get_widget()
get_widget (self) -> Gtk.Widget
Returns the Gtk.AppChooserWidget
of this dialog.
Returns: the
Gtk.AppChooserWidget
ofself
.Since: 3.0
set_heading()
set_heading (self, heading:str)
Sets the text to display at the top of the dialog.If the heading is not set, the dialog displays a default text.
get_heading()
get_heading (self) -> str
Returns the text to display at the top of the dialog.
- Returns:
the text to display at the top of the dialog, or
None
, in whichcase a default text is displayed
Example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class AppChooserDialog(Gtk.AppChooserDialog):
def __init__(self):
Gtk.AppChooserDialog.__init__(self, content_type="image/png")
self.set_title("AppChooserDialog")
self.connect("response", self.on_response)
def on_response(self, dialog, response):
if response == Gtk.ResponseType.OK:
app_info = appchooserdialog.get_app_info()
name = app_info.get_display_name()
description = app_info.get_description()
print("Name:\t\t%s" % (name))
print("Description:\t%s" % (description))
appchooserdialog = AppChooserDialog()
appchooserdialog.run()