Skip to content
New issue

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

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

Already on GitHub? # to your account

There is no style for focused or default button #211

Closed
jnsebgosselin opened this issue Nov 25, 2019 · 4 comments
Closed

There is no style for focused or default button #211

jnsebgosselin opened this issue Nov 25, 2019 · 4 comments
Assignees
Milestone

Comments

@jnsebgosselin
Copy link

[Versions from your environment]

  • QDarkStyle: commit 716979b on develop
  • Python 3.7.3 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10
  • Python: 3.7

There is actually no visual indicator for focused or default button in qdarkstyle. This makes navigating through the interface with the keyboard very hard because there is no way to know which button is focused and which is the default button.

Below I present an example comparing qdarkstyle with the Qt Windows vista style.

In the Qt windows vista style, the dark dashed frame indicates that the button is focused with the keyboard, while the solid blue frame indicates that it is the default button (meaning that a clicked signal is emitted if enter is pressed).

qdarkstyle_focus

Relevant Code [if necessary]

import sys
import qdarkstyle
from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import (QApplication, QPushButton,
                            QFrame, QGridLayout, QLabel)


app = QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())


class FocusEmittingButton(QPushButton):
    sig_focus_in = Signal(str)

    def __init__(self, *args, **kargs):
        super().__init__(*args, **kargs)
        self.setFocusPolicy(Qt.StrongFocus)
        self.setAutoDefault(True)

    def focusInEvent(self, event):
        text = '{} is focused.'.format(self.text())
        self.sig_focus_in.emit(text)
        super().focusInEvent(event)


toolbar = QFrame()
layout = QGridLayout(toolbar)

label = QLabel('No button pressed.')
layout.addWidget(label, 0, 1, 1, 3)
for i in range(3):
    button = FocusEmittingButton('Button {}'.format(i + 1))
    button.sig_focus_in.connect(label.setText)
    layout.addWidget(button, 1, i + 1)
button.setFocus()

toolbar.show()
sys.exit(app.exec_())
@brezniczky
Copy link

brezniczky commented Jan 6, 2020

Quite a problem - appears to also apply to Ubuntu 16.04.1, PySide2 5.14, Python 3.5.2.
(Seems to be already a problem with QDarkStyle 2.6.5., I don't know if it was ever meant to work - but it would be a timely and very welcome improvement in case it wasn't a priority beforehand.)

@dpizetta
Copy link
Collaborator

dpizetta commented Jan 9, 2020

Hi guys, I've changed to show border but less evident than when on focus.

focus

@goanpeca
Copy link
Collaborator

Thoughts @jnsebgosselin ?

@dpizetta
Copy link
Collaborator

dpizetta commented Jan 14, 2020

In the buttons, the contrast is not so big because of the grey color, but I think it is ok. The gif also decrease the contrast when converted, it is a little higher live :)

Also, I changed the focus for other fields too, see below - I do not push yet.

focus-for-all-inputs

@dpizetta dpizetta added this to the 2.8 milestone Jan 14, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants