MeVisLab Scripting Reference
MLABPythonWidgetControl Class Reference
Inheritance diagram for MLABPythonWidgetControl:
MLABSimpleWidgetControl MLABWidgetControl

Public Slots

Scripting method that are useful for creating own Python MDL controls


QVariant object ()
 
QWidget * createChildWidget (MLABTree *tree, QWidget *parent=nullptr)
 
MLABTreefindTree (const QString &name)
 
QString findTreeStringValue (const QString &name, const QString &defaultValue=QString())
 
int findTreeIntValue (const QString &name, int defaultValue=0)
 
double findTreeDoubleValue (const QString &name, double defaultValue=0.)
 
bool findTreeBoolValue (const QString &name, bool defaultValue=false)
 
MLABFieldlookupField (MLABTree *tree)
 
void addFieldListener (MLABField *field, PyObject *callable)
 
MLABPythonWidgetControlCommand * addCommand (MLABTree *tree)
 
QMenu * createMenu (MLABTree *tree, QWidget *owner)
 
- Public Slots inherited from MLABWidgetControl
void adjustSize ()
 
virtual void setEnabled (bool flag)
 
virtual void setVisible (bool flag)
 
virtual bool isVisible ()
 
virtual void setFocus ()
 
virtual bool hasFocus ()
 
virtual void setToolTip (const QString &string)
 
virtual void setWhatsThis (const QString &string)
 
void displayWhatsThis ()
 
void displayWhatsThis (const QString &text)
 
virtual void setTitle (const QString &)
 
QWidget * widget ()
 
QLayout * layout ()
 
virtual QString windowHandle ()
 
virtual bool createScreenshot (const QString &filename, bool grabFromScreen=true, bool scaleToLowRes=false)
 
bool isReloadable () const
 
void reload (MLABTree *tree)
 
QString createGlobalScreenshot ()
 
QString applicationName ()
 
QSize size ()
 
int width ()
 
int height ()
 
int minWidth ()
 
int minHeight ()
 
int maxWidth ()
 
int maxHeight ()
 
virtual void setMinWidth (int s)
 
virtual void setMinHeight (int s)
 
void setMaxWidth (int s)
 
void setMaxHeight (int s)
 
QSize sizeHint ()
 
QSize minSize ()
 
QSize maxSize ()
 
void setMinSize (QSize size)
 
void setMaxSize (QSize size)
 
void updateLayout ()
 
int windowID ()
 
MLABWidgetControlcontrol (const QString &name)
 
float scaleFactor ()
 
MLABModulemodule ()
 
QString getType ()
 
QString getName ()
 
bool acceptDrops ()
 
void setAcceptDrops (bool flag)
 
void raiseWidget ()
 
void setStyleSheetFromString (const QString &styleSheetText)
 
void setStyleSheetFromFile (const QString &styleSheetFileName)
 
MLABTreetree ()
 
void updateMaxSize ()
 
bool expandX ()
 
bool expandY ()
 
MLABTreePtr getDefaultTagValues () const
 
virtual bool hasUncommittedChanges () const
 
virtual void applyUncommittedChanges ()
 
virtual void revertUncommittedChanges ()
 
MLABFieldfield () const
 

Detailed Description

Python widget control.

The python widget control takes ownership if a Python object instance and delegates the C++ calls to the Python code.

The python instance needs to implement a method named:

def createWidget(self, control, parent):
MLABWidgetControl * control(const QString &name)
Returns a named control in the context of this control.

where control is the owning MLABPythonWidgetControl and parent it the parent QWidget.

If the control should have MDL children, implement a

def setupChildren(self):

method and use MLABPythonWidgetControl::createChildWidget() to create child widgets.

If you want to know when your control gets destroyed, implement:

def controlDestroyed(self):

Member Function Documentation

◆ addCommand

MLABPythonWidgetControlCommand* MLABPythonWidgetControl::addCommand ( MLABTree tree)
slot

add a scripting command for the given tree.

The returned object has a MLABPythonWidgetControlCommand::call() method which can be called to emit the command (and thus call the attached scripting function with the arguments passed to call). Currently only up to 4 arguments are supported.

◆ addFieldListener

void MLABPythonWidgetControl::addFieldListener ( MLABField field,
PyObject *  callable 
)
slot

add a fieldlistener for the given field (field can be read from an MDL tree using lookupField())

◆ createChildWidget

QWidget* MLABPythonWidgetControl::createChildWidget ( MLABTree tree,
QWidget *  parent = nullptr 
)
slot

Create a child widget from given MDL tree, the returned widget needs to be added to a Qt layout.

If no parent is given, the main widget of the control is used. This should only be called from the setupChildren() Python method.

◆ createMenu

QMenu* MLABPythonWidgetControl::createMenu ( MLABTree tree,
QWidget *  owner 
)
slot

create a QMenu from MDL SubMenu items given in tree.

◆ findTree

MLABTree* MLABPythonWidgetControl::findTree ( const QString &  name)
slot

Searches inside the MDL tree of the control (including the MDL prototype definition for that control) and returns the first tree with given name (case insensitive).

For more complex searches, you can directly access the MDL tree via MLABWidgetControl::tree().

◆ findTreeBoolValue

bool MLABPythonWidgetControl::findTreeBoolValue ( const QString &  name,
bool  defaultValue = false 
)
slot

Searches inside the MDL tree of the control (including the MDL prototype definition for that control) and returns the first tree's double value with given name (case insensitive).

◆ findTreeDoubleValue

double MLABPythonWidgetControl::findTreeDoubleValue ( const QString &  name,
double  defaultValue = 0. 
)
slot

Searches inside the MDL tree of the control (including the MDL prototype definition for that control) and returns the first tree's double value with given name (case insensitive).

◆ findTreeIntValue

int MLABPythonWidgetControl::findTreeIntValue ( const QString &  name,
int  defaultValue = 0 
)
slot

Searches inside the MDL tree of the control (including the MDL prototype definition for that control) and returns the first tree's integer value with given name (case insensitive).

◆ findTreeStringValue

QString MLABPythonWidgetControl::findTreeStringValue ( const QString &  name,
const QString &  defaultValue = QString() 
)
slot

Searches inside the MDL tree of the control (including the MDL prototype definition for that control) and returns the first tree's value with given name (case insensitive).

◆ lookupField

MLABField* MLABPythonWidgetControl::lookupField ( MLABTree tree)
slot

lookup the field given by the value of the passed tree

◆ object

QVariant MLABPythonWidgetControl::object ( )
slot

return the python object for scripting