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_combo
¶
-
is_spin
¶
-
max_
¶
-
min_
¶
-
none_ok
¶
-
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
-
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
¶
-
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¶
-
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.
-
class
wbia.guitool.PreferenceWidget.
QPreferenceModel
(**kwargs)[source]¶ Bases:
PyQt5.QtCore.QAbstractItemModel
Convention states only items with column index 0 can have children
-
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¶
Bases:
PyQt5.QtWidgets.QStyledItemDelegate
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
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
-
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
-
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.
-
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.
-
-
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.
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_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.
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_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.
-
model
¶
-
-
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
-
get
(column, row, **kwargs)[source]¶ getters always receive primary rowids, rectify if col_ider is specified (row might be a row_pair)
-
-
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()
-
rows_updated
¶
-
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)
-
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
-
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
-
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.
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_timestamp_delegate module¶
wbia.guitool.api_tree_node module¶
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
¶
-
rows_updated
¶
-
-
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¶
wbia.guitool.guitool_components module¶
-
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)
-
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,))
-
class
wbia.guitool.guitool_components.
CustomCheckBox
(text='', parent=None, checked=False, changed=None)[source]¶ Bases:
PyQt5.QtWidgets.QCheckBox
-
class
wbia.guitool.guitool_components.
CustomComboBox
(parent=None, default=None, options=None, changed=None)[source]¶ Bases:
PyQt5.QtWidgets.QComboBox
-
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)
-
class
wbia.guitool.guitool_components.
GuiProgContext
(title, prog_bar)[source]¶ Bases:
object
-
prog_hook
¶
-
-
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)
-
closed
¶
-
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
¶
-
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,))
-
prog_bar
¶
-
progress_changed_signal
¶
-
show_indefinite_progress_signal
¶
-
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)
-
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
-
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)
-
toggle_finished
¶
-
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)
-
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.
get_nested_attr
(obj, attr)[source]¶ attr = ‘sizePolicy().verticalPolicy()’
-
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.
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.
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.
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:
-
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_decorators module¶
wbia.guitool.guitool_delegates module¶
-
class
wbia.guitool.guitool_delegates.
APIDelegate
(parent)[source]¶ Bases:
PyQt5.QtWidgets.QItemDelegate
-
is_persistant_editable
= True¶
-
-
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
-
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
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
-
wbia.guitool.guitool_dialogs.
are_you_sure
(parent=None, msg=None, title='Confirmation', default=None)[source]¶ Prompt user for conformation before changing something
builds nested menu for context menus but can be used for other menu related things.
References
-
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)
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.
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_main module¶
-
class
wbia.guitool.guitool_main.
GuitoolApplication
(args)[source]¶ Bases:
PyQt5.QtWidgets.QApplication
-
wbia.guitool.guitool_main.
ensure_qapp
()¶
-
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_misc module¶
-
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_
¶
-
-
class
wbia.guitool.guitool_misc.
QLoggedOutput
(parent=None, visible=True)[source]¶ Bases:
PyQt5.QtWidgets.QTextEdit
-
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
-
wbia.guitool.guitool_misc.
make_word_hotlinks
(name_list, used_chars=[], after_colon=False)[source]¶ 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_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
-
class
wbia.guitool.guitool_tables.
ColumnListTableView
(*args, **kwargs)[source]¶ Bases:
PyQt5.QtWidgets.QTableView
Table View for an AbstractItemModel
-
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
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)
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
-
click_inside_signal
¶
-
key_press_signal
¶
-
pick_event_signal
¶
-
wbia.guitool.qt_enums module¶
wbia.guitool.qtype module¶
-
wbia.guitool.qtype.
cast_into_qt
(data)[source]¶ Casts python data into a representation suitable for QT (usually a string)
wbia.guitool.stripe_proxy_model module¶
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.
rrrr
(verbose=1)¶ Reloads wbia.guitool and submodules