filebrowsectrl
Classes:
|
|
|
A control to allow the user to type in a filename or browse with the standard file dialog to select file. |
|
with following additions: |
-
class
DirBrowseCtrl
(parent, id=- 1, pos=(- 1, - 1), size=(- 1, - 1), style=537401408, labelText='Select a directory:', buttonText='Browse', toolTip='Type directory name or browse to select', dialogTitle='', initialValue=None, changeCallback=None, name='DirBrowseCtrl')[source] Bases:
FileBrowseCtrl
Methods:
OnBrowse
([ev])Going to browse for file…
Attributes:
-
class
FileBrowseCtrl
(parent, id=-1, pos=(-1, -1), size=(-1, -1), style=524289, labelText='File Entry:', buttonText='Browse', toolTip='Type a filename or click the browse button to choose a file', dialogTitle='Choose a file', initialValue='', changeCallback=<function '<lambda>'>, labelWidth=0, name='fileBrowseButton', show_cancel_btn=True, fileMask='All files (*.*)|*.*', dialog_title='File Picker', **kwargs)[source] Bases:
TextCtrlWrapper
,FileBrowseButton
A control to allow the user to type in a filename or browse with the standard file dialog to select file.
Based on and subclassed from wx.lib.filebrowsebutton.FileBrowseButton but with a wx.SearchCtrl in place of the wx.TextCtrl to provide the cancel/clear button and with an icon on the browse button.
- Parameters
id (
int
) – Control identifier. A value of-1
denotes a default value. Default-1
.pos (
Point
) – Control position. Default(-1, -1)
.size (
Size
) – Control size. Default(-1, -1)
.style (
int
) – Window style. See wx.Window and ClearableTextCtrl for supported styles. Default524289
.labelText (
str
) – Text for label to left of text field. Default'File Entry:'
.buttonText (
str
) – Text for button which launches the file dialog. Default'Browse'
.toolTip (
str
) – Help text. Default'Type a filename or click the browse button to choose a file'
.dialogTitle (
str
) – Title used in file dialog. Default'Choose a file'
.initialValue (
str
) – The initial value of the TextCtrl. Default''
.changeCallback – Optional callback called for all changes in value of the control. Default
domdf_wxpython_tools.filebrowsectrl.
.labelWidth – Width of the label. Default
0
.name – Default
'fileBrowseButton'
.show_cancel_btn (
bool
) – Whether to show or hide the cancel button. DefaultTrue
.dialog_title (
str
) – The title of the FileDialog. Default'File Picker'
.fileMask (
str
) – File mask (glob pattern, such as *.*) to use in file dialog. See wx.FileDialog for more information. Default'All files (*.*)|*.*'
.
Methods:
ChangeValue
(value)Sets the new text control value.
GetLabel
()Retrieve the label’s current text.
GetLineLength
(lineNo)Gets the length of the specified line, not including any trailing newline character(s).
GetLineText
(lineNo)Returns the contents of a given line in the text control, not including any trailing newline character(s).
Returns the number of lines in the text control buffer.
GetRange
(from_, to_)Returns the string containing the text starting in the positions from and up to in the control.
Returns
True
if the controls contents may be edited by user (note that it always can be changed by the program).Returns
True
if the text has been modified by user.Returns
True
if this is a multi line edit control andFalse
otherwise.Returns
True
if this is a single line edit control andFalse
otherwise.Mark text as modified (dirty).
OnBrowse
([event])Going to browse for file…
SetLabel
(value)Set the label’s current text.
SetModified
(modified)Marks the control as being modified by the user or not.
SetValue
(value[, callBack])Sets the new text control value.
Create the browse-button control.
Create the text control.
Attributes:
-
ChangeValue
(value)[source] Sets the new text control value.
It also marks the control as not-modified which means that IsModified() would return
False
immediately after the call to ChangeValue .The insertion point is set to the start of the control (i.e. position 0) by this function.
This functions does not generate the wxEVT_TEXT event but otherwise is identical to SetValue .
- Parameters
value (
str
) – The new value to set. It may contain newline characters if the text control is multi-line.
-
GetLineLength
(lineNo)[source] Gets the length of the specified line, not including any trailing newline character(s).
-
GetLineText
(lineNo)[source] Returns the contents of a given line in the text control, not including any trailing newline character(s).
-
GetNumberOfLines
()[source] Returns the number of lines in the text control buffer.
- Returns
- Return type
-
GetRange
(from_, to_)[source] Returns the string containing the text starting in the positions from and up to in the control.
The positions must have been returned by another wx.TextCtrl method.
-
IsEditable
()[source] Returns
True
if the controls contents may be edited by user (note that it always can be changed by the program).In other words, this functions returns
True
if the control hasn’t been put in read-only mode by a previous call to SetEditable .- Return type
-
IsModified
()[source] Returns
True
if the text has been modified by user.Note that calling SetValue doesn’t make the control modified.
- Returns
- Return type
-
IsMultiLine
()[source] Returns
True
if this is a multi line edit control andFalse
otherwise.- Returns
- Return type
-
IsSingleLine
()[source] Returns
True
if this is a single line edit control andFalse
otherwise.- Returns
- Return type
-
SetModified
(modified)[source] Marks the control as being modified by the user or not.
- Parameters
modified (
bool
)
-
SetValue
(value, callBack=1)[source] Sets the new text control value.
It also marks the control as not-modified which means that IsModified() would return
False
immediately after the call to SetValue .The insertion point is set to the start of the control (i.e. position 0) by this function unless the control value doesn’t change at all, in which case the insertion point is left at its original position.
Note that, unlike most other functions changing the controls values, this function generates a wxEVT_TEXT event. To avoid this you can use ChangeValue instead.
Parameters: value (string) – The new value to set. It may contain newline characters if the text control is multi-line.
-
class
FileBrowseCtrlWithHistory
(*arguments, **namedarguments)[source] Bases:
FileBrowseCtrl
- with following additions:
__init__(…, history=None)
- history – optional list of paths for initial history drop-down
(must be passed by name, not a positional argument) If history is callable it will must return a list used for the history drop-down
- changeCallback – as for FileBrowseCtrl, but with a work-around
for win32 systems which don’t appear to create wx.EVT_COMBOBOX events properly. There is a (slight) chance that this work-around will cause some systems to create two events for each Combobox selection. If you discover this condition, please report it!
As for a FileBrowseCtrl.__init__ otherwise.
- GetHistoryControl()
Return reference to the control which implements interfaces required for manipulating the history list. See GetHistoryControl documentation for description of what that interface is.
- GetHistory()
Return current history list
- SetHistory( value=(), selectionIndex = None )
Set current history list, if selectionIndex is not
None
, select that index
Methods:
Return the current history list
Return a pointer to the control which provides (at least) the following methods for manipulating the history list:
OnSetFocus
(event)When the history scroll is selected, update the history
SetHistory
([value, selectionIndex, control])Set the current history list
Create the text control.
Attributes:
-
GetHistoryControl
()[source] Return a pointer to the control which provides (at least) the following methods for manipulating the history list:
Append( item ) – add item Clear() – clear all items Delete( index ) – 0-based index to delete from list SetSelection( index ) – 0-based index to select in list
Semantics of the methods follow those for the wxComboBox control