Hey Aren, I believe it is because you are using layouts within layouts and ending up with the default alignment. Are you expecting a top left or top center alignment? You should look at the ability to control alignment when adding widgets to the layouts: http://doc.qt.io/qt-4.8/qboxlayout.html#addWidget
You can also look at adding a stretch at the end of the layout to push everything to the left or top. Another alternative is to use a grid or form layout instead. Justin On Tue, 14 Jul 2015 6:59 AM Aren Voorhees <[email protected]> wrote: > Hey all, > > I'm trying to dive into understanding classes, and Pyside simultaneously, > should be easy right? I've been working on trying to build a simple gui - > most of it has gone pretty easy, although I've started running into an > issue with widget placement when using tabs. Everything is where I expect > it to be on the first tab, but then items are really spaced out and/or > shifted down too far on any tabs after the first. I've tried a bunch of > things, but nothing has worked so far. If anyone could give me a hand > figuring out how to fix it, that'd be awesome! The widgets where the > problem is are commented. > > Thanks! > > from PySide import QtGui > from PySide import QtCore > import maya.OpenMayaUI as mui > from shiboken import wrapInstance > import pymel.core as pm > import maya.cmds as cmds > > > #=================================================== > #Gets the main Maya window > #=================================================== > > > def maya_main_window(): > pointer = mui.MQtUtil.mainWindow() > return wrapInstance(long(pointer), QtGui.QWidget) > > > #=================================================== > #Creates the window class > #=================================================== > > > class MyWindow(QtGui.QDialog): > def __init__(self, parent=maya_main_window()): > super(MyWindow, self).__init__(parent) > > self.setWindowTitle("Anim Tools") > self.setWindowFlags(QtCore.Qt.Tool) > > self.setAttribute(QtCore.Qt.WA_DeleteOnClose) > > self.create_ui() > self.create_connections() > > def create_ui(self): > > #=================================================== > #UI Elements > #=================================================== > > #Create Tabs > self.tab_widget = QtGui.QTabWidget() > self.tab1 = QtGui.QWidget() > self.tab2 = QtGui.QWidget() > self.tab3 = QtGui.QWidget() > self.tab_widget.addTab(self.tab1, "Key Tools") > self.tab_widget.addTab(self.tab2, "I/O") > self.tab_widget.addTab(self.tab3, "Temp") > > #Tab1 > self.shiftLbl = QtGui.QLabel("Shifts keyframes of the selected > object.") > self.label1 = QtGui.QLabel("Number of frames to shift:") > self.spinBox1 = QtGui.QSpinBox() > self.spinBox1.setRange(-10000, 10000) > self.spinBox1.setMaximumWidth(75) > self.button1 = QtGui.QPushButton("Shift") > self.button1.setStyleSheet("background-color:rgb(59,248,130); > color: black") > self.line1 = QtGui.QFrame() > self.line1.setFrameShape(QtGui.QFrame.HLine) > self.cropLbl = QtGui.QLabel("Crop your time line to the last > keyframe of the selected object.") > self.cropBtn = QtGui.QPushButton("Crop") > self.cropBtn.setStyleSheet("background-color:rgb(59,248,130); > color: black") > > #Tab2 > self.procAnimsLbl1 = QtGui.QLabel("Import and export Anims") > self.pathBar = QtGui.QLineEdit() > self.browseBtn = QtGui.QPushButton("...") > self.browseBtn.setStyleSheet("background-color:rgb(59,248,130); > color: black") > > #Tab3 > self.testLbl = QtGui.QLabel("Test") > > #=================================================== > #Layouts > #=================================================== > > #Tab1 H Layout1 > horizontalLayout1 = QtGui.QHBoxLayout() > horizontalLayout1.addWidget(self.label1) > horizontalLayout1.addWidget(self.spinBox1) > > #Tab 1 Master layout > tab1MasterLayout = QtGui.QVBoxLayout(self.tab1) > tab1MasterLayout.addWidget(self.shiftLbl) > tab1MasterLayout.addLayout(horizontalLayout1) > tab1MasterLayout.addWidget(self.button1) > tab1MasterLayout.addWidget(self.line1) > tab1MasterLayout.addWidget(self.cropLbl) > tab1MasterLayout.addWidget(self.cropBtn) > > #Tab 2 H Layout > tab2HLayout = QtGui.QHBoxLayout() > tab2HLayout.addWidget(self.procAnimsLbl1) > > #Tab 2 Master layout > tab2MasterLayout = QtGui.QVBoxLayout(self.tab2) > tab2MasterLayout.addWidget(self.procAnimsLbl1) > #-----------------------This > widget is too low! > > > #Tab 3 Master layout > tab3MasterLayout = QtGui.QVBoxLayout(self.tab3) > tab3MasterLayout.addWidget(self.testLbl) > #------------------------------So > is this one! > > #Creates and assigns objects to mainLayout > mainLayout = QtGui.QVBoxLayout() > mainLayout.addWidget(self.tab_widget) > self.setLayout(mainLayout) > > #=================================================== > #Create connections > #=================================================== > > def create_connections(self): > pass > > > #=================================================== > #Functions > #=================================================== > > def shift_keys(self): > pass > > def keyframe_crop(self): > pass > > def import_anims(self): > pass > > def file_browse(self): > pass > > #=================================================== > #Shows the window > #=================================================== > > if __name__ == "__main__": > > > try: > ui.close() > except: > pass > > ui = MyWindow() > ui.show() > > > > > -- > 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/7f9a989f-b65c-44a9-8bcc-5f6679be0e64%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/7f9a989f-b65c-44a9-8bcc-5f6679be0e64%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/CAPGFgA1Kqnz-KVUm9ajf0N%2B36BD2s877Uq-7ADV7YfjYPGZR%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
