Separating out PySide UI code

Hello all,

I’m wanting to port out PySide code(UI Code only) so that I have separate modules, but can’t seem to get to where I need to be on it.
My main desire is to just have the main_ui.py be the central script that grabs everything from, but I can’t seem to figure out how to inherit the Widget information from the other code.
Essentially, there is QWidget code in librariesThatIWantToReach.py and I want main_ui.py to read that code.

I currently have this folder structure:
MainPackageFolder
-init.py
–libs(folder)
----init.py
----librariesThatIWantToReach.py
–ui(folder)
----init.py
----main_ui.py

I’m using the main_ui.py as the main hub for everything, as being my main PySide QWidget instance.
This is my main_ui.py code(trimmed down to the necessities)



import libs.awRenamer as AWR
import libs.awMirrorObj as AMO

def showui():
    main_window = maya.OpenMayaUI.MQtUtil.mainWindow()
    return wrapInstance(long(main_window), QWidget)

class AWTools_UI(QDialog):
    """
    Words
    """
    def __init__(self, parent=showui()):
        super(AWTools_UI, self).__init__(parent)

    def start(self):
        self.setWindowTitle('Alex Rigging Tools')
        self.setObjectName('AlexRiggingTools')
        self.setMinimumSize(400, 750)
        self.setMaximumSize(400, 750)
        self.setWindowFlags(QtCore.Qt.Tool)

        self._layout()
        self._connections()



And in the other code(libraries that I want to reach), I just have the main functions like


def searchReplace(searchFor, replaceWith, currentSelection):
    for selected in currentSelection:
        name = selected.replace(searchFor, replaceWith)
        pmc.rename(selected, name)

But like I said above, I want the UI code to be in there as well and I want the QWidget instance from main_ui.py to pull in any information from an instance in librariesThatIWantToReach.py.
I’ve tried a bunch of stuff, but can’t seem to figure something out and haven’t found any examples doing what I’d like to do.
Hopefully this made sense. Thanks.

Edit: I think I came up with a better way of explaining:

I have the UI code for each tool segment in the module that it’s supposed to be in. I want to pull from that code and assign it to an object like a QHBoxLayout or a QWidget(not sure of what would work yet) that I can then assign to a position in the UI in the main_ui.py code.