-3

I recently installed qtile which is written and configured in python and I'm used to have a keybinding which includes single quotes '. This command is working :

    Keys = [
        Key(
            ["mod4"], "m",
            lazy.screen.next_group()
        ),
    ]

I want something like :

    Keys = [
        Key(
            ["mod4"], "'",               # <<- "m" got replaced by single quote
            lazy.screen.next_group()
        ),
    ]

It does work perfectly with m, but not if I change it to '. Can I fix it or must I change the binding ?

ATR
  • 107
  • 6
  • 1
    Sorry? `"m"` and `'m'` in Python are **exactly** the same. It's not possible for any code to even know that there's a difference between them, because they parse to the same literal value; once parsing is done and code is actually being run, any distinctions that might have existed in the original text are gone. – Charles Duffy Jul 10 '20 at 14:52
  • Please [edit] this with a [mre] that lets someone see the exact failure you get when using single quotes, and include details of that error in the question. "Doesn't work perfectly" doesn't describe an error well enough for us to say anything useful about it. – Charles Duffy Jul 10 '20 at 14:52
  • Charly Duffy I don't want to replace the single quotes with double quotes : I want to replace `m` by single quotes – ATR Jul 10 '20 at 14:55
  • 1
    `["mod4"], "'",` should work. – John Gordon Jul 10 '20 at 14:55
  • As far as Python is concerned, `"'"` is indeed perfectly valid. This may be a qtile problem, but it isn't a Python problem. – Charles Duffy Jul 10 '20 at 14:57
  • I already tried it, and `["mod4"], "'",` doesn't change anything – ATR Jul 10 '20 at 14:57
  • *shrug*. Talk to qtile's authors. You tagged this `python`, `variables` and `single-quotes`; from the perspective of all those things, there's nothing wrong with `"'"`. Try it yourself: Run `print("'")` in a Python interpreter, and you'll see it prints only a literal single-quote. Same thing if you assign it to a variable first (`a="'"; print(a)`, or such). – Charles Duffy Jul 10 '20 at 14:58
  • By the way, I didn't say "it doesn't work perfectly", but "it **does** work perfectly" – ATR Jul 10 '20 at 15:00
  • "Does" in the other (`m`) case, inverted for the current one. Could have added square braces to be clear about the changes to reflect meaning as opposed to literal text, but seemed clear from context to anyone reading. – Charles Duffy Jul 10 '20 at 15:02
  • BTW, I'd look at whether the `Key` definition comes direct from qtile code or is coming from the Qt bindings that qtile uses (assuming from the name that that's the GUI framework in question). If it's the latter, you might be able to revive this question by retagging it to be about qt, or about whichever python-qt library is in use. I wouldn't be astonished if qt had a different name for the single-quote character's associated key, rather than having the symbol refer to itself. – Charles Duffy Jul 10 '20 at 15:03

1 Answers1

3

Personally not familiar with qtile, but from the docs:

Special keys

These are most commonly used special keys. For complete list please see the code. You can create bindings on them just like for the regular keys. For example Key(["mod1"], "F4", lazy.window.kill()).

And a link to here: https://github.com/qtile/qtile/blob/master/libqtile/xkeysyms.py, which states 'apostrophe': 0x0027, in the list of special keys.

This all suggests to me that to bind single quotes, you must use something like the following:

 Keys = [
    Key(
        ["mod4"], "apostrophe",
        lazy.screen.next_group()
    ),
]
Leo Qi
  • 557
  • 5
  • 13