fields module¶
-
class
campos.fields.BoolField(*args, **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to ask for yes or no input
-
class
campos.fields.DateField(*args, format='dd/MM/yyyy', min=datetime.date(2016, 12, 7), max=datetime.date(9999, 12, 31), **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to introduce
datetime.datevalues.Parameters: - format (
str) – Qt’s format string used to show the current value and to convert values assigned to min , max and value . Defaults to ‘dd/MM/yyyy’ - min (
datetime.dateorstr) – minimum admitted date, defaults todatetime.date.today() - max (
datetime.dateorstr) – maximum admitted date, defaults todatetime.date.max
Note
if the values passed to min , max or value are strings then a date object is parsed using the current format
-
format¶ Qt’s date format string used to show the date in the widget and to parse string values assigned to min, max and value.
Type: str
-
max¶ Maximum admitted date.
Type: datetime.dateor date stringNote
if the value passed to max is a string then a date is parsed using current format
-
min¶ Minimum admitted date.
Type: datetime.dateor date stringNote
if the value passed to min is a string then a date is parsed using current format
- format (
-
class
campos.fields.DatetimeField(*args, format='dd/MM/yyyy HH:mm:ss', min=datetime.datetime(1, 1, 1, 0, 0), max=datetime.datetime(9999, 12, 31, 23, 59, 59, 999999), **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to introduce
datetime.datetimevalues.Parameters: - format (
str) – Qt’s format string used to show current value and to convert values assigned to min , max and value . Defaults to ‘dd/MM/yyyy HH:mm:ss’ - min (
datetime.datetimeorstr) – minimum admitted datetime, defaults todatetime.datetime.min - max (
datetime.datetimeorstr) – maximum admitted datetime, defaults todatetime.datetime.max
Note
if the values passed to min , max or value are strings then a datetime object is parsed using current format
-
format¶ Qt’s format string used to show current value and to convert values assigned to min , max and value .
Type: str
-
max¶ Maximum admitted datetime.
Type: datetime.datetimeor datetime stringNote
if the value passed to max is a string then a datetime is parsed using current format
-
min¶ Minimum admitted datetime.
Type: datetime.datetimeor datetime stringNote
if the value passed to min is a string then a datetime is parsed using current format
- format (
-
class
campos.fields.DirField(*args, chooser_title='Choose a directory', button_text='Browse', **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to input a directory path.
Dir path can be entered manually.
Parameters: - chooser_title (
str) – text to show in the directory chooser - button_text (
str) – text to show in the directory chooser invoker button
See also
FileInputText to show in the directory chooser invoker button.
Type: str
-
chooser_title¶ Text to show in the directory chooser.
Type: str
- chooser_title (
-
class
campos.fields.FileField(*args, multi_select=False, chooser_title='Choose a file', button_text='Browse', **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to input file(s).
File paths can be entered manually and are separated by
PATH_SEP. The value of this field is always a list of paths, independently of the value of multi_selectParameters: - multi_select (
bool) – whether to allow or not selection of several files - chooser_title (
str) – text to show in the file chooser - button_text (
str) – text to show in the file chooser invoker button
See also
-
add_filter(name, patterns)[source]¶ Adds a named filter to this field. Filters do not apply to manually entered paths.
For instance, if you want to show the following filters:
Image files (*.png *.jpg) Text files (*.txt) Any files (*)
You can add them like this:
fi = FileField() fi.add_filter('Image files', ['*.png', '*.jpg']) fi.add_filter('Text files', ['*.txt']) fi.add_filter('Any files', ['*'])
Parameters: - name (
str) – a string identifying the filter - patterns (iterable of strings) – a collection of Qt’s filename-wildcard patterns
- name (
Text to show in the file chooser invoker button.
Type: str
-
chooser_title¶ Text to show in the file chooser.
Type: str
-
multi_select¶ Whether to allow or not selection of several files.
Type: bool
- multi_select (
-
class
campos.fields.FloatField(*args, precision=2, **kwargs)[source]¶ Bases:
campos.fields.IntFieldField to introduce
floatvaluesParameters: precision – decimal places, defaults to 2 -
precision¶ Decimal places.
Type: int
-
-
class
campos.fields.IntField(*args, min=0, max=100, step=1, **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to introduce
intvaluesParameters: - min (
int) – minimum admitted value, defaults to 0 - max – maximum admitted value, defaults to 100
- step – amount to increase or decrease current value by, defaults to 1
-
max¶ Maximum admitted value.
Type: int
-
min¶ Minimum admitted value.
Type: int
-
step¶ Amount to increase or decrease current value by.
Type: int
- min (
-
class
campos.fields.SelectField(*args, choices=(), blank=False, blank_text='', get_text=None, get_value=None, **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to select an option among several ones.
The value of this field is a
tuplewith the text of the selected option at index 0 and its value at index 1.choices argument can be an iterable or a callable that yields an iterable and its members can adopt several shapes:
- If is an string then that’s the option’s text and value.
- If is a subscriptable object then the text is expected at index 0 and value at index 1 defaulting to index 0 if is not reachable.
- If is other kind of object then the text is it
str()result and value is the object itself.
Note
previous rules only apply for option’s text or value if get_text or get_value aren’t defined:
Parameters: - choices (iterable or callable) – options to show
- blank (
bool) – whether to show or not an option meaning no selection. - blank_text (
str) – text to show in the meaningless option(value is equal to text too) - get_text (callable or
str) – used to obtain option’s text, can be a callable to invoke using each choices member as first argument or a string indicating the name of the attribute to read from them. - get_value – used to obtain option’s value, can be a callable to invoke using each choices member as first argument or a string indicating the name of the attribute to read from them.
-
add_choice(text, value)[source]¶ Adds a new choice to the options list.
Parameters: - text (
str) – text of the new option - value (any) – value of the new option
- text (
-
value¶ The selected option.
Note
To change the current selection you can pass only the new option’s text or a tuple like
(option's text, option's value).Returns: a tuplelike(option's text, option's value)Return type: tuple
-
class
campos.fields.StringField(*args, min_length=0, max_length=100, **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to introduce
strParameters: - min_length (
int) – minimum admitted length, defaults to 0 - max_length (
int) – maximum admitted length, defaults to 100
-
max_length¶ Maximum admitted length.
Type: int
-
min_length¶ Minimum admitted length.
Type: int
- min_length (
-
class
campos.fields.TextField(*args, **kwargs)[source]¶ Bases:
campos.fields.StringFieldField to introduce large strings
-
max_length¶ Maximum admitted length.
Type: int
-
-
class
campos.fields.TimeField(*args, format='HH:mm:ss', min=datetime.time(0, 0), max=datetime.time(23, 59, 59, 999999), **kwargs)[source]¶ Bases:
campos.core.BaseFieldField to introduce
datetime.timevalues.Parameters: - format (
str) – Qt’s format string used to show the current value and to convert values assigned to min , max and value . Defaults to ‘HH:mm:ss’ - min (
datetime.timeorstr) – minimum admitted time, defaults todatetime.time.min - max (
datetime.timeorstr) – maximum admitted time, defaults todatetime.time.max
Note
if the values passed to min , max or value are strings then a time object is parsed using the current format
-
format¶ Qt’s time format string used to show the time in the widget and to parse string values assigned to min, max and value.
Type: str
-
max¶ Maximum admitted time.
Type: datetime.timeor time stringNote
if the value passed to max is a string then a time is parsed using the current format
-
min¶ Minimum admitted time.
Type: datetime.timeor time stringNote
if the value passed to min is a string then a time is parsed using the current format
- format (