bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.21k stars 54 forks source link

[BUG] Incorrect KeyboardButton label #88

Closed DuckyMomo20012 closed 2 years ago

DuckyMomo20012 commented 2 years ago

Describe the bug The label displayed on KeyboardButton is incorrect.

To Reproduce Steps to reproduce the behavior:

  1. You can copy the snippet code below:
    
    import pytermgui as ptg

with ptg.WindowManager() as manager:

def handleClick():
    window.close()

window = ptg.Window(
    ptg.Label("Button Help"),
    ptg.KeyboardButton("Help", lambda *_: handleClick()),
    ptg.Label("Button Test with index 1"),
    ptg.KeyboardButton(
        "Test",
        lambda *_: handleClick(),
        index=1,
    ),
    index=1,
)

window.set_title("Error")
manager.add(window)
manager.run()
2. Run program.
3. See the error.

**Expected behavior**
KeyboardButton("Help") will look like: "[ (H)elp ]", and KeyboardButton("Test", index=1) will give "[ T(e)st ]" just like in the [document](https://ptg.bczsalba.com/pytermgui/widgets/keyboard_button.html#KeyboardButton):

![examples of keyboard button](https://user-images.githubusercontent.com/64480713/181041030-8802bcba-5067-49e3-88f7-f60e4c3d5f74.png)

**Screenshots**
![unexpected output](https://user-images.githubusercontent.com/64480713/181041456-953c6d13-e077-40fd-8378-c59f4dd65968.png)

**System information**

PyTermGUI version 6.4.0

System details: Python version: 3.10.4 $TERM: xterm-256color $COLORTERM: truecolor Color support: ColorSystem.TRUE OS Platform: Linux-5.15.0-41-generic-x86_64-with-glibc2.35

bczsalba commented 2 years ago

No idea how this slipped through, thanks for the shout!