Title: RE: two questions - no common theme
[EMAIL PROTECTED]
#- Any help will be greatly appreciated.
It's always better to address two different questions in two different mails, with appropiate subjects.
. Facundo
Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - P
Ilroy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 09, 2005 3:08 PM
To: python-list@python.org
Subject: two questions - no common theme
And now for a pair of questions that are completely different:
1) I'd like to be able to bind callbacks to presses of the arrow buttons
on the keyb
...how do I get hold of a list of its subdirectories?
This does what you asked for:
import os
targetpath='c:\\'
all=os.listdir(targetpath)
subdirs=[x for x in all
if os.path.isdir(os.path.join(targetpath, x))]
But you may need to take a look at os.walk (as others
have suggested) also.
Larr
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?
, , ,
http://effbot.org/books/tkinterbook/events-and-bindings.htm
For an ordinary 102-key PC-style keyboard, the special keys are Cancel
(th
def walktree(self,top=".", depthfirst=False):
"""
Walk a directory tree, starting from 'top'
This code is based on os.path.walk, with the callback function
replaced by a yield and recursion replaced by iteration
"""
if type(top) != types.StringType:
os.walk gives an object with all files in a tree, e.g.
f = os.walk('c:\\temp')
for i in f:
print i
--
http://mail.python.org/mailman/listinfo/python-list
And now for a pair of questions that are completely different:
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?
2) The function 'listdir' in os.path returns a list of all the files
in the given directory - how do I get hold