Reference

formlayout

Module creating Qt form dialogs/layouts to edit various type of parameters

formlayout License Agreement (MIT License)

Copyright (c) 2009-2015 Pierre Raybaut

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

formlayout.u(obj)[source]

Return string as it is

formlayout.is_text_string(obj)[source]

Return True if obj is a text string, False if it is anything else, like binary data (Python 3) or QString (Python 2, PyQt API #1)

formlayout.is_binary_string(obj)[source]

Return True if obj is a binary string, False if it is anything else

formlayout.is_string(obj)[source]

Return True if obj is a text or binary Python string object, False if it is anything else, like a QString (Python 2, PyQt API #1)

formlayout.to_text_string(obj, encoding=None)[source]

Convert obj to (unicode) text string

class formlayout.ColorButton(parent=None)[source]

Color choosing push button

formlayout.text_to_qcolor(text)[source]

Create a QColor from specified string Avoid warning from Qt when an invalid QColor is instantiated

class formlayout.ColorLayout(color, parent=None)[source]

Color-specialized QLineEdit layout

class formlayout.FileLayout(value, parent=None)[source]

File-specialized QLineEdit layout

class formlayout.SliderLayout(value, parent=None)[source]

QSlider with QLabel

update(self)[source]
class formlayout.RadioLayout(buttons, index, parent=None)[source]

Radio buttons layout with QButtonGroup

class formlayout.CheckLayout(boxes, checks, parent=None)[source]

Check boxes layout with QButtonGroup

class formlayout.PushLayout(buttons, parent=None)[source]

Push buttons horizontal layout

class formlayout.CountLayout(field, parent=None)[source]

Field with a QSpinBox

formlayout.font_is_installed(font)[source]

Check if font is installed

formlayout.tuple_to_qfont(tup)[source]
Create a QFont from tuple:
(family [string], size [int], italic [bool], bold [bool])
class formlayout.FontLayout(value, parent=None)[source]

Font selection

class formlayout.FormWidget(data, comment='', parent=None)[source]
get_dialog()[source]

Return FormDialog instance

class formlayout.FormComboWidget(datalist, comment='', parent=None)[source]
class formlayout.FormTabWidget(datalist, comment='', parent=None)[source]
class formlayout.FormDialog(data, title='', comment='', icon=None, parent=None, apply=None, ok=None, cancel=None, result=None, outfile=None, type=None, scrollbar=None, background_color=None, widget_color=None)[source]

Form Dialog

accept(self)[source]
reject(self)[source]
get()[source]

Return form result

formlayout.fedit(data, title='', comment='', icon=None, parent=None, apply=None, ok=True, cancel=True, result='list', outfile=None, type='form', scrollbar=False, background_color=None, widget_color=None)[source]

Create form dialog and return result (if Cancel button is pressed, return None)

Parameters:
  • data (tuple) – datalist, datagroup (see below)
  • title (str) – form title
  • comment (str) – header comment
  • icon (QIcon) – dialog box icon
  • parent (QWidget) – parent widget
  • ok (str) – customized ok button label
  • cancel (str) – customized cancel button label
  • apply (function) – (label, function) customized button label and callback
  • apply – function taking two arguments (result, widgets)
  • result (str) – result serialization (‘list’, ‘dict’, ‘OrderedDict’, ‘JSON’ or ‘XML’)
  • outfile (str) – write result to the file outfile.[py|json|xml]
  • type (str) – layout type (‘form’ or ‘questions’)
  • scrollbar (bool) – vertical scrollbar
  • background_color (str) – color of the background
  • widget_color (str) – color of the widgets
Returns:

Serialized result (data type depends on result parameter)

datalist: list/tuple of (field_name, field_value) datagroup: list/tuple of (datalist or datagroup, title, comment)

Tips:
  • one field for each member of a datalist
  • one tab for each member of a top-level datagroup
  • one page (of a multipage widget, each page can be selected with a combo box) for each member of a datagroup inside a datagroup
Supported types for field_value:
  • int, float, str, unicode, bool
  • colors: in Qt-compatible text form, i.e. in hex format or name (red,…)
    (automatically detected from a string)
  • list/tuple:
    • the first element will be the selected index (or value)
    • the other elements can be couples (key, value) or only values