Message140180
Almost certainly a tkinter bug.
A work around is below. First build a DLL from the following C++ source (and add a similar function for the 'save' dlg rather than the 'open' dlg):
#include "windows.h"
#include "Commdlg.h"
#include "tchar.h"
extern "C"{
__declspec(dllexport) wchar_t * _cdecl GetOpenFileNamePlus(HWND Parent,LPCWSTR InitDir,LPCWSTR FilenameIn,LPCWSTR Filter,LPCWSTR DefExt,LPCWSTR Title)
{
OPENFILENAME OpenFile;
// MessageBox(NULL,Title,L"",MB_OK);
memset (&OpenFile, 0, sizeof(OPENFILENAME));
static wchar_t Filename[MAX_PATH*2];
_tcscpy(Filename,FilenameIn);
OpenFile.lpstrInitialDir=InitDir;
OpenFile.lStructSize = sizeof(OPENFILENAME);
OpenFile.hwndOwner = Parent;
OpenFile.lpstrFile = Filename;
OpenFile.nMaxFile = MAX_PATH*2+10;
OpenFile.lpstrFilter = Filter;
OpenFile.nFilterIndex = 0;
OpenFile.lpstrDefExt=DefExt;
OpenFile.lpstrTitle = Title;
OpenFile.Flags=OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
long Stat=GetOpenFileName(&OpenFile);
if(Stat)
return Filename;
else
return NULL;
}
}
Then in python call it like this, for example:
import ctypes
commdlg=ctypes.windll.commdlg_plus
commdlg.GetOpenFileNamePlus.argtypes= [ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
commdlg.GetOpenFileNamePlus.restype= ctypes.c_wchar_p
s=commdlg.GetOpenFileNamePlus(0, "StartDir", "DefFilename", "Text files\0*.txt\0Image files\0*.jpg;*.gif\0\0","txt", "Select a file") |
|
Date |
User |
Action |
Args |
2011-07-12 13:17:24 | digiproc | set | recipients:
+ digiproc, loewis, terry.reedy, ned.deily, brian.curtin, hfischer |
2011-07-12 13:17:24 | digiproc | set | messageid: <1310476644.82.0.00380178931372.issue12219@psf.upfronthosting.co.za> |
2011-07-12 13:17:24 | digiproc | link | issue12219 messages |
2011-07-12 13:17:23 | digiproc | create | |
|