Example #1
0
    def _set_layout ( self, adapter ):
        # If we did not receive a GUI toolkit neutral layout manager, convert
        # it to an adapted one (or None):
        if not isinstance( adapter, QtLayout ):
            adapter = adapted_layout( adapter )

        cur_layout = self.layout
        if cur_layout is None:
            if adapter is not None:
                self.control.setLayout( adapter() )

            return

        cur_layout = cur_layout()
        if (adapter is None) or (adapter.layout is not cur_layout):
            # According to the Qt docs, you have to 'delete' the existing
            # layout to remove it, but I don't know how to do a C++ 'delete'
            # from Python. So we instead delete all items from the current
            # layout as the next best thing, and then add the specified layout
            # manager (if any) to the original layout manager:
            while cur_layout.takeAt( 0 ) is not None: pass

            if adapter is not None:
                widget = cur_layout.parentWidget()
                if isinstance( widget, QMainWindow ):
                    layout = adapter()
                    ### PYSIDE: layout.setMargin( 0 )
                    panel = QWidget()
                    panel.setLayout( layout )
                    widget.setCentralWidget( panel )
                else:
                    cur_layout.addItem( adapter() )
Example #2
0
    def _get_parent_layout ( self ):
        # fixme: I haven't been able to find a direct way to do this in Qt, so
        # we are using an ad hoc algorithm of searching the parent widget's
        # layout hierarchy for a layout containing this control...
        control = self.control
        parent  = control.parentWidget()
        if parent is not None:
            layout = parent.layout()
            if layout is not None:
                return adapted_layout( self._parent_layout( control, layout ) )

        return None
Example #3
0
    def _get_layout ( self ):
        from layout import adapted_layout

        return adapted_layout( self.layout_item.GetSizer() )

#-- EOF ------------------------------------------------------------------------
Example #4
0
    def _get_layout(self):
        from layout import adapted_layout

        return adapted_layout(self.layout_item.layout())
Example #5
0
 def _get_parent_layout ( self ):
     return adapted_layout( self.control.GetContainingSizer() )
Example #6
0
 def _get_layout ( self ):
     return adapted_layout( self.control.GetSizer() )
Example #7
0
    def _get_layout ( self ):
        control = self.control

        return adapted_layout( getattr( control, '_mw', control ).layout() )