The gramps.gui.widgets Module

Custom widgets.

Basic Entry

class gramps.gui.widgets.basicentry.BasicEntry[source]

Bases: gi.repository.Gtk.Entry

Constructors:
Entry(**properties)
new()
new_with_buffer(buffer:Gtk.EntryBuffer)

Buttons

class gramps.gui.widgets.buttons.IconButton(func, handle, icon='gtk-edit', size=<enum GTK_ICON_SIZE_MENU of type GtkIconSize>)[source]

Bases: gi.overrides.Gtk.Button

Constructors:
Button(**properties)
new()
new_from_icon_name(icon_name:str, size:int)
new_from_stock(stock_id:str)
new_with_label(label:str)
new_with_mnemonic(label:str)
class gramps.gui.widgets.buttons.WarnButton[source]

Bases: gi.overrides.Gtk.Button

Constructors:
Button(**properties)
new()
new_from_icon_name(icon_name:str, size:int)
new_from_stock(stock_id:str)
new_with_label(label:str)
new_with_mnemonic(label:str)
on_clicked(func)[source]
class gramps.gui.widgets.buttons.SimpleButton(image, func)[source]

Bases: gi.overrides.Gtk.Button

Constructors:
Button(**properties)
new()
new_from_icon_name(icon_name:str, size:int)
new_from_stock(stock_id:str)
new_with_label(label:str)
new_with_mnemonic(label:str)
class gramps.gui.widgets.buttons.PrivacyButton(button, obj, readonly=False)[source]

Bases: object

get_active()[source]
set_active(val)[source]
set_sensitive(val)[source]

Date Entry

class gramps.gui.widgets.dateentry.DateEntry(uistate, track)[source]

Bases: gi.repository.Gtk.HBox

Constructors:
HBox(**properties)
new(homogeneous:bool, spacing:int)
get_text()[source]
set_text(text)[source]

Expand Collapse Arrow

class gramps.gui.widgets.expandcollapsearrow.ExpandCollapseArrow(collapsed, onbuttonpress, pair)[source]

Bases: gi.repository.Gtk.EventBox

Constructors:
EventBox(**properties)
new()

Fanchart

class gramps.gui.widgets.fanchart.FanChartBaseWidget(dbstate, uistate, callback_popup=None)[source]

Bases: gi.repository.Gtk.DrawingArea

Constructors:
DrawingArea(**properties)
new()
CENTER = 50
background_box(person, generation, userdata)[source]

determine red, green, blue value of background of the box of person, which has gender gender, and is in ring generation

boxtype(radius)[source]

default is only one type of box type

static create_map_rect_to_sector(radius, rect, arc_used_ratio, start_rad, stop_rad)[source]

Create a 2D-transform, mapping a rectangle onto a circle sector.

Parameters:
  • radius – average radius of the target sector
  • rect – (x1, y1, x2, y2)
  • arc_used_ratio – From 0.0 to 1.0. Rather than stretching onto the whole sector, only the middle arc_used_ratio part will be mapped onto.
  • start_rad – start radial angle of the sector, in radians
  • stop_rad – stop radial angle of the sector, in radians
Returns:

a lambda (x,y)|->(xNew,yNew) to feed to warpPath.

do_get_preferred_height()[source]

GTK3 uses width for height sizing model. This method will override the virtual method

do_get_preferred_width()[source]

GTK3 uses width for height sizing model. This method will override the virtual method

do_mouse_click()[source]

action to take on left mouse click

do_size_request(requisition)[source]

Overridden method to handle size request events.

draw_arc_text(cr, text, radius, start, stop, font)[source]

Display text at a particular radius, between start and stop degrees, setting it up along the arc, center-justified.

Text not fitting a single line will be word-wrapped away.

draw_gradient(cr, widget, halfdist)[source]
draw_innerring(cr, person, userdata, start, inc)[source]

Procedure to draw a person in the inner ring position

draw_radbox(cr, radiusin, radiusout, start_rad, stop_rad, color, thick=False)[source]
draw_text(cr, text, radius, start, stop, height=50, radial=False, fontcolor=(0, 0, 0), bold=False)[source]

Display text at a particular radius, between start and stop degrees.

edit_fam_cb(obj, family_handle)[source]
edit_person_cb(obj, person_handle)[source]
family_at(generation, pos, btype)[source]

returns the family at generation, pos, btype

fontbold(a)[source]

The font should be bold if no transparency and font is set. In that case, True is returned

fontcolor(r, g, b, a)[source]

return the font color based on the r, g, b of the background

gen_pixels()[source]

how many pixels a generation takes up in the fanchart

halfdist()[source]

Compute the half radius of the circle

innerpeople_generator()[source]

a generator over all people inside of the core person

on_drag_begin(widget, data)[source]

Set up some inital conditions for drag. Set up icon.

on_drag_data_get(widget, context, sel_data, info, time)[source]

Returned parameters after drag. Specified for ‘person-link’, for others return text info about person.

on_drag_data_received(widget, context, x, y, sel_data, info, time)[source]

Handle the standard gtk interface for drag_data_received.

If the selection data is defined, extract the value from sel_data.data

on_drag_end(widget, data)[source]

Set up some inital conditions for drag. Set up icon.

on_draw(widget, cr, scale=1.0)[source]

callback to draw the fanchart

on_key_press(widget, eventkey)[source]

grab key press

on_mouse_down(widget, event)[source]
on_mouse_move(widget, event)[source]
on_mouse_up(widget, event)[source]
people_generator()[source]

a generator over all people outside of the core person

person_at(generation, pos, btype)[source]

returns the person at generation, pos, btype

person_under_cursor(curx, cury)[source]

Determine the generation and the position in the generation at position x and y, as well as the type of box. generation = -1 on center black dot generation >= self.generations outside of diagram

personpos_at_angle(generation, angledeg, btype)[source]

returns the person in generation generation at angle of type btype.

prepare_background_box()[source]

Method that is called every reset of the chart, to precomputed values needed for the background of the boxes

reset()[source]

Reset the fan chart. This should trigger computation of all data structures needed

set_userdata_age(person, userdata)[source]
set_userdata_timeperiod(person, userdata)[source]

set the userdata as used by timeperiod

wrap_truncate_layout(layout, font, width_pixels)[source]

Uses the layout to wrap and truncate its text to given width

Returns: (w,h) as returned by layout.get_pixel_size()

class gramps.gui.widgets.fanchart.FanChartWidget(dbstate, uistate, callback_popup=None)[source]

Bases: gramps.gui.widgets.fanchart.FanChartBaseWidget

Constructors:
DrawingArea(**properties)
new()
change_slice(generation, selected)[source]
do_mouse_click()[source]
draw_childring(cr)[source]
draw_person(cr, gender, name, start, stop, generation, state, parents, child, person, userdata)[source]

Display the piece of pie for a given person. start and stop are in degrees. Gender is indication of father position or mother position in the chart

expand_parents(generation, selected, current)[source]
family_at(generation, pos, btype)[source]

returns the family at generation, pos, btype Difficult here, we would need to go to child, and then obtain the first parent family, as that is the family that is shown.

gen_pixels()[source]

how many pixels a generation takes up in the fanchart

halfdist()[source]

Compute the half radius of the circle

hide_parents(generation, selected, angle)[source]
innerpeople_generator()[source]

a generator over all people inside of the core person

nrgen()[source]
on_draw(widget, cr, scale=1.0)[source]

The main method to do the drawing. If widget is given, we assume we draw in GTK3 and use the allocation. To draw raw on the cairo context cr, set widget=None.

people_generator()[source]

a generator over all people outside of the core person

person_at(generation, pos, btype)[source]

returns the person at generation, pos, btype

personpos_at_angle(generation, angledeg, btype)[source]

returns the person in generation generation at angle.

set_generations()[source]

Set the generations to max, and fill data structures with initial data.

set_values(root_person_handle, maxgen, background, childring, radialtext, fontdescr, grad_start, grad_end, filter, alpha_filter, form)[source]

Reset the values to be used:

Parameters:
  • root_person_handle – person to show
  • maxgen – maximum generations to show
  • background (int) – config setting of which background procedure to use
  • childring – to show the center ring with children or not
  • radialtext – try to use radial text or not
  • fontdescr – string describing the font to use
  • grad_start – colors to use for background procedure
  • grad_end – colors to use for background procedure
  • filter – the person filter to apply to the people in the chart
  • alpha – the alpha transparency value (0-1) to apply to filtered out data
  • form – the FORM_ constant for the fanchart
show_parents(generation, selected, angle, slice)[source]
shrink_parents(generation, selected, current)[source]
class gramps.gui.widgets.fanchart.FanChartGrampsGUI(on_childmenu_changed)[source]

Bases: object

class for functions fanchart GUI elements will need in Gramps

add_child_to_fam_cb(obj, family_handle)[source]
add_partner_to_pers_cb(obj, person_handle)[source]

Add a family with the person preset

add_person_cb(obj)[source]

Add a person

callback_add_child(person, family_handle)[source]
copy_person_to_clipboard_cb(obj, person_handle)[source]

Renders the person data into some lines of text and puts that into the clipboard

edit_fam_cb(obj, family_handle)[source]
edit_person_cb(obj, person_handle)[source]
main()[source]

Fill the data structures with the active data. This initializes all data.

on_add_parents(obj, person_handle)[source]
on_popup(obj, event, person_handle, family_handle=None)[source]

Builds the full menu (including Siblings, Spouses, Children, and Parents) with navigation.

reord_fam_cb(obj, person_handle)[source]
set_fan(fan)[source]

Set the fanchartwidget to work on

Fanchart Descendant

class gramps.gui.widgets.fanchartdesc.FanChartDescWidget(dbstate, uistate, callback_popup=None)[source]

Bases: gramps.gui.widgets.fanchart.FanChartBaseWidget

Constructors:
DrawingArea(**properties)
new()
CENTER = 60
boxtype(radius)[source]

default is only one type of box type

change_slice(generation, selected, btype)[source]
do_mouse_click()[source]
draw_parentring(cr)[source]
draw_person(cr, name, start_rad, slice, radius, radiusend, generation, dup, person, userdata, family=False, thick=False)[source]

Display the piece of pie for a given person. start_rad and slice are in radial.

family_at(generation, pos, btype)[source]

returns the family at generation, pos, btype

gen_pixels()[source]

how many pixels a generation takes up in the fanchart

halfdist()[source]

Compute the half radius of the circle

innerpeople_generator()[source]

a generator over all people inside of the core person

nrgen()[source]
on_draw(widget, cr, scale=1.0)[source]

The main method to do the drawing. If widget is given, we assume we draw in GTK3 and use the allocation. To draw raw on the cairo context cr, set widget=None.

people_generator()[source]

a generator over all people outside of the core person

person_at(generation, pos, btype)[source]

returns the person at generation, pos, btype

personpos_at_angle(generation, angledeg, btype)[source]

returns the person in generation generation at angle.

set_generations()[source]

Set the generations to max, and fill data structures with initial data.

set_values(root_person_handle, maxgen, background, fontdescr, grad_start, grad_end, filter, alpha_filter, form, angle_algo, dupcolor)[source]

Reset the values to be used:

Parameters:
  • root_person_handle – person to show
  • maxgen – maximum generations to show
  • background (int) – config setting of which background procedure to use
  • fontdescr – string describing the font to use
  • grad_start – colors to use for background procedure
  • grad_end – colors to use for background procedure
  • filter – the person filter to apply to the people in the chart
  • alpha_filter – the alpha transparency value (0-1) to apply to filtered out data
  • form – the FORM_ constant for the fanchart
  • angle_algo – alorithm to use to calculate the sizes of the boxes
  • dupcolor – color to use for people or families that occur a second or more time
class gramps.gui.widgets.fanchartdesc.FanChartDescGrampsGUI(on_childmenu_changed)[source]

Bases: gramps.gui.widgets.fanchart.FanChartGrampsGUI

class for functions fanchart GUI elements will need in Gramps

main()[source]

Fill the data structures with the active data. This initializes all data.

Gramplet Bar

Module that implements the gramplet bar fuctionality.

class gramps.gui.widgets.grampletbar.DetachedWindow(grampletbar, gramplet, x_pos, y_pos)[source]

Bases: gramps.gui.managedwindow.ManagedWindow

Class for showing a detached gramplet.

build_menu_names(obj)[source]

Part of the Gramps window interface.

close(*args)[source]

Dock the detached gramplet back in the GrampletBar from where it came.

get_notebook()[source]

Return the notebook.

get_title()[source]

Returns the window title.

handle_response(object, response)[source]

Callback for taking care of button clicks.

page_added(notebook, gramplet, page_num)[source]

Called when the gramplet is added to the notebook. This takes the focus from the help button (bug #6306).

class gramps.gui.widgets.grampletbar.GrampletBar(dbstate, uistate, pageview, configfile, defaults)[source]

Bases: gi.repository.Gtk.Notebook

Constructors:
Notebook(**properties)
new()
add_gramplet(gname)[source]

Add a gramplet by name.

all_gramplets()[source]

Return a list of names of all the gramplets in the GrampletBar.

cb_close_changed()[source]

Close button preference changed.

get_config_funcs()[source]

Return a list of configuration functions.

has_gramplet(gname)[source]

Return True if the GrampletBar contains the gramplet, else False.

on_delete()[source]

Called when the view is closed.

remove_gramplet(gname)[source]

Remove a gramplet by name.

restore()[source]

Restore the GrampletBar to its default gramplets.

set_active()[source]

Called with the view is set as active.

set_inactive()[source]

Called with the view is set as inactive.

class gramps.gui.widgets.grampletbar.TabGramplet(pane, dbstate, uistate, title, **kwargs)[source]

Bases: gi.overrides.Gtk.ScrolledWindow, gramps.gui.widgets.grampletpane.GuiGramplet

Constructors:
ScrolledWindow(**properties)
new(hadjustment:Gtk.Adjustment=None, vadjustment:Gtk.Adjustment=None)
get_container_widget()[source]

Return the top level container widget.

get_title()[source]

Gramplet Pane

GrampletView interface.

class gramps.gui.widgets.grampletpane.LinkTag(buffer)[source]

Bases: gi.repository.Gtk.TextTag

Constructors:
TextTag(**properties)
new(name:str=None)
lid = 0
linkcolor = '#f07746'
class gramps.gui.widgets.grampletpane.GrampletWindow(gramplet)[source]

Bases: gramps.gui.managedwindow.ManagedWindow

Class for showing a detached gramplet.

build_menu_names(obj)[source]

Part of the GRAMPS window interface.

close(*args)[source]

Dock the detached GrampletWindow back in the column from where it came.

get_title()[source]

Returns the window title.

handle_response(object, response)[source]

Callback for taking care of button clicks.

class gramps.gui.widgets.grampletpane.GuiGramplet(pane, dbstate, uistate, title, **kwargs)[source]

Bases: object

Class that handles the GUI representation of a Gramplet.

append_text(text, scroll_to=u'end')[source]
clear_text()[source]
get_container_widget()[source]
get_text()[source]
insert_text(text)[source]
make_gui_options()[source]
on_button_press(view, event)[source]
on_key_press_event(widget, event)[source]

Signal handler.

Handle formatting shortcuts.

on_motion(view, event)[source]
redo()[source]
render_text(text)[source]
set_has_data(value)[source]
set_text(text, scroll_to=u'start')[source]
set_tooltip(tip)[source]
set_use_markup(value)[source]
undo()[source]
class gramps.gui.widgets.grampletpane.GridGramplet(pane, dbstate, uistate, title, **kwargs)[source]

Bases: gramps.gui.widgets.grampletpane.GuiGramplet

Class that handles the plugin interfaces for the GrampletView.

LOCAL_DRAG_TARGET = (Gdk.Atom.intern("GRAMPLET", False), 0, 80)
LOCAL_DRAG_TYPE = u'GRAMPLET'
TARGET_TYPE_FRAME = 80
change_state(obj)[source]

Change the state of a gramplet.

close(*obj)[source]

Remove (delete) the gramplet from view.

detach()[source]

Detach the gramplet from the GrampletView, and open in own window.

edit_title(widget)[source]

Edit the title in the GUI.

edit_title_done(widget, event=None)[source]

Edit title in GUI, finishing callback.

edit_title_keypress(widget, event)[source]

Edit the title, handle escape.

get_container_widget()[source]
get_detached_height()[source]
get_detached_width()[source]
get_expand()[source]
get_height()[source]
get_source_widget()[source]

Hack to allow us to send this object to the drop_widget method as a context.

get_title()[source]
set_detached_height(height)[source]
set_detached_width(width)[source]
set_expand(value)[source]
set_height(height)[source]
set_properties(obj)[source]

Set the properties of a gramplet.

set_state(state)[source]

Set the state of a gramplet.

set_title(new_title, set_override=True)[source]
class gramps.gui.widgets.grampletpane.GrampletPane(configfile, pageview, dbstate, uistate, **kwargs)[source]

Bases: gi.overrides.Gtk.ScrolledWindow

Constructors:
ScrolledWindow(**properties)
new(hadjustment:Gtk.Adjustment=None, vadjustment:Gtk.Adjustment=None)
add_gramplet(obj)[source]
build_panel(gramplet)[source]
can_configure()[source]

See PageView

Returns:bool
clear_gramplets()[source]

Detach all of the mainframe gramplets from the columns.

config_panel(configdialog)[source]

Function that builds the widget in the configuration dialog

drop_widget(source, context, x, y, timedata)[source]

This is the destination method for handling drag and drop of a gramplet onto the main scrolled window. Also used for adding new gramplets, then context should be GridGramplet

get_column_frame(column_num)[source]
get_columns()[source]
load_gramplets()[source]
on_delete()[source]
place_gramplets(recolumn=False)[source]

Place the gramplet mainframes in the columns.

restore_gramplet(obj)[source]
save()[source]
set_active()[source]
set_columns(num)[source]
set_inactive()[source]
set_state_all()[source]

This seems to be necessary to hide the hidden parts of a collapsed gramplet on sidebars.

show_all()[source]

This seems to be necessary to hide the hidden parts of a collapsed gramplet on main view.

class gramps.gui.widgets.grampletpane.Configuration(pane)[source]

Bases: object

A config wrapper to redirect set/get to GrampletPane.

get(key)[source]
register(key, vtype, getter, setter)[source]

register a key with type, getter, and setter methods.

set(widget, key)[source]

Hooked to signal, it is widget, key. Hooked to config, it is key, widget

Labels

class gramps.gui.widgets.labels.LinkLabel(label, func, handle, emph=False, theme='CLASSIC')[source]

Bases: gi.repository.Gtk.EventBox

Constructors:
EventBox(**properties)
new()
enter_text(obj, event, handle)[source]
leave_text(obj, event, handle)[source]
set_padding(x, y)[source]
class gramps.gui.widgets.labels.EditLabel(text)[source]

Bases: gi.repository.Gtk.HBox

Constructors:
HBox(**properties)
new(homogeneous:bool, spacing:int)
class gramps.gui.widgets.labels.BasicLabel(text, ellipsize=<enum PANGO_ELLIPSIZE_NONE of type PangoEllipsizeMode>)[source]

Bases: gi.overrides.Gtk.Label

Constructors:
Label(**properties)
new(str:str=None)
new_with_mnemonic(str:str=None)
class gramps.gui.widgets.labels.GenderLabel(text)[source]

Bases: gi.overrides.Gtk.Label

Constructors:
Label(**properties)
new(str:str=None)
new_with_mnemonic(str:str=None)
class gramps.gui.widgets.labels.MarkupLabel(text, x_align=0, y_align=0.5)[source]

Bases: gi.overrides.Gtk.Label

Constructors:
Label(**properties)
new(str:str=None)
new_with_mnemonic(str:str=None)
class gramps.gui.widgets.labels.DualMarkupLabel(text, alt, x_align=0, y_align=0.5)[source]

Bases: gi.repository.Gtk.HBox

Constructors:
HBox(**properties)
new(homogeneous:bool, spacing:int)

Menu Item

ToolComboEntry class.

class gramps.gui.widgets.menuitem.MenuItemWithData(label='')[source]

Bases: gi.overrides.Gtk.MenuItem

Constructors:
MenuItem(**properties)
new()
new_with_label(label:str)
new_with_mnemonic(label:str)
data
do_get_property(pspec)
do_set_property(pspec, value)
get_data(_=None)[source]

obtain the data, for backward compat, we allow a dummy argument

set_data(data)[source]

Monitored Widgets

class gramps.gui.widgets.monitoredwidgets.MonitoredCheckbox(obj, button, set_val, get_val, on_toggle=None, readonly=False)[source]

Bases: object

class gramps.gui.widgets.monitoredwidgets.MonitoredEntry(obj, set_val, get_val, read_only=False, autolist=None, changed=None)[source]

Bases: object

connect(signal, callback, *data)[source]
enable(value)[source]
force_value(value)[source]
get_value(value)[source]
grab_focus()[source]
reinit(set_val, get_val)[source]
set_text(text)[source]
update()[source]
class gramps.gui.widgets.monitoredwidgets.MonitoredEntryIndicator(obj, set_val, get_val, indicator, read_only=False, autolist=None, changed=None)[source]

Bases: gramps.gui.widgets.monitoredwidgets.MonitoredEntry

Show an Entry box with an indicator in it that disappears when entry becomes active

class gramps.gui.widgets.monitoredwidgets.MonitoredSpinButton(obj, set_val, get_val, read_only=False, autolist=None, changed=None)[source]

Bases: object

Class for signal handling of spinbuttons. (Code is a modified copy of MonitoredEntry)

connect(signal, callback)[source]

Connect the signal of monitored widget to the specified callback.

Parameters:
  • signal – Signal prototype for which a connection should be set up.
  • callback – Callback function to be called when signal is emitted.
enable(value)[source]

Change the property editable and sensitive of the monitored widget to value.

Parameters:value (bool) – If widget should be editable or deactivated.
force_value(value)[source]

Set the value of the monitored widget to the specified value.

Parameters:value – Value to be set.
get_value()[source]

Get the current value of the monitored widget.

Returns:Current value of monitored widget.
grab_focus()[source]

Assign the keyboard focus to the monitored widget.

reinit(set_val, get_val)[source]

Reinitialize class with the specified callback functions.

Parameters:
  • set_val – callback to be called when SpinButton is changed
  • get_val – callback to be called to retrieve value for SpinButton
set_value(value)[source]

Set the value of the monitored widget to the specified value.

Parameters:value – Value to be set.
update()[source]

Updates value of monitored SpinButton with the value returned by the get_val callback.

class gramps.gui.widgets.monitoredwidgets.MonitoredText(obj, set_val, get_val, read_only=False)[source]

Bases: object

on_change(obj)[source]
class gramps.gui.widgets.monitoredwidgets.MonitoredType(obj, set_val, get_val, mapping, custom, readonly=False, custom_values=None)[source]

Bases: object

on_change(obj)[source]
reinit(set_val, get_val)[source]
update()[source]
class gramps.gui.widgets.monitoredwidgets.MonitoredDataType(obj, set_val, get_val, readonly=False, custom_values=None, ignore_values=None)[source]

Bases: object

fix_value(value)[source]
on_change(obj)[source]
reinit(set_val, get_val)[source]
update()[source]
class gramps.gui.widgets.monitoredwidgets.MonitoredMenu(obj, set_val, get_val, mapping, readonly=False, changed=None)[source]

Bases: object

change_menu(mapping)[source]
force(value)[source]
on_change(obj)[source]
class gramps.gui.widgets.monitoredwidgets.MonitoredStrMenu(obj, set_val, get_val, mapping, readonly=False)[source]

Bases: object

on_change(obj)[source]
class gramps.gui.widgets.monitoredwidgets.MonitoredDate(field, button, value, uistate, track, readonly=False)[source]

Bases: object

Class that associates a pixmap with a text widget, providing visual feedback that indicates if the text widget contains a valid date.

invoke_date_editor(obj)[source]

Invokes Date Editor dialog when the user clicks the Calendar button. If date was in fact built, sets the date_obj to the newly built date.

set_date(widget)[source]

Parse date from text entry to date object

update_after_editor(date_obj)[source]

Update text entry and validate it

validate(widget, data)[source]

Validate current date in text entry

class gramps.gui.widgets.monitoredwidgets.MonitoredComboSelectedEntry(objcombo, objentry, textlist, set_val_list, get_val_list, default=0, read_only=False)[source]

Bases: object

A MonitoredEntry driven by a Combobox to select what the entry field works upon

enable(value)[source]
entry_reinit()[source]

Make the entry field show the value corresponding to the active key

get_value_entry()[source]
on_combochange(obj)[source]

callback for change on the combo, change active iter, update associated entrybox

reinit(set_val_list, get_val_list)[source]

The interface is attached to another object, so the methods need to be reset.

update()[source]

Method called when object changed without interface change Eg: name editor save brings you back to person editor that must update

class gramps.gui.widgets.monitoredwidgets.MonitoredTagList(label, button, set_list, get_list, db, uistate, track, readonly=False)[source]

Bases: object

A MonitoredTagList consists of a label to display a list of tags and a button to invoke the tag editor.

cb_edit(button, event)[source]

Invoke the tag editor.

Multi Tree View

An override to allow easy multiselections.

class gramps.gui.widgets.multitreeview.MultiTreeView[source]

Bases: gi.overrides.Gtk.TreeView

Constructors:
TreeView(**properties)
new()
new_with_model(model:Gtk.TreeModel)
key_press_event(widget, event)[source]
on_button_press(widget, event)[source]
on_button_release(widget, event)[source]

Photo

class gramps.gui.widgets.photo.Photo(use_small_size=False)[source]

Bases: gi.repository.Gtk.EventBox

Constructors:
EventBox(**properties)
new()
handle_button_press(widget, event)[source]

Display the image with the default external viewer.

set_image(full_path, mime_type=None, rectangle=None)[source]

Set the image to be displayed.

set_uistate(uistate, handle)[source]

Set uistate and media handle so that Photo can be handled by UI.

Progress Dialog

This module provides a progress dialog for displaying the status of long running operations.

class gramps.gui.widgets.progressdialog.LongOpStatus(msg='', total_steps=None, interval=1, can_cancel=False)[source]

Bases: gramps.gen.utils.callback.Callback

LongOpStatus provides a way of communicating the status of a long running operations. The intended use is that when a long running operation is about to start it should create an instance of this class and emit it so that any listeners can pick it up and use it to record the status of the operation.

Signals

  • op-heartbeat - emitted every ‘interval’ calls to heartbeat.
  • op-end - emitted once when the operation completes.

Example usage:

class MyClass(Callback):

    __signals__ = {
   'op-start'   : object
    }

    def long(self):
        status = LongOpStatus("doing long job", 100, 10)

        for i in xrange(0,99):
            time.sleep(0.1)
            status.heartbeat()

        status.end()

class MyListener(object):

     def __init__(self):
     self._op = MyClass()
     self._op.connect('op-start', self.start)
     self._current_op = None

     def start(self,long_op):
     self._current_op.connect('op-heartbeat', self.heartbeat)
     self._current_op.connect('op-end', self.stop)

     def hearbeat(self):
     # update status display

     def stop(self):
     # close the status display
         self._current_op = None
can_cancel()[source]
Returns:True if the operation can be cancelled.
Return type:bool
cancel()[source]

Inform the operation that it should complete.

end()[source]

End the operation. Causes the ‘op-end’ signal to be emitted.

estimated_secs_to_complete()[source]

Return the number of seconds estimated left before operation completes. This will change as ‘hearbeat’ is called.

Returns:estimated seconds to complete.
Return type:int
get_interval()[source]

Get the interval between ‘op-hearbeat’ signals.

Returns:the interval between ‘op-hearbeat’ signals.
Return type:int
get_msg()[source]
Returns:The current status description messages.
Return type:string
get_total_steps()[source]

Get to total number of steps. NOTE: this is not the number of times that the ‘op-heartbeat’ message will be emited. ‘op-heartbeat’ is emited get_total_steps/interval times.

Returns:total number of steps.
Return type:int
heartbeat()[source]

This should be called for each step in the operation. It will emit a ‘op-heartbeat’ every ‘interval’ steps. It recalcuates the ‘estimated_secs_to_complete’ from the time taken for previous steps.

set_msg(msg)[source]

Set the current description message.

Parameters:msg (string) – The description message.
should_cancel()[source]

Return true of the user has asked for the operation to be cancelled.

Returns:True of the operation should be cancelled.
Return type:bool
step()[source]

Convenience function so LongOpStatus can be used as a ProgressBar if set up correctly

was_cancelled()[source]

Has this process been cancelled?

class gramps.gui.widgets.progressdialog.ProgressMonitor(dialog_class, dialog_class_params=(), title='Progress Information', popup_time=None)[source]

Bases: object

A dialog for displaying the status of long running operations.

It will work with LongOpStatus objects to track the progress of long running operations. If the operations is going to take longer than popup_time it will pop up a dialog with a progress bar so that the user gets some feedback about what is happening.

add_op(op_status)[source]

Add a new status object to the progress dialog.

Parameters:op_status (LongOpStatus) – the status object.
class gramps.gui.widgets.progressdialog.GtkProgressDialog(window_params, title)[source]

Bases: gi.overrides.Gtk.Dialog

Constructors:
Dialog(**properties)
new()
add(long_op_status)[source]

Add a new status object to the progress dialog.

Parameters:long_op_status (LongOpStatus) – the status object.
Returns:a key that can be used as the pbar_idx to the other methods.
Return type:int
close()[source]
hide()[source]

Hide the dialog and process any events.

remove(pbar_idx)[source]

Remove the specified status object from the progress dialog.

Parameters:pbar_idx (int) – the index as returned from add()
show()[source]

Show the dialog and process any events.

step(pbar_idx)[source]

Click the progress bar over to the next value. Be paranoid and insure that it doesn’t go over 100%.

Parameters:pbar_idx (int) – the index as returned from add()

Shortlist ComboEntry

ShortlistComboEntry class.

class gramps.gui.widgets.shortlistcomboentry.ShortlistComboEntry(items, shortlist=True, validator=None)[source]

Bases: gramps.gui.widgets.validatedcomboentry.ValidatedComboEntry

Constructors:
ComboBox(**properties)
new()
new_with_area(area:Gtk.CellArea)
new_with_area_and_entry(area:Gtk.CellArea)
new_with_entry()
new_with_model(model:Gtk.TreeModel)
new_with_model_and_entry(model:Gtk.TreeModel)

Spring Separator

Separator classes used for Toolbar.

class gramps.gui.widgets.springseparator.SpringSeparatorToolItem[source]

Bases: gi.repository.Gtk.SeparatorToolItem

Constructors:
SeparatorToolItem(**properties)
new()
class gramps.gui.widgets.springseparator.SpringSeparatorAction(name, label, tooltip, stock_id)[source]

Bases: gi.overrides.Gtk.Action

Constructors:
Action(**properties)
new(name:str, label:str=None, tooltip:str=None, stock_id:str=None)

Statusbar

class gramps.gui.widgets.statusbar.Statusbar[source]

Bases: gi.repository.Gtk.HBox

Constructors:
HBox(**properties)
new(homogeneous:bool, spacing:int)
clear_filter()[source]

Clear the filter status text.

get_context_id(context_description)[source]

Return a new or existing context identifier.

get_progress_bar()[source]

Return the progress bar widget.

get_warning_button()[source]

Return the warning button widget.

pop(context_id)[source]

Remove the top message from a statusbar’s stack.

push(context_id, text)[source]

Push message onto a statusbar’s stack.

remove(context_id, message_id)[source]

Remove the message with the specified message_id.

set_filter(text)[source]

Set the filter status text.

Styled Text Buffer

Text buffer subclassed from Gtk.TextBuffer handling StyledText.

class gramps.gui.widgets.styledtextbuffer.LinkTag(buffer, data, **properties)[source]

Bases: gi.repository.Gtk.TextTag

Constructors:
TextTag(**properties)
new(name:str=None)
lid = 0
class gramps.gui.widgets.styledtextbuffer.GtkSpellState(textbuffer)[source]

Bases: object

A simple state machine kinda thingy.

Trying to track Gtk.Spell activities on a buffer and re-apply formatting after Gtk.Spell replaces a misspelled word.

STATE_CLICKED = 1
STATE_DELETED = 2
STATE_INSERTING = 3
STATE_NONE = 0
after_buffer_insert_text(textbuffer, iter, text, length)[source]
backward_word_start(iter)[source]

Gtk.Spell style Gtk.TextIter.backward_word_start.

The parameter ‘iter’ is changing as side effect.

forward_word_end(iter)[source]

Gtk.Spell style Gtk.TextIter.forward_word_end.

The parameter ‘iter’ is changing as side effect.

get_word_extents_from_mark(textbuffer, mark)[source]

Get the word extents as Gtk.Spell does.

Used to get the beginning of the word, in which user right clicked. Formatting found at that position used after Gtk.Spell replaces misspelled words.

on_buffer_delete_range(textbuffer, start, end)[source]
on_buffer_insert_text(textbuffer, iter, text, length)[source]
on_buffer_mark_set(textbuffer, iter, mark)[source]
reset_state()[source]
class gramps.gui.widgets.styledtextbuffer.StyledTextBuffer[source]

Bases: gramps.gui.widgets.undoablebuffer.UndoableBuffer

Constructors:
TextBuffer(**properties)
new(table:Gtk.TextTagTable=None)
after_delete_range(textbuffer, start, end)[source]
after_insert_text(textbuffer, iter, text, length)[source]

Format inserted text.

apply_style(style, value)[source]

Apply a style with the given value to the selection.

Parameters:
  • style (StyledTextTagStyle int value) – style type to apply
  • value (depends on the style type) – value of the style type
clear_selection()[source]

Clear tags from selection.

do_changed(data=None)[source]

Parse for patterns in the text.

do_mark_set(iter, mark)[source]

Update style state each time the cursor moves.

get_style_at_cursor(style)[source]

Get the actual value of the given style at the cursor position.

Parameters:style (StyledTextTagStyle int value) – style type to apply
Returns:value of the style type
Return type:depends on the style type
get_text(start=None, end=None, include_hidden_chars=True)[source]

Return the buffer text.

Note

s_ prefix means StyledText*, while g_ prefix means Gtk.*.

match_add(pattern, flavor)[source]

Add a pattern to look for in the text.

match_check(pos)[source]

Check if pos falls into any of the matched patterns.

on_insert_text(textbuffer, iter, text, length)[source]
remove_style(style)[source]

Delete all occurences with any value of the given style.

Parameters:style (StyledTextTagStyle int value) – style type to apply
set_text(s_text)[source]

Set the content of the buffer with markup tags.

Note

s_ prefix means StyledText*, while g_ prefix means Gtk.*.

Styled Text Editor

Text editor subclassed from Gtk.TextView handling StyledText.

class gramps.gui.widgets.styledtexteditor.StyledTextEditor[source]

Bases: gi.repository.Gtk.TextView

Constructors:
TextView(**properties)
new()
new_with_buffer(buffer:Gtk.TextBuffer)
do_match_changed(match)[source]

Default signal handler.

URL highlighting.

Parameters:match (tuple or None) – the new match parameters

Warning

Do not override the handler, but connect to the signal.

get_text()[source]

Get the text of the text buffer of the editor.

Returns:the formatted text from the editor.
Return type:StyledText
get_toolbar()[source]

Get the formatting toolbar of the editor.

Returns:toolbar widget to use as formatting GUI.
Return type:Gtk.Toolbar

Return a string useful for a tooltip given a LinkTag object.

on_button_press_event(widget, event)[source]

Signal handler.

Handles the <CTRL> + Left click over a URL match.

on_button_release_event(widget, event)[source]

Copy selection to clipboard for left click if selection given

on_delete_from_cursor(widget, mode, count)[source]

Signal handler. for debugging only.

on_insert_at_cursor(widget, string)[source]

Signal handler. for debugging only.

on_key_press_event(widget, event)[source]

Signal handler.

Handle formatting shortcuts.

on_motion_notify_event(widget, event)[source]

Signal handler.

As the mouse cursor moves the handler checks if there’s a new regexp match at the new location. If match changes the ‘match-changed’ signal is raised.

on_paste_clipboard(widget)[source]

Signal handler. for debugging only.

on_populate_popup(widget, menu)[source]

Signal handler.

Insert extra menuitems:

  1. Insert spellcheck selector submenu for spell checking.
  2. Insert extra menus depending on ULR match result.
on_unrealize(widget)[source]

Signal handler.

Set the default Gtk settings back before leaving.

redo(obj=None)[source]
reset()[source]

Reset the undoable buffer

search_web(widget)[source]

Search the web for selected text.

set_text(text)[source]

Set the text of the text buffer of the editor.

Parameters:text (StyledText) – formatted text to edit in the view.

Callback for setting or editing a link’s object.

undo(obj=None)[source]

Tool ComboEntry

ToolComboEntry class.

class gramps.gui.widgets.toolcomboentry.ToolComboEntry(data_type, args)[source]

Bases: gramps.gui.widgets.valuetoolitem.ValueToolItem

Constructors:
ToolItem(**properties)
new()
get_value()[source]
set_value(value)[source]

Undoable Buffer

gtk textbuffer with undo functionality

class gramps.gui.widgets.undoablebuffer.Stack(stack_size=None)[source]

Bases: list

Very simple stack implementation that cannot grow beyond an at init determined size. Inherits from list. Only append checks if this is really the case!

append(item)[source]
class gramps.gui.widgets.undoablebuffer.UndoableInsert(text_iter, text, length, text_buffer)[source]

Bases: object

something that has been inserted into our textbuffer

class gramps.gui.widgets.undoablebuffer.UndoableDelete(text_buffer, start_iter, end_iter)[source]

Bases: object

something that has been deleted from our textbuffer

class gramps.gui.widgets.undoablebuffer.UndoableBuffer[source]

Bases: gi.overrides.Gtk.TextBuffer

Constructors:
TextBuffer(**properties)
new(table:Gtk.TextTagTable=None)
begin_not_undoable_action()[source]

don’t record the next actions

toggles self.not_undoable_action

can_redo[source]
can_undo[source]
deleteclass

alias of UndoableDelete

end_not_undoable_action()[source]

record next actions

toggles self.not_undoable_action

insertclass

alias of UndoableInsert

on_delete_range_undoable(text_buffer, start_iter, end_iter)[source]
on_insert_text_undoable(textbuffer, text_iter, text, length)[source]
redo()[source]

redo inserts or deletions

redone actions are moved to undo stack

reset()[source]

Resets buffer to initial state.

undo()[source]

undo inserts or deletions

undone actions are being moved to redo stack

undo_stack_size = 700

Undoable Entry

class gramps.gui.widgets.undoableentry.UndoableInsertEntry(text, length, position, editable)[source]

Bases: object

something that has been inserted into our Gtk.editable

class gramps.gui.widgets.undoableentry.UndoableDeleteEntry(editable, start, end)[source]

Bases: object

something that has been deleted from our textbuffer

class gramps.gui.widgets.undoableentry.UndoableEntry[source]

Bases: gi.repository.Gtk.Entry

Constructors:
Entry(**properties)
new()
new_with_buffer(buffer:Gtk.EntryBuffer)
begin_not_undoable_action()[source]

don’t record the next actions

toggles self.not_undoable_action

deleteclass

alias of UndoableDeleteEntry

end_not_undoable_action()[source]

record next actions

toggles self.not_undoable_action

insertclass

alias of UndoableInsertEntry

redo()[source]

redo inserts or deletions

redone actions are moved to undo stack

reset()[source]

Resets buffer to initial state.

set_text(text)[source]
undo()[source]

undo inserts or deletions

undone actions are being moved to redo stack

undo_stack_size = 50

Undoable Styled Buffer

gtk textbuffer with undo functionality

class gramps.gui.widgets.undoablestyledbuffer.UndoableInsertStyled(text_iter, text, length, text_buffer)[source]

Bases: gramps.gui.widgets.undoablebuffer.UndoableInsert

something that has been inserted into our styledtextbuffer

class gramps.gui.widgets.undoablestyledbuffer.UndoableDeleteStyled(text_buffer, start_iter, end_iter)[source]

Bases: gramps.gui.widgets.undoablebuffer.UndoableDelete

class gramps.gui.widgets.undoablestyledbuffer.UndoableApplyStyle(text_buffer, tag, start, end)[source]

a style has been applied to our textbuffer

set_after(tags, offset)[source]
class gramps.gui.widgets.undoablestyledbuffer.UndoableStyledBuffer[source]

Bases: gramps.gui.widgets.styledtextbuffer.StyledTextBuffer

Constructors:
TextBuffer(**properties)
new(table:Gtk.TextTagTable=None)
deleteclass

alias of UndoableDeleteStyled

insertclass

alias of UndoableInsertStyled

on_tag_afterinsert_undoable(buffer, tag, start, end)[source]
on_tag_insert_undoable(buffer, tag, start, end)[source]
undo_disabled(*args, **kwds)[source]

Assures that not_undoable_action is False during the context.

Usage example (see gramps/gui/widgets/styledtexteditor.py):

with self.buffer.undo_disabled():
    ... # heavy stuff like spell checking

Validated Combo Entry

The ValidatedComboEntry widget class.

class gramps.gui.widgets.validatedcomboentry.ValidatedComboEntry(datatype, model=None, column=-1, validator=None, width=-1)[source]

Bases: gi.overrides.Gtk.ComboBox

Constructors:
ComboBox(**properties)
new()
new_with_area(area:Gtk.CellArea)
new_with_area_and_entry(area:Gtk.CellArea)
new_with_entry()
new_with_model(model:Gtk.TreeModel)
new_with_model_and_entry(model:Gtk.TreeModel)
do_grab_focus()[source]
do_mnemonic_activate(group_cycling)[source]
get_active_data()[source]
get_data_column()[source]
set_active_data(data)[source]
set_data_column(data_column)[source]
set_entry_editable(is_editable)[source]

Validated Masked Entry

class gramps.gui.widgets.validatedmaskedentry.FadeOut(widget, err_color='#ffd5d5')[source]

Bases: gi.overrides.GObject.Object

Constructors:
Object(**properties)
new(object_type:GType, parameters:list)
COMPLAIN_DELAY = 500
MERGE_COLORS_DELAY = 100
start(color)[source]

Schedules a start of the countdown.

Parameters:color – initial background color
Returns:True if we could start, False if was already in progress
stop()[source]

Stops the fadeout and restores the background color

class gramps.gui.widgets.validatedmaskedentry.MaskedEntry[source]

Bases: gramps.gui.widgets.undoableentry.UndoableEntry

Constructors:
Entry(**properties)
new()
new_with_buffer(buffer:Gtk.EntryBuffer)
get_background()[source]
get_completion()[source]
get_empty_mask(start=None, end=None)[source]

Get the empty mask between start and end

Parameters:
  • start
  • end
Returns:

mask

Return type:

string

get_field()[source]
get_field_length(field)[source]
get_field_pos(field)[source]

Get the position at the specified field.

get_field_text(field)[source]
get_fields()[source]

Get the fields assosiated with the entry. A field is dynamic content separated by static. For example, the format string 000-000 has two fields separated by a dash. if a field is empty it’ll return an empty string otherwise it’ll include the content

Returns:fields
Return type:list of strings
get_mask()[source]
Returns:the mask
is_empty()[source]
prefill(itemdata, sort=False)[source]
set_completion(completion)[source]
set_completion_mode(popup=None, inline=None)[source]

Set the way how completion is presented.

Parameters:
  • popup (boolean) – enable completion in popup window
  • inline (boolean) – enable inline completion
set_exact_completion(value)[source]

Enable exact entry completion. Exact means it needs to start with the value typed and the case needs to be correct.

Parameters:value (boolean) – enable exact completion
set_field(field, select=False)[source]
set_mask(mask)[source]

Set the mask of the Entry.

Supported format characters are:

  • ‘0’ digit
  • ‘L’ ascii letter (a-z and A-Z)
  • ‘&’ alphabet, honors the locale
  • ‘a’ alphanumeric, honors the locale
  • ‘A’ alphanumeric, honors the locale

This is similar to MaskedTextBox: http://msdn2.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask(VS.80).aspx

Example mask for a ISO-8601 date >>> entry.set_mask(‘0000-00-00’)

Parameters:mask – the mask to set
set_pixbuf(pixbuf)[source]
set_stock(stock_name)[source]
set_tooltip(text)[source]
update_background(color, unset=False)[source]
class gramps.gui.widgets.validatedmaskedentry.ValidatableMaskedEntry(data_type=None, err_color='#ffd5d5', error_icon='gtk-stop')[source]

Bases: gramps.gui.widgets.validatedmaskedentry.MaskedEntry

Constructors:
Entry(**properties)
new()
new_with_buffer(buffer:Gtk.EntryBuffer)
do_changed()[source]
do_get_property(prop)[source]

Return the gproperty’s value.

do_set_property(prop, value)[source]

Set the property of writable properties.

is_valid()[source]
Returns:True if the widget is in validated state
set_blank()[source]

Change the validation state to blank state, this only applies for mandatory widgets, draw an icon and set a tooltip

set_default_error_msg(text)[source]

Set default message for validation error.

Default error message for an instance is useful when completion is used, because this case custom validation is not called.

Parameters:text (str) – can contain one and only one ‘%s’, where the actual value of the Entry will be inserted.
set_invalid(text=None, fade=True)[source]

Change the validation state to invalid.

Parameters:
  • text – text of tooltip of None
  • fade – if we should fade the background
set_text(text)[source]

Set the text of the entry

Parameters:text
set_valid()[source]

Change the validation state to valid, which will remove icons and reset the background color

validate(force=False)[source]

Checks if the data is valid. Validates data-type and custom validation.

Parameters:force – if True, force validation
Returns:validated data or ValueUnset if it failed

Value Action

ValueAction class.

class gramps.gui.widgets.valueaction.ValueAction(name, tooltip, default, itemtype, *args)[source]

Bases: gi.overrides.Gtk.Action

Constructors:
Action(**properties)
new(name:str, label:str=None, tooltip:str=None, stock_id:str=None)
connect_proxy(proxy)[source]

Connect a widget to an action object as a proxy.

Parameters:proxy (ValueToolItem subclass) – widget to be connected
do_changed()[source]

Default signal handler for ‘changed’ signal.

Synchronize all the proxies with the active value.

do_create_tool_item()[source]

Create a ‘default’ toolbar item widget.

Override the default method, to be able to pass the required parameters to the proxy’s constructor.

This method is called from Gtk.UIManager.ensure_update(), when a ‘toolitem’ is found in the UI definition with a name refering to a ValueAction. Thus, to use the action via the UIManager a ‘default’ toolitem type has to be set with the Gtk.Action.set_tool_item_type() method, before invoking the Gtk.UIManager.ensure_update() method.

Widgets other than the default type has to be created and added manually with the Gtk.Action.connect_proxy() method.

Returns:a toolbar item connected to the action.
Return type:ValueToolItem subclass
get_value()[source]

Get the value from the action.

set_value(value)[source]

Set value to action.

Value Tool Item

ValueToolItem class.

class gramps.gui.widgets.valuetoolitem.ValueToolItem(data_type, args)[source]

Bases: gi.repository.Gtk.ToolItem

Constructors:
ToolItem(**properties)
new()
get_value()[source]

Get value from the proxied widget.

The method is responsible converting the data type between action and widget.

set_value(value)[source]

Set new value for the proxied widget.

The method is responsible converting the data type between action and widget.