Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rezising the main windows failed #958

Open
epaiser opened this issue Jan 19, 2023 · 2 comments
Open

Rezising the main windows failed #958

epaiser opened this issue Jan 19, 2023 · 2 comments

Comments

@epaiser
Copy link

epaiser commented Jan 19, 2023

Hi guys,
I'm in face a problem that could be related to some bug.

When design a widget application with designer using a PyDMEmbeddedDisplay initially hidden with a PushButton to show it and resize the main window or hide and resize back to the initial geometry, after show the EmbeddedDisplay and resize bigger the main window not return back to the initial (smaller) size when I issue hide EmbeddedDisplay and resize self.

I did the same exactly exercise without calling pydm (using pure PyQt) and it works.

I'm attaching both versions (working without pydm and not working with pydm). Designer has the same geometry and layout for both.

Please run and try this two attached simple code.

Someone could help on this issue?

Thank you

with_pydm.zip
without_pydm.zip

@jbellister-slac
Copy link
Collaborator

Sure, I can take a look today

@jbellister-slac
Copy link
Collaborator

jbellister-slac commented Jan 21, 2023

So the difference between the two cases is that your pure PyQt version uses a QWidget as the top level object and that is what self is referring to in the resize calls, whereas pydm uses a QMainWindow, of which Display is just a widget within that window, and so self there is referring to that display widget only rather than the main window.

So when you call setFixedHeight in the pure PyQt version, it is essentially setting the height of the whole window. In the pydm version, it is only setting the height of that specific widget, and Qt won't shrink the whole window back down when you resize that widget only. (Can reproduce the basic pydm behavior in the pyqt example by setting the height of self.widget rather than self, can pretty much exactly recreate the behavior by also setting it to inherit from QMainWindow and breaking the layout in designer)

But the bottom line is what you probably want for pydm is to use self.window().setFixedHeight()
That will give you a handle on the main window which will then resize everything as you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants