Wx中的Speedmeter小部件无法正常工作

时间:2015-06-05 10:38:52

标签: python wxpython wxwidgets

wx._core.PyAssertionError:C ++断言" m_window"在../ src / gtk / dcclient失败。

是我得到的错误。我正在运行一个ubuntu 15.04系统,我已经尝试了所有故障排除这个错误,但无法找到一种方法来解决这个问题。 这是代码:

class SpeedFrame(wx.Frame):
def __init__(self, parent):
    wx.Frame.__init__(self, parent, -1, "Speedometer")
    pi=3.14
    speed = SM.SpeedMeter(self, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS)

    # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!)
    speed.SetAngleRange(-pi/6, 7*pi/6)

    # Create The Intervals That Will Divide Our SpeedMeter In Sectors
    intervals = range(0, 201, 20)
    speed.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed)
    # Usually This Is Black
    colours = [wx.BLACK]*10
    speed.SetIntervalColours(colours)

    # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
    ticks = [str(interval) for interval in intervals]
    speed.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    speed.SetTicksColour(wx.WHITE)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    speed.SetNumberOfSecondaryTicks(5)

    # Set The Font For The Ticks Markers
    speed.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL))

    # Set The Text In The Center Of SpeedMeter
    speed.SetMiddleText("Km/h")
    # Assign The Colour To The Center Text
    speed.SetMiddleTextColour(wx.WHITE)
    # Assign A Font To The Center Text
    speed.SetMiddleTextFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))

    # Set The Colour For The Hand Indicator
    speed.SetHandColour(wx.Colour(255, 50, 0))

    # Do Not Draw The External (Container) Arc. Drawing The External Arc May
    # Sometimes Create Uglier Controls. Try To Comment This Line And See It
    # For Yourself!
    speed.DrawExternalArc(False)

    # Set The Current Value For The SpeedMeter
    speed.SetSpeedValue(44)

0 个答案:

没有答案