Calling UI objects

Hi,
I am currently writing a ui script for Maya in python.

It goes something like this

def loadUI():
    #loads UI

def getMayaWindow():
    #gets the maya main window

class MainClass():
    def __init__ (self, parent = getMayaWindow()):
    #initialise
        super(MainClass, self).__init__(parent)
        self.setupUi(self)

    #create connections to ui            
    self.QComboBox.addItems([1,2,3,4])
    self.deleteButton.clicked.connect(self.delete)

def delete(self):
    self.deselect = self.QListWidget.selectedItems()
    for j in self.deselect:
        self.QListWidget.takeItem(self.QListWidget.row(j))

so, I have ui that has different tabs at the top and I do not want to put every single piece of code in the MainClass because that would be too messy and long. For every tab, I want to write its script in a different .py file. I want to create the connections under the init function, at the same time, load functions from another script into this MainClass to be used.

Question is, how should I go about calling objectName from the ui in a new file? I tried to import the MainClass code but that didn’t work and I don’t want the initialize the ui window in the new .py file. What’s a good way to go about this?

Thanks

So I’m not sure exactly what you’re asking. But I think you’re hoping to have a window/dialog with a tabbed layout, and you want each tab to be defined in it’s own separate python file?

So this example pyqt tabs - Python Tutorial show just how to setup some basic QWidgets in a tabbed layout.

If you replace those widgets with you’re own custom widgets, you should be able to do what you’re looking for.
Unless I’ve misunderstood completely.

Your question is not very clear.

What I understand here is that you want to separate each tab content in a different .py file.

In your MainClass you can create your UI, and then create a TabLayout as @bob.w said.
Then you can import all those UI .py files, calling a function on each of them that receives the tabLayout and add a tab with contents to it.

   import uiTab1
   import uiTab2
   import uiTab3

   CreationFunction():
        //Create Ui stuff...
        //Create a tab layout
        uiTab1.create(tabLayout)
        uiTab2.create(tabLayout)
        .....

Each file would be:

uiTab1.py

 def create(QTabLayout lyt):   
       ///create other UI related to this tab.
       lyt.addWidget()....

Hopefully you meant that. I can fix my answer if it wasn’t what you were asking!