How do I find out the colours availible? I have only found about 6 in the Docs section. Also how do I change the foreground colour of a wxStaticText ?
Thanks
-Sam
How do I find out the colours availible? I have only found about 6 in the Docs section. Also how do I change the foreground colour of a wxStaticText ?
Thanks
-Sam
How do I find out the colours availible? I have only found
about 6 in the Docs section.
How many do you want?
24-bit colour is available with the wxColour(r, g, b) constructor, or there
is a typemap in place that lets you use hex strings like "#RRGGBB" where
ever a wxCOlour object is expected.
There are a whole bunch of colour names defined that you can use with the
wxNamedColour(name) constructor. See the docs for wxColourDatabase for a
list of names. The typemap mentioned above also lets you use colour name
strings directly like "BLUE" where ever a wxColour is expected.
Then there are the predefined wxColour objects. They are:
extern wxColour *wxBLACK;
extern wxColour *wxWHITE;
extern wxColour *wxRED;
extern wxColour *wxBLUE;
extern wxColour *wxGREEN;
extern wxColour *wxCYAN;
extern wxColour *wxLIGHT_GREY;
Also how do I change the foreground
colour of a wxStaticText ?
st = wxStaticText(parent, -1, "SOme text")
st.SetForegroundColour("BLUE")
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users
Speaking of the ColourDatabase, is it available through wxPython. I looked
around through wxPython.wx and couldn't find it. I ended up rolling my own
database of colors, pens and brushes (extremely easy in python -- I did this
in about 10 minutes yesterday) because I was leaking memory.
-tim (who fully expects ColourDatabase to be someplace obvious....)
----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.sourceforge.net>
Sent: Wednesday, February 21, 2001 12:58 PM
Subject: Re: [wxPython] Colours
> How do I find out the colours availible? I have only found
> about 6 in the Docs section.How many do you want?
24-bit colour is available with the wxColour(r, g, b) constructor, or
there
is a typemap in place that lets you use hex strings like "#RRGGBB" where
ever a wxCOlour object is expected.There are a whole bunch of colour names defined that you can use with the
wxNamedColour(name) constructor. See the docs for wxColourDatabase for a
list of names. The typemap mentioned above also lets you use colour name
strings directly like "BLUE" where ever a wxColour is expected.Then there are the predefined wxColour objects. They are:
extern wxColour *wxBLACK;
extern wxColour *wxWHITE;
extern wxColour *wxRED;
extern wxColour *wxBLUE;
extern wxColour *wxGREEN;
extern wxColour *wxCYAN;
extern wxColour *wxLIGHT_GREY;> Also how do I change the foreground
> colour of a wxStaticText ?st = wxStaticText(parent, -1, "SOme text")
st.SetForegroundColour("BLUE")--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users
Speaking of the ColourDatabase, is it available through wxPython.
Nope, but I can add it. I'd also like to add more colour names to it,
perhaps all the colours in X11's rbg.txt...
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users
Hi Robin,
I have an application (a plot widget) where I need to plot a large number of
lines using data obtained from NumPy. It turns out that the bottleneck at
the moment is the conversion of my Numeric array into tuples to make
wxDC.DrawLines happy. I looked into the code in helpers.cpp and gdi.cpp and
it looks like the only change that would need to be made would be to use the
sequence protocol rather than the list and tuple protocols in
wxPoint_LIST_helper. Since wxPoint_helper already uses the sequence
protocol, this seems like a reasonable thing to do. The only real problem is
that then the name wouldn't really be appropriate (it really should be
wxPoint_SEQUENCE_helper), but I'm not sure that that's a big deal.
I've included a sketch of the modifications I think would be needed below. I
haven't tested this since I've been using the Windows installer versions of
Python, wxPython and wxWindows and I haven't got around to compiling them
myself. If you think this a good idea I can do the install, test this out
and supply a patch sometime next week.
This also fixes a couple of quasi-bugs: currently the lists supplied to
wxPoint_LIST_helper can contain tuples with length greater than two and it
can contain nonnumeric values. In the first case, the values are silently
dropped, in the second, it appears that one gets zero. A couple of changes I
made here (the PyNumber_Int check and the "length-2 sequences" language)
could probably be added to wxPoint_helper as well.
Regards,
-tim
wxPoint* wxPoint_LIST_helper(PyObject* source) {
//
// Here I've changed to use the sequence protocol rather than the list
protocol
//
if (!PySequence_Check(source)) { goto error; }
int count = PyObject_Length(source);
wxPoint* temp = new wxPoint[count];
if (! temp) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate temporary
array");
return NULL;
}
for (int x=0; x<count; x++) {
//
// Changed to use the sequence protocol and added check that the
sequence length was indeed 2.
//
PyObject* o = PySequence_GetItem(source, x);
if (PySequence_Check(o) && PyObject_Length(source) == 2) {
PyObject* o1 = PySequence_GetItem(o, 0);
PyObject* o2 = PySequence_GetItem(o, 1);
//
// Added checking for whether the item can be coerced to an
integer
//
if (o1 == NULL || (o1 = PyNumber_Int(o1)) == NULL) {goto error;}
if (o2 == NULL || (o2 = PyNumber_Int(o2)) == NULL) { goto
error;}
//
// Since we've already done the coercion, we can use AS_LONG
instead of AsLong.
//
temp[x].x = PyInt_AS_LONG(o1);
temp[x].y = PyInt_AS_LONG(o2);
}
else if (PyInstance_Check(o)) {
wxPoint* pt;
if (SWIG_GetPtrObj(o,(void **) &pt,"_wxPoint_p")) {goto error;}
temp[x] = *pt;
}
else { goto error; }
return temp;
//
// Consolidated all of the error handling here, as in wxPoint_helper
//
error:
PyErr_SetString(PyExc_TypeError, "Expected a sequence wxPoints
or length-2 sequences.");
return NULL;
}
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users
I've included a sketch of the modifications I think would be needed below.
I
haven't tested this since I've been using the Windows installer versions
of
Python, wxPython and wxWindows and I haven't got around to compiling them
myself. If you think this a good idea I can do the install, test this out
and supply a patch sometime next week.
It looks good Tim, I look forward to the patch. One thing I've never been
clear on is if there is much overhead in using the generic sequence protocol
functions rather than the type specific ones. I guess I should just dig
into the Python source and find out myself, but has anybody else looked into
that already?
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users
It looks good Tim, I look forward to the patch. One thing I've never been
clear on is if there is much overhead in using the generic sequence protocol
functions rather than the type specific ones. I guess I should just dig
into the Python source and find out myself, but has anybody else looked into
that already?
PyObject *
PySequence_GetItem(s, i)
PyObject *s;
int i;
{
PySequenceMethods *m;
if (s == NULL)
return null_error();
m = s->ob_type->tp_as_sequence;
if (m && m->sq_item) {
if (i < 0) {
if (m->sq_length) {
int l = (*m->sq_length)(s);
if (l < 0)
return NULL;
i += l;
}
}
return m->sq_item(s, i);
}
return type_error("unindexable object");
}
--
regards,
Niki
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users