two questions - no common theme

Fredrik Lundh fredrik at pythonware.com
Wed Feb 9 15:39:21 EST 2005


Sean McIlroy wrote:

> 1) I'd like to be able to bind callbacks to presses of the arrow
> buttons on the keyboard. How do you say that in Tkinter?

<Up>, <Down>, <Left>, <Right>

http://effbot.org/books/tkinterbook/events-and-bindings.htm

    For an ordinary 102-key PC-style keyboard, the special keys are Cancel
    (the Break key), BackSpace, Tab, Return(the Enter key), Shift_L (any
    Shift key), Control_L (any Control key), Alt_L (any Alt key), Pause,
    Caps_Lock, Escape, Prior (Page Up), Next (Page Down), End, Home,
    Left, Up, Right, Down, Print, Insert, Delete, F1, F2, F3, F4, F5, F6,
    F7, F8, F9, F10, F11, F12, Num_Lock, and Scroll_Lock.

> 2) The function 'listdir' in os.path returns a list of all the files
> in the given directory - how do I get hold of a list of its
> subdirectories?

listdir returns files and directories; use os.path.isdir(path) to check if path is
a directory:

    for name in os.listdir(path):
        p = os.path.join(path, name)
        if os.path.isdir(p):
            ...

</F> 






More information about the Python-list mailing list