ColinDuquesnoy/QDarkStyleSheet

QPushButton minimum size

Closed this issue · 10 comments

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_())

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.

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.

@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.

@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.

@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 :)

My bad @jnsebgosselin

Screen Shot 2019-06-27 at 11 28 44

There is indeed a minimum size on mac!

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

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

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

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