0

In making a wxPython agw SpeedMeter, I have the following to make a colour and interval list:

    intervals = range(0, 100, 5)
    self.SetIntervals(intervals)
    colour_list = [c.COLORS["blue"], c.COLORS["yellow"], c.COLORS["orange"], c.COLORS["red"]]
    colours = []
    for colour in colour_list:
        for _ in range(5):
            colours.append(colour)
    self.SetIntervalColours(colours)

NOTE: c.COLORS["red"], for instance, is just a wx.COLOUR(255,0,0) -- I've also tried this with just rgb tuples (not wx.COLOUR)

So, this leaves me with intervals = length 20 and colours = length 20. Yet I get this error:

ERROR: Length Of Colour List Does Not Match Length Of Intervals Ranges List.

I'm not quite sure why. I've run the code in a console and printed the lengths, they are as expected. Intervals is 0 - 95 in 5 step increments (20), colours is 4 colors 5 times each (20).

Am I missing something?

linus72982
  • 1,418
  • 2
  • 16
  • 31

1 Answers1

0

I figured it out after diving into the code of SpeedMeter. The colour list always has to be 1 less than the interval list. In my above code, I just changed 100 in the range of interval to 105 -- voila.

linus72982
  • 1,418
  • 2
  • 16
  • 31