PyQt - Gui contents got resized but not the window

60 views
Skip to first unread message

likage

unread,
Nov 22, 2019, 8:44:16 PM11/22/19
to Python Programming for Autodesk Maya
Hi all, I am trying to 'scale' down the gui so as to reduce the spacing between my widgets whenever the tool is called.

I tried using `setFixedSize`, while it does seems to scales down to what I had wanted, but the window, see attached, stays as it is and it is not being scaled down with it.
As such, this has results in extra blank unnecessary spaces.

gui_resize_issue.png



My GUI comes from using qt-designer and the following is a small code portion of the GUI initialization:
class MyTool(MayaQWidgetDockableMixin, QtWidgets.QWidget):
    def __init__(self, parent=None, dockable=True):
        super(MyTool, self).__init__(parent=parent)

        # self.ui comes from a qt-designer file
        self.ui = Ui_MyTestWidget()
        self.ui.setupUi(self)

        # set other methods/ connections etc...
        ...
        ...

        # Attempting to 'scale' down the widgets, seems to work but not for the window
        # using self.adjustSize() does not seems to be doing anything
        self.setFixedSize(890, 505)


This is how I called upon my GUI:
import main_tool
app = main_tool.
MyTool()

Appreciate for any insights!

Justin Israel

unread,
Nov 23, 2019, 12:35:18 AM11/23/19
to python_in...@googlegroups.com
Fixing your layout size depends on a few more specifics of how you are running your tool. 
First off, using setFixedSize() is going to do exactly what it says, which is to lock your widget to one size. This means that the parent widget now has all that empty space when it resizes large than the fixed size of that child widget. You obviously don't want that effect.
In your screenshot, are we looking at the result of a floating standalone window, or is this the widget docked into Maya's layout? If its docked into Maya's layout, then shouldn't it expand to the size of the dock widget? And if its a standalone window, shouldn't it expand to the bounds of the parent window? It isn't clear to me what you want to do with that extra space of the container. 
 

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11579ffc-d7e2-4716-a70b-80e6dd6457a6%40googlegroups.com.

Alok Gandhi

unread,
Nov 23, 2019, 12:40:11 AM11/23/19
to python_in...@googlegroups.com
In addition to what Justin said, if it is a standalone window and you do not that extra space to show up, the set the size of your main application window to the fixed size and remove the fix size from the widget, so it expands to fill your application window.

likage

unread,
Nov 25, 2019, 1:46:31 PM11/25/19
to Python Programming for Autodesk Maya
Hi everyone, on the first launch, the window is not docked anywhere but rather as a floating window.

As Justin has mentioned - "bounds of the parent window", how do I resize the parent window then?
Will I be implementing the resizing as how I called upon the tool launch?

Justin Israel

unread,
Nov 25, 2019, 3:12:10 PM11/25/19
to python_in...@googlegroups.com
Because of the use of a possible parent dock widget, you may have to do something like:

if self.isDockable():
    self.parent().resize(x, y)

--
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 python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages