dialogs

Several dialog classes and helper functions for file/folder dialogs

Classes:

FloatEntryDialog(*args, **kwargs)

Alternative to wx.NumberEntryDialog that provides a TextCtrl which only allows numbers and decimal points to be entered.

IntEntryDialog(*args, **kwargs)

Alternative to wx.NumberEntryDialog that provides a TextCtrl which only allows numbers to be entered.

Wildcards()

Class to generate glob wildcards for wx.FileDialog

Functions:

file_dialog(*args, **kwargs)

Create a wx.FileDialog with for the extension and filetypestring given, and return the filename selected.

file_dialog_multiple(parent, extension, …)

Create a wx.FileDialog with the extension and filetypestring given, and return a list of the files selected.

file_dialog_wildcard(parent, title, wildcard)

Create a wx.FileDialog with the wildcard string given, and return a list of the files selected.

class FloatEntryDialog(*args, **kwargs)[source]

Bases: TextEntryDialog

Alternative to wx.NumberEntryDialog that provides a TextCtrl which only allows numbers and decimal points to be entered.

Based on http://wxpython-users.1045709.n5.nabble.com/Adding-Validation-to-wx-TextEntryDialog-td2371082.html

Methods:

GetValue()

GetValue()[source]
class IntEntryDialog(*args, **kwargs)[source]

Bases: TextEntryDialog

Alternative to wx.NumberEntryDialog that provides a TextCtrl which only allows numbers to be entered.

Based on http://wxpython-users.1045709.n5.nabble.com/Adding-Validation-to-wx-TextEntryDialog-td2371082.html

Methods:

GetValue()

GetValue()[source]
class Wildcards[source]

Bases: object

Class to generate glob wildcards for wx.FileDialog

Methods:

__repr__()

Return repr(self).

__str__()

Return str(self).

add_all_files_wildcard([hint_format])

Add a wildcard for ‘All Files’.

add_common_filetype(filetype[, hint_format, …])

Add a common filetype.

add_filetype(description[, extensions, …])

Add a filetype to the wildcards

add_image_wildcard([value_format])

Add a wildcard for all image filetypes.

Attributes:

wildcard

Returns a string representing the wildcards for use in wx.FileDialog or file_dialog_wildcards

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

add_all_files_wildcard(hint_format=0)[source]

Add a wildcard for ‘All Files’.

Parameters

hint_format (int) – How the hints should be formatted. Valid values are None and style_hidden. Default 0.

add_common_filetype(filetype, hint_format=8, value_format=12)[source]

Add a common filetype.

Parameters
  • filetype (str) – The name of the filetype, Possible values are in common_filetypes

  • hint_format (int) – How the hints should be formatted. Default 8.

  • value_format (int) – How the values should be formatted. Default 12.

Valid values for hint_format and value_format are style_uppercase, style_lowercase and style_hidden, which can be combined using the | operator.

add_filetype(description, extensions=None, hint_format=8, value_format=12)[source]

Add a filetype to the wildcards

Parameters
  • description (str) – Description of the filetype

  • extensions (Optional[Sequence[str]]) – A list of valid file extensions for the filetype. Default None.

  • hint_format (int) – How the hints should be formatted. Default 8.

  • value_format (int) – How the values should be formatted. Default 12.

Valid values for hint_format and value_format are style_uppercase, style_lowercase and style_hidden, which can be combined using the | operator.

add_image_wildcard(value_format=12)[source]

Add a wildcard for all image filetypes.

Parameters

value_format (int) – How the values should be formatted. Default 12.

Valid values for value_format are style_uppercase, style_lowercase and style_hidden, which can be combined using the | operator.

property wildcard

Returns a string representing the wildcards for use in wx.FileDialog or file_dialog_wildcards

Return type

str

file_dialog(*args, **kwargs)[source]

Create a wx.FileDialog with for the extension and filetypestring given, and return the filename selected.

Parameters
  • parent

  • extension

  • title

  • filetypestring

  • style

  • **kwargs

Return type

Optional[str]

Returns

The filename selected in the dialog. If wx.FD_MULTIPLE is in the style, this will be the first filename selected.

file_dialog_multiple(parent, extension, title, filetypestring, style=6, **kwargs)[source]

Create a wx.FileDialog with the extension and filetypestring given, and return a list of the files selected.

Parameters
  • parent (Window) – Parent window. Should not be None.

  • extension (str)

  • title (str)

  • filetypestring (str)

  • style – Default 6.

  • **kwargs

Return type

Optional[List[str]]

Returns

List of filenames for the selected files. If wx.FD_MULTIPLE is not in the style, the list will contain only one element.

file_dialog_wildcard(parent, title, wildcard, style=6, **kwargs)[source]

Create a wx.FileDialog with the wildcard string given, and return a list of the files selected.

Parameters
  • parent (Window) – Parent window. Should not be None.

  • wildcard (str)

  • title (str)

  • style (int) – Default 6.

  • kwargs

Returns

List of filenames for the selected files. If wx.FD_MULTIPLE is not in the style, the list will contain only one element

Return type

list of str