]> git.saurik.com Git - wxWidgets.git/commitdiff
A more dynamic wxWizard sample, and a fix for wxGrid wrappers
authorRobin Dunn <robin@alldunn.com>
Thu, 22 Aug 2002 00:00:04 +0000 (00:00 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 22 Aug 2002 00:00:04 +0000 (00:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16668 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/wxWizard.py
wxPython/src/grid.i
wxPython/src/msw/grid.cpp
wxPython/src/msw/misc2.cpp
wxPython/src/msw/misc2.py
wxPython/src/msw/wizard.cpp
wxPython/src/wizard.i

index 053567fadc4dce4e8279c3530c5cff60135efd28..402a307031b31ee6707243316081d88b5dee2ec5 100644 (file)
@@ -6,21 +6,88 @@ import images
 
 #----------------------------------------------------------------------
 
+def makePageTitle(wizPg, title):
+    sizer = wxBoxSizer(wxVERTICAL)
+    wizPg.SetSizer(sizer)
+    title = wxStaticText(wizPg, -1, title)
+    title.SetFont(wxFont(18, wxSWISS, wxNORMAL, wxBOLD))
+    sizer.AddWindow(title, 0, wxALIGN_CENTRE|wxALL, 5)
+    sizer.AddWindow(wxStaticLine(wizPg, -1), 0, wxEXPAND|wxALL, 5)
+    return sizer
+
+#----------------------------------------------------------------------
+
 class TitledPage(wxWizardPageSimple):
     def __init__(self, parent, title):
         wxWizardPageSimple.__init__(self, parent)
-        self.sizer = sizer = wxBoxSizer(wxVERTICAL)
-        self.SetSizer(sizer)
+        self.sizer = makePageTitle(self, title)
+
+
+#----------------------------------------------------------------------
+
+class SkipNextPage(wxPyWizardPage):
+    def __init__(self, parent, title):
+        wxPyWizardPage.__init__(self, parent)
+        self.next = self.prev = None
+        self.sizer = makePageTitle(self, title)
+
+        self.cb = wxCheckBox(self, -1, "Skip next page")
+        self.sizer.Add(self.cb, 0, wxALL, 5)
 
-        title = wxStaticText(self, -1, title)
-        title.SetFont(wxFont(18, wxSWISS, wxNORMAL, wxBOLD))
-        sizer.AddWindow(title, 0, wxALIGN_CENTRE|wxALL, 5)
-        sizer.AddWindow(wxStaticLine(self, -1), 0, wxEXPAND|wxALL, 5)
+    def SetNext(self, next):
+        self.next = next
 
+    def SetPrev(self, prev):
+        self.prev = prev
 
 
+    # Classes derived from wxPyWizardPanel must override
+    # GetNext and GetPrev, and may also override GetBitmap
+    # as well as all those methods overridable by
+    # wxPyWindow.
+
+    def GetNext(self):
+        """If the checkbox is set then return the next page's next page"""
+        next = self.next
+        if self.cb.GetValue():
+            next = next.GetNext()
+        return next
+
+    def GetPrev(self):
+        return self.prev
+
 #----------------------------------------------------------------------
 
+class UseAltBitmapPage(wxPyWizardPage):
+    def __init__(self, parent, title):
+        wxPyWizardPage.__init__(self, parent)
+        self.next = self.prev = None
+        self.sizer = makePageTitle(self, title)
+
+        self.sizer.Add(wxStaticText(self, -1, "This page uses a different bitmap"),
+                       0, wxALL, 5)
+
+    def SetNext(self, next):
+        self.next = next
+
+    def SetPrev(self, prev):
+        self.prev = prev
+
+    def GetNext(self):
+        return self.next
+
+    def GetPrev(self):
+        return self.prev
+
+    def GetBitmap(self):
+        # You usually wouldn't need to override this method
+        # since you can set a non-default bitmap in the
+        # wxWizardPageSimple constructor, but if you need to
+        # dynamically change the bitmap based on the
+        # contents of the wizard, or need to also change the
+        # next/prev order then it can be done by overriding
+        # GetBitmap.
+        return images.getWizTest2Bitmap()
 
 #----------------------------------------------------------------------
 
@@ -61,7 +128,14 @@ class TestPanel(wxPanel):
 
 
     def OnWizCancel(self, evt):
-        pass
+        page = evt.GetPage()
+        self.log.write("OnWizCancel: %s\n" % page.__class__)
+
+        # Show how to prevent cancelling of the wizard.  The
+        # other events can be Veto'd too.
+        if page is self.page1:
+            wxMessageBox("Cancelling on the first page has been prevented.", "Sorry")
+            evt.Veto()
 
 
     def OnRunSimpleWizard(self, evt):
@@ -72,13 +146,15 @@ class TestPanel(wxPanel):
         page2 = TitledPage(wizard, "Page 2")
         page3 = TitledPage(wizard, "Page 3")
         page4 = TitledPage(wizard, "Page 4")
+        self.page1 = page1
 
-        page1.sizer.Add(wxStaticText(page1, -1, """\
+        page1.sizer.Add(wxStaticText(page1, -1, """
 This wizard is totally useless, but is meant to show how to
 chain simple wizard pages together in a non-dynamic manner.
 IOW, the order of the pages never changes, and so the
 wxWizardPageSimple class can easily be used for the pages."""))
         wizard.FitToPage(page1)
+        page4.sizer.Add(wxStaticText(page4, -1, "\nThis is the last page."))
 
         # Use the convenience Chain function to connect the pages
         wxWizardPageSimple_Chain(page1, page2)
@@ -93,7 +169,39 @@ wxWizardPageSimple class can easily be used for the pages."""))
 
 
     def OnRunDynamicWizard(self, evt):
-        pass
+        # Create the wizard and the pages
+        wizard = wxWizard(self, self.ID_wiz, "Simple Wizard",
+                          images.getWizTest1Bitmap())
+
+        page1 = TitledPage(wizard, "Page 1")
+        page2 = SkipNextPage(wizard, "Page 2")
+        page3 = TitledPage(wizard, "Page 3")
+        page4 = UseAltBitmapPage(wizard, "Page 4")
+        page5 = TitledPage(wizard, "Page 5")
+        self.page1 = page1
+
+        page1.sizer.Add(wxStaticText(page1, -1, """
+This wizard shows the ability to choose at runtime the order
+of the pages and also which bitmap is shown.
+"""))
+        wizard.FitToPage(page1)
+        page5.sizer.Add(wxStaticText(page5, -1, "\nThis is the last page."))
+
+        # Set the initial order of the pages
+        page1.SetNext(page2)
+        page2.SetPrev(page1)
+        page2.SetNext(page3)
+        page3.SetPrev(page2)
+        page3.SetNext(page4)
+        page4.SetPrev(page3)
+        page4.SetNext(page5)
+        page5.SetPrev(page4)
+
+
+        if wizard.RunWizard(page1):
+            wxMessageBox("Wizard completed successfully", "That's all folks!")
+        else:
+            wxMessageBox("Wizard was cancelled", "That's all folks!")
 
 #----------------------------------------------------------------------
 
index 147ca26bf499f5832fbbdc994f91423595f05022..bb353e2e8d789b0661f6f05daaff74911601bdc1 100644 (file)
@@ -398,7 +398,7 @@ wxPyMake_TEMPLATE(wxGridTableBase)
     void CBNAME(int a, const wxString& c)  {                                    \
         bool found;                                                             \
         wxPyBeginBlockThreads();                                                \
-        if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
+        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
             PyObject* s = wx2PyString(c);                                       \
             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s));          \
             Py_DECREF(s);                                                       \
index 9af5e6c4c44290fd8057e9df05b5cfe5bf6798b6..25954b9060d6ae51231d70c6ef5b08ee612d4dfc 100644 (file)
@@ -425,7 +425,7 @@ wxPyMake_TEMPLATE(wxGridTableBase)
     void CBNAME(int a, const wxString& c)  {                                    \
         bool found;                                                             \
         wxPyBeginBlockThreads();                                                \
-        if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
+        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
             PyObject* s = wx2PyString(c);                                       \
             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s));          \
             Py_DECREF(s);                                                       \
index 1c55aa1c0a4cf3b96a1a1b7815412c74dcf5b069..6fbe6cab8ba841d9d1bda4079c2d25dfc4bb50bc 100644 (file)
@@ -6567,6 +6567,90 @@ static PyObject *_wrap_wxProcess_CloseOutput(PyObject *self, PyObject *args, PyO
     return _resultobj;
 }
 
+#define wxProcess_IsInputOpened(_swigobj)  (_swigobj->IsInputOpened())
+static PyObject *_wrap_wxProcess_IsInputOpened(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    bool  _result;
+    wxPyProcess * _arg0;
+    PyObject * _argo0 = 0;
+    char *_kwnames[] = { "self", NULL };
+
+    self = self;
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxProcess_IsInputOpened",_kwnames,&_argo0)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyProcess_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxProcess_IsInputOpened. Expected _wxPyProcess_p.");
+        return NULL;
+        }
+    }
+{
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
+    _result = (bool )wxProcess_IsInputOpened(_arg0);
+
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
+}    _resultobj = Py_BuildValue("i",_result);
+    return _resultobj;
+}
+
+#define wxProcess_IsInputAvailable(_swigobj)  (_swigobj->IsInputAvailable())
+static PyObject *_wrap_wxProcess_IsInputAvailable(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    bool  _result;
+    wxPyProcess * _arg0;
+    PyObject * _argo0 = 0;
+    char *_kwnames[] = { "self", NULL };
+
+    self = self;
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxProcess_IsInputAvailable",_kwnames,&_argo0)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyProcess_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxProcess_IsInputAvailable. Expected _wxPyProcess_p.");
+        return NULL;
+        }
+    }
+{
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
+    _result = (bool )wxProcess_IsInputAvailable(_arg0);
+
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
+}    _resultobj = Py_BuildValue("i",_result);
+    return _resultobj;
+}
+
+#define wxProcess_IsErrorAvailable(_swigobj)  (_swigobj->IsErrorAvailable())
+static PyObject *_wrap_wxProcess_IsErrorAvailable(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    bool  _result;
+    wxPyProcess * _arg0;
+    PyObject * _argo0 = 0;
+    char *_kwnames[] = { "self", NULL };
+
+    self = self;
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxProcess_IsErrorAvailable",_kwnames,&_argo0)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyProcess_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxProcess_IsErrorAvailable. Expected _wxPyProcess_p.");
+        return NULL;
+        }
+    }
+{
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
+    _result = (bool )wxProcess_IsErrorAvailable(_arg0);
+
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
+}    _resultobj = Py_BuildValue("i",_result);
+    return _resultobj;
+}
+
 static void *SwigwxJoystickTowxObject(void *ptr) {
     wxJoystick *src;
     wxObject *dest;
@@ -10483,6 +10567,9 @@ static PyMethodDef misc2cMethods[] = {
         { "wxJoystick_GetPosition", (PyCFunction) _wrap_wxJoystick_GetPosition, METH_VARARGS | METH_KEYWORDS },
         { "delete_wxJoystick", (PyCFunction) _wrap_delete_wxJoystick, METH_VARARGS | METH_KEYWORDS },
         { "new_wxJoystick", (PyCFunction) _wrap_new_wxJoystick, METH_VARARGS | METH_KEYWORDS },
+        { "wxProcess_IsErrorAvailable", (PyCFunction) _wrap_wxProcess_IsErrorAvailable, METH_VARARGS | METH_KEYWORDS },
+        { "wxProcess_IsInputAvailable", (PyCFunction) _wrap_wxProcess_IsInputAvailable, METH_VARARGS | METH_KEYWORDS },
+        { "wxProcess_IsInputOpened", (PyCFunction) _wrap_wxProcess_IsInputOpened, METH_VARARGS | METH_KEYWORDS },
         { "wxProcess_CloseOutput", (PyCFunction) _wrap_wxProcess_CloseOutput, METH_VARARGS | METH_KEYWORDS },
         { "wxProcess_GetOutputStream", (PyCFunction) _wrap_wxProcess_GetOutputStream, METH_VARARGS | METH_KEYWORDS },
         { "wxProcess_GetErrorStream", (PyCFunction) _wrap_wxProcess_GetErrorStream, METH_VARARGS | METH_KEYWORDS },
index df54b3c25fefbb2cb9a40e813ccc4760bb253171..39aa1535ff057b12b9a4f6399f2ec50fc091ce10 100644 (file)
@@ -604,6 +604,15 @@ class wxProcessPtr(wxEvtHandlerPtr):
     def CloseOutput(self, *_args, **_kwargs):
         val = apply(misc2c.wxProcess_CloseOutput,(self,) + _args, _kwargs)
         return val
+    def IsInputOpened(self, *_args, **_kwargs):
+        val = apply(misc2c.wxProcess_IsInputOpened,(self,) + _args, _kwargs)
+        return val
+    def IsInputAvailable(self, *_args, **_kwargs):
+        val = apply(misc2c.wxProcess_IsInputAvailable,(self,) + _args, _kwargs)
+        return val
+    def IsErrorAvailable(self, *_args, **_kwargs):
+        val = apply(misc2c.wxProcess_IsErrorAvailable,(self,) + _args, _kwargs)
+        return val
     def __repr__(self):
         return "<C wxProcess instance at %s>" % (self.this,)
 class wxProcess(wxProcessPtr):
index 9f43004ac844f3a8ba8819359749a4b2c5e7c108..0e33f29e18680c84d60e82d401deacc90e512c89 100644 (file)
@@ -2264,6 +2264,9 @@ SWIGEXPORT(void) initwizardc() {
         PyDict_SetItemString(d,"wxEVT_WIZARD_PAGE_CHANGING", PyInt_FromLong((long) wxEVT_WIZARD_PAGE_CHANGING));
         PyDict_SetItemString(d,"wxEVT_WIZARD_CANCEL", PyInt_FromLong((long) wxEVT_WIZARD_CANCEL));
         PyDict_SetItemString(d,"wxEVT_WIZARD_HELP", PyInt_FromLong((long) wxEVT_WIZARD_HELP));
+
+    wxClassInfo::CleanUpClasses();
+    wxClassInfo::InitializeClasses();
 {
    int i;
    for (i = 0; _swig_mapping[i].n1; i++)
index 5a1e4dbdca239426e6494689c75afe55be7a64e1..b53e3d313ce2e1ee8701b38c3637fd85757b6622 100644 (file)
@@ -343,6 +343,12 @@ public:
 
 
 //----------------------------------------------------------------------
+
+%init %{
+    wxClassInfo::CleanUpClasses();
+    wxClassInfo::InitializeClasses();
+%}
+
 //----------------------------------------------------------------------
 // This file gets appended to the shadow class file.
 //----------------------------------------------------------------------