You can programatically reorder a layout after it has been read in from the
ui file into QObjects:
class Widget(QtGui.QWidget):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
layout = QtGui.QVBoxLayout(self)
self.b1 = QtGui.QPushButton("one", self)
self.b2 = QtGui.QPushButton("two", self)
self.l1 = QtGui.QHBoxLayout()
self.l1.addWidget(self.b1)
self.l2 = QtGui.QHBoxLayout()
self.l2.addWidget(self.b2)
layout.addLayout(self.l1)
layout.addLayout(self.l2)
self.b1.clicked.connect(self.reorder)
self.b2.clicked.connect(self.reorder)
def reorder(self):
item = self.layout().takeAt(1)
self.layout().insertItem(0, item)
Justin
On Thu, Nov 29, 2018 at 3:29 PM kiteh <[email protected]> wrote:
> Hi all, I have a .ui file in which I have created some widgets using
> qt-designer in a specific order.
>
> Eg.
> QFrame
> |- horLayout_01
> |-|- buttonA
> |- horLayout_02
> |-|- LabelB
> |-|- buttonB
> |- horLayout_03
> |-|- buttonC
> |-|- buttonC
>
> And later on, this particular UI is being called and use together with a
> QObject (which is also another UI, but created in pythonic terms), such
> that the code looks something like this:
> # `mainInfoPanel` is the file that uses .ui file for setting all the
> signals within..
> # `BasePanel` is the GUI created pythonically
>
> import mainInfoPanel as mainInfoWidget
>
> class infoPanel(BasePanel):
> def _build_ui(self, parent):
> self._widget = mainInfoWidget(parent)
> super(infoPanel, self)._build_ui(parent)
>
> And so, my question here is - will it be possible to reorder the layout of
> the .ui file it is reading from under the `_build_ui`?
>
> Eg. to this:
> QFrame
> |- horLayout_01
> |-|- buttonA
> |- horLayout_03
> |-|- buttonC
> |-|- buttonC
> |- horLayout_02
> |-|- LabelB
> |-|- buttonB
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/ee8c06f0-9627-4060-993b-80b9959926ac%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/ee8c06f0-9627-4060-993b-80b9959926ac%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA38Gfzy_ZpTxA3axL5FXbubMnHPs1xbnvWKaOV7JEojWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.