diffpy.pdfgui.gui.wxextensions package

Extensions to wxPython used in PDFgui.

Submodules

diffpy.pdfgui.gui.wxextensions.listctrls module

This module contains custom wxListCtrl subclasses. AutoWidthListCtrl - A wxListCtrl object that automatically adjusts the width of its columns. ColumnSortListCtrl - An AutoWidthListCtrl that sorts its entries when the column header is clicked. KeyEventsListCtrl - A ColumnSortListCtrl that selects and item as you type its name.

class diffpy.pdfgui.gui.wxextensions.listctrls.AutoWidthListCtrl(parent, ID, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0, *args, **kwargs)[source]

Bases: ListCtrl, ListCtrlAutoWidthMixin

WxListCtrl subclass that automatically adjusts its column width.

clearSelections()[source]

Clear all selections in the list.

setSelection(itemtext=None)[source]

Convenience function for simple selection of a list item by label.

itemtext – The label of the item to select. If itemtext is None

(default) then all items will be deselected.

class diffpy.pdfgui.gui.wxextensions.listctrls.ColumnSortListCtrl(parent, ID, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0, *args, **kwargs)[source]

Bases: AutoWidthListCtrl, ColumnSorterMixin

AutoWidthListCtrl subclass that sorts its columns when the column header is pressed.

This ListCtrl requires an itemDataMap member dictionary to be initialized before the sorting capabilities can be realized. This dictionary simply references the ListCtrl’s entries by a unique number. This number must be stored as the ItemData (with SetItemData) of the entry. The member data must be in the form of a tuple, where the tuple has a number of entries as the ListCtrl has columns. The sorting routine sorts the items in the ListCtrl by the entries in this tuple.

GetListCtrl()[source]

This method is required by the sorter mixin.

initializeSorter()[source]

Initialize the column sorter mixin after the ListCtrl is filled.

This method must be called whenever the itemDataMap is altered.

makeIDM()[source]

This method automatically sets up the itemDataMap.

The itemDataMap gets filled with the current ListCtrl entries. The itemDataMap does not update automatically when the list is changed. To update the itemDataMap this method must be called again. initializeSorter should be called after a call to this method.

class diffpy.pdfgui.gui.wxextensions.listctrls.KeyEventsListCtrl(parent, id, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0, *args, **kwargs)[source]

Bases: ColumnSortListCtrl

ColumnSortListCtrl that catches key events and selects the item that matches.

It only searches for items in the first column.

OnKey(evt)[source]
OnKeyDown(evt)[source]
findPrefix(prefix)[source]

diffpy.pdfgui.gui.wxextensions.validators module

class diffpy.pdfgui.gui.wxextensions.validators.TextValidator(flag=2, allowNeg=False)[source]

Bases: Validator

This validator is designed to check text input for wxTextCtrls.

(It might have uses in other widgets.) It can validate for letters only, digits only, floats only, and can allow for a negative at the beginning of a digit string or a negative float.

Clone() Object[source]

All validator classes must implement the Clone() function, which returns an identical copy of itself.

OnChar(event)[source]
TransferFromWindow() bool[source]

This overridable function is called when the value in the window must be transferred to the validator.

TransferToWindow() bool[source]

This overridable function is called when the value associated with the validator must be transferred to the window.

Validate(parent) bool[source]

This overridable function is called when the value in the associated window must be validated.

diffpy.pdfgui.gui.wxextensions.autowidthlabelsgrid module

This module contains AutoWidthListCtrl, a wxListCtrl object that automatically adjusts the width of its columns.

class diffpy.pdfgui.gui.wxextensions.autowidthlabelsgrid.AutoWidthLabelsGrid[source]

Bases: Grid

Wx grid which allows labels auto sizing.

AutosizeLabels(rows=True, cols=False)[source]

diffpy.pdfgui.gui.wxextensions.textctrlutils module

This module contains utilities that can be used with wxTextCtrls.

diffpy.pdfgui.gui.wxextensions.textctrlutils.textCtrlAsGridCell(panel, event)[source]

Process a textCtrl key event as if the textCtrl was a grid cell.

This catches ESC and ENTER events in textCtrls and processes them as if the textCtrl were a grid cell. This method can be bound to the wx.EVT_KEY_DOWN event of any textCtrl. See phaseconfigurepanel.py in diffpy.pdfgui.gui for an example.

ESC – Cancel the edit and highlight the text. This requires that

panel has a _focusedText attribute that stores the previous value.

ENTER – Confirm the edit and move to the next cell (the default TAB

behavior).

diffpy.pdfgui.gui.wxextensions.paneldialog module

This module contains the PanelDialog class, a simple class that turns any panel into a dialog.

class diffpy.pdfgui.gui.wxextensions.paneldialog.PanelDialog(*args, **kwds)[source]

Bases: Dialog

This class will turn any panel into a dialog.

Using this makes for quicker development and encourages the developer to design a gui as a collection of panels, instead of a monolithic mega-panel.

setPanel(panel)[source]

Call this method to add the panel to the dialog.