Giter Club home page Giter Club logo

Comments (8)

robertlugg avatar robertlugg commented on July 24, 2024

Ah, I originally misunderstood. I thought you meant "first character", but now I see, so perhaps a button would have the text "eXit" and then 'X' is the hotkey. Is that correct?

Are there cases where the user wants a different keystroke, so maybe for buttons left, right, up, down, they want a, d, w, s ? How about set priority:
search for &c within the text where 'c' is any single character. If found use it.
if not found, search first first uppercase char
if not found, no hotkey.

Also, if we use '&', then I suggest & should be used to insert an & without assigning a hotkey.

from easygui.

horstjens avatar horstjens commented on July 24, 2024

there is the (rare) case that you want the hotkey not to be visible on the button itself (think of translation or many buttons with nearly identical names). Other example would be to have a button with the string "left" but hotkey should be "cursor left key". would be cool to give ascii code or some other code as hotkey parameter (optional)

from easygui.

robertlugg avatar robertlugg commented on July 24, 2024

I just checked in a change that allows key bindings. One thing to check is if the return is proper. For instance, if a button is named '&Yes', it returns '&Yes' and not 'Yes'.

For a literal &, use a double like: &&

Also modified things such that cancel (Escape, the big red X) will always close a dialog and return None.

Limitation: Can't bind control keys such as arrows Enter, etc to a button.

from easygui.

robertlugg avatar robertlugg commented on July 24, 2024

Horst, I didn't address your request to handle control keys. there also is no way to hide the character. If you have ideas for syntax, I'd appreciate it.

from easygui.

horstjens avatar horstjens commented on July 24, 2024

would it be possible to take the first characther in square brackets as hotkey ? ( like "press this [B]utton" --> B ) as this is how i normally indicate the button to be pressed in a visible text string.

from easygui.

robertlugg avatar robertlugg commented on July 24, 2024

It should be easy to switch it over. I'll give it a try.

from easygui.

robertlugg avatar robertlugg commented on July 24, 2024

I updated the code and committed it. Now, you can say [B]utton which will display the B also, or say [[B]]utton, which will hide the B. Or, you can assign a keysym like [] which will bind F1 to that button. One big question: When we return the button pressed, do we include the [, ], etc or not?

from easygui.

horstjens avatar horstjens commented on July 24, 2024

as far as i understand easygui always returns the full text string of the clicked (hotkeyed) button. I vote for including all the square brackets, as it make sense that you get returned the same string that you wrote as parameter.

from easygui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.