[SOLVED] Taskpanel open .ui panel after object creation
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 62
- Joined: Tue Oct 26, 2021 5:39 pm
[SOLVED] Taskpanel open .ui panel after object creation
Hello,
I have made .ui interface with QT designer and a featurepart object which gets his parameters from the interface. Everything is working fine but after creation when I double click the feature in the tree the translation panel opens in the task panel.
How can I open my .ui interface? I want the same behavior as when you edit a sketch.
Thanks,
Karim
I have made .ui interface with QT designer and a featurepart object which gets his parameters from the interface. Everything is working fine but after creation when I double click the feature in the tree the translation panel opens in the task panel.
How can I open my .ui interface? I want the same behavior as when you edit a sketch.
Thanks,
Karim
Last edited by karim.achaibou on Sat Dec 25, 2021 4:43 pm, edited 2 times in total.
- ebrahim raeyat
- Posts: 625
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Taskpanel
you must implement doubleClicked() method, look at my punch object:
https://github.com/ebrahimraeyat/Civil/ ... ch.py#L301
https://github.com/ebrahimraeyat/Civil/ ... ch.py#L301
Re: Taskpanel
A simple example:
Just copy both files into the same directory and start the macro.-
- Posts: 62
- Joined: Tue Oct 26, 2021 5:39 pm
Re: Taskpanel
I got it to work after looking at your .py file but now all values are set to zero in the taskpanel. How do you set the values in the taskpanel to the values of the featurepython object? Code below doesn't update the taskpanel.ebrahim raeyat wrote: ↑Wed Oct 27, 2021 10:22 am you must implement doubleClicked() method, look at my punch object:
https://github.com/ebrahimraeyat/Civil/ ... ch.py#L301
Code: Select all
class BoxTaskPanel():
def __init__(self, obj):
self.form = Gui.PySideUic.loadUi(path_to_ui)
self.fp = obj
self.form.BoxLength = obj.Length
self.form.BoxWidth = obj.Width
self.form.BoxHeight = obj.Height
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Taskpanel
If you look at the source code for part workbench attachment there is a good example of gui.expressionbinding. Make your ui spinboxes Gui::QuantitySpinBox class types.
https://github.com/FreeCAD/FreeCAD/tree ... mentEditor
https://github.com/FreeCAD/FreeCAD/tree ... mentEditor
- ebrahim raeyat
- Posts: 625
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Taskpanel
I think you must give the Value of width and height like:karim.achaibou wrote: ↑Wed Oct 27, 2021 6:53 pmCode: Select all
class BoxTaskPanel(): def __init__(self, obj): self.form = Gui.PySideUic.loadUi(path_to_ui) self.fp = obj self.form.BoxWidth = obj.Width self.form.BoxHeight = obj.Height
Code: Select all
self.form.BoxWidth = obj.Width.Value
self.form.BoxHeight = obj.Height.Value
what are the type of BoxWidth, BoxHeight Gui? if those are spinBox, then you must set the value like this:
Code: Select all
self.form.BoxWidth.setValue = obj.Width.Value
self.form.BoxHeight.setValue = obj.Height.Value
-
- Posts: 62
- Joined: Tue Oct 26, 2021 5:39 pm
Re: Taskpanel
Code: Select all
self.form.BoxWidth.setValue = obj.Width.Value
self.form.BoxHeight.setValue = obj.Height.Value
The following code updates the taskpanel with the object properties:
Code: Select all
self.form.BoxLength.setValue(obj.Length)
After creating the object through the panel the object is displayed and can be edited and recomputes automatically when the dimensions are edited in the data panel of the combo view.
When I double click the object, the taskpanel opens as accepted and parameters can be updated and part also updates automatically.
When I now want to change the parameters in the data panel the object doesn't update automatically and the object is "touched" and now I need to recompute the object manually.
- ebrahim raeyat
- Posts: 625
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: Taskpanel
oops, thanks for your hint.karim.achaibou wrote: ↑Thu Oct 28, 2021 6:46 pmIt is indeed a spinbox and the above code got me in the wright direction but didn't work for meCode: Select all
self.form.BoxWidth.setValue = obj.Width.Value self.form.BoxHeight.setValue = obj.Height.Value
The following code updates the taskpanel with the object properties:
Only a new problem occurs...Code: Select all
self.form.BoxLength.setValue(obj.Length)
After creating the object through the panel the object is displayed and can be edited and recomputes automatically when the dimensions are edited in the data panel of the combo view.
When I double click the object, the taskpanel opens as accepted and parameters can be updated and part also updates automatically.
When I now want to change the parameters in the data panel the object doesn't update automatically and the object is "touched" and now I need to recompute the object manually.
for your question:
you must do it manually with qt signal & slot.
-
- Posts: 62
- Joined: Tue Oct 26, 2021 5:39 pm
Re: Taskpanel
Thanks, I will look for more info about QT signals and slots.
-
- Posts: 62
- Joined: Tue Oct 26, 2021 5:39 pm
Re: Solved: Taskpanel open .ui panel after object creation
small addition:
when implementing the doubleClicked function in the viewprovider class you can access the setEdit(vobj) function. But if you do that, you can not longer right click and use the transform function because you have overwritten it. Therefore create new functions as below:
result in my case:
when implementing the doubleClicked function in the viewprovider class you can access the setEdit(vobj) function. But if you do that, you can not longer right click and use the transform function because you have overwritten it. Therefore create new functions as below:
Code: Select all
def doubleClicked(self, vobj):
self.setEditPanel(vobj)
def setEditPanel(self, vobj, mode=0):
obj = vobj.Object
panel = BoxTaskPanel(obj.Name, ... relevant parameters ...)
Gui.Control.showDialog(panel)
return True
- doubleclinking opens the panel to edit my properties
- rightclicking + selecting transform in pop-up menu opens the transform function