CY CF
2014-08-21 14:16:41 UTC
Hi All,
I am making a slider linked to a speedmeter.
The needle initially takes the value of the slider.
But once modifying the value of slider it doesn't update anymore.
any advise?
cheers, Cam
import wx
import os
import wx.lib.agw.speedmeter as SM
import sys
import math
class MyFrame(wx.Frame):
def __init__(self,parent):
# creation du panneau
wx.Frame.__init__(self,parent,-1,"Bojia Karovka")
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(-math.pi/6, 7*math.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("WOB")
# Assign The Colour To The Center Text
speed.SetMiddleTextColour(wx.BLACK)
# 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 gauge to initial slider position
#self.pos=self.slider.GetValue()
#creation of slider
self.slider=wx.Slider(speed,-1,50,0,150,pos=(15,415),size=(350,-1),style=wx.SL_AUTOTICKS|wx.SL_LABELS)
self.slider.SetTickFreq(5,1)
#value of needle
val=self.slider.Bind(wx.EVT_SLIDER,self.sliderUpdate)
def sliderUpdate(self, event):
speed = SM.SpeedMeter(self,
agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS)
#get slider position
val=self.slider.Bind(wx.EVT_SLIDER,self.sliderUpdate)
pos2=self.slider.GetValue()
#self.pos=self.slider.SetValue(pos2)
speed.SetSpeedValue(val)
self.pos=self.slider
APP=wx.App(0)
frame=MyFrame(None)
APP.SetTopWindow(frame)
frame.Show()
APP.MainLoop()
I am making a slider linked to a speedmeter.
The needle initially takes the value of the slider.
But once modifying the value of slider it doesn't update anymore.
any advise?
cheers, Cam
import wx
import os
import wx.lib.agw.speedmeter as SM
import sys
import math
class MyFrame(wx.Frame):
def __init__(self,parent):
# creation du panneau
wx.Frame.__init__(self,parent,-1,"Bojia Karovka")
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(-math.pi/6, 7*math.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("WOB")
# Assign The Colour To The Center Text
speed.SetMiddleTextColour(wx.BLACK)
# 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 gauge to initial slider position
#self.pos=self.slider.GetValue()
#creation of slider
self.slider=wx.Slider(speed,-1,50,0,150,pos=(15,415),size=(350,-1),style=wx.SL_AUTOTICKS|wx.SL_LABELS)
self.slider.SetTickFreq(5,1)
#value of needle
val=self.slider.Bind(wx.EVT_SLIDER,self.sliderUpdate)
def sliderUpdate(self, event):
speed = SM.SpeedMeter(self,
agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS)
#get slider position
val=self.slider.Bind(wx.EVT_SLIDER,self.sliderUpdate)
pos2=self.slider.GetValue()
#self.pos=self.slider.SetValue(pos2)
speed.SetSpeedValue(val)
self.pos=self.slider
APP=wx.App(0)
frame=MyFrame(None)
APP.SetTopWindow(frame)
frame.Show()
APP.MainLoop()
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users