Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13861

How can I create a responsive UI with buttons, that scales with size changes with PyQt5?

$
0
0

I am currently working on a Python Project and I would like to create the UI with PyQt5 (preferably with the help of PyQt5 Designer).

I have recently finished a Youtube tutorial about the basics of PyQt5, but I am still at beginner level.

I am currently trying to create the Main Menu of the program.

I would like the Main Menu to look like this (the background image would decorate the background but it's not today's problem):

screenshot of the original state

But if possible, I hope there is a way to achieve it, I would like the buttons to scale with window size.So for example when the user resizes the window, I would like it to look somehow ike this (not exactly, but something similar):

screenshot of the expected result

So as you can see I would like the button width and height getting changed, as the user resizes the window (and keeping their ratio within the window).

I hope there is a way to solve this problem.Thank you for the help in advance.

I tried to right click on QWidget and then clicking on the last option (might be Alignment in English, I am not native) and then clicking on that option (Maybe align as Grid in English)

attempt to use layouts

After doing this, the layout this expanded to the window size, the button got resized as well.

clean window with a layout set

expanded button after using layouts

But the button width corresponds to the layout size (not just for example 1/3 of it as I would like) and the height does not change that greatly, just the width.


Viewing all articles
Browse latest Browse all 13861

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>