From 6c5ae2d2a6f716e8a89b27579026b9d085f84191 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 24 Jan 2002 01:24:39 +0000 Subject: [PATCH] Demo cleanup and path issues. other tweaks. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13775 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/Main.py | 18 +++-- wxPython/demo/XML_Resource.py | 3 +- wxPython/demo/hangman.py | 2 +- wxPython/demo/wxHtmlWindow.py | 6 +- wxPython/demo/wxImage.py | 9 ++- wxPython/demo/wxMimeTypesManager.py | 3 +- wxPython/demo/wxStaticBitmap.py | 3 +- wxPython/demo/wxWave.py | 5 +- wxPython/setup.py | 1 + wxPython/src/html.i | 2 +- wxPython/src/msw/controls2.cpp | 112 ++-------------------------- wxPython/src/msw/html.cpp | 4 +- wxPython/src/my_typemaps.i | 1 + 13 files changed, 44 insertions(+), 125 deletions(-) diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index 4ee72f29a1..8e630857ef 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -11,7 +11,7 @@ # Licence: wxWindows license #---------------------------------------------------------------------------- -import sys, os, time +import sys, os, time, string from wxPython.wx import * from wxPython.lib.splashscreen import SplashScreen from wxPython.html import wxHtmlWindow @@ -95,6 +95,13 @@ class MyLog(wxPyLog): self.tc.AppendText(message + '\n') +#--------------------------------------------------------------------------- + +def opj(path): + """Convert paths to the platform-specific separator""" + return apply(os.path.join, tuple(string.split(path, '/'))) + + #--------------------------------------------------------------------------- class wxPythonDemo(wxFrame): @@ -374,7 +381,6 @@ class wxPythonDemo(wxFrame): lead = text[:6] if lead != '' and lead != '': text = string.join(string.split(text, '\n'), '
') - #text = '
' + text + '
' self.ovr.SetPage(text) self.nb.SetPageText(0, name) @@ -466,7 +472,7 @@ class wxPythonDemo(wxFrame): class MySplashScreen(wxSplashScreen): def __init__(self): - bmp = wxImage('bitmaps/splash.gif').ConvertToBitmap() + bmp = wxImage(opj("bitmaps/splash.gif")).ConvertToBitmap() wxSplashScreen.__init__(self, bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 4000, None, -1) @@ -480,15 +486,15 @@ class MySplashScreen(wxSplashScreen): def ShowTip(self, frame): try: - showTipText = open("data/showTips").read() + showTipText = open(opj("data/showTips")).read() showTip, index = eval(showTipText) except IOError: showTip, index = (1, 0) if showTip: - tp = wxCreateFileTipProvider("data/tips.txt", index) + tp = wxCreateFileTipProvider(opj("data/tips.txt"), index) showTip = wxShowTip(frame, tp) index = tp.GetCurrentTip() - open("data/showTips", "w").write(str( (showTip, index) )) + open(opj("data/showTips"), "w").write(str( (showTip, index) )) diff --git a/wxPython/demo/XML_Resource.py b/wxPython/demo/XML_Resource.py index d89f84d036..ba5350f539 100644 --- a/wxPython/demo/XML_Resource.py +++ b/wxPython/demo/XML_Resource.py @@ -1,10 +1,11 @@ from wxPython.wx import * from wxPython.xrc import * +from Main import opj #---------------------------------------------------------------------- -RESFILE = "data/resource_wdr.xrc" +RESFILE = opj("data/resource_wdr.xrc") class TestPanel(wxPanel): def __init__(self, parent, log): diff --git a/wxPython/demo/hangman.py b/wxPython/demo/hangman.py index 6d59a85d15..eb591471a8 100644 --- a/wxPython/demo/hangman.py +++ b/wxPython/demo/hangman.py @@ -294,7 +294,7 @@ class MyFrame(wxFrame): menu = wxMenu() #menu.Append(1010, "Internal", "Use internal dictionary", TRUE) menu.Append(1011, "ASCII File...") - urls = [ 'wxPython home', 'http://alldunn.com/wxPython/main.html', + urls = [ 'wxPython home', 'http://wxPython.org/', 'slashdot.org', 'http://slashdot.org/', 'cnn.com', 'http://cnn.com', 'The New York Times', 'http://www.nytimes.com', diff --git a/wxPython/demo/wxHtmlWindow.py b/wxPython/demo/wxHtmlWindow.py index cd15d3f131..942dea6134 100644 --- a/wxPython/demo/wxHtmlWindow.py +++ b/wxPython/demo/wxHtmlWindow.py @@ -5,6 +5,8 @@ from wxPython.wx import * from wxPython.html import * import wxPython.lib.wxpTag +from Main import opj + #---------------------------------------------------------------------- # This shows how to catch the OnLinkClicked non-event. (It's a virtual @@ -104,7 +106,7 @@ class TestHtmlPanel(wxPanel): def OnShowDefault(self, event): - name = os.path.join(self.cwd, 'data/test.htm') + name = os.path.join(self.cwd, opj('data/test.htm')) self.html.LoadPage(name) @@ -118,7 +120,7 @@ class TestHtmlPanel(wxPanel): def OnWithWidgets(self, event): os.chdir(self.cwd) - name = os.path.join(self.cwd, 'data/widgetTest.htm') + name = os.path.join(self.cwd, opj('data/widgetTest.htm')) self.html.LoadPage(name) diff --git a/wxPython/demo/wxImage.py b/wxPython/demo/wxImage.py index bed1c2ca8b..6a15003e85 100644 --- a/wxPython/demo/wxImage.py +++ b/wxPython/demo/wxImage.py @@ -1,13 +1,14 @@ from wxPython.wx import * +from Main import opj #---------------------------------------------------------------------- def runTest(frame, nb, log): - bmp = wxImage('bitmaps/image.bmp', wxBITMAP_TYPE_BMP).ConvertToBitmap() - gif = wxImage('bitmaps/image.gif', wxBITMAP_TYPE_GIF).ConvertToBitmap() - png = wxImage('bitmaps/image.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() - jpg = wxImage('bitmaps/image.jpg', wxBITMAP_TYPE_JPEG).ConvertToBitmap() + bmp = wxImage(opj('bitmaps/image.bmp'), wxBITMAP_TYPE_BMP).ConvertToBitmap() + gif = wxImage(opj('bitmaps/image.gif'), wxBITMAP_TYPE_GIF).ConvertToBitmap() + png = wxImage(opj('bitmaps/image.png'), wxBITMAP_TYPE_PNG).ConvertToBitmap() + jpg = wxImage(opj('bitmaps/image.jpg'), wxBITMAP_TYPE_JPEG).ConvertToBitmap() panel = wxPanel(nb, -1) pos = 10 diff --git a/wxPython/demo/wxMimeTypesManager.py b/wxPython/demo/wxMimeTypesManager.py index 7c9a03a2c1..0ad99a74c3 100644 --- a/wxPython/demo/wxMimeTypesManager.py +++ b/wxPython/demo/wxMimeTypesManager.py @@ -2,6 +2,7 @@ import pprint, string, os from wxPython.wx import * from mimetypes_wdr import * +from Main import opj #---------------------------------------------------------------------------- @@ -166,7 +167,7 @@ overview = """\ import mimetypes_wdr def MyBitmapsFunc( index ): - return wxImage( "bitmaps/noicon.png", wxBITMAP_TYPE_PNG ).ConvertToBitmap() + return wxImage( opj("bitmaps/noicon.png"), wxBITMAP_TYPE_PNG ).ConvertToBitmap() mimetypes_wdr.MyBitmapsFunc = MyBitmapsFunc diff --git a/wxPython/demo/wxStaticBitmap.py b/wxPython/demo/wxStaticBitmap.py index edaf6c8fb9..467f56d604 100644 --- a/wxPython/demo/wxStaticBitmap.py +++ b/wxPython/demo/wxStaticBitmap.py @@ -1,5 +1,6 @@ from wxPython.wx import * +from Main import opj import string import images @@ -24,7 +25,7 @@ class TestPanel(wxPanel): # (lots of colors so it explodes in size and takes a noticable # amount of time to convert back to a bitmap.) So we'll just # do it the old way - bmp = wxBitmap('bitmaps/robin.jpg', wxBITMAP_TYPE_JPEG) + bmp = wxBitmap(opj('bitmaps/robin.jpg'), wxBITMAP_TYPE_JPEG) wxStaticBitmap(self, -1, bmp, (80, 150)) wxStaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", diff --git a/wxPython/demo/wxWave.py b/wxPython/demo/wxWave.py index 880d871bc7..3be8f9e715 100644 --- a/wxPython/demo/wxWave.py +++ b/wxPython/demo/wxWave.py @@ -1,5 +1,6 @@ from wxPython.wx import * +from Main import opj #---------------------------------------------------------------------- @@ -15,9 +16,9 @@ class TestPanel(wxPanel): try: import time if int(time.time()) % 2 == 1: - wave = wxWave('data/anykey.wav') + wave = wxWave(opj('data/anykey.wav')) else: - wave = wxWave('data/plan.wav') + wave = wxWave(opj('data/plan.wav')) wave.Play() except NotImplementedError, v: wxMessageBox(str(v), "Exception Message") diff --git a/wxPython/setup.py b/wxPython/setup.py index 47ca253c00..f224408ece 100755 --- a/wxPython/setup.py +++ b/wxPython/setup.py @@ -705,6 +705,7 @@ if not GL_ONLY and BUILD_XRC: '%s/xh_frame.cpp' % XMLLOC, '%s/xh_gauge.cpp' % XMLLOC, + '%s/xh_gdctl.cpp' % XMLLOC, '%s/xh_html.cpp' % XMLLOC, '%s/xh_listb.cpp' % XMLLOC, '%s/xh_listc.cpp' % XMLLOC, diff --git a/wxPython/src/html.i b/wxPython/src/html.i index e8a04be0ff..497741dcc6 100644 --- a/wxPython/src/html.i +++ b/wxPython/src/html.i @@ -146,7 +146,7 @@ public: wxDC* GetDC(); int GetCharHeight(); int GetCharWidth(); - wxWindow* GetWindow(); + wxHtmlWindow* GetWindow(); //void SetFonts(wxString normal_face, wxString fixed_face, int *LIST); %addmethods { void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes) { diff --git a/wxPython/src/msw/controls2.cpp b/wxPython/src/msw/controls2.cpp index f624881dc3..4c7f47568e 100644 --- a/wxPython/src/msw/controls2.cpp +++ b/wxPython/src/msw/controls2.cpp @@ -10025,25 +10025,23 @@ static PyObject *_wrap_new_wxGenericDirCtrl(PyObject *self, PyObject *args, PyOb wxGenericDirCtrl * _result; wxWindow * _arg0; wxWindowID _arg1 = (wxWindowID ) -1; - wxString * _arg2 = (wxString *) &wxDirDialogDefaultFolderStr; + char * _arg2 = (char *) wxDirDialogDefaultFolderStr; wxPoint * _arg3 = (wxPoint *) &wxDefaultPosition; wxSize * _arg4 = (wxSize *) &wxDefaultSize; long _arg5 = (long ) (wxDIRCTRL_3D_INTERNAL)|wxSUNKEN_BORDER; - wxString * _arg6 = (wxString *) &wxEmptyString; + char * _arg6 = (char *) wxEmptyString; int _arg7 = (int ) 0; char * _arg8 = (char *) "dirCtrl"; PyObject * _argo0 = 0; - PyObject * _obj2 = 0; wxPoint temp; PyObject * _obj3 = 0; wxSize temp0; PyObject * _obj4 = 0; - PyObject * _obj6 = 0; char *_kwnames[] = { "parent","id","dir","pos","size","style","filter","defaultFilter","name", NULL }; char _ptemp[128]; self = self; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|iOOOlOis:new_wxGenericDirCtrl",_kwnames,&_argo0,&_arg1,&_obj2,&_obj3,&_obj4,&_arg5,&_obj6,&_arg7,&_arg8)) + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|isOOlsis:new_wxGenericDirCtrl",_kwnames,&_argo0,&_arg1,&_arg2,&_obj3,&_obj4,&_arg5,&_arg6,&_arg7,&_arg8)) return NULL; if (_argo0) { if (_argo0 == Py_None) { _arg0 = NULL; } @@ -10052,25 +10050,6 @@ static PyObject *_wrap_new_wxGenericDirCtrl(PyObject *self, PyObject *args, PyOb return NULL; } } - if (_obj2) -{ -#if PYTHON_API_VERSION >= 1009 - char* tmpPtr; int tmpSize; - if (!PyString_Check(_obj2) && !PyUnicode_Check(_obj2)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - if (PyString_AsStringAndSize(_obj2, &tmpPtr, &tmpSize) == -1) - return NULL; - _arg2 = new wxString(tmpPtr, tmpSize); -#else - if (!PyString_Check(_obj2)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - _arg2 = new wxString(PyString_AS_STRING(_obj2), PyString_GET_SIZE(_obj2)); -#endif -} if (_obj3) { _arg3 = &temp; @@ -10082,29 +10061,10 @@ static PyObject *_wrap_new_wxGenericDirCtrl(PyObject *self, PyObject *args, PyOb _arg4 = &temp0; if (! wxSize_helper(_obj4, &_arg4)) return NULL; -} - if (_obj6) -{ -#if PYTHON_API_VERSION >= 1009 - char* tmpPtr; int tmpSize; - if (!PyString_Check(_obj6) && !PyUnicode_Check(_obj6)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - if (PyString_AsStringAndSize(_obj6, &tmpPtr, &tmpSize) == -1) - return NULL; - _arg6 = new wxString(tmpPtr, tmpSize); -#else - if (!PyString_Check(_obj6)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - _arg6 = new wxString(PyString_AS_STRING(_obj6), PyString_GET_SIZE(_obj6)); -#endif } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - _result = (wxGenericDirCtrl *)new_wxGenericDirCtrl(_arg0,_arg1,*_arg2,*_arg3,*_arg4,_arg5,*_arg6,_arg7,_arg8); + _result = (wxGenericDirCtrl *)new_wxGenericDirCtrl(_arg0,_arg1,_arg2,*_arg3,*_arg4,_arg5,_arg6,_arg7,_arg8); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) return NULL; @@ -10115,14 +10075,6 @@ static PyObject *_wrap_new_wxGenericDirCtrl(PyObject *self, PyObject *args, PyOb Py_INCREF(Py_None); _resultobj = Py_None; } -{ - if (_obj2) - delete _arg2; -} -{ - if (_obj6) - delete _arg6; -} return _resultobj; } @@ -10159,25 +10111,23 @@ static PyObject *_wrap_wxGenericDirCtrl_Create(PyObject *self, PyObject *args, P wxGenericDirCtrl * _arg0; wxWindow * _arg1; wxWindowID _arg2 = (wxWindowID ) -1; - wxString * _arg3 = (wxString *) &wxDirDialogDefaultFolderStr; + char * _arg3 = (char *) wxDirDialogDefaultFolderStr; wxPoint * _arg4 = (wxPoint *) &wxDefaultPosition; wxSize * _arg5 = (wxSize *) &wxDefaultSize; long _arg6 = (long ) (wxDIRCTRL_3D_INTERNAL)|wxSUNKEN_BORDER; - wxString * _arg7 = (wxString *) &wxEmptyString; + char * _arg7 = (char *) wxEmptyString; int _arg8 = (int ) 0; char * _arg9 = (char *) "dirCtrl"; PyObject * _argo0 = 0; PyObject * _argo1 = 0; - PyObject * _obj3 = 0; wxPoint temp; PyObject * _obj4 = 0; wxSize temp0; PyObject * _obj5 = 0; - PyObject * _obj7 = 0; char *_kwnames[] = { "self","parent","id","dir","pos","size","style","filter","defaultFilter","name", NULL }; self = self; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO|iOOOlOis:wxGenericDirCtrl_Create",_kwnames,&_argo0,&_argo1,&_arg2,&_obj3,&_obj4,&_obj5,&_arg6,&_obj7,&_arg8,&_arg9)) + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO|isOOlsis:wxGenericDirCtrl_Create",_kwnames,&_argo0,&_argo1,&_arg2,&_arg3,&_obj4,&_obj5,&_arg6,&_arg7,&_arg8,&_arg9)) return NULL; if (_argo0) { if (_argo0 == Py_None) { _arg0 = NULL; } @@ -10193,25 +10143,6 @@ static PyObject *_wrap_wxGenericDirCtrl_Create(PyObject *self, PyObject *args, P return NULL; } } - if (_obj3) -{ -#if PYTHON_API_VERSION >= 1009 - char* tmpPtr; int tmpSize; - if (!PyString_Check(_obj3) && !PyUnicode_Check(_obj3)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - if (PyString_AsStringAndSize(_obj3, &tmpPtr, &tmpSize) == -1) - return NULL; - _arg3 = new wxString(tmpPtr, tmpSize); -#else - if (!PyString_Check(_obj3)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - _arg3 = new wxString(PyString_AS_STRING(_obj3), PyString_GET_SIZE(_obj3)); -#endif -} if (_obj4) { _arg4 = &temp; @@ -10223,41 +10154,14 @@ static PyObject *_wrap_wxGenericDirCtrl_Create(PyObject *self, PyObject *args, P _arg5 = &temp0; if (! wxSize_helper(_obj5, &_arg5)) return NULL; -} - if (_obj7) -{ -#if PYTHON_API_VERSION >= 1009 - char* tmpPtr; int tmpSize; - if (!PyString_Check(_obj7) && !PyUnicode_Check(_obj7)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - if (PyString_AsStringAndSize(_obj7, &tmpPtr, &tmpSize) == -1) - return NULL; - _arg7 = new wxString(tmpPtr, tmpSize); -#else - if (!PyString_Check(_obj7)) { - PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); - return NULL; - } - _arg7 = new wxString(PyString_AS_STRING(_obj7), PyString_GET_SIZE(_obj7)); -#endif } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - _result = (bool )wxGenericDirCtrl_Create(_arg0,_arg1,_arg2,*_arg3,*_arg4,*_arg5,_arg6,*_arg7,_arg8,_arg9); + _result = (bool )wxGenericDirCtrl_Create(_arg0,_arg1,_arg2,_arg3,*_arg4,*_arg5,_arg6,_arg7,_arg8,_arg9); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) return NULL; } _resultobj = Py_BuildValue("i",_result); -{ - if (_obj3) - delete _arg3; -} -{ - if (_obj7) - delete _arg7; -} return _resultobj; } diff --git a/wxPython/src/msw/html.cpp b/wxPython/src/msw/html.cpp index 654e82277a..ecba04ab38 100644 --- a/wxPython/src/msw/html.cpp +++ b/wxPython/src/msw/html.cpp @@ -1495,7 +1495,7 @@ static PyObject *_wrap_wxHtmlWinParser_GetCharWidth(PyObject *self, PyObject *ar #define wxHtmlWinParser_GetWindow(_swigobj) (_swigobj->GetWindow()) static PyObject *_wrap_wxHtmlWinParser_GetWindow(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; - wxWindow * _result; + wxHtmlWindow * _result; wxHtmlWinParser * _arg0; PyObject * _argo0 = 0; char *_kwnames[] = { "self", NULL }; @@ -1512,7 +1512,7 @@ static PyObject *_wrap_wxHtmlWinParser_GetWindow(PyObject *self, PyObject *args, } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - _result = (wxWindow *)wxHtmlWinParser_GetWindow(_arg0); + _result = (wxHtmlWindow *)wxHtmlWinParser_GetWindow(_arg0); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) return NULL; diff --git a/wxPython/src/my_typemaps.i b/wxPython/src/my_typemaps.i index 0fcf295e4a..f27dc7dc9a 100644 --- a/wxPython/src/my_typemaps.i +++ b/wxPython/src/my_typemaps.i @@ -391,6 +391,7 @@ %typemap(python, out) wxToolBar* { $target = wxPyMake_wxObject($source); } %typemap(python, out) wxToolBarBase* { $target = wxPyMake_wxObject($source); } %typemap(python, out) wxWindow* { $target = wxPyMake_wxObject($source); } +%typemap(python, out) wxHtmlWindow* { $target = wxPyMake_wxObject($source); } %typemap(python, out) wxSizer* { $target = wxPyMake_wxSizer($source); } -- 2.45.2