wxpython SpeedMeter ERROR

Hi all,

Firstly I’m new to python and wxpython and wxwidgets, have a small error and cant figure it out and the documentation is very sparse from what ihave googled, thus far.

i am working with the SpeedMeter module, python 2.8 and wxgtk 2.8, i am trying to make a gauge that has the icon in the center, when i run the demo it works when i use the code from the demo it breaks giving this error:

···

TBCC-DELL-Mobile1:~/python$ python GKPCM
Traceback (most recent call last):
File “GKPCM”, line 173, in
frame=MyFrame(None)
File “GKPCM”, line 136, in init
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 465, in init
bufferedstyle=bufferedstyle)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 272, in init
self.OnSize(None)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 323, in OnSize
self.UpdateDrawing()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 337, in UpdateDrawing
self.Draw(dc)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 972, in Draw
middleicon = self.GetMiddleIcon()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 1500, in GetMiddleIcon
return self._middleicon
AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’


Can anyone tell me what i have done wrong? it wont let me attache the code so here is the code;


import wx
import os
import wx.lib.agw.speedmeter as SM
import sys
import math
import wx.gizmos as gizmos
from wx.lib.colourdb import getColourList
import wx.lib.buttons
from math import pi, sqrt

try:
dirName = os.path.dirname(os.path.abspath(file))
except:
dirName = os.path.dirname(os.path.abspath(sys.argv[0]))

bitmapDir = os.path.join(dirName, ‘bitmaps’)
sys.path.append(os.path.split(dirName)[0])

class MyFrame(wx.Frame):

def __init__(self,parent):
    wx.Frame.__init__(self,parent,-1,"test",pos=(3, 3),size=(480, 320))

    SPEEDOpanel = wx.Panel(self, -1,style=wx.NO_BORDER, pos=(240, 0), size=(240, 240))
    TACHpanel = wx.Panel(self, -1, pos=(0, 0), size=(240, 240))
    ODOpanel = wx.Panel(self, -1, pos=(125, 200), size=(125, 30), style=wx.NO_BORDER)
    AIRpanel = wx.Panel(self, -1, pos=(0, 240), size=(240, 240), style=wx.NO_BORDER)
    OILpanel = wx.Panel(self, -1, pos=(120, 240), size=(80, 80), style=wx.NO_BORDER)
    FUELpanel = wx.Panel(self, -1, pos=(240, 240), size=(80, 80), style=wx.NO_BORDER)
    ENGpanel = wx.Panel(self, -1, pos=(360, 240), size=(80, 80), style=wx.NO_BORDER)

    SPEEDOpanel.SetBackgroundColour(wx.BLACK)
    TACHpanel.SetBackgroundColour(wx.BLUE)
    ODOpanel.SetBackgroundColour(wx.RED)
    AIRpanel.SetBackgroundColour(wx.BLUE)
    OILpanel.SetBackgroundColour(wx.CYAN)
    FUELpanel.SetBackgroundColour(wx.BLACK)
    ENGpanel.SetBackgroundColour(wx.BLUE)

#SPEEDOMETER----------------------------------------------------------------------------------------------------------

    SPEEDO = SM.SpeedMeter(SPEEDOpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    SPEEDO.SetAngleRange(-7.25, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 260, 20)
    SPEEDO.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*12
    SPEEDO.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    SPEEDO.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    SPEEDO.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    SPEEDO.SetNumberOfSecondaryTicks(10)

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

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

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

    # Set The Colour For The Gauge Background
    SPEEDO.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    SPEEDO.DrawExternalArc(False)
    SPEEDO.SetSpeedValue(0)

#TACHOMETER----------------------------------------------------------------------------------------------------------

    TACH = SM.SpeedMeter(TACHpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    TACH.SetAngleRange(-6, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 15, 1)
    TACH.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*14
    TACH.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    TACH.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    TACH.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    TACH.SetNumberOfSecondaryTicks(1)

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

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

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

    # Set The Colour For The Gauge Background
    TACH.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    TACH.DrawExternalArc(False)
    TACH.SetSpeedValue(0)

#ODOMETER--------------------------------------------------------------------------------------------------------------
DECIMAL1=wx.gizmos.LEDNumberCtrl(ODOpanel,-1, pos=wx.Point(0, 0), size=wx.Size(125, 30), style=wx.gizmos.LED_ALIGN_LEFT)
DECIMAL1.SetBackgroundColour(“BLACK”)
DECIMAL1.SetForegroundColour(“RED”)
DECIMAL1.SetValue(“192768”)
#AIRTEMP---------------------------------------------------------------------------------------------------------------
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))

    # Air Temp Control
    AIR.SetAngleRange(5,7.25)

    intervals = range(0, 5)
    AIR.SetIntervals(intervals)

    colours = [wx.BLACK]*3
    colours.append(wx.RED)
    AIR.SetIntervalColours(colours)

    ticks = ["140", "", "210", "", "280"]
    AIR.SetTicks(ticks)
    AIR.SetTicksColour(wx.RED)
   
    AIR.SetHandColour(wx.Colour(255, 255, 0))

    # Define The Icon We Want
    icon = wx.Icon("temp.ico", wx.BITMAP_TYPE_ICO)
    icon.SetWidth(16)
    icon.SetHeight(16)

    # Draw The Icon In The Center Of SpeedMeter       
    AIR.SetMiddleIcon(icon)       

    AIR.SetSpeedBackground(wx.WHITE)       

    #AIR.SetArcColour(wx.RED)
   
    AIR.SetSpeedValue(0)
    AIR.SetDirection("Reverse")

APP=wx.App(0)

frame=MyFrame(None)
APP.SetTopWindow(frame)
frame.Show()
APP.MainLoop()


All help is appreciated

Hi,

Hi all,

Firstly I'm new to python and wxpython and wxwidgets, have a small error and cant figure it out and the documentation is very sparse from what ihave googled, thus far.

i am working with the SpeedMeter module, python 2.8 and wxgtk 2.8, i am trying to make a gauge that has the icon in the center, when i run the demo it works when i use the code from the demo it breaks giving this error:

The middleIcon is set with this code in the demo:

# Define The Icon We Want
         icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smfuel.ico")), wx.BITMAP_TYPE_ICO)
         icon.SetWidth(24)
         icon.SetHeight(24)

         # Draw The Icon In The Center Of SpeedMeter
         self.SpeedWindow3.SetMiddleIcon(icon)

Looking at your code I see:

       # Define The Icon We Want
         icon = wx.Icon("temp.ico", wx.BITMAP_TYPE_ICO)
         icon.SetWidth(16)
         icon.SetHeight(16)

         # Draw The Icon In The Center Of SpeedMeter
         AIR.SetMiddleIcon(icon)

so where is 'temp.ico' coming from, I guess it is not found and so icon.IsOK() is False, in the newer code of speedmeter.py this should raise an exception.

BTW, what 2.8 version of wxPython are you using, hopefully 2.8.12, but even that is pretty old, would be good if you would use 3.0.2.

Werner

···

On 3/6/2015 6:52, t gillespie wrote:

well i would love to be in python 3 for this but you see i have a wifi hotspot on my phone and the phoenix version of wxwidgets is something like 55MB and so that takes something like 8 hours to get on my “out of LTE dialup speed” :wink:

I changed the name of the file to a file that i made sure was in the directory and still no dice, i think the error is the same :::

tjohnson@TBCC-DELL-Mobile1:~/python$ python GKPCM
Traceback (most recent call last):
File “GKPCM”, line 301, in
frame=MyFrame(None)
File “GKPCM”, line 156, in init
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(80, 80))
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 465, in init
bufferedstyle=bufferedstyle)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 272, in init
self.OnSize(None)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 323, in OnSize
self.UpdateDrawing()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 337, in UpdateDrawing
self.Draw(dc)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 972, in Draw
middleicon = self.GetMiddleIcon()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 1500, in GetMiddleIcon
return self._middleicon
AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’

Do you suppose that the main problem is wxpython version related? if so i am gonna have to take a trip to my sisters to use the WiFi… < LAME

also i figured out why it wouldnt let me upload my code… i forgot the py extension, i never use it when i code on my machine… the version i have uploaded this time is the “complete version” with the exception of the fact i cant get this icon thing to work. i can get the rest of the python code to feed this application.

GKPCM.py (12.8 KB)

···

On Friday, March 6, 2015 at 1:49:13 AM UTC-6, t gillespie wrote:

Hi all,

Firstly I’m new to python and wxpython and wxwidgets, have a small error and cant figure it out and the documentation is very sparse from what ihave googled, thus far.

i am working with the SpeedMeter module, python 2.8 and wxgtk 2.8, i am trying to make a gauge that has the icon in the center, when i run the demo it works when i use the code from the demo it breaks giving this error:


TBCC-DELL-Mobile1:~/python$ python GKPCM
Traceback (most recent call last):
File “GKPCM”, line 173, in
frame=MyFrame(None)
File “GKPCM”, line 136, in init
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 465, in init
bufferedstyle=bufferedstyle)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 272, in init
self.OnSize(None)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 323, in OnSize
self.UpdateDrawing()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 337, in UpdateDrawing
self.Draw(dc)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 972, in Draw
middleicon = self.GetMiddleIcon()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 1500, in GetMiddleIcon
return self._middleicon
AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’


Can anyone tell me what i have done wrong? it wont let me attache the code so here is the code;


import wx
import os
import wx.lib.agw.speedmeter as SM
import sys
import math
import wx.gizmos as gizmos
from wx.lib.colourdb import getColourList
import wx.lib.buttons
from math import pi, sqrt

try:
dirName = os.path.dirname(os.path.abspath(file))
except:
dirName = os.path.dirname(os.path.abspath(sys.argv[0]))

bitmapDir = os.path.join(dirName, ‘bitmaps’)
sys.path.append(os.path.split(dirName)[0])

class MyFrame(wx.Frame):

def __init__(self,parent):
    wx.Frame.__init__(self,parent,-1,"test",pos=(3, 3),size=(480, 320))

    SPEEDOpanel = wx.Panel(self, -1,style=wx.NO_BORDER, pos=(240, 0), size=(240, 240))
    TACHpanel = wx.Panel(self, -1, pos=(0, 0), size=(240, 240))
    ODOpanel = wx.Panel(self, -1, pos=(125, 200), size=(125, 30), style=wx.NO_BORDER)
    AIRpanel = wx.Panel(self, -1, pos=(0, 240), size=(240, 240), style=wx.NO_BORDER)
    OILpanel = wx.Panel(self, -1, pos=(120, 240), size=(80, 80), style=wx.NO_BORDER)
    FUELpanel = wx.Panel(self, -1, pos=(240, 240), size=(80, 80), style=wx.NO_BORDER)
    ENGpanel = wx.Panel(self, -1, pos=(360, 240), size=(80, 80), style=wx.NO_BORDER)


    SPEEDOpanel.SetBackgroundColour(wx.BLACK)
    TACHpanel.SetBackgroundColour(wx.BLUE)
    ODOpanel.SetBackgroundColour(wx.RED)
    AIRpanel.SetBackgroundColour(wx.BLUE)
    OILpanel.SetBackgroundColour(wx.CYAN)
    FUELpanel.SetBackgroundColour(wx.BLACK)
    ENGpanel.SetBackgroundColour(wx.BLUE)

#SPEEDOMETER----------------------------------------------------------------------------------------------------------

    SPEEDO = SM.SpeedMeter(SPEEDOpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    SPEEDO.SetAngleRange(-7.25, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 260, 20)
    SPEEDO.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*12
    SPEEDO.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    SPEEDO.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    SPEEDO.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    SPEEDO.SetNumberOfSecondaryTicks(10)

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

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

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

    # Set The Colour For The Gauge Background
    SPEEDO.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    SPEEDO.DrawExternalArc(False)
    SPEEDO.SetSpeedValue(0)

#TACHOMETER----------------------------------------------------------------------------------------------------------

    TACH = SM.SpeedMeter(TACHpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    TACH.SetAngleRange(-6, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 15, 1)
    TACH.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*14
    TACH.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    TACH.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    TACH.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    TACH.SetNumberOfSecondaryTicks(1)

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

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

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

    # Set The Colour For The Gauge Background
    TACH.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    TACH.DrawExternalArc(False)
    TACH.SetSpeedValue(0)

#ODOMETER--------------------------------------------------------------------------------------------------------------
DECIMAL1=wx.gizmos.LEDNumberCtrl(ODOpanel,-1, pos=wx.Point(0, 0), size=wx.Size(125, 30), style=wx.gizmos.LED_ALIGN_LEFT)
DECIMAL1.SetBackgroundColour(“BLACK”)
DECIMAL1.SetForegroundColour(“RED”)
DECIMAL1.SetValue(“192768”)
#AIRTEMP---------------------------------------------------------------------------------------------------------------
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))

    # Air Temp Control
    AIR.SetAngleRange(5,7.25)

    intervals = range(0, 5)
    AIR.SetIntervals(intervals)

    colours = [wx.BLACK]*3
    colours.append(wx.RED)
    AIR.SetIntervalColours(colours)

    ticks = ["140", "", "210", "", "280"]
    AIR.SetTicks(ticks)
    AIR.SetTicksColour(wx.RED)
   
    AIR.SetHandColour(wx.Colour(255, 255, 0))

    # Define The Icon We Want
    icon = wx.Icon("temp.ico", wx.BITMAP_TYPE_ICO)
    icon.SetWidth(16)
    icon.SetHeight(16)


    # Draw The Icon In The Center Of SpeedMeter       
    AIR.SetMiddleIcon(icon)       

    AIR.SetSpeedBackground(wx.WHITE)       

    #AIR.SetArcColour(wx.RED)
   
    AIR.SetSpeedValue(0)
    AIR.SetDirection("Reverse")

APP=wx.App(0)

frame=MyFrame(None)
APP.SetTopWindow(frame)
frame.Show()
APP.MainLoop()


All help is appreciated

well i would love to be in python 3 for this but you see i have a wifi hotspot on my phone and the phoenix version of wxwidgets is something like 55MB and so that takes something like 8 hours to get on my "out of LTE dialup speed" :wink:

I have been there, I do love my 30MB line, sorry:-(

BTW, I ment wxPython 3.0.2 (classic) which is for Python 2, but still a pretty big download.

I changed the name of the file to a file that i made sure was in the directory and still no dice, i think the error is the same :::

tjohnson@TBCC-DELL-Mobile1:~/python$ python GKPCM
Traceback (most recent call last):
  File "GKPCM", line 301, in <module>
    frame=MyFrame(None)
  File "GKPCM", line 156, in __init__
    AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(80, 80))
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 465, in __init__
    bufferedstyle=bufferedstyle)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 272, in __init__
    self.OnSize(None)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 323, in OnSize
    self.UpdateDrawing()
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 337, in UpdateDrawing
    self.Draw(dc)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 972, in Draw
    middleicon = self.GetMiddleIcon()
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 1500, in GetMiddleIcon
    return self._middleicon
AttributeError: 'SpeedMeter' object has no attribute '_middleicon'

Do you suppose that the main problem is wxpython version related? if so i am gonna have to take a trip to my sisters to use the WiFi... < LAME

No I don't think, otherwise you would get the same error in the wxPython demo.

Looking at the source of 2.8.12.1 here I see that self._middleicon is set/defined when SetMiddleIcon is called.

From the exception above I can't see at what point in your code this is thrown.

Either run it in a debugger or add some print statements, e.g. just before you call SetMiddleIcon with your icon:
         # Draw The Icon In The Center Of SpeedMeter
        print('icon being set %s' % icon.IsOK())
         AIR.SetMiddleIcon(icon)

Werner

···

On 3/6/2015 13:17, t gillespie wrote:

ok i tried to debug it in IDLE, and added that line of print, and still same error, btw wxpython 2.8.12.1, idel debugger outputs same message then crashes…

···

On Friday, March 6, 2015 at 1:49:13 AM UTC-6, t gillespie wrote:

Hi all,

Firstly I’m new to python and wxpython and wxwidgets, have a small error and cant figure it out and the documentation is very sparse from what ihave googled, thus far.

i am working with the SpeedMeter module, python 2.8 and wxgtk 2.8, i am trying to make a gauge that has the icon in the center, when i run the demo it works when i use the code from the demo it breaks giving this error:


TBCC-DELL-Mobile1:~/python$ python GKPCM
Traceback (most recent call last):
File “GKPCM”, line 173, in
frame=MyFrame(None)
File “GKPCM”, line 136, in init
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 465, in init
bufferedstyle=bufferedstyle)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 272, in init
self.OnSize(None)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 323, in OnSize
self.UpdateDrawing()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 337, in UpdateDrawing
self.Draw(dc)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 972, in Draw
middleicon = self.GetMiddleIcon()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 1500, in GetMiddleIcon
return self._middleicon
AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’


Can anyone tell me what i have done wrong? it wont let me attache the code so here is the code;


import wx
import os
import wx.lib.agw.speedmeter as SM
import sys
import math
import wx.gizmos as gizmos
from wx.lib.colourdb import getColourList
import wx.lib.buttons
from math import pi, sqrt

try:
dirName = os.path.dirname(os.path.abspath(file))
except:
dirName = os.path.dirname(os.path.abspath(sys.argv[0]))

bitmapDir = os.path.join(dirName, ‘bitmaps’)
sys.path.append(os.path.split(dirName)[0])

class MyFrame(wx.Frame):

def __init__(self,parent):
    wx.Frame.__init__(self,parent,-1,"test",pos=(3, 3),size=(480, 320))

    SPEEDOpanel = wx.Panel(self, -1,style=wx.NO_BORDER, pos=(240, 0), size=(240, 240))
    TACHpanel = wx.Panel(self, -1, pos=(0, 0), size=(240, 240))
    ODOpanel = wx.Panel(self, -1, pos=(125, 200), size=(125, 30), style=wx.NO_BORDER)
    AIRpanel = wx.Panel(self, -1, pos=(0, 240), size=(240, 240), style=wx.NO_BORDER)
    OILpanel = wx.Panel(self, -1, pos=(120, 240), size=(80, 80), style=wx.NO_BORDER)
    FUELpanel = wx.Panel(self, -1, pos=(240, 240), size=(80, 80), style=wx.NO_BORDER)
    ENGpanel = wx.Panel(self, -1, pos=(360, 240), size=(80, 80), style=wx.NO_BORDER)


    SPEEDOpanel.SetBackgroundColour(wx.BLACK)
    TACHpanel.SetBackgroundColour(wx.BLUE)
    ODOpanel.SetBackgroundColour(wx.RED)
    AIRpanel.SetBackgroundColour(wx.BLUE)
    OILpanel.SetBackgroundColour(wx.CYAN)
    FUELpanel.SetBackgroundColour(wx.BLACK)
    ENGpanel.SetBackgroundColour(wx.BLUE)

#SPEEDOMETER----------------------------------------------------------------------------------------------------------

    SPEEDO = SM.SpeedMeter(SPEEDOpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    SPEEDO.SetAngleRange(-7.25, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 260, 20)
    SPEEDO.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*12
    SPEEDO.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    SPEEDO.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    SPEEDO.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    SPEEDO.SetNumberOfSecondaryTicks(10)

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

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

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

    # Set The Colour For The Gauge Background
    SPEEDO.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    SPEEDO.DrawExternalArc(False)
    SPEEDO.SetSpeedValue(0)

#TACHOMETER----------------------------------------------------------------------------------------------------------

    TACH = SM.SpeedMeter(TACHpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    TACH.SetAngleRange(-6, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 15, 1)
    TACH.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*14
    TACH.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    TACH.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    TACH.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    TACH.SetNumberOfSecondaryTicks(1)

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

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

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

    # Set The Colour For The Gauge Background
    TACH.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    TACH.DrawExternalArc(False)
    TACH.SetSpeedValue(0)

#ODOMETER--------------------------------------------------------------------------------------------------------------
DECIMAL1=wx.gizmos.LEDNumberCtrl(ODOpanel,-1, pos=wx.Point(0, 0), size=wx.Size(125, 30), style=wx.gizmos.LED_ALIGN_LEFT)
DECIMAL1.SetBackgroundColour(“BLACK”)
DECIMAL1.SetForegroundColour(“RED”)
DECIMAL1.SetValue(“192768”)
#AIRTEMP---------------------------------------------------------------------------------------------------------------
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))

    # Air Temp Control
    AIR.SetAngleRange(5,7.25)

    intervals = range(0, 5)
    AIR.SetIntervals(intervals)

    colours = [wx.BLACK]*3
    colours.append(wx.RED)
    AIR.SetIntervalColours(colours)

    ticks = ["140", "", "210", "", "280"]
    AIR.SetTicks(ticks)
    AIR.SetTicksColour(wx.RED)
   
    AIR.SetHandColour(wx.Colour(255, 255, 0))

    # Define The Icon We Want
    icon = wx.Icon("temp.ico", wx.BITMAP_TYPE_ICO)
    icon.SetWidth(16)
    icon.SetHeight(16)


    # Draw The Icon In The Center Of SpeedMeter       
    AIR.SetMiddleIcon(icon)       

    AIR.SetSpeedBackground(wx.WHITE)       

    #AIR.SetArcColour(wx.RED)
   
    AIR.SetSpeedValue(0)
    AIR.SetDirection("Reverse")

APP=wx.App(0)

frame=MyFrame(None)
APP.SetTopWindow(frame)
frame.Show()
APP.MainLoop()


All help is appreciated

pdb says:

root@TBCC-DELL-Mobile1:/home/tjohnson/python# python -m pdb GKPCM.py

/home/tjohnson/python/GKPCM.py(1)()
→ import wx
(Pdb) cont
Traceback (most recent call last):
File “/usr/lib/python2.7/pdb.py”, line 1314, in main
pdb._runscript(mainpyfile)
File “/usr/lib/python2.7/pdb.py”, line 1233, in _runscript
self.run(statement)
File “/usr/lib/python2.7/bdb.py”, line 400, in run
exec cmd in globals, locals
File “”, line 1, in
File “GKPCM.py”, line 1, in
import wx
File “GKPCM.py”, line 156, in init
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(80, 80))
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 465, in init
bufferedstyle=bufferedstyle)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 272, in init
self.OnSize(None)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 323, in OnSize
self.UpdateDrawing()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 337, in UpdateDrawing
self.Draw(dc)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 972, in Draw
middleicon = self.GetMiddleIcon()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 1500, in GetMiddleIcon
return self._middleicon
AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’
Uncaught exception. Entering post mortem debugging
Running ‘cont’ or ‘step’ will restart the program
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py(1500)GetMiddleIcon()
→ return self._middleicon
(Pdb) cont
Post mortem debugger finished. The GKPCM.py will be restarted
/home/tjohnson/python/GKPCM.py(1)()
→ import wx

which is the same thing… it happens when the code hits the init statement of the control with a middle icon…

···

On Friday, March 6, 2015 at 1:49:13 AM UTC-6, t gillespie wrote:

Hi all,

Firstly I’m new to python and wxpython and wxwidgets, have a small error and cant figure it out and the documentation is very sparse from what ihave googled, thus far.

i am working with the SpeedMeter module, python 2.8 and wxgtk 2.8, i am trying to make a gauge that has the icon in the center, when i run the demo it works when i use the code from the demo it breaks giving this error:


TBCC-DELL-Mobile1:~/python$ python GKPCM
Traceback (most recent call last):
File “GKPCM”, line 173, in
frame=MyFrame(None)
File “GKPCM”, line 136, in init
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 465, in init
bufferedstyle=bufferedstyle)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 272, in init
self.OnSize(None)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 323, in OnSize
self.UpdateDrawing()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 337, in UpdateDrawing
self.Draw(dc)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 972, in Draw
middleicon = self.GetMiddleIcon()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”, line 1500, in GetMiddleIcon
return self._middleicon
AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’


Can anyone tell me what i have done wrong? it wont let me attache the code so here is the code;


import wx
import os
import wx.lib.agw.speedmeter as SM
import sys
import math
import wx.gizmos as gizmos
from wx.lib.colourdb import getColourList
import wx.lib.buttons
from math import pi, sqrt

try:
dirName = os.path.dirname(os.path.abspath(file))
except:
dirName = os.path.dirname(os.path.abspath(sys.argv[0]))

bitmapDir = os.path.join(dirName, ‘bitmaps’)
sys.path.append(os.path.split(dirName)[0])

class MyFrame(wx.Frame):

def __init__(self,parent):
    wx.Frame.__init__(self,parent,-1,"test",pos=(3, 3),size=(480, 320))

    SPEEDOpanel = wx.Panel(self, -1,style=wx.NO_BORDER, pos=(240, 0), size=(240, 240))
    TACHpanel = wx.Panel(self, -1, pos=(0, 0), size=(240, 240))
    ODOpanel = wx.Panel(self, -1, pos=(125, 200), size=(125, 30), style=wx.NO_BORDER)
    AIRpanel = wx.Panel(self, -1, pos=(0, 240), size=(240, 240), style=wx.NO_BORDER)
    OILpanel = wx.Panel(self, -1, pos=(120, 240), size=(80, 80), style=wx.NO_BORDER)
    FUELpanel = wx.Panel(self, -1, pos=(240, 240), size=(80, 80), style=wx.NO_BORDER)
    ENGpanel = wx.Panel(self, -1, pos=(360, 240), size=(80, 80), style=wx.NO_BORDER)


    SPEEDOpanel.SetBackgroundColour(wx.BLACK)
    TACHpanel.SetBackgroundColour(wx.BLUE)
    ODOpanel.SetBackgroundColour(wx.RED)
    AIRpanel.SetBackgroundColour(wx.BLUE)
    OILpanel.SetBackgroundColour(wx.CYAN)
    FUELpanel.SetBackgroundColour(wx.BLACK)
    ENGpanel.SetBackgroundColour(wx.BLUE)

#SPEEDOMETER----------------------------------------------------------------------------------------------------------

    SPEEDO = SM.SpeedMeter(SPEEDOpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    SPEEDO.SetAngleRange(-7.25, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 260, 20)
    SPEEDO.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*12
    SPEEDO.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    SPEEDO.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    SPEEDO.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    SPEEDO.SetNumberOfSecondaryTicks(10)

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

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

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

    # Set The Colour For The Gauge Background
    SPEEDO.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    SPEEDO.DrawExternalArc(False)
    SPEEDO.SetSpeedValue(0)

#TACHOMETER----------------------------------------------------------------------------------------------------------

    TACH = SM.SpeedMeter(TACHpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(240, 240))

    # Set The Region Of Existence Of SpeedMeter
    TACH.SetAngleRange(-6, -2)

    # SpeedMeter In Sectors
    intervals = range(0, 15, 1)
    TACH.SetIntervals(intervals)

    # Assign The Same Colours To All Sectors
    # Usually This Is Black
    colours = [wx.BLACK]*14
    TACH.SetIntervalColours(colours)

    # Assign The Ticks
    ticks = [str(interval) for interval in intervals]
    TACH.SetTicks(ticks)
    # Set The Ticks/Tick Markers Colour
    TACH.SetTicksColour(wx.RED)
    # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
    TACH.SetNumberOfSecondaryTicks(1)

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

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

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

    # Set The Colour For The Gauge Background
    TACH.SetSpeedBackground(wx.BLACK)

    # Do Not Draw The External (CONTAINER) Arc
    TACH.DrawExternalArc(False)
    TACH.SetSpeedValue(0)

#ODOMETER--------------------------------------------------------------------------------------------------------------
DECIMAL1=wx.gizmos.LEDNumberCtrl(ODOpanel,-1, pos=wx.Point(0, 0), size=wx.Size(125, 30), style=wx.gizmos.LED_ALIGN_LEFT)
DECIMAL1.SetBackgroundColour(“BLACK”)
DECIMAL1.SetForegroundColour(“RED”)
DECIMAL1.SetValue(“192768”)
#AIRTEMP---------------------------------------------------------------------------------------------------------------
AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(240, 240))

    # Air Temp Control
    AIR.SetAngleRange(5,7.25)

    intervals = range(0, 5)
    AIR.SetIntervals(intervals)

    colours = [wx.BLACK]*3
    colours.append(wx.RED)
    AIR.SetIntervalColours(colours)

    ticks = ["140", "", "210", "", "280"]
    AIR.SetTicks(ticks)
    AIR.SetTicksColour(wx.RED)
   
    AIR.SetHandColour(wx.Colour(255, 255, 0))

    # Define The Icon We Want
    icon = wx.Icon("temp.ico", wx.BITMAP_TYPE_ICO)
    icon.SetWidth(16)
    icon.SetHeight(16)


    # Draw The Icon In The Center Of SpeedMeter       
    AIR.SetMiddleIcon(icon)       

    AIR.SetSpeedBackground(wx.WHITE)       

    #AIR.SetArcColour(wx.RED)
   
    AIR.SetSpeedValue(0)
    AIR.SetDirection("Reverse")

APP=wx.App(0)

frame=MyFrame(None)
APP.SetTopWindow(frame)
frame.Show()
APP.MainLoop()


All help is appreciated

BTW, don't use idle with a wxPython application. idle is tkinter based and the two don't like each other.

Hhm, do you see the error also in the wxPython demo and does the wxPython demo have a control with this style set "SM.SM_DRAW_MIDDLE_ICON"?

Werner

···

On 3/6/2015 14:35, t gillespie wrote:

pdb says:

root@TBCC-DELL-Mobile1:/home/tjohnson/python# python -m pdb GKPCM.py
> /home/tjohnson/python/GKPCM.py(1)<module>()
-> import wx
(Pdb) cont
Traceback (most recent call last):
  File "/usr/lib/python2.7/pdb.py", line 1314, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript
    self.run(statement)
  File "/usr/lib/python2.7/bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "GKPCM.py", line 1, in <module>
    import wx
  File "GKPCM.py", line 156, in __init__
    AIR = SM.SpeedMeter(AIRpanel, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC, pos=(0, 0), size=(80, 80))
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 465, in __init__
    bufferedstyle=bufferedstyle)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 272, in __init__
    self.OnSize(None)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 323, in OnSize
    self.UpdateDrawing()
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 337, in UpdateDrawing
    self.Draw(dc)
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 972, in Draw
    middleicon = self.GetMiddleIcon()
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py", line 1500, in GetMiddleIcon
    return self._middleicon
AttributeError: 'SpeedMeter' object has no attribute '_middleicon'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py(1500)GetMiddleIcon()
-> return self._middleicon
(Pdb) cont
Post mortem debugger finished. The GKPCM.py will be restarted
> /home/tjohnson/python/GKPCM.py(1)<module>()
-> import wx

which is the same thing... it happens when the code hits the init statement of the control with a middle icon...

SM.SM_DRAW_MIDDLE_ICON is the method from the demo. which is also in my code. i can put all the parts that cause the error back into the script and if you could run it and see if you get the same error?

···

On Friday, March 6, 2015 at 8:51:38 AM UTC-6, werner wrote:

On 3/6/2015 14:35, t gillespie wrote:

pdb says:

root@TBCC-DELL-Mobile1:/home/tjohnson/python# python -m pdb GKPCM.py

/home/tjohnson/python/GKPCM.py(1)()

→ import wx

(Pdb) cont

Traceback (most recent call last):

File “/usr/lib/python2.7/pdb.py”, line 1314, in main

pdb._runscript(mainpyfile)

File “/usr/lib/python2.7/pdb.py”, line 1233, in _runscript

self.run(statement)

File “/usr/lib/python2.7/bdb.py”, line 400, in run

exec cmd in globals, locals

File “”, line 1, in

File “GKPCM.py”, line 1, in

import wx

File “GKPCM.py”, line 156, in init

AIR = SM.SpeedMeter(AIRpanel,

agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_PARTIAL_SECTORS|SM.SM_DRAW_MIDDLE_ICON,bufferedstyle=SM.SM_BUFFERED_DC,
pos=(0, 0), size=(80, 80))

File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”,
line 465, in init

bufferedstyle=bufferedstyle)

File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”,
line 272, in init

self.OnSize(None)

File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”,
line 323, in OnSize

self.UpdateDrawing()

File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”,
line 337, in UpdateDrawing

self.Draw(dc)

File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”,
line 972, in Draw

middleicon = self.GetMiddleIcon()

File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py”,
line 1500, in GetMiddleIcon

return self._middleicon

AttributeError: ‘SpeedMeter’ object has no attribute ‘_middleicon’

Uncaught exception. Entering post mortem debugging

Running ‘cont’ or ‘step’ will restart the program

/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/agw/speedmeter.py(1500)GetMiddleIcon()

→ return self._middleicon

(Pdb) cont

Post mortem debugger finished. The GKPCM.py will be restarted

/home/tjohnson/python/GKPCM.py(1)()

→ import wx

which is the same thing… it happens when the code hits the init
statement of the control with a middle icon…

BTW, don’t use idle with a wxPython application. idle is tkinter based
and the two don’t like each other.

Hhm, do you see the error also in the wxPython demo and does the
wxPython demo have a control with this style set “SM.SM_DRAW_MIDDLE_ICON”?

Werner

Good idea, see also MakingSampleApps - wxPyWiki

Werner

···

On 3/6/2015 23:42, t gillespie wrote:

SM.SM_DRAW_MIDDLE_ICON is the method from the demo. which is also in my code. i can put all the parts that cause the error back into the script and if you could run it and see if you get the same error?