Can you share your UI file or a simplified version of it?karim.achaibou wrote: ↑Mon Nov 22, 2021 7:14 pm When I call the show function on my object without overwriting it, I get a blank dialogCode: Select all
panel = BoxTaskPanel(obj) panel.show()
[SOLVED] Open UI panel in standalone window
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: SOLVED: Open UI panel in standalone window
-
- Posts: 62
- Joined: Tue Oct 26, 2021 5:39 pm
Re: SOLVED: Open UI panel in standalone window
UI as in created in QT designer?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>426</width>
<height>336</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Lengte</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="TubeLength">
<property name="suffix">
<string>mm</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Binnen diameter</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Wanddikte</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="TubeThickness">
<property name="suffix">
<string>mm</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="TubeInnerDia">
<property name="suffix">
<string>mm</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QListWidget" name="typeWidget"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="lbl_PType">
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="lineEdit_filter_sizeList">
<property name="inputMask">
<string/>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>type to filter</string>
</property>
</widget>
</item>
<item row="1" column="3" rowspan="8">
<widget class="QListWidget" name="sizeList">
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>typeWidget</tabstop>
<tabstop>sizeList</tabstop>
<tabstop>lineEdit_filter_sizeList</tabstop>
<tabstop>TubeLength</tabstop>
<tabstop>TubeInnerDia</tabstop>
<tabstop>TubeThickness</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
Re: SOLVED: Open UI panel in standalone window
Yep. OK, this is what I thought. Actually your UI is already a QDialog.
In this case, you should do something like :
Code: Select all
class BoxTaskPanel:
def __init__(self, obj, parent=Gui.getMainWindow()):
self.form = Gui.PySideUic.loadUi(path_to_ui)
self.form.setWindowTitle("Choose Tube")
self.form.setWindowFlag(QtCore.Qt.Tool)
self.form.setParent(parent)
self.fp = obj
....
def show(self):
self.form.show()
Last edited by openBrain on Tue Nov 23, 2021 8:08 am, edited 1 time in total.
Re: SOLVED: Open UI panel in standalone window
Or maybe create Ui by hand, for simple UI (but also for complex and repetitive UI) sometimes is better and more concise than using Qt designer.
Regards
Carlo D.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/