Problems With ColourSelect Box Inside A wxDialog

William Wonneberger wberger at ccil.org
Wed Oct 10 17:13:39 EDT 2001


Hey Robert;

Thanks for getting back to me so soon.  I really appreciate it.

>Just a quick response,  as I'm in a bit of a hurry now. Looking at
>
>   wxDialog.__init__(self, parent, -1, "wxPlotter Settings",
>        wxDefaultPosition, wxSize(350, 200))
>
>and
>
>   self.colorselect = ColourSelect(self, -1, [0, 0, 110],
>        wxPoint(70, 200), wxDefaultSize)
>
>It would seem that you're putting the control *outside* your dialog 
>area. (That's one of the reasons I always use sizers these days.)
>
>

You called it!  The ColourSelect was being positioned outside the
bounds of the dialog box.  The corrected code is now as follows;

class wxPlotterSettingsDialog(wxDialog):
    def __init__(self, parent):        
        wxDialog.__init__(self, parent, -1, "wxPlotter Settings",
wxDefaultPosition, wxSize(350, 200))
        self.static = wxStaticText(self, -1, "Number of points to
draw: ", wxPoint(70, 22))
        self.linesSpin = wxSpinCtrl(self, 20, "", wxPoint(200, 20),
wxSize(55, 20))
        self.linesSpin.SetRange(1, 360)
        self.linesSpin.SetValue(parent.lineCount)
        self.static = wxStaticText(self, -1, "Line Color: ",
wxPoint(70, 50))              
        self.colorselect = ColourSelect(self, wxPoint(200, 46), [0, 0,
110], wxSize(55, 20))                        
        self.static = wxStaticText(self, -1, "Background Color: ",
wxPoint(70, 75))
        self.colorselect = ColourSelect(self, wxPoint(200, 73), [0, 0,
110], wxSize(55, 20))                        
        self.static = wxStaticText(self, -1, "Line Ending: ",
wxPoint(70, 102))
        self.lineEnding1 = wxRadioButton(self, 25, "Rectangle", (140,
100))
        self.lineEnding2 = wxRadioButton(self, 26, "Circle", (215,
100))
        self.lineEnding3 = wxRadioButton(self, 27, "None", (270, 100))
        self.button = wxButton(self, wxID_OK, " OK ", wxPoint(95,
140), wxDefaultSize).SetDefault()
        self.button = wxButton(self, wxID_CANCEL, " Cancel ",
wxPoint(175, 140), wxDefaultSize)
        
        EVT_BUTTON(self, 2001, self.OnOK)
        EVT_SPIN(self, 2002, self.OnPointsSpin)        

    def OnOK(self, event):
        self.wnd.Stop()
        self.EndModal(wxID_OK)

    def OnPointsSpin(self, event):
        print "Spin control selected."

    def GetLines(self):
        return self.linesSpin.GetValue()

    def GetLineEnding(self):
        print "lineEnding1 = ", self.lineEnding1.GetValue()
        print "lineEnding2 = ", self.lineEnding2.GetValue()
        print "lineEnding3 = ", self.lineEnding3.GetValue()
        return 0


And thank you for recommending that I look into using sizers as well.
Yet another item to learn in effectively developing with wxPython.

Again, thank you very, very much for your time, help, and patience...

Bill Wonneberger
wberger at ccil.org




More information about the Python-list mailing list