1.1.4.1. extras

This module contains miscellaneous extra GTK widgets.

1.1.4.1.1. Classes

1.1.4.1.1.1. Cell Renderers

class CellRendererPythonText(*args, **kwargs)[source]

Bases: Gtk.CellRendererText

A base Gtk.CellRendererText class to facilitate rendering native Python values into strings of various formats.

render_python_value(value)[source]

The method to render value into a string to be displayed within the cell.

Parameters:value – The Python value to render.
Return type:str
Returns:Either the value rendered as a string or None. Returning None will cause the cell to be displayed as empty.
class CellRendererBytes(*args, **kwargs)[source]

Bases: king_phisher.client.widget.extras.CellRendererPythonText

A custom CellRendererPythonText to render numeric values representing bytes.

class CellRendererDatetime(*args, **kwargs)[source]

Bases: king_phisher.client.widget.extras.CellRendererPythonText

A custom CellRendererPythonText to render numeric values representing bytes.

class CellRendererInteger(*args, **kwargs)[source]

Bases: king_phisher.client.widget.extras.CellRendererPythonText

A custom CellRendererPythonText to render numeric values with comma separators.

1.1.4.1.1.2. Column Definitions

class ColumnDefinitionBase(title, width)[source]

Bases: object

A base class for defining attributes of columns to be displayed within TreeView instances.

__init__(title, width)[source]

Initialize self. See help(type(self)) for accurate signature.

cell_renderer = None[source]

The CellRenderer to use for rendering the content.

g_type = None[source]

The type to specify in the context of GObjects.

name[source]

The title converted to lowercase and with spaces replaced with underscores.

python_type = None[source]

The type to specify in the context of native Python code.

sort_function = None[source]

An optional custom sort function to use for comparing values. This is necessary when g_type is not something that can be automatically sorted. If specified, this function will be passed to Gtk.TreeSortable.set_sort_func().

title[source]

The title of the column to be displayed within the TreeView instance.

width[source]

An integer specifying the width of the column.

class ColumnDefinitionBytes(title, width=25)[source]

Bases: king_phisher.client.widget.extras.ColumnDefinitionBase

class ColumnDefinitionDatetime(title, width=25)[source]

Bases: king_phisher.client.widget.extras.ColumnDefinitionBase

class ColumnDefinitionInteger(title, width=15)[source]

Bases: king_phisher.client.widget.extras.ColumnDefinitionBase

class ColumnDefinitionString(title, width=30)[source]

Bases: king_phisher.client.widget.extras.ColumnDefinitionBase

1.1.4.1.1.3. Miscellaneous

class FileChooserDialog(title, parent, **kwargs)[source]

Bases: Gtk.FileChooserDialog

Display a file chooser dialog with additional convenience methods.

__init__(title, parent, **kwargs)[source]
Parameters:
  • title (str) – The title for the file chooser dialog.
  • parent (Gtk.Window) – The parent window for the dialog.
quick_add_filter(name, patterns)[source]

Add a filter for displaying files, this is useful in conjunction with run_quick_open().

Parameters:
  • name (str) – The name of the filter.
  • patterns (list, str) – The pattern(s) to match.
run_quick_open()[source]

Display a dialog asking a user which file should be opened. The value of target_path in the returned dictionary is an absolute path.

Returns:A dictionary with target_uri and target_path keys representing the path chosen.
Return type:dict
run_quick_save(current_name=None)[source]

Display a dialog which asks the user where a file should be saved. The value of target_path in the returned dictionary is an absolute path.

Parameters:current_name (set) – The name of the file to save.
Returns:A dictionary with target_uri and target_path keys representing the path chosen.
Return type:dict
run_quick_select_directory()[source]

Display a dialog which asks the user to select a directory to use. The value of target_path in the returned dictionary is an absolute path.

Returns:A dictionary with target_uri and target_path keys representing the path chosen.
Return type:dict
class MultilineEntry(*args, **kwargs)[source]

Bases: Gtk.Frame

A custom entry widget which can be styled to look like Gtk.Entry but accepts multiple lines of input.

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

class WebKitHTMLView[source]

Bases: WebKitX.WebView

A WebView widget with additional convenience methods for rendering simple HTML content from either files or strings. If a link is opened within the document, the webview will emit the ‘open-uri’ signal instead of navigating to it.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

load_html_data(html_data, html_file_uri=None)[source]

Load arbitrary HTML data into the WebKit engine to be rendered.

Parameters:
  • html_data (str) – The HTML data to load into WebKit.
  • html_file_uri (str) – The URI of the file where the HTML data came from.
load_html_file(html_file)[source]

Load arbitrary HTML data from a file into the WebKit engine to be rendered.

Parameters:html_file (str) – The path to the file to load HTML data from.
load_markdown_data(md_data, html_file_uri=None, gh_flavor=True, template=None, template_vars=None)[source]

Load markdown data, render it into HTML and then load it in to the WebKit engine. When gh_flavor is enabled, the markdown data is rendered using partial GitHub flavor support as provided by PartialGithubFlavoredMarkdownExtension. If template is specified, it is used to load a Jinja2 template using template_env into which the markdown data is passed in the variable markdown along with any others specified in the template_vars dictionary.

Parameters:
  • md_data (str) – The markdown data to render into HTML for displaying.
  • html_file_uri (str) – The URI of the file where the HTML data came from.
  • gh_flavor (bool) – Whether or not to enable partial GitHub markdown syntax support.
  • template (str) – The name of a Jinja2 HTML template to load for hosting the rendered markdown.
  • template_vars – Additional variables to pass to the Jinja2 Template when rendering it.
Returns:

load_markdown_file(md_file, **kwargs)[source]

Load markdown data from a file and render it using load_markdown_data().

Parameters:
  • md_file (str) – The path to the file to load markdown data from.
  • kwargs – Additional keyword arguments to pass to load_markdown_data().
template_env = <king_phisher.templates.TemplateEnvironmentBase object>[source]

The TemplateEnvironmentBase instance to use when rendering template content. The environment uses the FindFileSystemLoader loader.