13. widgets — A collection of custom widgets used in the pyFormex GUI

A collection of custom widgets used in the pyFormex GUI

The widgets in this module were primarily created in function of the pyFormex GUI. The user can apply them to change the GUI or to add interactive widgets to his scripts. Of course he can also use all the Qt widgets directly.

Classes defined in module widgets

class widgets.Options

An empty class to allow easy attribute syntax

class widgets.FileSelection(path='.', pattern='*.*', exist=False, multi=False, dir=False)

A file selection dialog.

You can specify a default path/filename that will be suggested initially. If a pattern is specified, only matching files will be shown. A pattern can be something like Images (*.png *.jpg) or a list of such strings. Default mode is to accept any filename. You can specify exist=True to accept only existing files. Or set exist=True and multi=True to accept multiple files. If dir==True, a single existing directory is asked.

Methods

getFilename(timeout=None)

Ask for a filename by user interaction.

Return the filename selected by the user. If the user hits CANCEL or ESC, None is returned.

class widgets.ProjectSelection(path=None, pattern=None, exist=False, compression=4, ignore_signature=True)

A file selection dialog specialized for opening projects.

Methods

class widgets.SaveImageDialog(path=None, pattern=None, exist=False, multi=False)

A dialog for saving to an image file.

The dialog contains the normal file selection widget plus some extra fields to set the Save Image parameters:

  • Whole Window: If checked, the whole pyFormex main window will be saved. If unchecked, only the current OpenGL viewport is saved.
  • Crop Root: If checked, the window will be cropped from the root window. This mode is required if you want to include the window decorations.

Methods

class widgets.DockedSelection(slist=[], title='Selection Dialog', mode=None, sort=False, func=None)

A docked selection widget.

A widget that is docked in the main window and contains a modeless dialog for selecting items.

Methods

class widgets.ModelessSelection(slist=[], title='Selection Dialog', mode=None, sort=False, func=None, width=None, height=None)

A modeless dialog for selecting one or more items from a list.

Methods

setSelected(selected, bool)

Mark the specified items as selected.

getResult()

Return the list of selected values.

If the user cancels the selection operation, the return value is None. Else, the result is always a list, possibly empty or with a single value.

class widgets.Selection(slist=[], title='Selection Dialog', mode=None, sort=False, selected=[])

A dialog for selecting one or more items from a list.

  • slist: a list of items that are initially selected.

Methods

setSelected(selected)

Mark the specified items as selected.

getResult()

Return the list of selected values.

If the user cancels the selection operation, the return value is None. Else, the result is always a list, possibly empty or with a single value.

class widgets.InputItem(name, *args, **kargs)

A single input item, usually with a label in front.

The created widget is a QHBoxLayout which can be embedded in the vertical layout of a dialog.

This is a super class for all input items. It just creates a label. The input field(s) should be added by the dedicated subclass.

The constructor has one required argument: name. It is the name used to identify the item and should be unique for all InputItems in the same dialog. Other (optional) positional parameters are passed to the QHBoxLayout constructor.

By default the constructor adds a label to the QHBoxLayout, with text set by the text keyword argument or (by default) by the name of the item. Use the text argument if you want the displayed text to be different from the items name. A text='' parameter will suppress the label. This is e.g. used in the InputBoolean constructor, where the text is displayed by the input field.

The superclass also defines default values for the text(), value() and setValue() methods.

Subclasses should initialize the superclass as follows:

InputItem.__init__(self,name,*args,**kargs)

Subclasses should override:

  • text(): if they called the superclass __init__() method with text='';
  • value(): if they did not create a self.input widget who’s text() is the return value of the item.
  • setValue(): always, unless the field is readonly.

Subclasses can set validators on the input, like input.setValidator(QtGui.QIntValidator(input))

Subclasses can define a show() method e.g. to select the data in the input field on display of the dialog.

Methods

name()

Return the name of the InputItem.

text()

Return the displayed text of the InputItem.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputInfo(name, value, *args, **kargs)

An unchangeable input field with a label in front.

It is just like an InputString, but the text can not be edited.

There are no specific options.

Methods

value()

Return the widget’s value.

class widgets.InputLabel(name, value, *args, **kargs)

An unchangeable information field.

The value is displayed as a string.

By default, the text format will be guessed to be either plain text, ReStructuredText ot html. Specify plain=True to display in plain text.

Methods

setValue(val)

Change the widget’s value.

class widgets.InputString(name, value, max=None, *args, **kargs)

A string input field with a label in front.

If the type of value is not a string, the input string will be eval’ed before returning.

Options:

  • max: the maximum number of characters in the string.

Methods

show()

Select all text on first display.

value()

Return the widget’s value.

class widgets.InputText(name, value, *args, **kargs)

A scrollable text input field with a label in front.

By default, the text format will be guessed to be either plain text, ReStructuredText ot html.

Specify plain=True to display in plain text.

If the type of value is not a string, the input text will be eval’ed before returning.

Methods

show()

Select all text on first display.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputBool(name, value, *args, **kargs)

A boolean input item.

Methods

text()

Return the displayed text.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputCombo(name, default, choices=[], onselect=None, *args, **kargs)

A combobox InputItem.

A combobox is a widget allowing the selection of an item from a drop down list.

choices is a list/tuple of possible values. default is the initial/default choice. If default is not in the choices list, it is prepended. If default is None, the first item of choices is taken as the default.

The choices are presented to the user as a combobox, which will initially be set to the default value.

An optional onselect function may be specified, which will be called whenever the current selection changes.

Methods

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputRadio(name, default, choices=[], direction='h', *args, **kargs)

A radiobuttons InputItem.

Radio buttons are a set of buttons used to select a value from a list.

choices is a list/tuple of possible values. default is the initial/default choice. If default is not in the choices list, it is prepended. If default is None, the first item of choices is taken as the default.

The choices are presented to the user as a hbox with radio buttons, of which the default will initially be pressed. If direction == ‘v’, the options are in a vbox.

Methods

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputPush(name, default=None, choices=[], direction='h', *args, **kargs)

A pushbuttons InputItem.

Methods

setText(text, index=0)

Change the text on button index.

setIcon(icon, index=0)

Change the icon on button index.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputInteger(name, value, *args, **kargs)

An integer input item.

Options:

  • min, max: range of the scale (integer)

Methods

show()

Select all text on first display.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputFloat(name, value, *args, **kargs)

An float input item.

Methods

show()

Select all text on first display.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputFloatTable(name, value, *args, **kargs)

A table of floats input item.

Methods

show()

Select all text on first display.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputSlider(name, value, *args, **kargs)

An integer input item using a slider.

Options:

  • min, max: range of the scale (integer)
  • ticks: step for the tick marks (default range length / 10)
  • func: an optional function to be called whenever the value is changed. The function takes a float/integer argument.

Methods

class widgets.InputFSlider(name, value, *args, **kargs)

A float input item using a slider.

Options:

  • min, max: range of the scale (integer)
  • scale: scale factor to compute the float value
  • ticks: step for the tick marks (default range length / 10)
  • func: an optional function to be called whenever the value is changed. The function receives the input field as argument. With this argument, the fields attirbutes like name, value, text, can be retrieved.

Methods

class widgets.InputPoint(name, value, *args, **kargs)

A 3D point/vector input item.

Methods

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputButton(name, value, *args, **kargs)

A button input item.

The button input field is a button displaying the current value. Clicking on the button executes a function responsible for changing the value.

Extra parameters:

  • func: the function to call when the button is clicked. The current input value is passed as an argument. The function should return the value to be set, or None if it is to be unchanged. If no function is specified, the value can not be changed.

Methods

doFunc()

Set the value by calling the button’s func

class widgets.InputColor(name, value, *args, **kargs)

A color input item.

Methods

setValue(value)

Change the widget’s value.

class widgets.InputFont(name, value, *args, **kargs)

An input item to select a font.

Methods

class widgets.InputWidget(name, value, *args, **kargs)

An input item containing any other widget.

The widget should have:

  • a results attribute that is set to a dict with the resulting input values when the widget’s acceptData() is called.
  • an acceptData() method, that sets the widgets results dict.
  • a setValue(dict) method that sets the widgets values to those specified in the dict.

The return value of this item is an ODict.

Methods

text()

Return the displayed text.

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputGroup(name, items, *args, **kargs)

A boxed group of InputItems.

Methods

value()

Return the widget’s value.

setValue(val)

Change the widget’s value.

class widgets.InputDialog(items, caption=None, parent=None, flags=None, actions=None, default=None, scroll=False, store=None, prefix='', autoprefix=False, flat=None, modal=None)

A dialog widget to interactively set the value of one or more items.

Overview

The pyFormex user has full access to the Qt4 framework on which the GUI was built. Therefore he can built input dialogs as complex and powerful as he can imagine. However, directly dealing with the Qt4 libraries requires some skills and, for simple input widgets, more effort than needed.

The InputDialog class presents a unified system for quick and easy creation of common dialog types. The provided dialog can become quite sophisticated with tabbed pages, groupboxes and custom widgets. Both modal and modeless (non-modal) dialogs can be created.

Items

Each basic input item is a dictionary, where the fields have the following meaning:

  • name: the name of the field,
  • value: the initial or default value of the field,
  • itemtype: the type of values the field can accept,
  • options: a dict with options for the field.
  • text: if specified, the text value will be displayed instead of the name. The name value will remain the key in the return dict. Use this field to display a more descriptive text for the user, while using a short name for handling the value in your script.
  • buttons:
  • tooltip:
  • min:
  • max:
  • scale:
  • func:

Other arguments

  • caption: the window title to be shown in the window decoration
  • actions: a list of action buttons to be added at the bottom of the input form. By default, a Cancel and Ok button will be added, to either reject or accept the input values.
  • default: the default action
  • parent: the parent widget (by default, this is the pyFormex main window)
  • autoprefix: if True, the names of items inside tabs and group boxes will get prefixed with the tab and group names, separated with a ‘/’.
  • flat: if True, the results are returned in a single (flat) dictionary, with keys being the specified or autoprefixed ones. If False, the results will be structured: the value of a tab or a group is a dictionary with the results of its fields. The default value is equal to the value of autoprefix.
  • flags:
  • modal:

Methods

add_items(items, form)

Add input items to form.

items is a list of input item data layout is the widget layout where the input widgets will be added

add_tab(name, items, **extra)

Add a Tab page of input items.

add_group(name, items, **extra)

Add a group of input items.

add_input(item)

Add a single input item.

timeout()

Hide the dialog and set the result code to TIMEOUT

timedOut()

Returns True if the result code was set to TIMEOUT

show(timeout=None, timeoutfunc=None, modal=False)

Show the dialog.

For a non-modal dialog, the user has to call this function to display the dialog. For a modal dialog, this is implicitely executed by getResult().

If a timeout is given, start the timeout timer.

acceptData(result=1)

Update the dialog’s return value from the field values.

This function is connected to the ‘accepted()’ signal. Modal dialogs should normally not need to call it. In non-modal dialogs however, you can call it to update the results without having to raise the accepted() signal (which would close the dialog).

updateData(d)

Update a dialog from the data in given dictionary.

d is a dictionary where the keys are field names in the dialog. The values will be set in the corresponding input items.

getResults(timeout=None)

Get the results from the input dialog.

This fuction is used to present a modal dialog to the user (i.e. a dialog that must be ended before the user can continue with the program. The dialog is shown and user interaction is processed. The user ends the interaction either by accepting the data (e.g. by pressing the OK button or the ENTER key) or by rejecting them (CANCEL button or ESC key). On accept, a dictionary with all the fields and their values is returned. On reject, an empty dictionary is returned.

If a timeout (in seconds) is given, a timer will be started and if no user input is detected during this period, the input dialog returns with the default values set. A value 0 will timeout immediately, a negative value will never timeout. The default is to use the global variable input_timeout.

The result() method can be used to find out how the dialog was ended. Its value will be one of ACCEPTED, REJECTED ot TIMEOUT.

class widgets.TableModel(data, chead=None, rhead=None, edit=True)

A table model that represent data as a two-dimensional array of items.

data is any tabular data organized in a fixed number of rows and colums. This means that an item at row i and column j can be addressed as data[i][j]. Optional lists of column and row headers can be specified.

Methods

flags(index)

Return the TableModel flags.

class widgets.ArrayModel(data, chead=None, rhead=None, edit=True)

A TableModel specialized for represents 2D array data.

  • data: a numpy array with two dimensions.
  • chead, rhead: column and row headers. The default will show column and row numbers.
  • edit: if True (default), the data can be edited. Set to False to make the data readonly.

Methods

class widgets.Table(data, chead=None, rhead=None, label=None, edit=True, parent=None)

A widget to show/edit a two-dimensional array of items.

  • data: a 2-D array of items, with nrow rows and ncol columns. If data is an ndarray instance, the Table will use an ArrayModel, else a TableModel. The difference is important when editing the table. Also, an ArrayModel has default row and column headers, while a TableModel doesn’t.
  • chead: an optional list of ncol column headers.
  • rhead: an optional list of nrow row headers.
  • label: currently unused (intended to display an optional label in the upper left corner if both chead and rhead are specified.

Methods

class widgets.Tabs(items, parent=None)

Present a list of widgets as a single tabbed widget.

  • items: a list of (header,widget) tuples.
  • caption:
  • parent:

Methods

class widgets.GenericDialog(widgets, title=None, parent=None, actions=[('OK',)], default='OK')

A generic dialog widget.

The dialog if formed by a number of widgets stacked in a vertical box layout. At the bottom is a horizontal button box with possible actions.

  • widgets: a list of widgets to include in the dialog
  • title: the window title for the dialog
  • parent: the parent widget. If None, it is set to pf.GUI.
  • actions: the actions to include in the bottom button box. By default, an ‘OK’ button is displayed to close the dialog. Can be set to None to avoid creation of a button box.
  • default: the default action, ‘OK’ by default.

Methods

class widgets.TableDialog(data, chead=None, rhead=None, title=None, parent=None, actions=[('OK',)], default='OK')

A dialog widget to show/edit a two-dimensional array of items.

A convenience class representing a Table within a dialog.

Methods

class widgets.MessageBox(text, format='', level='info', actions=['OK'], default=None, timeout=None, modal=None, parent=None, check=None)

A message box is a widget displaying a short text for the user.

The message box displays a text, an optional icon depending on the level and a number of push buttons.

  • text: the text to be shown. This can be either plain text or html or reStructuredText.
  • format: the text format: either ‘plain’, ‘html’ or ‘rest’. Any other value will try automatic recognition. Recognition of plain text and html is automatic. A text is autorecognized to be reStructuredText if its first line starts with ‘..’ and is followed by a blank line.
  • level: defines the icon that will be shown together with the text. If one of ‘question’, ‘info’, ‘warning’ or ‘error’, a matching icon will be shown to hint the user about the type of message. Any other value will suppress the icon.
  • actions: a list of strings. For each string a pushbutton will be created which can be used to exit the dialog and remove the message. By default there is a single button labeled ‘OK’.

When the MessageBox is displayed with the getResult() method, a modal dialog is created, i.e. the user will have to click a button or hit the ESC key before he can continue.

If you want a modeless dialog, allowing the user to continue while the message stays open, use the show() mehod to display it.

Methods

addCheck(text)

Add a check field at the bottom of the layout.

getResult()

Display the message box and wait for user to click a button.

This will show the message box as a modal dialog, so that the user has to click a button (or hit the ESC key) before he can continue. Returns the text of the button that was clicked or an empty string if ESC was hit.

class widgets.WarningBox

A message box is a widget displaying a short text for the user.

The message box displays a text, an optional icon depending on the level and a number of push buttons.

  • text: the text to be shown. This can be either plain text or html or reStructuredText.
  • format: the text format: either ‘plain’, ‘html’ or ‘rest’. Any other value will try automatic recognition. Recognition of plain text and html is automatic. A text is autorecognized to be reStructuredText if its first line starts with ‘..’ and is followed by a blank line.
  • level: defines the icon that will be shown together with the text. If one of ‘question’, ‘info’, ‘warning’ or ‘error’, a matching icon will be shown to hint the user about the type of message. Any other value will suppress the icon.
  • actions: a list of strings. For each string a pushbutton will be created which can be used to exit the dialog and remove the message. By default there is a single button labeled ‘OK’.

When the MessageBox is displayed with the getResult() method, a modal dialog is created, i.e. the user will have to click a button or hit the ESC key before he can continue.

If you want a modeless dialog, allowing the user to continue while the message stays open, use the show() mehod to display it.

Methods

class widgets.TextBox(text, format=None, actions=['OK', None], modal=None, parent=None, caption=None, mono=False, timeout=None, flags=None)

Display a text and wait for user response.

Possible choices are ‘OK’ and ‘CANCEL’. The function returns True if the OK button was clicked or ‘ENTER’ was pressed, False if the ‘CANCEL’ button was pressed or ESC was pressed.

Methods

class widgets.InputBox(*args)

A widget accepting a line of input.

Methods

class widgets.ButtonBox(name, actions=[], parent=None, stretch=[-1, -1])

A box with action buttons.

  • name: a label to be displayed in front of the button box. An empty string will suppress it.
  • actions: a list of (button label, button function) tuples. The button function can be a normal callable function, or one of the values widgets.ACCEPTED or widgets.REJECTED. In the latter case, parent should be specified.
  • parent: the parent dialog holding this button box. It should be specified if one of the buttons actions is widgets.ACCEPTED or widgets.REJECTED.

Methods

class widgets.ComboBox(name, choices, func=None, *args)
class widgets.CoordsBox(ndim=3, readonly=False, *args)

A widget displaying the coordinates of a point.

Methods

getValues()

Return the current x,y,z values as a list of floats.

setValues(values)

Set the three values of the widget.

class widgets.ImageView(image=None, maxheight=None, parent=None)

A widget displaying an image.

Methods

showImage(image)

Show an image in the viewer.

image: either a filename or an existing QImage instance. If a filename, it should be an image file that can be read by the QImage constructor. Most image formats are understood by QImage. The variable gui.image.image_formats_qtr provides a list.

class widgets.OldTableDialog(items, caption=None, parent=None, tab=False)

A dialog widget to show two-dimensional arrays of items.

Methods

class widgets.OldInputDialog(items, caption=None, parent=None, flags=None, actions=None, default=None, scroll=False)

A dialog widget to set the value of one or more items.

While general input dialogs can be constructed from all the underlying Qt classes, this widget provides a way to construct fairly complex input dialogs with a minimum of effort.

The input dialog can be modal or non-modal dialog.

Methods

add_input_items(items, layout)

Add input items.

items is a list of input item data layout is the widget layout where the input widgets will be added

timeout()

Hide the dialog and set the result code to TIMEOUT

timedOut()

Returns True if the result code was set to TIMEOUT

show(timeout=None, timeoutfunc=None, modal=False)

Show the dialog.

For a non-modal dialog, the user has to call this function to display the dialog. For a modal dialog, this is implicitely executed by getResult().

If a timeout is given, start the timeout timer.

acceptData(result=1)

Update the dialog’s return value from the field values.

This function is connected to the ‘accepted()’ signal. Modal dialogs should normally not need to call it. In non-modal dialogs however, you can call it to update the results without having to raise the accepted() signal (which would close the dialog).

updateData(d)

Update a dialog from the data in given dictionary.

d is a dictionary where the keys are field names in the dialog. The values will be set in the corresponding input items.

getResult(timeout=None)

Get the results from the input dialog.

This fuction is used to present a modal dialog to the user (i.e. a dialog that must be ended before the user can continue with the program. The dialog is shown and user interaction is processed. The user ends the interaction either by accepting the data (e.g. by pressing the OK button or the ENTER key) or by rejecting them (CANCEL button or ESC key). On accept, a dictionary with all the fields and their values is returned. On reject, an empty dictionary is returned.

If a timeout (in seconds) is given, a timer will be started and if no user input is detected during this period, the input dialog returns with the default values set. A value 0 will timeout immediately, a negative value will never timeout. The default is to use the global variable input_timeout.

The result() method can be used to find out how the dialog was ended. Its value will be one of ACCEPTED, REJECTED ot TIMEOUT.

Functions defined in module widgets

widgets.maxSize()

Return the maximum widget size.

The maximum widget size is the (available) screen size. This may be smaller than the physical screen size (e.g. excluding docking panels).

widgets.addTimeOut(widget, timeout=None, timeoutfunc=None)

Add a timeout to a widget.

  • timeoutfunc is a callable. If None it will be set to the widget’s timeout method if one exists.
  • timeout is a float value. If None, it will be set to to the global input_timeout.

If timeout is positive, a timer will be installed into the widget which will call the timeoutfunc after timeout seconds have elapsed. The timeoutfunc can be any callable, but usually will emit a signal to make the widget accept or reject the input. The timeoutfunc will not be called is if the widget is destructed before the timer has finished.

widgets.selectFont()

Ask the user to select a font.

A font selection dialog widget is displayed and the user is requested to select a font. Returns a font if the user exited the dialog with the OK button. Returns None if the user clicked CANCEL.

widgets.getColor(col=None, caption=None)

Create a color selection dialog and return the selected color.

col is the initial selection. If a valid color is selected, its string name is returned, usually as a hex #RRGGBB string. If the dialog is canceled, None is returned.

widgets.defaultItemType(item)

Guess the InputItem type from the value

widgets.simpleInputItem(name, value=None, itemtype=None, **kargs)

A convenience function to create an InputItem dictionary

widgets.groupInputItem(name, items=[], **kargs)

A convenience function to create an InputItem dictionary

widgets.tabInputItem(name, items=[], **kargs)

A convenience function to create an InputItem dictionary

widgets.compatInputItem(name, value, itemtype=None, kargs={})

A convenience function to create an InputItem dictionary

This function accepts InputItem data in the old format: ( name, value, [ itemtype, [ optionsdict ] ] ) and turns them into a dictionary as required by the new InputItem format.

widgets.convertInputItemList(items)

Convert a list of InputItems from old to new format.

In the old format, data for InputItems could be lists or tuples or dictionaries, and there were even differently interpreted lists or tuples. In the new format, all InputItem data are dictionaries.

This function helps the transition to the new format, by doing its best to convert lists of data in old format to the new format. For most simple old inputdata, calling this function will suffice. However, this function does not guarantee full and correct conversion of all old format. Users are therfore encouraged to restructure their data and either write them as dictionaries per item, or use the simpleInputItem call to create the dictionary for each item.

The conversion does the following:

  • if the item data is a list or a tuple, it is converted to a new format dictionary by calling compatInputItem function with the data

Anything else will currently raise a ValueError.

widgets.inputAny(name, value, itemtype=<type 'str'>, **options)

Create an InputItem of any type, depending on the arguments.

Arguments: only name and value are required

  • name: name of the item, also the key for the return value
  • value: initial value,
  • itemtype: one of the available itemtypes, default derived from value or str if value is not recognized.
  • text: descriptive text displayed on the input dialog, default equal to name
  • choices: a list of posible values (for selection types)
  • min,max: limits for range types
  • validator: customized validation function
widgets.inputAnyOld(item, parent=None)

Create an InputItem with the old data style.

This translates the data from the legacy InputItem data to the new style required by InputAny. Returns the InputItem constrctured with the data.

widgets.updateDialogItems(data, newdata)

Update the input data fields with new data values

  • data: a list of dialog items, as required by an InputDialog.
  • newdata: a dictionary with new values for (some of) the items.

The data items with a name occurring as a key in newdata will have their value replaced with the corresponding value in newdata, unless this value is None.

The user should make sure to set only values of the proper type!

widgets.updateOldDialogItems(data, newdata)

Update the input data fields with new data values

  • data: a list of dialog items, as required by an OldInputDialog.
  • newdata: a dictionary with new values for (some of) the items.

The values in data which have a matching key in newdata will be replaced with the new value, unless it is None.

This function requires that the dialog items are lists, not tuples.

widgets.updateText(widget, text, format='')

Update the text of a text display widget.

  • widget: a widget that has the setText(), setPlainText() and setHtml() methods to set the widget’s text. Examples are QMessageBox and QTextEdit.
  • text: a multiline string with the text to be displayed.
  • format: the format of the text. If empty, autorecognition will be tried. Currently available formats are: plain, html and rest (reStructuredText).

This function allows to display other text formats besides the plain text and html supported by the widget. Any format other than plain or html will be converted to one of these before sending it to the widget. Currently, we convert the following formats:

  • rest (reStructuredText): If the :mod:docutils is available, rest text is converted to html, otherwise it will be displayed as plain text. A text is autorecognized as reStructuredText if its first line starts with ‘..’. Note: If you add a ‘..’ line to your text to have it autorecognized as reST, be sure to have it followed with a blank line, or your first paragraph could be turned into comments.
widgets.dialogButtons(dialog, actions=None, default=None)

Create a set of dialog buttons

dia is a dialog widget

actions is a list of tuples (name,) or (name,function). If a function is specified, it will be executed on pressing the button. If no function is specified, and name is one of ‘ok’ or ‘cancel’ (case is ignored), the button will be bound to the dialog’s ‘accept’ or ‘reject’ slot. If actions==None (default), it will be set to the default [('Cancel',),('OK',)].

Specify actions=[] if you want an empty dialogDuttons. default is the name of the action to set as the default. If no default is given, it is set to the LAST button.

Returns a horizontal box layout with the buttons.

Documentation

Previous topic

12. elements — Element local coordinates and numbering.

Next topic

14. menu — Menus for the pyFormex GUI.

This Page