[python-users] Bug in Tkinter?
Thomas Lenarz
tommesml at netcologne.de
Sa Feb 20 10:43:27 CET 2010
Christopher Arndt schrieb:
> Am 19.02.2010 13:47, schrieb Patrick Holz:
>> Habe nach einem Bugreport gegooglet, aber nichts gefunden. Daher die
>> Frage: Könnte jemand das mal verifizieren, bevor ich einen Bugreport
>> aufmache?
>
> Schon mal in die Tkinter oder tk Sourcen geschaut um das Problem näher
> einzugrenzen?
Hallo Patrick,
ich hätte auch nur Vorschläge zur Vorgehensweise (kann leider selbst
nicht testen, da kein Windows 7 verfügbar).
-aus Python heraus einmal askopenfilenames() statt askopenfiles()
ausprobieren -> Problem gleich?
-Den File-Dialog einmal direkt unter TCL/TK ausprobieren.
-Die relevanten Sourcen anschauen und ggf. debuggen:
--Python: tkFileDialog.py
--TK: tkWinDialog.c Hier wird die Windows API-Funktion
GetOpenFileNameW() mit dem Flag OFN_ALLOWMULTISELECT genutzt.
Der interessante Teil folgt nach dem Aufruf von GetOpenFileNameW():
if (winCode != 0) {
if (ofn.Flags & OFN_ALLOWMULTISELECT) {
/*
* The result in custData->szFile contains many items, separated
* with null characters. It is terminated with two nulls in a row.
* The first element is the directory path.
*/
WCHAR *files;
Tcl_DString dirBuf;
[...]
Also, Windows liefert offenbar eine durch 0-Bytes separierte Liste von
Dateinamen zurück, die insgesamt durch zwei aufeinanderfolgende 0-Bytes
abgeschlossen wird.
Möglicherweise hat Microsoft in Windows7 das Rückgabeformat verändert?
Unter http://msdn.microsoft.com/en-us/library/ms646927(VS.85).aspx habe
ich die Beschreibung der API-Funktion GetOpenFileName() gefunden. (Hoffe
der Link funktioniert.)
Unter der Beschreibung des Flags OFN_ALLOWMULTISELECT findet man eine
Beschreibung der Rückgabestruktur von mehreren Dateinamen. Hier scheint
es tatsächlich auch unterschiedliche Varianten zu geben:
--
OFN_ALLOWMULTISELECT
Specifies that the File Name list box allows multiple selections.
If you also set the OFN_EXPLORER flag, the dialog box uses the
Explorer-style user interface; otherwise, it uses the old-style user
interface.
If the user selects more than one file, the lpstrFile buffer
returns the path to the current directory followed by the file names of
the selected files. The nFileOffset member is the offset, in bytes or
characters, to the first file name, and the nFileExtension member is not
used. For Explorer-style dialog boxes, the directory and file name
strings are NULL separated, with an extra NULL character after the last
file name. This format enables the Explorer-style dialog boxes to return
long file names that include spaces. For old-style dialog boxes, the
directory and file name strings are separated by spaces and the function
uses short file names for file names with spaces. You can use the
FindFirstFile function to convert between long and short file names.
If you specify a custom template for an old-style dialog box, the
definition of the File Name list box must contain the LBS_EXTENDEDSEL value.
--
Hoffe die Infos können irgendwie helfen....
Viel Erfolg bei der Suche...
Viele Grüße
Thomas
Mehr Informationen über die Mailingliste python-users