schrodinger.ui.qt.formlayout module

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.

Additional changes copyright Schrodinger, LLC. All rights reserved.

schrodinger.ui.qt.formlayout.u(obj)

Return string as it is

schrodinger.ui.qt.formlayout.is_text_string(obj)

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

schrodinger.ui.qt.formlayout.is_binary_string(obj)

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

schrodinger.ui.qt.formlayout.is_string(obj)

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)

schrodinger.ui.qt.formlayout.to_text_string(obj, encoding=None)

Convert obj to (unicode) text string

class schrodinger.ui.qt.formlayout.ColorButton(parent=None)

Bases: PyQt6.QtWidgets.QPushButton

Color choosing push button

colorChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(parent=None)
choose_color()
get_color()
set_color(color)
color
pyqtProperty(type, fget=None, fset=None, freset=None, fdel=None, doc=None,

designable=True, scriptable=True, stored=True, user=False, constant=False, final=False, notify=None, revision=0) -> property attribute

type is the type of the property. It is either a type object or a string that is the name of a C++ type. freset is a function for resetting an attribute to its default value. designable sets the DESIGNABLE flag (the default is True for writable properties and False otherwise). scriptable sets the SCRIPTABLE flag. stored sets the STORED flag. user sets the USER flag. constant sets the CONSTANT flag. final sets the FINAL flag. notify is the NOTIFY signal. revision is the REVISION. The other parameters are the same as those required by the standard Python property type. Properties defined using pyqtProperty behave as both Python and Qt properties. Decorators can be used to define new properties or to modify existing ones.

schrodinger.ui.qt.formlayout.text_to_qcolor(text)

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

class schrodinger.ui.qt.formlayout.ColorLayout(color, parent=None)

Bases: PyQt6.QtWidgets.QHBoxLayout

Color-specialized QLineEdit layout

__init__(color, parent=None)
update_color(text)
update_text(color)
text()
setStyleSheet(style)
class schrodinger.ui.qt.formlayout.FileLayout(value, parent=None)

Bases: PyQt6.QtWidgets.QHBoxLayout

File-specialized QLineEdit layout

__init__(value, parent=None)
getfile()
text()
setStyleSheet(style)
class schrodinger.ui.qt.formlayout.SliderLayout(value, parent=None)

Bases: PyQt6.QtWidgets.QHBoxLayout

QSlider with QLabel

__init__(value, parent=None)
update(self)
value()
setStyleSheet(style)
class schrodinger.ui.qt.formlayout.RadioLayout(buttons, index, parent=None)

Bases: PyQt6.QtWidgets.QVBoxLayout

Radio buttons layout with QButtonGroup

__init__(buttons, index, parent=None)
currentIndex()
setStyleSheet(style)
class schrodinger.ui.qt.formlayout.CheckLayout(boxes, checks, parent=None)

Bases: PyQt6.QtWidgets.QVBoxLayout

Check boxes layout with QButtonGroup

__init__(boxes, checks, parent=None)
values()
setStyleSheet(style)
class schrodinger.ui.qt.formlayout.PushLayout(buttons, parent=None)

Bases: PyQt6.QtWidgets.QHBoxLayout

Push buttons horizontal layout

__init__(buttons, parent=None)
call(callback)
apply(callback)
class schrodinger.ui.qt.formlayout.CountLayout(field, parent=None)

Bases: PyQt6.QtWidgets.QHBoxLayout

Field with a QSpinBox

__init__(field, parent=None)
text()
currentIndex()
n()
setStyleSheet(style)
schrodinger.ui.qt.formlayout.font_is_installed(font)

Check if font is installed

schrodinger.ui.qt.formlayout.tuple_to_qfont(tup)
Create a QFont from tuple:

(family [string], size [int], italic [bool], bold [bool])

schrodinger.ui.qt.formlayout.qfont_to_tuple(font)
class schrodinger.ui.qt.formlayout.FontLayout(value, parent=None)

Bases: PyQt6.QtWidgets.QGridLayout

Font selection

__init__(value, parent=None)
get_font()
setStyleSheet(style)
schrodinger.ui.qt.formlayout.is_float_valid(edit)
schrodinger.ui.qt.formlayout.is_required_valid(edit, widget_color)
class schrodinger.ui.qt.formlayout.FormWidget(data, comment='', parent=None)

Bases: PyQt6.QtWidgets.QWidget

__init__(data, comment='', parent=None)
get_dialog()

Return FormDialog instance

setup()
get()
get_widgets()
class schrodinger.ui.qt.formlayout.FormComboWidget(datalist, comment='', parent=None)

Bases: PyQt6.QtWidgets.QWidget

__init__(datalist, comment='', parent=None)
setup()
get()
get_widgets()
class schrodinger.ui.qt.formlayout.FormTabWidget(datalist, comment='', parent=None)

Bases: PyQt6.QtWidgets.QWidget

__init__(datalist, comment='', parent=None)
setup()
get()
get_widgets()
class schrodinger.ui.qt.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)

Bases: PyQt6.QtWidgets.QDialog

Form Dialog

__init__(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)
register_float_field(field)
register_required_field(field)
float_valid()
required_valid()
update_buttons(valid)
accept(self)
reject(self)
apply()
get()

Return form result

schrodinger.ui.qt.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)

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