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

QPushButton minimum size #194

Closed
jnsebgosselin opened this issue Jun 25, 2019 · 10 comments
Closed

QPushButton minimum size #194

jnsebgosselin opened this issue Jun 25, 2019 · 10 comments
Assignees
Milestone

Comments

@jnsebgosselin
Copy link

Describe Your Environment

  • QDarkStyle: latest develop at 0b85473
  • Python 3.7.1 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10

Language

[Python]

Description / Steps to Reproduce [if necessary]

QPushButton doesn't seem to have any minimum width value under the dark style theme and the minimum width of the buttons is derived instead based on the widget's contents with no regard to the lenght of the label. I think for very short labels like OK, this makes the button width too small.

Please see this Stackoverflow post for a better explanation of this issue:

https://stackoverflow.com/questions/19385812/how-to-set-qpushbutton-stylesheet-affecting-buttons-size

Actual Result

image

Expected Results / Proposed Result

image

Relevant Code [if necessary]

import sys
import qdarkstyle
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout

app = QApplication(sys.argv)
is_darkstyle = True
if is_darkstyle:
    app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
icon_color = 'white' if is_darkstyle else 'black'


widget = QWidget()
layout = QHBoxLayout(widget)
for label in ['OK', 'Cancel', 'Apply', 'Restore to Defaults']:
    pushbutton = QPushButton(label)
    layout.addWidget(pushbutton)
widget.show()

sys.exit(app.exec_())
@goanpeca
Copy link
Collaborator

This depends if we want to make this style follow the os or not. On macos the small buttons are in line with how the OS looks.

@jnsebgosselin
Copy link
Author

jnsebgosselin commented Jun 25, 2019

This depends if we want to make this style follow the os or not. On macos the small buttons are in line with how the OS looks.

Can you show a screenshot of the above code results with the macOS theme please?

Edit: when I do a quick search for "macOS dialog" in Google, the results I get do not seem to indicate that the width of the dialog buttons are fitted to the content of the button... so that is strange.

@jnsebgosselin
Copy link
Author

@goanpeca I agree that we are not forced to make the style follow the OS and that it is more a matter of taste than an actual bug.

IMO, the width of the PushButton with the OK label is too small, hard to click on and look silly. It probably looks like that to me because I'm used to see dialog buttons with uniform width on Windows.

@dpizetta
Copy link
Collaborator

@jnsebgosselin In my opinion, it is a good idea to keep at least a minimum size for dialog buttons, but on the other side, I agree with @goanpeca. However, some checks are needed because I remember that I removed the min-width in some place because of some bug. I can check this. I'll mark to 2.9, so we can discuss more, and as @goanpeca said, we need to choose with we will follow the OS or not.

@dpizetta dpizetta added this to the 2.9 milestone Jun 27, 2019
@jnsebgosselin
Copy link
Author

@jnsebgosselin In my opinion, it is a good idea to keep at least a minimum size for dialog buttons, but on the other side, I agree with @goanpeca. However, some checks are needed because I remember that I removed the min-width in some place because of some bug. I can check this. I'll mark to 2.9, so we can discuss more, [...]

Ok thanks. I'm still waiting for @goanpeca screenshot :P I do not have access to a mac, but from what I can see with a little google search, there seems to be a minimum width for the dialog buttons in macOS too.

[...] and as @goanpeca said, we need to choose with we will follow the OS or not.

I totally agree with the fact that we do not need to follow the OS here.

I do believe however that the defaults used by the most popular OSes are the results of years of work by people that are specialized in UX and UI best practices. So I think that when we decide to diverge from the default behaviors set by these OSes, we need to think this over very carefully. In this particular case, I think that the tiny Ok buttons in the dialogs look and feel clumsy to interact with.

Just my two cents here. I'll be Ok with whatever is decided in the end :)

@goanpeca
Copy link
Collaborator

My bad @jnsebgosselin

Screen Shot 2019-06-27 at 11 28 44

There is indeed a minimum size on mac!

@dpizetta dpizetta modified the milestones: 2.9, 2.8 Jun 27, 2019
@dpizetta dpizetta self-assigned this Jun 27, 2019
@dpizetta
Copy link
Collaborator

dpizetta commented Jan 9, 2020

I'll set min-size=80 as this is the default size from Qt Designer

Screenshot from 2020-01-09 15-19-21

@goanpeca
Copy link
Collaborator

I think we should use the values that Qt defines before we do any CSS patch.

@dpizetta
Copy link
Collaborator

dpizetta commented Jan 13, 2020

@goanpeca
Copy link
Collaborator

I mean that we could query this minimum width values instead of hardcoding them?

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

No branches or pull requests

3 participants