The PyResource class provides an interface to create widgets or to load .ui files from Python. More...
#include <WidgetFactory.h>
Public Member Functions | |
bool | connect (const char *sender, const char *signal, PyObject *cb) |
Makes a connection between the sender widget sender and its signal signal of the created resource and Python callback function cb. More... | |
Py::Object | connect (const Py::Tuple &) |
Searches for the sender, the signal and the callback function to connect with in the argument object args. More... | |
void | load (const char *name) |
Loads an .ui file with the name name. More... | |
PyResource () | |
Py::Object | repr () |
Py::Object | setValue (const Py::Tuple &) |
Searches for a widget, its value name and the new value in the argument object args to set even this new value. More... | |
Py::Object | show (const Py::Tuple &) |
If any resource has been loaded this methods shows it as a modal dialog. More... | |
Py::Object | value (const Py::Tuple &) |
Searches for a widget and its value in the argument object args to returns its value as Python object. More... | |
~PyResource () | |
Static Public Member Functions | |
static void | init_type () |
The PyResource class provides an interface to create widgets or to load .ui files from Python.
With
you can create a PyResource object containing the widget. If a relative file name is given PyResource looks first in the current working directory and afterwards in the home path where FreeCAD resides.
If the appropriate .ui file cannot be found or creation fails an exception is thrown. In case the widget in the .ui file does not inherit from QDialog it is embedded in a ContainerDialog object. To show the widget you can call
Furthermore it is possible to get or set values from any widgets inside the parent widget or to connect a Python callback function with a widget.
If the button with the name "Button_Name" is clicked the message "Button clicked" is printed. For example if you have a QLineEdit inside your widget you can set the text with
or retrieve the entered text with
PyResource::PyResource | ( | ) |
PyResource::~PyResource | ( | ) |
Makes a connection between the sender widget sender and its signal signal of the created resource and Python callback function cb.
If the sender widget does not exist or no resource has been loaded this method returns false, otherwise it returns true.
References draftgeoutils.intersections::connect().
Referenced by connect(), and init_type().
Py::Object PyResource::connect | ( | const Py::Tuple & | args | ) |
Searches for the sender, the signal and the callback function to connect with in the argument object args.
In the case it fails nullptr is returned.
References connect().
|
static |
References connect(), setValue(), show(), and value().
Referenced by Gui::Application::Application().
void PyResource::load | ( | const char * | name | ) |
Loads an .ui file with the name name.
If the .ui file cannot be found or the QWidgetFactory cannot create an instance an exception is thrown. If the created resource does not inherit from QDialog an instance of ContainerDialog is created to embed it.
References App::Application::getHomePath().
Referenced by draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::loadDefaults(), draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::onLoadStyle(), and draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::onSaveStyle().
Py::Object PyResource::repr | ( | ) |
Py::Object PyResource::setValue | ( | const Py::Tuple & | args | ) |
Searches for a widget, its value name and the new value in the argument object args to set even this new value.
In the case it fails nullptr is returned.
Referenced by init_type().
Py::Object PyResource::show | ( | const Py::Tuple & | ) |
If any resource has been loaded this methods shows it as a modal dialog.
Referenced by init_type(), Mod.Show.mTempoVis.TempoVis::show_all_dependencies(), and Mod.Show.mTempoVis.TempoVis::show_all_dependent().
Py::Object PyResource::value | ( | const Py::Tuple & | args | ) |
Searches for a widget and its value in the argument object args to returns its value as Python object.
In the case it fails nullptr is returned.
Referenced by PathScripts.PathProperty.Property::displayString(), PathScripts.PathProperty.PropertyQuantity::displayString(), PathScripts.PathSetupSheetOpPrototype.Property::displayString(), PathScripts.PathSetupSheetOpPrototype.PropertyQuantity::displayString(), Mod.PartDesign.WizardShaft.SegmentFunction.SegmentFunction::evaluate(), PathScripts.PathProperty.Property::getValue(), PathScripts.PathSetupSheetOpPrototype.Property::getValue(), init_type(), Mod.PartDesign.WizardShaft.SegmentFunction.IntervalFunction::lowervalue(), PathScripts.PathProperty.Property::setValue(), and PathScripts.PathSetupSheetOpPrototype.Property::setValue().