wbia.guitool package

Submodules

wbia.guitool.PrefWidget2 module

CommandLine:
python -m wbia.guitool.PrefWidget2 EditConfigWidget –show python -m wbia.guitool.guitool_components ConfigConfirmWidget –show
class wbia.guitool.PrefWidget2.ConfigNodeWrapper(name=None, config=None, parent=None, param_info=None)[source]

Bases: utool.util_dev.NiceRepr

Wraps a dtool.Config object for internal qt use

is_checkable()[source]
is_combo
is_leaf()[source]
is_spin
iter_children()[source]
make_tree_strlist(indent='', verbose=None)[source]

Creates tree structured printable represntation

max_
min_
none_ok
print_tree()[source]
qt_child(row)[source]
qt_get_data(column)[source]
qt_is_editable()[source]

Really means able to change value.

qt_num_cols()[source]
qt_num_rows()[source]
qt_parent()[source]
qt_set_data(qvar)[source]

Sets backend data using QVariants

set_value(new_val)[source]
step_
type_
valid_values
class wbia.guitool.PrefWidget2.ConfigValueDelegate[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

A delegate that decides what the editor should be for each row in a specific column

CommandLine:
python -m wbia.guitool.PrefWidget2 EditConfigWidget –show python -m wbia.guitool.PrefWidget2 EditConfigWidget –show –verbconf

References

http://stackoverflow.com/questions/28037126/how-to-use-qcombobox-as-delegate-with-qtableview http://www.qtcentre.org/threads/41409-PyQt-QTableView-with-comboBox http://stackoverflow.com/questions/28680150/qtableview-data-in-background–cell-is-edited https://forum.qt.io/topic/46628/qtreeview-with-qitemdelegate-and-qcombobox-inside-not-work-propertly/5 http://stackoverflow.com/questions/33990029/what-are-the-mechanics-of-the-default-delegate-for-item-views-in-qt #http://www.qtcentre.org/archive/index.php/t-64165.html #http://doc.qt.io/qt-4.8/style-reference.html

createEditor(parent, option, index)[source]

Creates different editors for different types of data

currentIndexChanged(combo_idx)[source]
editorEvent(self, QEvent, QAbstractItemModel, QStyleOptionViewItem, QModelIndex) → bool[source]
eventFilter(self, QObject, QEvent) → bool[source]
paint(self, QPainter, QStyleOptionViewItem, QModelIndex)[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
updateEditorGeometry(self, QWidget, QStyleOptionViewItem, QModelIndex)[source]
class wbia.guitool.PrefWidget2.EditConfigWidget(parent=None, config=None, user_mode=False, with_buttons=True, changed=None)[source]

Bases: PyQt5.QtWidgets.QWidget

Widget to edit a dtool.Config object

Parameters:config (dtool.Config) –
CommandLine:
python -m wbia.guitool.PrefWidget2 EditConfigWidget –show python -m wbia.guitool.PrefWidget2 EditConfigWidget –show –verbconf

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.PrefWidget2 import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> import dtool
>>> def changed(key=None):
>>>     print('config[key] = %r has changed' % (key,))
>>> class ExampleConfig(dtool.Config):
>>>     _param_info_list = [
>>>         ut.ParamInfo('str_option', 'hello'),
>>>         ut.ParamInfo('int_option', 42, none_ok=False),
>>>         ut.ParamInfo('int_option2', None, type_=int, min_=-2),
>>>         ut.ParamInfo('float_option', .42, max_=1.0, min_=0),
>>>         ut.ParamInfo('none_option', None),
>>>         ut.ParamInfo('none_combo_option', None, valid_values=[None, True, False]),
>>>         ut.ParamInfo('combo_option', 'up', valid_values=['up', 'down', 'strange', 'charm', 'top', 'bottom']),
>>>         ut.ParamInfo('bool_option', False),
>>>         ut.ParamInfo('bool_option2', None, type_=bool),
>>>         ut.ParamInfo('hidden_str', 'foobar', hideif=lambda cfg: not cfg['bool_option']),
>>>         ut.ParamInfo('hidden_combo', 'one', valid_values=['oneA', 'twoB', 'threeC'], hideif=lambda cfg: not cfg['bool_option']),
>>>     ]
>>> config = ExampleConfig()
>>> widget = EditConfigWidget(config=config, changed=changed)
>>> widget.rootNode.print_tree()
>>> from wbia.plottool import fig_presenter
>>> fig_presenter.register_qt4_win(widget)
>>> widget.show()
>>> ut.quit_if_noshow()
>>> widget.resize(400, 500)
>>> guitool.qtapp_loop(qwin=widget, freq=10)
data_changed
init_layout()[source]
init_mvc()[source]
print_internals()[source]
refresh_layout()[source]
reset_to_default()[source]
reset_to_original()[source]
set_to_external(cfg)[source]
class wbia.guitool.PrefWidget2.NoneSpinBox(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QDoubleSpinBox

Custom spin box that handles None / nan values

HARD_MAX = 536870913.0
HARD_MIN = -536870913.0
NONE_VALUE = -536870912.0
keyPressEvent(self, QKeyEvent)[source]
setMaximum(self, float)[source]
setMinimum(min_)[source]

hack to get around None being invalid

setRange(self, float, float)[source]
setValue(self, float)[source]
stepBy(self, int)[source]
textFromValue(self, float) → str[source]
validate(self, str, int) → Tuple[QValidator.State, str, int][source]
value(self) → float[source]
valueFromText(self, str) → float[source]
class wbia.guitool.PrefWidget2.QConfigModel(**kwargs)[source]

Bases: PyQt5.QtCore.QAbstractItemModel

Convention states only items with column index 0 can have children

columnCount(**kwargs)[source]
data(**kwargs)[source]
flags(**kwargs)[source]
headerData(**kwargs)[source]
index(**kwargs)[source]
index2Pref(**kwargs)[source]
parent(**kwargs)[source]
rowCount(**kwargs)[source]
setData(**kwargs)[source]
wbia.guitool.PrefWidget2.qindexstr(index)[source]
wbia.guitool.PrefWidget2.report_thread_error(fn)[source]

Decorator to help catch errors that QT wont report

wbia.guitool.PreferenceWidget module

old code ported from utool

class wbia.guitool.PreferenceWidget.EditPrefWidget(pref_struct)[source]

Bases: PyQt5.QtWidgets.QWidget

The Settings Pane; Subclass of Main Windows.

populatePrefTreeSlot(pref_struct)[source]

Populates the Preference Tree Model

refresh_layout()[source]
class wbia.guitool.PreferenceWidget.QPreferenceModel(**kwargs)[source]

Bases: PyQt5.QtCore.QAbstractItemModel

Convention states only items with column index 0 can have children

columnCount(**kwargs)[source]
data(**kwargs)[source]
flags(**kwargs)[source]
headerData(**kwargs)[source]
index(**kwargs)[source]
index2Pref(**kwargs)[source]
parent(**kwargs)[source]
rowCount(**kwargs)[source]
setData(**kwargs)[source]
class wbia.guitool.PreferenceWidget.Ui_editPrefSkel[source]

Bases: object

THE PREFERENCE SKELETON

retranslateUi(editPrefSkel)[source]
setupUi(editPrefSkel)[source]
wbia.guitool.PreferenceWidget.report_thread_error(fn)[source]

Decorator to help catch errors that QT wont report

wbia.guitool.PreferenceWidget.test_preference_gui()[source]
CommandLine:
python -m wbia.guitool.PreferenceWidget –exec-test_preference_gui –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.PreferenceWidget import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> scope = test_preference_gui()
>>> ut.quit_if_noshow()
>>> guitool.qtapp_loop(freq=10)

wbia.guitool._api_tree_node_cython module

wbia.guitool.api_button_delegate module

class wbia.guitool.api_button_delegate.APIButtonDelegate(parent=None)[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

button_clicked
editorEvent(self, QEvent, QAbstractItemModel, QStyleOptionViewItem, QModelIndex) → bool[source]
get_index_butkw(qtindex)[source]

The model data for a button should be a (text, callback) tuple. OR it could be a function which accepts an qtindex and returns a button

is_qtindex_pressed(qtindex)[source]
on_button_click(qtindex)[source]
paint(self, QPainter, QStyleOptionViewItem, QModelIndex)[source]
wbia.guitool.api_button_delegate.paint_button(painter, option, text='button', pressed=True, bgcolor=None, fgcolor=None, clicked=None, button=None, view=None)[source]
wbia.guitool.api_button_delegate.rgb_to_qbrush(rgb)[source]
wbia.guitool.api_button_delegate.rgb_to_qcolor(rgb)[source]

wbia.guitool.api_item_model module

class wbia.guitool.api_item_model.APIItemModel(headers=None, parent=None)[source]

Bases: PyQt5.QtCore.QAbstractItemModel

Item model for displaying a list of columns

iders

functions that return ids for setters and getters

Type:list
col_name_list

keys or SQL-like name for column to reference abstracted data storage using getters and setters

Type:list
col_type_list

column value (Python) types

Type:list
col_nice_list

well-formatted names of the columns

Type:list
col_edit_list

booleans for if column should be editable

Type:list
col_setter_list

setter functions

Type:list
col_getter_list

getter functions

Type:list
col_sort_index

index into col_name_list for sorting

Type:int
col_sort_reverse

flag to reverse the sort ordering

Type:bool
EditableItemColor = <PyQt5.QtGui.QColor object>
FalseItemColor = <PyQt5.QtGui.QColor object>
TrueItemColor = <PyQt5.QtGui.QColor object>
canFetchMore(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Returns true if there is more data available for parent; otherwise returns false. The default implementation always returns false. If canFetchMore() returns true, the fetchMore() function should be called. This is the behavior of QAbstractItemView, for example.

References

http://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html # Extend this to work well with QTreeViews http://blog.tjwakeham.com/lazy-loading-pyqt-data-models/ http://stackoverflow.com/questions/38506808/pyqt4-force-view-to-fetchmore-from

clear_cache()[source]
columnCount(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Qt Override

data(qtindex, role=0, **kwargs)[source]

Depending on the role, returns either data or how to display data Returns the data stored under the given role for the item referred to by the index.

Note

If you do not have a value to return, return None

fetchMore(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Fetches any available data for the items with the parent specified by the parent index.

Reimplement this if you are populating your model incrementally. The default implementation does nothing.

flags(qtindex)[source]

Qt Override

Returns:
0: ‘NoItemFlags’ # It does not have any properties set.
1: ‘ItemIsSelectable’ # It can be selected. 2: ‘ItemIsEditable’ # It can be edited. 4: ‘ItemIsDragEnabled’ # It can be dragged. 8: ‘ItemIsDropEnabled’ # It can be used as a drop target.

16: ‘ItemIsUserCheckable’ # It can be checked or unchecked by the user. 32: ‘ItemIsEnabled’ # The user can interact with the item. 64: ‘ItemIsTristate’ # The item is checkable with three separate states.

Return type:Qt.ItemFlag
get_header_data(colname, qtindex)[source]

Use _get_data if the column number is known

get_header_name(column)[source]
get_iders()[source]
get_row_and_qtindex_from_id(_id)[source]

uses an sqlrowid (from iders) to get a qtindex

headerData(section, orientation, role=0)[source]

Qt Override

Returns:the data for the given role and section in the header with the specified orientation. For horizontal headers, the section number corresponds to the column number. Similarly, for vertical headers, the section number corresponds to the row number.
index(row, column, parent=<PyQt5.QtCore.QModelIndex object>)[source]

Qt Override

Returns:the index of the item in the model specified by the given row, column and parent index. When reimplementing this function in a subclass, call createIndex() to generate model indexes that other components can use to refer to items in your model.

Note

Object must be specified to sort delegates.

parent(qindex)[source]

A common convention used in models that expose tree data structures is that only items in the first column have children. For that case, when reimplementing this function in a subclass the column of the returned QModelIndex would be 0.

When reimplementing this function in a subclass, be careful to avoid calling QModelIndex member functions, such as QModelIndex.parent(), since indexes belonging to your model will simply call your implementation, leading to infinite recursion.

FIXME:
seems to segfault in here https://riverbankcomputing.com/pipermail/pyqt/2016-February/036977.html https://gist.github.com/estan/c051d1f798c4c46caa7d
Returns:the parent of the model item with the given index. If the item has no parent, an invalid QModelIndex is returned.
rowCount(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Qt Override

setData(qtindex, value, role=2)[source]

Sets the role data for the item at qtindex to value. value is a QVariant (called data in documentation) Returns a map with values for all predefined roles in the model for the item at the given index. Reimplement this function if you want to extend the default behavior of this function to include custom roles in the map.

set_ider_filters(ider_filters)[source]

Used to induce a filter on the rows, needs call of udpate rows after

sort(column, order)[source]

Qt Override

class wbia.guitool.api_item_model.ChangeLayoutContext(model_list, *args)[source]

Bases: object

Context manager emitting layoutChanged before body, not updating durring body, and then updating after body.

wbia.guitool.api_item_model.default_method_decorator(func)[source]

Dummy decorator

wbia.guitool.api_item_model.simple_thumbnail_widget()[source]

Very simple example to test thumbnails

CommandLine:
python -m wbia.guitool.api_item_model –test-simple_thumbnail_widget –show

Example

>>> # ENABLE_DOCTEST
>>> import wbia.guitool
>>> from wbia.guitool.api_item_model import *  # NOQA
>>> guitool.ensure_qapp()  # must be ensured before any embeding
>>> wgt = simple_thumbnail_widget()
>>> ut.quit_if_noshow()
>>> wgt.show()
>>> guitool.qtapp_loop(wgt, frequency=100, init_signals=True)
wbia.guitool.api_item_model.updater(func)[source]

Decorates a function by executing layoutChanged signals if not already in the middle of a layout changed

wbia.guitool.api_item_view module

provides common methods for api_tree_view and api_table_view

class wbia.guitool.api_item_view.APIItemView(parent=None)[source]

Bases: PyQt5.QtWidgets.QAbstractItemView

Trees and Tables implicitly inherit from this class. Abstractish class.

other function in this file will be injected into the concrete implementations of either a table or tree view. The code is only written once but duplicated in each of the psuedo-children. It is done this way to avoid explicit multiple inheritance.

wbia.guitool.api_item_view.connect_keypress_to_slot(view, func)[source]

hacky way to simulate slots for single key press events

wbia.guitool.api_item_view.connect_single_key_to_slot(view, key, func)[source]

hacky way to simulate slots for generic key press events

wbia.guitool.api_item_view.copy_selection_to_clipboard(view)[source]

Copys selected grid to clipboard

wbia.guitool.api_item_view.get_row_and_qtindex_from_id(view, _id)[source]

uses an sqlrowid (from iders) to get a qtindex

wbia.guitool.api_item_view.hide_cols(view)[source]
wbia.guitool.api_item_view.infer_delegates(view, **headers)[source]

Infers which columns should be given item delegates

wbia.guitool.api_item_view.injectviewinstance(self, *, classkey=('QtWidgets.QAbstractItemView', 'guitool'), allow_override=False, verbose=False, strict=True)

Injects an instance (self) of type (classkey) with all functions registered to (classkey)

call this in the __init__ class function

Parameters:
  • self – the class instance
  • classkey – key for a class, preferably the class type itself, but it doesnt have to be
SeeAlso:
make_class_method_decorator

Example

>>> # DISABLE_DOCTEST
>>> # DOCTEST_DISABLE
>>> utool.make_class_method_decorator(InvertedIndex)(smk_debug.invindex_dbgstr)
>>> utool.inject_instance(invindex)
wbia.guitool.api_item_view.itemDelegate(view, qindex)[source]

QtOverride: Returns item delegate for this index

wbia.guitool.api_item_view.keyPressEvent(view, event)[source]

Handles simple key press events. There is probably a better way to do this using real signals / slots, but maybe you need to always overwrite to set the handled flag correctly.

CommandLine:
xdoctest -m ~/code/guitool/guitool/api_item_view.py keyPressEvent –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.api_item_view import *  # NOQA
>>> import wbia.guitool as gt
>>> app = gt.ensure_qapp()[0]
>>> wgt = gt.simple_api_item_widget()
>>> view = wgt.view
>>> c_pressed = [0]
>>> def foo(view, event):
>>>     key = event.key()
>>>     print('[foo] Pressed key = %r' % (key,))
>>>     if event.key() == Qt.Key_C:
>>>         print('Pressed C')
>>>         c_pressed[0] = 1
>>>         return True
>>> view.connect_keypress_to_slot(foo)
>>> view._init_header_behavior()
>>> # Try to simulate an event for testing
>>> wgt.show()
>>> from wbia.guitool.__PYQT__ import QtTest, GUITOOL_PYQT_VERSION
>>> QTest = QtTest.QTest
>>> if GUITOOL_PYQT_VERSION == 4:
>>>     QTest.qWaitForWindowShown(wgt)
>>> else:
>>>     QTest.qWaitForWindowActive(wgt)
>>> qtindex = view.model().index(1, 2)
>>> point = view.visualRect(qtindex).center()
>>> #point = wgt.visibleRegion().boundingRect().center()
>>> #QTest.mouseClick(view.viewport(), Qt.LeftButton, Qt.NoModifier, point)
>>> QTest.mouseClick(wgt, Qt.LeftButton, Qt.NoModifier, point)
>>> selected_indices = view.selectedIndexes()
>>> print('selected_indices = %r' % (selected_indices,))
>>> # Why does this not work?
>>> def check_selection():
>>>     selected_indices = view.selectedIndexes()
>>>     if len(selected_indices) > 0:
>>>         return selected_indices[0].data()
>>> # Hack because I cant figure out how to get a click to simulate
>>> # a selection
>>> QTest.keyPress(view, Qt.Key_Right)
>>> QTest.keyPress(view, Qt.Key_B)
>>> ut.assert_eq(check_selection(), 'b')
>>> QTest.keyPress(view, Qt.Key_C)
>>> ut.assert_eq(check_selection(), 'b')
>>> assert c_pressed[0] == 1
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.qtapp_loop(wgt, frequency=100)
wbia.guitool.api_item_view.register_view_method(func, *, classkey=('QtWidgets.QAbstractItemView', 'guitool'), skipmain=False)

Will inject all decorated function as methods of classkey

classkey is some identifying string, tuple, or object

func can also be a tuple

wbia.guitool.api_item_view.select_row_from_id(view, _id, scroll=False, collapse=True)[source]

_id is from the iders function (i.e. an wbia rowid) selects the row in that view if it exists

wbia.guitool.api_item_view.selectedRows(view)[source]
wbia.guitool.api_item_view.setModel(view, model)[source]

QtOverride: Returns item delegate for this index

wbia.guitool.api_item_view.set_column_persistant_editor(view, column)[source]

Set each row in a column as persistant

wbia.guitool.api_item_widget module

This module contains functions and clases to get data visualized fast (in terms of development time)

class wbia.guitool.api_item_widget.APIItemWidget(headers=None, parent=None, model_class=<class 'wbia.guitool.api_item_model.APIItemModel'>, view_class=<class 'wbia.guitool.api_table_view.APITableView'>, tblnice='APIItemWidget', doubleClicked=None)[source]

Bases: PyQt5.QtWidgets.QWidget

SIMPLE WIDGET WHICH AUTO-CREATES MODEL AND VIEW FOR YOU.

change_headers(headers)[source]
connect_api(api, autopopulate=True)[source]
connect_signals()[source]
model
on_contextMenuRequested(index, pos)[source]
on_rows_updated(name, num)[source]
refresh_headers()[source]
resize_headers(api=None)[source]
class wbia.guitool.api_item_widget.CustomAPI(col_name_list=None, col_types_dict={}, col_getter_dict={}, col_bgrole_dict={}, col_ider_dict={}, col_setter_dict={}, editable_colnames={}, sortby=None, get_thumb_size=None, sort_reverse=False, col_width_dict={}, strict=False, col_display_role_func_dict=None, **kwargs)[source]

Bases: object

Allows list of lists to be represented as an abstract api table

# TODO: Rename CustomAPI API wrapper around a list of lists, each containing column data Defines a single table

add_column_names(new_colnames)[source]
get(column, row, **kwargs)[source]

getters always receive primary rowids, rectify if col_ider is specified (row might be a row_pair)

get_available_colnames()[source]
get_bgrole(column, row)[source]
get_iders()[source]
ider()[source]
make_headers(tblname='custom_api', tblnice='Custom API')[source]

Builds headers for APIItemModel

parse_column_tuples(col_name_list, col_types_dict, col_getter_dict, col_bgrole_dict, col_ider_dict, col_setter_dict, editable_colnames, sortby, sort_reverse=True, strict=False, **kwargs)[source]

parses simple lists into information suitable for making guitool headers

set(column, row, val)[source]
update_column_names(col_name_list)[source]
wbia.guitool.api_item_widget.simple_api_item_widget()[source]

Very simple example of basic APIItemWidget widget with CustomAPI

CommandLine:
python -m wbia.guitool.api_item_widget –test-simple_api_item_widget python -m wbia.guitool.api_item_widget –test-simple_api_item_widget –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.api_item_widget import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qapp()  # must be ensured before any embeding
>>> wgt = simple_api_item_widget()
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> wgt.show()
>>> gt.qtapp_loop(wgt, frequency=100)
wbia.guitool.api_item_widget.simple_api_tree_widget()[source]

Minimal example of a tree based api widget

CommandLine:
python -m wbia.guitool.api_item_widget –test-simple_api_tree_widget python -m wbia.guitool.api_item_widget –test-simple_api_tree_widget –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.api_item_widget import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qapp()  # must be ensured before any embeding
>>> wgt = simple_api_tree_widget()
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> wgt.show()
>>> guitool.qtapp_loop(wgt, frequency=100)

wbia.guitool.api_table_view module

class wbia.guitool.api_table_view.APITableView(parent=None)[source]

Bases: PyQt5.QtWidgets.QTableView

Table view of API data. Implicitly inherits from APIItemView

API_VIEW_BASE

alias of PyQt5.QtWidgets.QTableView

contextMenuClicked
keyPressEvent(event)[source]
CommandLine:
python -m wbia.guitool.api_item_widget –test-simple_api_item_widget –show python -m wbia.guitool.api_table_view –test-keyPressEvent –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.api_table_view import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qapp()
>>> view = APITableView()
>>> view._init_header_behavior()
mouseMoveEvent(self, QMouseEvent)[source]
mousePressEvent(self, QMouseEvent)[source]
mouseReleaseEvent(self, QMouseEvent)[source]
on_customMenuRequested(pos)[source]
on_rows_updated(tblname, num)[source]
rows_updated
setModel(model)[source]

QtOverride: Returns item delegate for this index

wbia.guitool.api_thumb_delegate module

CommandLine:
rm -rf /media/raid/work/PZ_MTEST/_ibsdb/_wbia_cache/match_thumbs/ python -m wbia.gui.inspect_gui –test-test_review_widget –show –verbose-thumb
class wbia.guitool.api_thumb_delegate.APIThumbDelegate(parent=None, get_thumb_size=None)[source]

Bases: PyQt5.QtWidgets.QItemDelegate

There is one Thumb Delegate per column. Keep that in mind when writing for this class.

TODO: The delegate can have a reference to the view, and it is allowed to resize the rows to fit the images. It probably should not resize columns but it can get the column width and resize the image to that size.

get_thumb_size is a callback function which should return whatever the requested thumbnail size is

SeeAlso:
api_item_view.infer_delegates
adjust_thumb_cell_size(qtindex, width, height)[source]

called during paint to ensure that the cell is large enough for the image.

get_model_data(qtindex)[source]

The model data for a thumb should be a tuple: (thumb_path, img_path, imgsize, bboxes, thetas)

get_thumb_path_if_exists(view, offset, qtindex)[source]

Checks if the thumbnail is ready to paint

Returns:thumb_path if computed otherwise returns None
paint(painter, option, qtindex)[source]

TODO: prevent recursive paint

sizeHint(self, QStyleOptionViewItem, QModelIndex) → QSize[source]
spawn_thumb_creation_thread(thumb_path, img_path, img_size, qtindex, view, offset, bbox_list, theta_list, interest_list)[source]
class wbia.guitool.api_thumb_delegate.ThumbnailCreationThread(thumb_path, img_path, img_size, thumbsize, qtindex, view, offset, bbox_list, theta_list, interest_list)[source]

Bases: PyQt5.QtCore.QRunnable

Helper to compute thumbnails concurrently

References

TODO: http://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt

run(self)[source]
thumb_would_not_be_visible()[source]
class wbia.guitool.api_thumb_delegate.ThumbnailCreationThread2(thread_func, args, qtindex, view, offset)[source]

Bases: PyQt5.QtCore.QRunnable

HACK TODO: http://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt

run(self)[source]
thumb_would_not_be_visible()[source]
wbia.guitool.api_thumb_delegate.get_thread_thumb_info(bbox_list, theta_list, thumbsize, img_size)[source]
CommandLine:
python -m wbia.guitool.api_thumb_delegate –test-get_thread_thumb_info

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.api_thumb_delegate import *  # NOQA
>>> # build test data
>>> bbox_list = [(100, 50, 400, 200)]
>>> theta_list = [0]
>>> thumbsize = 128
>>> img_size = 600, 300
>>> # execute function
>>> result = get_thread_thumb_info(bbox_list, theta_list, thumbsize, img_size)
>>> # verify results
>>> print(result)
((128, 64), [[[21, 11], [107, 11], [107, 53], [21, 53], [21, 11]]])
wbia.guitool.api_thumb_delegate.make_thread_thumb(img_path, dsize, new_verts_list, interest_list)[source]

Makes thumbnail with overlay. Called in thead

CommandLine:
python -m wbia.guitool.api_thumb_delegate –test-make_thread_thumb –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.api_thumb_delegate import *  # NOQA
>>> import wbia.plottool as pt
>>> # build test data
>>> img_path = ut.grab_test_imgpath('carl.jpg')
>>> dsize = (32, 32)
>>> new_verts_list = []
>>> # execute function
>>> thumb = make_thread_thumb(img_path, dsize, new_verts_list)
>>> ut.quit_if_noshow()
>>> pt.imshow(thumb)
>>> pt.show_if_requested()
wbia.guitool.api_thumb_delegate.read_thumb_as_qimg(thumb_path)[source]
Parameters:thumb_path
Returns:(qimg, width, height)
Return type:tuple
CommandLine:
python -m wbia.guitool.api_thumb_delegate –test-read_thumb_as_qimg –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.api_thumb_delegate import *  # NOQA
>>> import wbia.guitool
>>> # build test data
>>> thumb_path = ut.grab_test_imgpath('carl.jpg')
>>> # execute function
>>> guitool.ensure_qtapp()
>>> qimg = read_thumb_as_qimg(thumb_path)
>>> print(qimg)
>>> # xdoctest: +REQUIRES(--show)
>>> lbl = test_show_qimg(qimg)
>>> #guitool.qtapp_loop()
>>> # verify results
Timeit::
%timeit np.dstack((npimg, np.full(npimg.shape[0:2], 255, dtype=np.uint8))) %timeit cv2.cvtColor(npimg, cv2.COLOR_BGR2BGRA) npimg1 = np.dstack((npimg, np.full(npimg.shape[0:2], 255, dtype=np.uint8))) # seems to be memory leak in cvtColor? npimg2 = cv2.cvtColor(npimg, cv2.COLOR_BGR2BGRA)
wbia.guitool.api_thumb_delegate.read_thumb_size(thumb_path)[source]
wbia.guitool.api_thumb_delegate.register_thread(key, val)[source]
wbia.guitool.api_thumb_delegate.simple_thumbnail_widget()[source]

Very simple example to test thumbnails

CommandLine:
python -m wbia.guitool.api_thumb_delegate –test-simple_thumbnail_widget –show –verbthumb python -m wbia.guitool.api_thumb_delegate –test-simple_thumbnail_widget –show –tb

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.api_thumb_delegate import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qapp()  # must be ensured before any embeding
>>> wgt = simple_thumbnail_widget()
>>> ut.quit_if_noshow()
>>> wgt.show()
>>> guitool.qtapp_loop(wgt, frequency=100)
wbia.guitool.api_thumb_delegate.test_show_qimg(qimg)[source]
wbia.guitool.api_thumb_delegate.unregister_thread(key)[source]
wbia.guitool.api_thumb_delegate.view_would_not_be_visible(view, offset)[source]

Check if the current scroll position is far beyond the scroll position when this was initially requested.

wbia.guitool.api_timestamp_delegate module

wbia.guitool.api_tree_node module

class wbia.guitool.api_tree_node.TreeNode(id_, parent_node, level)[source]

Bases: PyQt5.QtCore.QObject

Cyth:
cdef:
long id_, level list child_nodes TreeNode parent_node
child_index(child_node)[source]

<CYTH returns=long> cdef TreeNode child_node

find_row_from_id(_id)[source]

given an id (like an wbia rowid) find the row of this item

get_child(index)[source]

<CYTH returns=”TreeNode”> cdef long index

get_children()[source]

</CYTH returns=”list”>

get_id()[source]

Returns python internal id of this class <CYTH returns=”long”>

get_level()[source]

<CYTH returns=”long”>

get_num_children()[source]

<CYTH returns=long>

get_parent()[source]

<CYTH returns=”TreeNode”>

get_row()[source]

Returns the row_index of this node w.r.t its parent.

cdef list sibling_nodes cdef long row

lazy_checks()[source]
set_children(child_nodes)[source]

<CYTH returns=”void”>

wbia.guitool.api_tree_node.build_internal_structure(model)[source]
Cyth:
<CYTH returns=”TreeNode”>
wbia.guitool.api_tree_node.build_scope_hack_list(root_node, scope_hack_list=[])[source]
wbia.guitool.api_tree_node.tree_node_string(self, indent='', charids=True, id_dict=None, last=None)[source]

makes a recrusive string representation of a treee

HACK:if charids is 2 uses ordinals instead of characters if charirsd is True triesto use Numbers otherwise uses nondetermensitic python ids

wbia.guitool.api_tree_view module

class wbia.guitool.api_tree_view.APITreeView(parent=None)[source]

Bases: PyQt5.QtWidgets.QTreeView

Tree view of API data. Implicitly inherits from APIItemView

API_VIEW_BASE

alias of PyQt5.QtWidgets.QTreeView

contextMenuClicked
keyPressEvent(self, QKeyEvent)[source]
on_customMenuRequested(pos)[source]
on_rows_updated(tblname, num)[source]
rows_updated
setModel(model)[source]

QtOverride: Returns item delegate for this index

wbia.guitool.api_tree_view.testdata_tree_view()[source]
CommandLine:
python -m wbia.guitool.api_tree_view testdata_tree_view python -m wbia.guitool.api_tree_view testdata_tree_view –show

Example

>>> # DISABLE_DOCTEST
>>> import wbia.guitool as gt
>>> from wbia.guitool.api_tree_view import *  # NOQA
>>> wgt = testdata_tree_view()
>>> view = wgt.view
>>> rows = view.selectedRows()
>>> print('rows = %r' % (rows,))
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.qtapp_loop(qwin=wgt)

wbia.guitool.filter_proxy_model module

class wbia.guitool.filter_proxy_model.FilterProxyModel(parent=None)[source]

Bases: PyQt5.QtCore.QIdentityProxyModel

data(self, QModelIndex, role: int = Qt.DisplayRole) → Any[source]
filterAcceptsRow(source_row, source_parent)[source]
get_header_data(colname, proxyIndex)[source]
index(self, int, int, parent: QModelIndex = QModelIndex()) → QModelIndex[source]
mapFromSource(sourceIndex)[source]

returns index into proxy model

mapToSource(proxyIndex)[source]

returns index into original model

parent(self, QModelIndex) → QModelIndex[source]
proxy_to_source(row, col, parent=<PyQt5.QtCore.QModelIndex object>)[source]
setData(self, QModelIndex, Any, role: int = Qt.EditRole) → bool[source]
sort(self, int, order: Qt.SortOrder = Qt.AscendingOrder)[source]
source_to_proxy(row, col, parent=<PyQt5.QtCore.QModelIndex object>)[source]
update_filterdict(new_dict)[source]

wbia.guitool.guitool_components module

class wbia.guitool.guitool_components.BlockSignals(qobj)[source]

Bases: object

class wbia.guitool.guitool_components.ComboRadioHybrid(parent=None, **kwargs)[source]

Bases: wbia.guitool.guitool_components.GuitoolWidget

CommandLine:
python -m wbia.guitool.guitool_components ComboRadioHybrid –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> parent = None
>>> options = ['red', 'blue', 'green', 'blue', 'black', 'blah']
>>> options = [(a.title(), a) for a in options]
>>> self = ComboRadioHybrid(parent=parent, options=options)
>>> self.setCurrentValue('black')
>>> #self.print_widget_heirarchy(attrs=['sizePolicy'])
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> self.show()
>>> print(self.currentText())
>>> gt.qtapp_loop(qwin=self, freq=10)
currentText()[source]
currentValue()[source]
initialize(options=[], num=2, default=None, changed=None)[source]
on_toggle(button, checked)[source]
setCurrentValue(value)[source]
class wbia.guitool.guitool_components.ConfigConfirmWidget(*args, **kwargs)[source]

Bases: wbia.guitool.guitool_components.GuitoolWidget

CommandLine:
python -m wbia.guitool.guitool_components ConfigConfirmWidget –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool
>>> import dtool
>>> guitool.ensure_qapp()  # must be ensured before any embeding
>>> tablename = None
>>> dict_ = {'K': 1, 'Knorm': 5,
>>>          'choice': ut.ParamInfo(varname='choice', default='one',
>>>                                 valid_values=['one', 'two'])}
>>> config = dtool.Config.from_dict(dict_, tablename)
>>> dlg = guitool.ConfigConfirmWidget.as_dialog(
>>>     title='Confirm Merge Query',
>>>     msg='Confirm',
>>>     detailed_msg=ut.lorium_ipsum()*10,
>>>     config=config)
>>> #dlg.resize(700, 500)
>>> self = dlg.widget
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> dlg.show()
>>> guitool.qtapp_loop(qwin=dlg)
>>> updated_config = self.config  # NOQA
>>> print('orig_config = %r' % (config,))
>>> print('updated_config = %r' % (updated_config,))
classmethod as_dialog(*args, **kwargs)[source]
cancel()[source]
confirm(confirm_option=None)[source]
initialize(title, msg, config, options=None, default=None, detailed_msg=None, with_spoiler=True)[source]
update_state(*args)[source]
class wbia.guitool.guitool_components.CustomCheckBox(text='', parent=None, checked=False, changed=None)[source]

Bases: PyQt5.QtWidgets.QCheckBox

stateChangedCustom(state)[source]
class wbia.guitool.guitool_components.CustomComboBox(parent=None, default=None, options=None, changed=None)[source]

Bases: PyQt5.QtWidgets.QComboBox

currentIndexChangedCustom(index)[source]
currentValue()[source]
findValueIndex(value)[source]

finds index of backend value and sets the current index

setCurrentValue(value)[source]
setDefault(default=None)[source]
setOptionText(option_text_list)[source]
setOptions(options)[source]
updateOptions(reselect=False, reselect_index=None)[source]
class wbia.guitool.guitool_components.FlowLayout(parent=None, margin=0, spacing=-1)[source]

Bases: PyQt5.QtWidgets.QLayout

References

https://gist.github.com/Cysu/7461066

CommandLine:
python -m wbia.guitool.guitool_components FlowLayout
Ignore:
>>> import sys
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> app = gt.ensure_qtapp()[0]
>>> #
>>> class Window(QtWidgets.QWidget):
>>>     def __init__(self):
>>>         super(Window, self).__init__()
>>>         #
>>>         flowLayout = FlowLayout()
>>>         #flowLayout.setLayoutDirection(Qt.RightToLeft)
>>>         flowLayout.addWidget(QtWidgets.QPushButton("Short"))
>>>         flowLayout.addWidget(QtWidgets.QPushButton("Longer"))
>>>         flowLayout.addWidget(QtWidgets.QPushButton("Different text"))
>>>         flowLayout.addWidget(QtWidgets.QPushButton("More text"))
>>>         flowLayout.addWidget(QtWidgets.QPushButton("Even longer button text"))
>>>         self.setLayout(flowLayout)
>>>         #
>>>         self.setWindowTitle("Flow Layout")
>>> mainWin = Window()
>>> mainWin.show()
>>> gt.qtapp_loop(freq=10)
addItem(self, QLayoutItem)[source]
count(self) → int[source]
expandingDirections(self) → Qt.Orientations[source]
hasHeightForWidth(self) → bool[source]
heightForWidth(self, int) → int[source]
itemAt(self, int) → QLayoutItem[source]
minimumSize(self) → QSize[source]
setGeometry(self, QRect)[source]
sizeHint(self) → QSize[source]
takeAt(self, int) → QLayoutItem[source]
class wbia.guitool.guitool_components.GuiProgContext(title, prog_bar)[source]

Bases: object

prog_hook
set_progress(count=None, total=None, msg=None)[source]
set_total(total)[source]
class wbia.guitool.guitool_components.GuitoolWidget(parent=None, orientation=None, verticalSizePolicy=None, horizontalSizePolicy=None, verticalStretch=None, horizontalStretch=None, spacing=None, margin=None, name=None, ori=None, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget

CommandLine:
python -m wbia.guitool.guitool_components GuitoolWidget –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> ut.exec_funckw(newWidget, globals())
>>> widget = GuitoolWidget(parent)
>>> widget.addWidget(gt.newButton(
>>>     widget, 'Print Hi', lambda: print('hi')))
>>> widget.addWidget(gt.newButton(
>>>     widget, 'Popup Hi', lambda: gt.user_info(widget, 'hi')))
>>> #widget.addRow('input 1', gt.newLineEdit(widget))
>>> #widget.addRow('input 2', gt.newComboBox(widget, ['one', 'two']))
>>> widget.show()
>>> widget.resize(int(ut.PHI * 500), 500)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.qtapp_loop(qwin=widget, freq=10)
addLayout(*args, **kwargs)[source]
addNewSpacer(w=0, h=0, hPolicy=None, vPolicy=None, **kwargs)[source]
classmethod as_dialog(parent=None, **kwargs)[source]
closeEvent(self, QCloseEvent)[source]
closed
initialize(**kwargs)[source]
set_all_margins(margin)[source]
class wbia.guitool.guitool_components.ProgHook(prog_bar=None, global_min=0, global_max=1, level=0)[source]

Bases: PyQt5.QtCore.QObject, utool.util_dev.NiceRepr

hooks into utool.ProgressIterator.

A hook represents a fraction of a progress step. Hooks can be divided recursively

References

http://stackoverflow.com/questions/19442443/busy-indication-with-pyqt-progress-bar

Parameters:
  • prog_bar (Qt.QProgressBar) –
  • substep_min (int) – (default = 0)
  • substep_size (int) – (default = 1)
  • level (int) – (default = 0)
CommandLine:
python -m wbia.guitool.guitool_components ProgHook –show –progtext

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> app = gt.ensure_qtapp()[0]
>>> parent = newWidget()
>>> parent.show()
>>> parent.resize(600, 40)
>>> prog_bar = newProgressBar(parent, visible=True)
>>> hook = prog_bar.utool_prog_hook
>>> subhook_list = hook.subdivide(num=4)
>>> hook_0_25 = subhook_list[0]
>>> hook_0_25.length = 2
>>> print('hook_0_25 = %s' % (hook_0_25,))
>>> hook_0_25.set_progress(0)
>>> print('hook_0_25 = %s' % (hook_0_25,))
>>> hook_0_25.set_progress(1)
>>> print('hook_0_25 = %s' % (hook_0_25,))
>>> substep_hooks_0_25 = hook_0_25.make_substep_hooks(num=4)
>>> print('substep_hooks_0_25 = %s' % (ut.repr2(substep_hooks_0_25, strvals=True),))
>>> subhook = substep_hooks_0_25[0]
>>> progiter = ut.ProgIter(list(range(4)), prog_hook=subhook)
>>> iter_ = iter(progiter)
>>> six.next(iter_)
>>> hook(2, 2)
>>> subhook2 = substep_hooks_0_25[1]
>>> subsubhooks = subhook2.subdivide(num=2)
>>> subsubhooks[0](0, 3)
>>> subsubhooks[0](1, 3)
>>> subsubhooks[0](2, 3, 'special part')
>>> subsubhooks[0](3, 3, 'other part')
>>> app.processEvents()
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
count
force_event_update()[source]
global_bounds()[source]
global_extent()[source]
global_progress()[source]

percent done of entire process

initialize_subhooks(num=None, spacing=None)[source]
local_progress()[source]

percent done of this subhook

make_substep_hooks(num=None, spacing=None)[source]

This takes into account your current position, and gives you only enough subhooks to complete a single step.

Need to know current count, stepsize, and total number of steps in this subhook.

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> app = gt.ensure_qtapp()[0]
>>> hook = ProgHook(None)
>>> subhook_list = hook.subdivide(num=4)
>>> hook_0_25 = subhook_list[0]
>>> hook = hook_0_25
>>> hook(1, 2)
>>> print('hook = %r' % (hook,))
>>> subhook_list1 = hook.make_substep_hooks(1)
>>> subhook1 = subhook_list1[0]
>>> print('subhook1 = %r' % (subhook1,))
>>> subhook_list2 = hook.make_substep_hooks(2)
>>> subhook2 = subhook_list2[1]
>>> subhook2.show_text = True
>>> # Test progress iter
>>> progiter = ut.ProgIter(list(range(3)), lbl='foo', prog_hook=subhook2)
>>> iter_ = iter(progiter); print('subhook2 = %r' % (subhook2,))
>>> # Iter
>>> print(six.next(iter_)); print('subhook2 = %r' % (subhook2,))
>>> print(six.next(iter_)); print('subhook2 = %r' % (subhook2,))
>>> print(six.next(iter_)); print('subhook2 = %r' % (subhook2,))
next_subhook()[source]
on_progress_changed(global_fraction, lbl)[source]
prog_bar
progress_changed_signal
register_progiter(progiter)[source]
set_progress(count, length=None, lbl=None)[source]
show_indefinite_progress()[source]
show_indefinite_progress_signal
show_indefinite_progress_slot()[source]
subdivide(num=None, spacing=None)[source]

Branches this hook into several new leafs. Only progress leafs are used to indicate global progress.

class wbia.guitool.guitool_components.RadioButtonGroup(parent=None, options=[], default=None, changed=None)[source]

Bases: PyQt5.QtWidgets.QWidget

Mutually exclusive set of options (alternative to combo box)

currentText()[source]
setCurrentValue(value)[source]
class wbia.guitool.guitool_components.ResizableTextEdit[source]

Bases: PyQt5.QtWidgets.QTextEdit

http://stackoverflow.com/questions/3050537/resizing-qts-qtextedit-to-match-text-height-maximumviewportsize

sizeHint(self) → QSize[source]
class wbia.guitool.guitool_components.SimpleTree(parent=None)[source]

Bases: PyQt5.QtCore.QObject

DEPRICATE IN FAVOR OF CONFIG WIDGETS? Need to make them heirarchical first

References

http://stackoverflow.com/questions/12737721/developing-pyqt4-tree-widget

add_checkbox(parent, title, data='ff', checked=False, changed=None)[source]
add_combobox(parent, title, data='ff', checked=False, changed=None)[source]
add_parent(parent=None, title='', data='ff')[source]
handleChanged(item, column)[source]
class wbia.guitool.guitool_components.Spoiler(parent=None, title='', animationDuration=300, checked=False, contentWidget=None)[source]

Bases: PyQt5.QtWidgets.QWidget

References

# Adapted from c++ version http://stackoverflow.com/questions/32476006/how-to-make-an-expandable-collapsable-section-widget-in-qt

CommandLine:
python -m wbia.guitool.guitool_components Spoiler –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> # build test data
>>> import wbia.guitool
>>> import wbia.guitool as gt
>>> guitool.ensure_qtapp()
>>> #ut.exec_funckw(newWidget, globals())
>>> parent = None
>>> widget1 = GuitoolWidget(parent)
>>> widget1.addWidget(gt.newButton(
>>>      widget1, 'Print Hi', lambda: print('hi')))
>>> #widget2 = GuitoolWidget(parent)
>>> #widget2.addWidget(gt.newButton(
>>> #    widget2, 'Popup Hi', lambda: gt.user_info(widget2, 'hi')))
>>> spoiler = Spoiler(title='spoiler title')
>>> widget1.layout().addWidget(spoiler)
>>> #top = widget1.addNewFrame()
>>> #top.layout().addWidget(spoiler)
>>> detailed_msg = 'Foo\nbar'
>>> child_widget = QtWidgets.QTextEdit()
>>> #child_widget.setWordWrap(True)
>>> #child_widget = QtWidgets.QPushButton()
>>> child_widget.setObjectName('child_widget')
>>> child_widget.setText(ut.lorium_ipsum() * 10)
>>> spoiler.setContentLayout(child_widget)
>>> widget1.print_widget_heirarchy()
>>> widget1.layout().setAlignment(Qt.AlignBottom)
>>> widget1.show()
>>> #widget1.resize(int(ut.PHI * 500), 500)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.qtapp_loop(qwin=widget1, freq=10)
finalize_animation()[source]
setContentLayout(contentLayout)[source]
toggle_finished
toggle_spoiler(checked)[source]
class wbia.guitool.guitool_components.TagEdit(parent=None, tags=None, valid_tags=None)[source]

Bases: PyQt5.QtWidgets.QLineEdit

Parameters:
  • self
  • parent (None) – (default = None)
  • tags (None) – (default = None)
  • editor_mode (str) – (default = ‘line’)
CommandLine:
python -m wbia.guitool.guitool_components TagEdit

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> self = TagEdit(tags=['a', 'b', 'c'])
>>> self.show()
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.qtapp_loop(qwin=self, freq=10)
setTags(tags)[source]
tags()[source]
wbia.guitool.guitool_components.adjustSizePolicy(widget, hPolicy=None, vPolicy=None, hStretch=None, vStretch=None)[source]
wbia.guitool.guitool_components.adjust_font(widget, bold=False, pointSize=None, italic=False)[source]
wbia.guitool.guitool_components.fix_child_attr_heirarchy(obj, attr, val)[source]
wbia.guitool.guitool_components.fix_child_size_heirarchy(obj, pol)[source]
wbia.guitool.guitool_components.getAvailableFonts()[source]
wbia.guitool.guitool_components.get_nested_attr(obj, attr)[source]

attr = ‘sizePolicy().verticalPolicy()’

wbia.guitool.guitool_components.get_widget_text_width(widget)[source]
wbia.guitool.guitool_components.layoutSplitter(splitter)[source]
wbia.guitool.guitool_components.make_style_sheet(bgcolor=None, fgcolor=None)[source]
wbia.guitool.guitool_components.msg_event(title, msg)[source]

Returns a message event slot

wbia.guitool.guitool_components.newButton(parent=None, text=None, clicked=None, pressed=None, qicon=None, visible=True, enabled=True, bgcolor=None, fgcolor=None, fontkw={}, shrink_to_text=False, min_width=None)[source]

wrapper around QtWidgets.QPushButton

Parameters:
  • parent (None) – (default = None)
  • text (str) – (default = None)
  • clicked (None) – (default = None)
  • pressed (None) – (default = None)
  • qicon (None) – (default = None)
  • visible (bool) – (default = True)
  • enabled (bool) – (default = True)
  • bgcolor (None) – (default = None)
  • fgcolor (None) – (default = None)
  • fontkw (dict) – (default = {})
  • shrink_to_text (bool) – (default = False)
  • min_width (None) – (default = None)
connectable signals:
void clicked(bool checked=false) void pressed() void released() void toggled(bool checked)
Returns:QtWidgets.QPushButton
CommandLine:
python -m wbia.guitool.guitool_components –exec-newButton python -m wbia.guitool.guitool_components –test-newButton python -m wbia.guitool.guitool_components newButton –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> exec(ut.execstr_funckw(newButton), globals())
>>> button = newButton(text='button')
>>> result = ('button = %s' % (ut.repr2(button),))
>>> print(result)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.qtapp_loop(qwin=button, freq=10)
wbia.guitool.guitool_components.newCheckBox(parent=None, text=None, changed=None, checked=False, visible=True, enabled=True, bgcolor=None, fgcolor=None, direction=None)[source]

wrapper around QtWidgets.QCheckBox

CommandLine:
python -m wbia.guitool.guitool_components newCheckBox

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> app = gt.ensure_qtapp()[0]
>>> parent = newWidget()
>>> cb1 = gt.newCheckBox(parent, text='check_text1',
>>>                      direction='RightToLeft')
>>> parent.addWidget(cb1)
>>> cb2 = parent.addNewCheckBox(text='check_text2',
>>>                             direction='LeftToRight')
>>> parent.show()
>>> parent.resize(600, 40)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> gt.print_widget_heirarchy(cb1)
>>> gt.qtapp_loop(qwin=parent, freq=10)
wbia.guitool.guitool_components.newComboBox(parent=None, options=None, changed=None, default=None, visible=True, enabled=True, bgcolor=None, fgcolor=None, fontkw={}, editor_mode='combo', num=2)[source]

wrapper around QtWidgets.QComboBox

Parameters:
  • parent (None) –
  • options (list) –

    a list of tuples, which are a of the following form: [

    (visible text 1, backend value 1), (visible text 2, backend value 2), (visible text 3, backend value 3),

    ]

  • changed (None) –
  • default (str) – backend value of default item
  • visible (bool) –
  • enabled (bool) –
  • bgcolor (None) –
  • fgcolor (None) –
  • bold (bool) –
Returns:

combo

Return type:

QtWidgets.QComboBox

CommandLine:
python -m wbia.guitool.guitool_components –test-newComboBox –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> exec(ut.execstr_funckw(newComboBox), globals())
>>> parent = None
>>> options = ['red', 'blue']
>>> combo = newComboBox(parent, options)
>>> result = str(combo)
>>> print(result)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> combo.show()
>>> gt.qtapp_loop(qwin=combo, freq=10)
wbia.guitool.guitool_components.newFont(fontname='Courier New', pointSize=-1, weight=-1, italic=False)[source]

wrapper around QtGui.QFont

wbia.guitool.guitool_components.newFrame(*args, **kwargs)[source]
wbia.guitool.guitool_components.newLabel(parent=None, text='', align='center', gpath=None, fontkw={}, min_width=None)[source]
Parameters:
  • parent (None) – (default = None)
  • text (str) – (default = ‘’)
  • align (str) – (default = ‘center’)
  • gpath (None) – (default = None)
  • fontkw (dict) – (default = {})
Kwargs:
parent, text, align, gpath, fontkw
Returns:label
Return type:?
CommandLine:
python -m wbia.guitool.guitool_components –exec-newLabel –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> parent = None
>>> text = ''
>>> align = 'center'
>>> gpath = ut.grab_test_imgpath('lena.png')
>>> fontkw = {}
>>> label = newLabel(parent, text, align, gpath, fontkw)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> label.show()
>>> guitool.qtapp_loop(qwin=label, freq=10)
wbia.guitool.guitool_components.newLayout(parent=None, ori=None, spacing=None, margin=None)[source]
wbia.guitool.guitool_components.newLineEdit(parent, text=None, enabled=True, align='center', textChangedSlot=None, textEditedSlot=None, editingFinishedSlot=None, visible=True, readOnly=False, editable=None, verticalStretch=0, fontkw={})[source]

This is a text line

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> parent = None
>>> text = None
>>> visible = True
>>> # execute function
>>> widget = newLineEdit(parent, text, visible)
>>> # verify results
>>> result = str(widget)
>>> print(result)
wbia.guitool.guitool_components.newMenu(parent, text, name=None)[source]

Defines each menu category in the menubar/toolbar/menu

wbia.guitool.guitool_components.newMenuAction(menu, name=None, text=None, shortcut=None, tooltip=None, slot_fn=None, enabled=True, triggered=None)[source]

Added as a helper function to menus

wbia.guitool.guitool_components.newMenubar(widget)[source]

Defines the menubar on top of the main widget

wbia.guitool.guitool_components.newOutputLog(parent, pointSize=6, visible=True, verticalStretch=1)[source]
wbia.guitool.guitool_components.newProgressBar(parent, visible=True, verticalStretch=1)[source]
Parameters:
  • parent
  • visible (bool) –
  • verticalStretch (int) –
Returns:

progressBar

Return type:

QProgressBar

CommandLine:
python -m wbia.guitool.guitool_components –test-newProgressBar:0 python -m wbia.guitool.guitool_components –test-newProgressBar:0 –show python -m wbia.guitool.guitool_components –test-newProgressBar:1 python -m wbia.guitool.guitool_components –test-newProgressBar:2 python -m wbia.guitool.guitool_components –test-newProgressBar:1 –progtext python -m wbia.guitool.guitool_components –test-newProgressBar:2 –progtext

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> # build test data
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> parent = None
>>> visible = True
>>> verticalStretch = 1
>>> # hook into utool progress iter
>>> progressBar = newProgressBar(parent, visible, verticalStretch)
>>> progressBar.show()
>>> progressBar.utool_prog_hook.show_indefinite_progress()
>>> #progressBar.utool_prog_hook.set_progress(0)
>>> #import time
>>> qtapp = guitool.get_qtapp()
>>> [(qtapp.processEvents(), ut.get_nth_prime_bruteforce(300)) for x in range(100)]
>>> #time.sleep(5)
>>> progiter = ut.ProgIter(range(100), freq=1, autoadjust=False, prog_hook=progressBar.utool_prog_hook)
>>> results1 = [ut.get_nth_prime_bruteforce(300) for x in progiter]
>>> # verify results
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> guitool.qtapp_loop(freq=10)

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> # build test data
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> parent = None
>>> visible = True
>>> verticalStretch = 1
>>> def complex_tasks(hook):
>>>     progkw = dict(freq=1, backspace=False, autoadjust=False)
>>>     num = 800
>>>     for x in ut.ProgIter(range(2), lbl='TASK', prog_hook=hook, **progkw):
>>>         ut.get_nth_prime_bruteforce(num)
>>>         subhook1, subhook2 = hook.make_substep_hooks(2)
>>>         for task1 in ut.ProgIter(range(2), lbl='task1.1', prog_hook=subhook1, **progkw):
>>>             ut.get_nth_prime_bruteforce(num)
>>>         for task2 in ut.ProgIter(range(2), lbl='task1.2', prog_hook=subhook2, **progkw):
>>>             ut.get_nth_prime_bruteforce(num)
>>> # hook into utool progress iter
>>> progressBar = newProgressBar(parent, visible, verticalStretch)
>>> hook = progressBar.utool_prog_hook
>>> complex_tasks(hook)
>>> # verify results
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> guitool.qtapp_loop(freq=10)

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> # build test data
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> parent = None
>>> visible = True
>>> verticalStretch = 1
>>> def complex_tasks(hook):
>>>     progkw = dict(freq=1, backspace=False, autoadjust=False)
>>>     num = 800
>>>     for x in ut.ProgIter(range(4), lbl='TASK', prog_hook=hook, **progkw):
>>>         ut.get_nth_prime_bruteforce(num)
>>>         subhook1, subhook2 = hook.make_substep_hooks(2)
>>>         for task1 in ut.ProgIter(range(2), lbl='task1.1', prog_hook=subhook1, **progkw):
>>>             ut.get_nth_prime_bruteforce(num)
>>>             subsubhooks = subhook1.make_substep_hooks(3)
>>>             for task1 in ut.ProgIter(range(7), lbl='task1.1.1', prog_hook=subsubhooks[0], **progkw):
>>>                 ut.get_nth_prime_bruteforce(num)
>>>             for task1 in ut.ProgIter(range(11), lbl='task1.1.2', prog_hook=subsubhooks[1], **progkw):
>>>                 ut.get_nth_prime_bruteforce(num)
>>>             for task1 in ut.ProgIter(range(3), lbl='task1.1.3', prog_hook=subsubhooks[2], **progkw):
>>>                 ut.get_nth_prime_bruteforce(num)
>>>         for task2 in ut.ProgIter(range(10), lbl='task1.2', prog_hook=subhook2, **progkw):
>>>             ut.get_nth_prime_bruteforce(num)
>>> # hook into utool progress iter
>>> progressBar = newProgressBar(parent, visible, verticalStretch)
>>> hook = progressBar.utool_prog_hook
>>> complex_tasks(hook)
>>> # verify results
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> guitool.qtapp_loop(freq=10)
Ignore:
from wbia.guitool.guitool_components import * # NOQA # build test data import wbia.guitool guitool.ensure_qtapp()
wbia.guitool.guitool_components.newQPoint(x, y)[source]
wbia.guitool.guitool_components.newScrollArea(parent, horizontalStretch=1, verticalStretch=1)[source]
wbia.guitool.guitool_components.newSizePolicy(widget=None, verticalSizePolicy=None, horizontalSizePolicy=None, horizontalStretch=None, verticalStretch=None, hSizePolicy=None, vSizePolicy=None, vStretch=None, hStretch=None)[source]

References

https://i.stack.imgur.com/Y8IDK.png http://doc.qt.io/qt-4.8/qsizepolicy.html http://doc.qt.io/qt-5/qsizepolicy.html

wbia.guitool.guitool_components.newSpacer(w=0, h=0, hPolicy=None, vPolicy=None)[source]
wbia.guitool.guitool_components.newSplitter(widget=None, orientation=None, verticalStretch=1, horizontalStretch=None, ori=None)[source]

input: widget - the central widget

wbia.guitool.guitool_components.newTabWidget(parent, horizontalStretch=1, verticalStretch=1)[source]
wbia.guitool.guitool_components.newTextEdit(parent=None, label=None, visible=None, label_pos='above', align='left', text=None, enabled=True, editable=True, fit_to_text=False, rich=False)[source]

This is a text area

wbia.guitool.guitool_components.newToolbar(widget)[source]

Defines the menubar on top of the main widget

wbia.guitool.guitool_components.newWidget(parent=None, *args, **kwargs)[source]
Parameters:
  • parent (QWidget) –
  • orientation (Orientation) – (default = 2)
  • verticalSizePolicy (Policy) – (default = 7)
  • horizontalSizePolicy (Policy) – (default = 7)
  • verticalStretch (int) – (default = 1)
Returns:

widget

Return type:

GuitoolWidget

wbia.guitool.guitool_components.print_widget_heirarchy(obj, *args, **kwargs)[source]
wbia.guitool.guitool_components.prop_text_map(prop, val)[source]
wbia.guitool.guitool_components.rectifyQtEnum(type_, value, default=NoParam)[source]
Parameters:
  • type (str) – name of qt enum
  • value (int or str) – string or integer value
  • default (int or str) – default value
Returns:

rectified_value

Return type:

int

TODO: move to qt_enums?

CommandLine:
python -m wbia.guitool.guitool_components rectifyQtEnum

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_components import *  # NOQA
>>> newvals = []
>>> newvals.append(rectifyQtEnum('Orientation', 'vert'))
>>> newvals.append(rectifyQtEnum('Orientation', 'Horizontal'))
>>> newvals.append(rectifyQtEnum('LayoutDirection', 'LeftToRight'))
>>> newvals.append(rectifyQtEnum('QSizePolicy', 'Expanding'))
>>> result = ut.repr4(newvals)
>>> print(result)
>>> assert all(isinstance(v, int) for v in newvals)
wbia.guitool.guitool_components.rectifySizePolicy(policy=None, default='Expanding')[source]
wbia.guitool.guitool_components.walk_widget_heirarchy(obj, **kwargs)[source]

print(‘n’.join(gt.walk_widget_heirarchy(self, attrs=[‘minimumWidth’], skip=True))) print(‘n’.join(gt.walk_widget_heirarchy(self, attrs=[‘sizePolicy’], skip=True)))

wbia.guitool.guitool_decorators module

wbia.guitool.guitool_decorators.checks_qt_error(func)[source]

Decorator which reports qt errors which would otherwise be silent Useful if we haven’t overriden sys.excepthook but we have, so this isnt useful.

wbia.guitool.guitool_decorators.slot_(*types)[source]

wrapper around pyqtslot decorator keep original function info

wbia.guitool.guitool_delegates module

class wbia.guitool.guitool_delegates.APIDelegate(parent)[source]

Bases: PyQt5.QtWidgets.QItemDelegate

is_persistant_editable = True
sizeHint(self, QStyleOptionViewItem, QModelIndex) → QSize[source]
class wbia.guitool.guitool_delegates.ButtonDelegate(parent)[source]

Bases: wbia.guitool.guitool_delegates.APIDelegate

A delegate that places a fully functioning QPushButton in every cell of the column to which it’s applied

paint(self, QPainter, QStyleOptionViewItem, QModelIndex)[source]
class wbia.guitool.guitool_delegates.ComboDelegate(parent)[source]

Bases: wbia.guitool.guitool_delegates.APIDelegate

A delegate that places a fully functioning QComboBox in every cell of the column to which it’s applied

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
currentIndexChanged()[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
class wbia.guitool.guitool_delegates.ImageDelegate(parent)[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

paint(self, QPainter, QStyleOptionViewItem, QModelIndex)[source]

wbia.guitool.guitool_dialogs module

class wbia.guitool.guitool_dialogs.QDirectoriesDialog(*args)[source]

Bases: PyQt5.QtWidgets.QFileDialog

class wbia.guitool.guitool_dialogs.ResizableMessageBox(*args)[source]

Bases: PyQt5.QtWidgets.QMessageBox

References

http://stackoverflow.com/questions/2655354/how-to-allow-resizing-of-qmessagebox-in-pyqt4

event(self, QEvent) → bool[source]
wbia.guitool.guitool_dialogs.are_you_sure(parent=None, msg=None, title='Confirmation', default=None)[source]

Prompt user for conformation before changing something

wbia.guitool.guitool_dialogs.build_nested_qmenu(widget, context_options, name=None)[source]

builds nested menu for context menus but can be used for other menu related things.

References

http://pyqt.sourceforge.net/Docs/PyQt4/qkeysequence.html

wbia.guitool.guitool_dialogs.connect_context_menu(widget, context_options)[source]
wbia.guitool.guitool_dialogs.msgbox(msg='', title='msgbox', detailed_msg=None)[source]

Make a non modal critical QtWidgets.QMessageBox.

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-msgbox python -m wbia.guitool.guitool_dialogs –test-msgbox –show

Example

>>> # ENABLE_DOCTEST
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> from wbia.guitool.guitool_dialogs import _register_msgbox  # NOQA
>>> # build test data
>>> msg = 'Hello World!'
>>> detailed_msg = 'I have a detailed message for you.'
>>> title = 'msgbox'
>>> # execute function
>>> msgbox = msgbox(msg, title, detailed_msg=detailed_msg)
>>> # verify results
>>> result = str(msgbox)
>>> print(result)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> msgbox.exec_()
wbia.guitool.guitool_dialogs.newDirectoryDialog(caption, directory=None, other_sidebar_dpaths=[], use_sidebar_cwd=True, single_directory=True)[source]
wbia.guitool.guitool_dialogs.newFileDialog(directory_, other_sidebar_dpaths=[], use_sidebar_cwd=True, mode='open', exec_=False)[source]
Parameters:
  • directory
  • other_sidebar_dpaths (list) – (default = [])
  • use_sidebar_cwd (bool) – (default = True)
  • _dialog_class_ (wrappertype) – (default = <class ‘PyQt5.QtWidgets.QFileDialog’>)
Returns:

qdlg

Return type:

?

CommandLine:
python -m wbia.guitool.guitool_dialogs newFileDialog –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> directory_ = '.'
>>> _dialog_class_ = QtWidgets.QFileDialog
>>> if ut.show_was_requested():
>>>     files = newFileDialog(directory_, mode='save', exec_=True)
>>>     print('files = %r' % (files,))
>>> else:
>>>     dlg = newFileDialog(directory_, mode='save', exec_=True)
wbia.guitool.guitool_dialogs.popup_menu(widget, pos, context_options)[source]

For (right-click) context menus

Parameters:
  • widget (QWidget) –
  • pos (QPoint) –
  • context_options (list) –

    of tuples. Can also replace func with nested context_options list. Tuples can be in the format:

    (name, func) (name, shortcut, func) - NOT FULLY SUPPORTED. USE AMPERSAND & INSTEAD
Returns:

(selection, actions)

Return type:

tuple

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-popup_menu python -m wbia.guitool.guitool_dialogs –test-popup_menu –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> import wbia.guitool
>>> import wbia.plottool as pt
>>> import functools
>>> from wbia.plottool import interact_helpers as ih
>>> fig = pt.figure()
>>> def spam(x=''):
...    print('spam' + str(x))
>>> def eggs():
...    print('eggs')
>>> def bacon():
...    print('bacon')
>>> def nospam():
...    print('i dont like spam')
...    import webbrowser
...    webbrowser.open('https://www.youtube.com/watch?v=anwy2MPT5RE')
>>> context_options = [
...     ('spam',  spam),
...     ('&bacon', bacon),
...     ('n&est', [
...         ('e&ggs', eggs),
...         ('&s&pam', functools.partial(spam, 1)),
...         ('sp&a&m', functools.partial(spam, 2)),
...         ('&spam', functools.partial(spam, 3)),
...         ('&spamspamspam', [
...              ('&spamspamspam', [
...                  ('&spam', nospam),
...             ])
...         ])
...     ])
... ]
>>> widget = fig.canvas
>>> pos = guitool.newQPoint(10, 10)
>>> # Hacky way to get a right click to span a context menu
>>> def figure_clicked(event, fig=fig, context_options=context_options):
...     import wbia.guitool
...     import wbia.plottool as pt
...     from wbia.plottool import interact_helpers as ih
...     pos = guitool.newQPoint(event.x, fig.canvas.geometry().height() - event.y)
...     widget = fig.canvas
...     (selection, actions) = popup_menu(widget, pos, context_options)
...     #print(str((selection, actions)))
>>> if ut.show_was_requested():
...     ih.connect_callback(fig, 'button_press_event', figure_clicked)
...     pt.show_if_requested()
>>> else:
...    (selection, actions) = popup_menu(widget, pos, context_options)
wbia.guitool.guitool_dialogs.select_directories(caption='Select Folder(s)', directory=None, other_sidebar_dpaths=[], use_sidebar_cwd=True)[source]
Parameters:
  • caption (str) – (default = ‘Select Directory’)
  • directory (None) – default directory to start in (default = None)
  • other_sidebar_dpaths (list) – (default = [])
  • use_sidebar_cwd (bool) – (default = True)
Returns:

dpath

Return type:

str

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-select_directory

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> # build test data
>>> caption = 'Select Directory'
>>> directory = None  # os.path.dirname(guitool.__file__)
>>> # execute function
>>> other_sidebar_dpaths = [os.path.dirname(ut.__file__)]
>>> dpath = select_directory(caption, directory, other_sidebar_dpaths)
>>> # verify results
>>> result = str(dpath)
>>> print(result)
wbia.guitool.guitool_dialogs.select_directory(caption='Select Directory', directory=None, other_sidebar_dpaths=[], use_sidebar_cwd=True)[source]
Parameters:
  • caption (str) – (default = ‘Select Directory’)
  • directory (None) – default directory to start in (default = None)
  • other_sidebar_dpaths (list) – (default = [])
  • use_sidebar_cwd (bool) – (default = True)
Returns:

dpath

Return type:

str

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-select_directory

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> # build test data
>>> caption = 'Select Directory'
>>> directory = None  # os.path.dirname(guitool.__file__)
>>> # execute function
>>> other_sidebar_dpaths = [os.path.dirname(ut.__file__)]
>>> dpath = select_directory(caption, directory, other_sidebar_dpaths)
>>> # verify results
>>> result = str(dpath)
>>> print(result)
wbia.guitool.guitool_dialogs.select_files(caption='Select Files:', directory=None, name_filter=None, other_sidebar_dpaths=[], use_sidebar_cwd=True, single_file=False)[source]

Selects one or more files from disk using a qt dialog

Parameters:
  • caption (str) – (default = ‘Select Files:’)
  • directory (None) – default directory to start in (default = None)
  • name_filter (None) – (default = None)
  • other_sidebar_dpaths (list) – (default = [])
  • use_sidebar_cwd (bool) – (default = True)

References

http://qt-project.org/doc/qt-4.8/qfiledialog.html

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-select_files

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> import wbia.guitool
>>> guitool.ensure_qtapp()
>>> # build test data
>>> caption = 'Select Files'
>>> name_filter = 'Python Files (*.py)'
>>> directory = os.path.dirname(guitool.__file__)
>>> # execute function
>>> other_sidebar_dpaths = [os.path.dirname(ut.__file__)]
>>> dpath = select_files(caption, directory, name_filter, other_sidebar_dpaths, single_file=True)
>>> # verify results
>>> result = str(dpath)
>>> print(result)
wbia.guitool.guitool_dialogs.select_images(caption='Select images:', directory=None)[source]
wbia.guitool.guitool_dialogs.user_info(parent=None, msg='msg', title='user_info')[source]
wbia.guitool.guitool_dialogs.user_input(parent=None, msg='msg', title='user_input', text='')[source]
Parameters:
  • parent (None) –
  • msg (str) –
  • title (str) –
Returns:

Return type:

str

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-user_input –show

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> parent = None
>>> msg = 'msg'
>>> title = 'user_input'
>>> text = 'default text'
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> dpath = user_input(parent, msg, title, text)
>>> result = str(dpath)
>>> print(result)
wbia.guitool.guitool_dialogs.user_option(parent=None, msg='msg', title='user_option', options=['Yes', 'No'], use_cache=False, default=None, detailed_msg=None)[source]

Prompts user with several options with ability to save decision

Parameters:
  • parent (None) –
  • msg (str) –
  • title (str) –
  • options (list) –
  • use_cache (bool) –
  • default (str) – default option
Returns:

reply

Return type:

str

CommandLine:
python -m wbia.guitool.guitool_dialogs –test-user_option

Example

>>> # GUI_DOCTEST
>>> # xdoctest: +REQUIRES(--gui)
>>> from wbia.guitool.guitool_dialogs import *  # NOQA
>>> import wbia.guitool as gt
>>> gt.ensure_qtapp()
>>> parent = None
>>> msg = 'msg'
>>> title = 'user_option'
>>> options = ['Yes', 'No']
>>> use_cache = False
>>> default = 'Yes'
>>> # execute function
>>> detailed_msg = 'hi'
>>> reply = user_option(parent, msg, title, options, use_cache, default, detailed_msg)
>>> result = str(reply)
>>> print(result)
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> #gt.guitool_main.qtapp_loop()
wbia.guitool.guitool_dialogs.user_question(msg)[source]

wbia.guitool.guitool_main module

class wbia.guitool.guitool_main.GuitoolApplication(args)[source]

Bases: PyQt5.QtWidgets.QApplication

http://codeprogress.com/python/libraries/pyqt/showPyQTExample.php?index=378&key=QApplicationKeyPressGlobally

notify(self, QObject, QEvent) → bool[source]
start_keylog()[source]
wbia.guitool.guitool_main.activate_qwindow(qwin)[source]
wbia.guitool.guitool_main.ensure_qapp()
wbia.guitool.guitool_main.ensure_qtapp()[source]
wbia.guitool.guitool_main.exit_application()[source]
wbia.guitool.guitool_main.get_qtapp()[source]
wbia.guitool.guitool_main.ping_python_interpreter(frequency=420)[source]

Create a QTimer which lets the python catch ctrl+c

wbia.guitool.guitool_main.qtapp_loop(qwin=None, ipy=False, enable_activate_qwin=True, frequency=420, init_signals=True, **kwargs)[source]
Parameters:
  • qwin (None) – (default = None)
  • ipy (bool) – set to True if running with IPython (default = False)
  • enable_activate_qwin (bool) – (default = True)
  • frequency (int) – frequency to ping python interpreter (default = 420)
  • init_signals (bool) – if False, handle terminal signals yourself (default = True)
CommandLine:
python -m wbia.guitool.guitool_main –test-qtapp_loop
wbia.guitool.guitool_main.qtapp_loop_nonblocking(qwin=None, **kwargs)[source]
Fixme:

In order to have a non-blocking qt application then the app must have been started with IPython.lib.inputhook.enable_gui import IPython.lib.inputhook IPython.lib.inputhook.enable_gui(‘qt4’) Actually lib.inputhook is depricated

Maybe IPython.terminal.pt_inputhooks import IPython.terminal.pt_inputhooks inputhook = IPython.terminal.pt_inputhooks.get_inputhook_func(‘qt4’)

wbia.guitool.guitool_main.remove_pyqt_input_hook()[source]

wbia.guitool.guitool_misc module

class wbia.guitool.guitool_misc.BlockContext(widget)[source]

Bases: object

class wbia.guitool.guitool_misc.GUILoggingHandler(write_slot)[source]

Bases: logging.StreamHandler

A handler class which sends messages to to a connected QSlot

emit(record)[source]

Emit a record.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

class wbia.guitool.guitool_misc.GUILoggingSender(write_slot)[source]

Bases: PyQt5.QtCore.QObject

write_
write_gui(msg)[source]
class wbia.guitool.guitool_misc.QLoggedOutput(parent=None, visible=True)[source]

Bases: PyQt5.QtWidgets.QTextEdit

gui_flush()[source]
gui_write(msg_)[source]
setVisible(self, bool)[source]
wbia.guitool.guitool_misc.find_used_chars(name_list)[source]

Move to guitool

wbia.guitool.guitool_misc.get_cplat_tab_height()[source]
wbia.guitool.guitool_misc.get_view_selection_as_str(view)[source]

References

http://stackoverflow.com/questions/3135737/copying-part-of-qtableview

wbia.guitool.guitool_misc.make_option_dict(options, shortcuts=True)[source]

helper for popup menu callbacks

Move to guitool

Parameters:
  • name_list (list) –
  • used_chars (list) – (default = [])
Returns:

hotlinked_name_list

Return type:

list

CommandLine:
python -m wbia.guitool.guitool_misc –exec-make_word_hotlinks

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.guitool_misc import *  # NOQA
>>> name_list = ['occlusion', 'occlusion:large', 'occlusion:medium', 'occlusion:small', 'lighting', 'lighting:shadowed', 'lighting:overexposed', 'lighting:underexposed']
>>> used_chars = []
>>> hotlinked_name_list = make_word_hotlinks(name_list, used_chars)
>>> result = ('hotlinked_name_list = %s' % (str(hotlinked_name_list),))
>>> print(result)
wbia.guitool.guitool_misc.set_qt_object_names(dict_)[source]

Hack to set qt object names from locals, vars, or general dict context

wbia.guitool.guitool_tables module

class wbia.guitool.guitool_tables.ColumnListItemModel(col_data_list=None, col_name_list=None, niceheader_list=None, col_type_list=None, col_edit_list=None, display_indices=False, col_sort_index=None, parent=None, *args)[source]

Bases: PyQt5.QtCore.QAbstractTableModel

Item model for displaying a list of columns

columnCount(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Qt Override

data(index, role=0)[source]

Returns the data to display

flags(index)[source]

Qt Override

get_coltype(column)[source]
get_column_alignment(column)[source]
get_data(index)[source]

Non-Qt Helper

get_editable(column)[source]
get_header(column)[source]

Non-Qt Helper

get_header_data(header, row)[source]

Non-Qt Helper

get_niceheader(column)[source]

Non-Qt Helper

headerData(section, orientation, role=0)[source]

Qt Override

index(row, column, parent=<PyQt5.QtCore.QModelIndex object>)[source]

Qt Override

rowCount(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Qt Override

setData(index, var, role=2)[source]

Sets the role data for the item at index to var. var is a QVariant (called data in documentation)

set_data(index, data)[source]

Non-Qt Helper

set_sorting(col_sort_index=None, order=1)[source]
sort(column, order)[source]

Qt Override

class wbia.guitool.guitool_tables.ColumnListTableView(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QTableView

Table View for an AbstractItemModel

cellButtonClicked()[source]
class wbia.guitool.guitool_tables.ColumnListTableWidget(col_data_list=None, col_name_list=None, niceheader_list=None, col_type_list=None, col_edit_list=None, display_indices=False, col_sort_index=None, parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

ColumnList Table Main Widget

change_data(col_data_list=None, col_name_list=None, niceheader_list=None, col_type_list=None, col_edit_list=None, display_indices=False, col_sort_index=None)[source]

Checks for deligates

get_index_header_data(header, index)[source]
is_index_clickable(index)[source]
set_column_as_delegate(column, delegate_type)[source]
set_column_persistant_editor(column)[source]

Set each row in a column as persistant

wbia.guitool.guitool_tables.make_listtable_widget(col_data_list, col_name_list, col_edit_list=None, show=True, raise_=True, on_click=None)[source]

wbia.guitool.mpl_embed module

http://matplotlib.org/examples/user_interfaces/embedding_in_qt4.html

class wbia.guitool.mpl_embed.QtAbstractMplInteraction(parent=None, width=5, height=4, dpi=100)[source]

Bases: matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg

Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).

Parameters:
  • self
  • parent (None) – (default = None)
  • width (int) – (default = 5)
  • height (int) – (default = 4)
  • dpi (int) – (default = 100)
CommandLine:
python -m wbia.guitool.mpl_embed –exec-QtAbstractMplInteraction –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.guitool.mpl_embed import *  # NOQA
>>> import wbia.plottool as pt
>>> import wbia.guitool
>>> guitool.ensure_qapp()  # must be ensured before any embeding
>>> self = QtAbstractMplInteraction()
>>> parent = None
>>> width = 5
>>> height = 4
>>> dpi = 100
>>> self = QtAbstractMplInteraction(parent)
>>> self.show()
>>> print('Blocking')
>>> self.start_blocking()
>>> print('Done')
>>> # xdoctest: +REQUIRES(--show)
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
>>> guitool.qtapp_loop(self, frequency=100, init_signals=True)
closeEvent(self, QCloseEvent)[source]
compute_initial_figure()[source]
start_blocking()[source]
stop_blocking()[source]

wbia.guitool.mpl_widget module

class wbia.guitool.mpl_widget.MatplotlibWidget(parent=None, orientation=None, verticalSizePolicy=None, horizontalSizePolicy=None, verticalStretch=None, horizontalStretch=None, spacing=None, margin=None, name=None, ori=None, **kwargs)[source]

Bases: wbia.guitool.guitool_components.GuitoolWidget

A qt widget that contains a matplotlib figure

References

http://matplotlib.org/examples/user_interfaces/embedding_in_qt4.html

clf()[source]
click_inside_signal
initialize(pan_and_zoom=False)[source]
key_press_signal
pick_event_signal
reset_ax()[source]

wbia.guitool.qt_enums module

wbia.guitool.qt_enums.define_qt_enum(block)[source]
wbia.guitool.qt_enums.parse_window_type_and_flags(self)[source]

wbia.guitool.qtype module

wbia.guitool.qtype.cast_from_qt(var, type_=None)[source]

Casts a QVariant to data

wbia.guitool.qtype.cast_into_qt(data)[source]

Casts python data into a representation suitable for QT (usually a string)

wbia.guitool.qtype.infer_coltype(column_list)[source]

Infer Column datatypes

wbia.guitool.qtype.locale_float(float_, precision=4)[source]

References

http://qt-project.org/doc/qt-4.8/qlocale.html#toString-9

wbia.guitool.qtype.numpy_to_qicon(npimg)[source]
wbia.guitool.qtype.numpy_to_qpixmap(npimg)[source]
wbia.guitool.qtype.qindexinfo(index)[source]
wbia.guitool.qtype.to_qcolor(color)[source]

wbia.guitool.stripe_proxy_model module

class wbia.guitool.stripe_proxy_model.StripeProxyModel(parent=None, numduplicates=1)[source]

Bases: PyQt5.QtCore.QIdentityProxyModel

columnCount(self, parent: QModelIndex = QModelIndex()) → int[source]
data(self, QModelIndex, role: int = Qt.DisplayRole) → Any[source]
index(self, int, int, parent: QModelIndex = QModelIndex()) → QModelIndex[source]
mapFromSource(sourceIndex)[source]

returns index into proxy model

mapToSource(proxyIndex)[source]

returns index into original model

parent(self, QModelIndex) → QModelIndex[source]
proxy_to_source(row, col, parent=<PyQt5.QtCore.QModelIndex object>)[source]
rowCount(self, parent: QModelIndex = QModelIndex()) → int[source]
setData(self, QModelIndex, Any, role: int = Qt.EditRole) → bool[source]
sort(self, int, order: Qt.SortOrder = Qt.AscendingOrder)[source]
source_to_proxy(row, col, parent=<PyQt5.QtCore.QModelIndex object>)[source]

Module contents

wbia.guitool.IMPORT_TUPLES = [('guitool_main', None), ('guitool_components', None), ('guitool_dialogs', None), ('guitool_decorators', None), ('guitool_misc', None), ('api_item_model', None), ('api_tree_view', None), ('api_table_view', None), ('qtype', None), ('stripe_proxy_model', None), ('filter_proxy_model', None)]

python -c “import wbia.guitool” –dump-guitool-init python -c “import wbia.guitool” –update-guitool-init

wbia.guitool.reassign_submodule_attributes(verbose=1)[source]

Updates attributes in the __init__ modules with updated attributes in the submodules.

wbia.guitool.reload_subs(verbose=1)[source]

Reloads wbia.guitool and submodules

wbia.guitool.rrrr(verbose=1)

Reloads wbia.guitool and submodules