This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Python: Docker CheckBox text gets corrupted

Tags: None
(comma "," separated)
saedjubarin
Registered Member
Posts
58
Karma
0
I have this in my Docker:

Code: Select all
        self.check_show_background = QCheckBox("Show Background", self.mainWidget)
        self.check_show_background.toggled.connect(lambda:self.button_state(self.check_show_background)) # yia boiiiii
        self.mainWidget.layout().addWidget(self.check_show_background)

    @pyqtSlot(bool)
    def button_state(self,button):
        print("button_state", button.text(), button.isChecked())
        if button.text() == "Show Background":
            if button.isChecked() == True:
                ext.show_background(True)
                print("yas")
            else:
                ext.show_background(False)
                print("no")


and when I use the CheckBox the first line of button_state prints out this:

Code: Select all
button_state Show Bac&kground True
button_state Show Bac&kground False
button_state Show Bac&kground True
button_state Show Bac&kground False
button_state Show Bac&kground True


How does the & get there?
User avatar
rbreu
Registered Member
Posts
52
Karma
0
The ampersand denotes the Keyboard Shortcut (Accelerator), so in your dialogue, when you can press "k" to get to that checkbox quickly. It should be underlined in your dialog, too. Looks like Qt automatically assigns accelerators if you don't set them yourself?
saedjubarin
Registered Member
Posts
58
Karma
0
rbreu wrote:The ampersand denotes the Keyboard Shortcut (Accelerator), so in your dialogue, when you can press "k" to get to that checkbox quickly. It should be underlined in your dialog, too. Looks like Qt automatically assigns accelerators if you don't set them yourself?


Ok, it's not underlined, but the explanation is clear. I followed a tutorial, bumped into that problem and sorted my way out. But thanks for the information!


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Evergrowing, Google [Bot], rblackwell