fsleyes_widgets.dialog¶
This module contains a collection of basic dialog classes, available for
use throughout fslpy. The available dialogs are:
SimpleMessageDialog |
A simple, no-frills wx.Dialog for displaying a message. |
TimeoutDialog |
A SimpleMessageDialog which automatically destroys itself after a specified timeout period. |
ProcessingDialog |
A SimpleMessageDialog which displays a message and runs a task in the background. |
TextEditDialog |
A dialog which shows an editable/selectable text field. |
FSLDirDialog |
A dialog which warns the user that the $FSLDIR environment variable is not set, and prompts them to identify the FSL installation directory. |
-
class
fsleyes_widgets.dialog.SimpleMessageDialog(parent=None, message='', style=None)¶ Bases:
wx._core.DialogA simple, no-frills
wx.Dialogfor displaying a message. The message can be updated via theSetMessage()method. As a simple usage example:import fsleyes_widgets.dialog as fsldlg dlg = fsldlg.SimpleMessageDialog(message='Loading data ...') dlg.Show() # load the data, like # you said you would # Data is loaded, so we # can kill the dialog dlg.Close() dlg.Destroy()
The
SimpleMessageDialogclass supports the following styles:SMD_KEEP_CENTEREDIf set, the dialog will be re-centred on its parent whenever its message changes. a
SimpleMessageDialoglooks something like this:
Create a
SimpleMessageDialog.Parameters: - parent – The
wxparent object. - message – The initial message to show.
- style – Only one style flag is supported,
SMD_KEEP_CENTERED. This flag is enabled by default.
-
__init__(parent=None, message='', style=None)¶ Create a
SimpleMessageDialog.Parameters: - parent – The
wxparent object. - message – The initial message to show.
- style – Only one style flag is supported,
SMD_KEEP_CENTERED. This flag is enabled by default.
- parent – The
-
Show()¶ Overrides
wx.Dialog.Show. Calls that method, and callswx.Yield.
-
SetMessage(msg)¶ Updates the message shown on this
SimpleMessageDialog.If the
SMD_KEEP_CENTEREDstyle is set, the dialog is re-centered on its parent, to account for changes in the message width.
-
__module__= 'fsleyes_widgets.dialog'¶
- parent – The
-
fsleyes_widgets.dialog.SMD_KEEP_CENTERED= 1¶ If set, the dialog will be re-centred on its parent whenever its message changes.
-
class
fsleyes_widgets.dialog.TimeoutDialog(parent, message, timeout=1000, **kwargs)¶ Bases:
fsleyes_widgets.dialog.SimpleMessageDialogA
SimpleMessageDialogwhich automatically destroys itself after a specified timeout period.Note
The timeout functionality will not work if you show the dialog by any means other than the
wx.Dialog.Show()orwx.Dialog.ShowModal()methods … but is there any other way of showing awx.Dialog?Create a
TimeoutDialog.Parameters: - parent – The
wxparent object. - message – The initial message to display.
- timeout – Timeout period in milliseconds.
- kwargs – Passed through to
SimpleMessageDialog.__init__().
-
__init__(parent, message, timeout=1000, **kwargs)¶ Create a
TimeoutDialog.Parameters: - parent – The
wxparent object. - message – The initial message to display.
- timeout – Timeout period in milliseconds.
- kwargs – Passed through to
SimpleMessageDialog.__init__().
- parent – The
-
Show()¶ Shows this
TimeoutDialog, and sets up a callback to close it after the specifiedtimeout.
-
ShowModal()¶ Shows this
TimeoutDialog, and sets up a callback to close it after the specifiedtimeout.
-
_TimeoutDialog__close()¶ Closes and destroys this
TimeoutDialog.
-
__module__= 'fsleyes_widgets.dialog'¶
- parent – The
-
class
fsleyes_widgets.dialog.ProcessingDialog(parent, message, task, *args, **kwargs)¶ Bases:
fsleyes_widgets.dialog.SimpleMessageDialogA
SimpleMessageDialogwhich displays a message and runs a task in the background. User interaction is blocked while the task runs, and the dialog closes and destroys itself automatically on task completion.The task is simply passed in as a function. If the task supports it, the
ProcessingDialogwill pass it two message-updating functions, which can be used by the task to update the message being displayed. This functionality is controlled by thepassFuncs,messageFuncanderrorFuncparameters to__init__().A
ProcessingDialogmust be displayed via theRun()method, not with thewx.Dialog.Show()orwx.Dialog.ShowModal()methods.Create a
ProcessingDialog.Parameters: - parent – The
wxparent object. - message – Initial message to display.
- task – The function to run.
- args – Positional arguments passed to the
taskfunction. - kwargs – Keyword arguments passed to the
taskfunction.
Some special keyword arguments are also accepted:
Name Description passFuncsIf
True, two extra keyword arguments are passed to thetaskfunction -messageFuncanderrorFunc.messageFuncis a function which accepts a single string as its argument; when it is called, the dialog message is updated to display the string.errorFuncis a function which accepts two arguemnts - a message string and anExceptioninstance. If the task detects an error, it may call this function. A new dialog is shown, containing the details of the error, to inform the user.messageFuncOverrides the default messageFuncdescribed above.errorFuncOverrides the default errorFuncdescribed above.-
__init__(parent, message, task, *args, **kwargs)¶ Create a
ProcessingDialog.Parameters: - parent – The
wxparent object. - message – Initial message to display.
- task – The function to run.
- args – Positional arguments passed to the
taskfunction. - kwargs – Keyword arguments passed to the
taskfunction.
Some special keyword arguments are also accepted:
Name Description passFuncsIf
True, two extra keyword arguments are passed to thetaskfunction -messageFuncanderrorFunc.messageFuncis a function which accepts a single string as its argument; when it is called, the dialog message is updated to display the string.errorFuncis a function which accepts two arguemnts - a message string and anExceptioninstance. If the task detects an error, it may call this function. A new dialog is shown, containing the details of the error, to inform the user.messageFuncOverrides the default messageFuncdescribed above.errorFuncOverrides the default errorFuncdescribed above.- parent – The
-
Run(mainThread=False)¶ Shows this
ProcessingDialog, and runs thetaskfunction passed to__init__(). When the task completes, this dialog is closed and destroyed.Parameters: mainThread – If Truethe task is run in the current thread. Otherwise, the default behaviour is to run the task in a separate thread.Returns: the return value of the taskfunction.Note
If
mainThread=True, the task should callwx.Yield()periodically - under GTK, there is a chance that thisProcessingDialogwill not get drawn before the task begins.
-
Show()¶ Raises a
NotImplementedError.
-
ShowModal()¶ Raises a
NotImplementedError.
-
_ProcessingDialog__defaultErrorFunc(msg, err)¶ Default
errorFunc. Opens a new dialog (awx.MessageBox) which contains a description of the error.
-
_ProcessingDialog__defaultMessageFunc(msg)¶ Default
messageFunc. Updates the message which is displayed on thisProcessingDialog. SeeSetMessage().
-
__module__= 'fsleyes_widgets.dialog'¶
- parent – The
-
class
fsleyes_widgets.dialog.TextEditDialog(parent, title='', message='', text='', icon=None, style=None)¶ Bases:
wx._core.DialogA dialog which shows an editable/selectable text field.
TextEditDialogsupports the following styles:TED_READONLYIf set, the user will not be able to change the text field contents. TED_MULTILINEIf set, the text field will span multiple lines. TED_OKIf set, an Ok button will be shown. TED_CANCELIf set, a Cancel button will be shown. TED_OK_CANCELIf set, Ok and Cancel buttons will be shown. TED_COPYIf set, a Copy button will be shown, allowing the use to copy the text to the system clipboard. TED_COPY_MESSAGEIf set, and if TED_COPYis also set, when the user chooses to copy the text to the system clipboard, a popup message is displayed.A
TextEditDialoglooks something like this:
Create a
TextEditDialog.Parameters: - parent – The
wxparent object. - title – Dialog title.
- message – Dialog message.
- text – String to display in the text field.
- icon – A
wxicon identifier, such aswx.ICON_INFORMATIONorwx.ICON_WARNING. - style – A combination of
TED_READONLY,TED_MULTILINE,TED_OK,TED_CANCEL,TED_OK_CANCEL,TED_COPYandTED_COPY_MESSAGE. Defaults toTED_OK.
-
__init__(parent, title='', message='', text='', icon=None, style=None)¶ Create a
TextEditDialog.Parameters: - parent – The
wxparent object. - title – Dialog title.
- message – Dialog message.
- text – String to display in the text field.
- icon – A
wxicon identifier, such aswx.ICON_INFORMATIONorwx.ICON_WARNING. - style – A combination of
TED_READONLY,TED_MULTILINE,TED_OK,TED_CANCEL,TED_OK_CANCEL,TED_COPYandTED_COPY_MESSAGE. Defaults toTED_OK.
- parent – The
-
onOk(ev)¶ Called when the Ok button is pressed. Ends the dialog.
-
onCancel(ev)¶ Called when the Cancel button is pressed. Ends the dialog.
-
SetMessage(message)¶ Set the message displayed on the dialog.
-
SetOkLabel(label)¶ Set the label to show on the Ok button.
-
SetCopyLabel(label)¶ Sets the label to show on the Copy button.
-
SetCancelLabel(label)¶ Sets the label to show on the Cancel button.
-
SetText(text)¶ Sets the text to show in the text field.
-
GetText()¶ Returns the text shown in the text field.
-
_TextEditDialog__onCharHook(ev)¶ Called on
EVT_CHAR_HOOKevents generated by theTextCtrl. Implements tab-navigation, and makes the enter key behave as if the user had clicked the OK button.
-
_TextEditDialog__onCopy(ev)¶ Called when the Copy button is pressed. Copies the text to the system clipboard, and pops up a
TimeoutDialoginforming the user.
-
__module__= 'fsleyes_widgets.dialog'¶
- parent – The
-
fsleyes_widgets.dialog.TED_READONLY= 1¶ If set, the user will not be able to change the text field contents.
-
fsleyes_widgets.dialog.TED_MULTILINE= 2¶ If set, the text field will span multiple lines.
-
fsleyes_widgets.dialog.TED_OK= 4¶ If set, an Ok button will be shown.
-
fsleyes_widgets.dialog.TED_CANCEL= 8¶ If set, a Cancel button will be shown.
-
fsleyes_widgets.dialog.TED_OK_CANCEL= 12¶ If set, Ok and Cancel buttons will be shown. Equivalent to
TED_OK | TED_CANCEL.
-
fsleyes_widgets.dialog.TED_COPY= 16¶ If set, a Copy button will be shown, allowing the use to copy the text to the system clipboard.
-
fsleyes_widgets.dialog.TED_COPY_MESSAGE= 32¶ If set, and if
TED_COPYis also set, when the user chooses to copy the text to the system clipboard, a popup message is displayed.
-
class
fsleyes_widgets.dialog.FSLDirDialog(parent, toolName, osxHint)¶ Bases:
wx._core.DialogA dialog which warns the user that the
$FSLDIRenvironment variable is not set, and prompts them to identify the FSL installation directory.If the user selects a directory, the
getFSLDir()method can be called to retrieve their selection after the dialog has been closed.A
FSLDirDialoglooks something like this:
Create a
FSLDirDialog.Parameters: - parent – The
wxparent object. - toolName – The name of the tool which is running.
- osxHint – If
True, an OSX-specific hint is added to the dialog.
-
__init__(parent, toolName, osxHint)¶ Create a
FSLDirDialog.Parameters: - parent – The
wxparent object. - toolName – The name of the tool which is running.
- osxHint – If
True, an OSX-specific hint is added to the dialog.
- parent – The
-
GetFSLDir()¶ If the user selected a directory, this method returns their selection. Otherwise, it returns
None.
-
_FSLDirDialog__onLocate(ev)¶ Called when the Locate button is pushed. Opens a
wx.DirDialogwhich allows the user to locate the FSL installation directory.
-
_FSLDirDialog__onSkip(ev)¶ called when the Skip button is pushed.
-
__module__= 'fsleyes_widgets.dialog'¶
- parent – The
-
class
fsleyes_widgets.dialog.CheckBoxMessageDialog(parent, title=None, message=None, cbMessages=None, cbStates=None, yesText=None, noText=None, cancelText=None, hintText=None, focus=None, icon=None, style=None)¶ Bases:
wx._core.DialogA
wx.Dialogwhich displays a message, one or morewx.CheckBoxwidgets, with associated messages, an Ok button, and (optionally) a Cancel button.Create a
CheckBoxMessageDialog.Parameters: - parent – A
wxparent object. - title – The dialog frame title.
- message – Message to show on the dialog.
- cbMessages – A list of labels, one for each
wx.CheckBox. - cbStates – A list of initial states (boolean values) for
each
wx.CheckBox. - yesText – Text to show on the yes/confirm button. Defaults to OK.
- noText – Text to show on the no button. If not provided, there will be no no button.
- cancelText – Text to show on the cancel button. If not provided, there will be no cancel button.
- hintText – If provided, shown as a “hint”, in a slightly faded font, between the checkboxes and the buttons.
- focus – One of
'yes','no'`, or'cancel', specifying which button should be given initial focus. - icon – A
wxicon identifier (e.g.wx.ICON_EXCLAMATION). - style – Passed through to the
wx.Dialog.__init__method. Defaults towx.DEFAULT_DIALOG_STYLE.
-
__init__(parent, title=None, message=None, cbMessages=None, cbStates=None, yesText=None, noText=None, cancelText=None, hintText=None, focus=None, icon=None, style=None)¶ Create a
CheckBoxMessageDialog.Parameters: - parent – A
wxparent object. - title – The dialog frame title.
- message – Message to show on the dialog.
- cbMessages – A list of labels, one for each
wx.CheckBox. - cbStates – A list of initial states (boolean values) for
each
wx.CheckBox. - yesText – Text to show on the yes/confirm button. Defaults to OK.
- noText – Text to show on the no button. If not provided, there will be no no button.
- cancelText – Text to show on the cancel button. If not provided, there will be no cancel button.
- hintText – If provided, shown as a “hint”, in a slightly faded font, between the checkboxes and the buttons.
- focus – One of
'yes','no'`, or'cancel', specifying which button should be given initial focus. - icon – A
wxicon identifier (e.g.wx.ICON_EXCLAMATION). - style – Passed through to the
wx.Dialog.__init__method. Defaults towx.DEFAULT_DIALOG_STYLE.
- parent – A
-
_CheckBoxMessageDialog__onCancelButton(ev)¶ If the
CHECKBOX_MSGDLG_CANCEL_BUTTONstyle was set, this method is called when the cancel button is clicked. Closes the dialog.
-
_CheckBoxMessageDialog__onNoButton(ev)¶ Called when the button on this
CheckBoxMessageDialogis clicked. Closes the dialog.
-
_CheckBoxMessageDialog__onYesButton(ev)¶ Called when the button on this
CheckBoxMessageDialogis clicked. Closes the dialog.
-
__module__= 'fsleyes_widgets.dialog'¶
-
CheckBoxState(index=0)¶ After this
CheckBoxMessageDialoghas been closed, this method will retrieve the state of the dialogCheckBox.
- parent – A