Ejemplo n.º 1
0
    def test_lib_agw_speedmeterMethods(self):
        panel = wx.Panel(self.frame)
        spW = SM.SpeedMeter(panel,
                            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!!!!)
        spW.SetAngleRange(-pi / 6, 7 * pi / 6)
        self.assertEqual(spW.GetAngleRange(), [-pi / 6, 7 * pi / 6])

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

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

        # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
        ticks = [str(interval) for interval in intervals]
        spW.SetTicks(ticks)
        self.assertEqual(spW.GetTicks(), ticks)

        # Set The Ticks/Tick Markers Colour
        spW.SetTicksColour(wx.WHITE)
        self.assertEqual(spW.GetTicksColour(), wx.WHITE)

        # We Want To Draw 5 Secondary Tickis Between The Principal Ticks
        spW.SetNumberOfSecondaryTicks(5)
        self.assertEqual(spW.GetNumberOfSecondaryTicks(), 5)

        # Set The Font For The Ticks Markers
        tf = wx.Font(7, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                     wx.FONTWEIGHT_NORMAL)
        spW.SetTicksFont(tf)
        self.assertEqual(spW.GetTicksFont(), ([tf], 7))

        # Set The Text In The Center Of SpeedMeter
        spW.SetMiddleText("Km/h")
        self.assertEqual(spW.GetMiddleText(), "Km/h")

        # Assign The Colour To The Center Text
        spW.SetMiddleTextColour(wx.WHITE)
        self.assertEqual(spW.GetMiddleTextColour(), wx.WHITE)

        # Assign A Font To The Center Text
        mf = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                     wx.FONTWEIGHT_BOLD)
        spW.SetMiddleTextFont(mf)
        self.assertEqual(spW.GetMiddleTextFont(), (mf, 8))

        # Set The Colour For The Hand Indicator
        hc = wx.Colour(255, 50, 0)
        spW.SetHandColour(hc)
        self.assertEqual(spW.GetHandColour(), hc)

        # 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!
        spW.DrawExternalArc(False)

        # Set The Current Value For The SpeedMeter
        spW.SetSpeedValue(44)
        self.assertEqual(spW.GetSpeedValue(), 44)
Ejemplo n.º 2
0
 def test_lib_agw_speedmeterCtor(self):
     spW = SM.SpeedMeter(self.frame,
                         agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS
                         | SM.SM_DRAW_MIDDLE_TEXT
                         | SM.SM_DRAW_SECONDARY_TICKS)
Ejemplo n.º 3
0
    def __init__(self, parent, saver):
        pi = 3.1415
        self.start_flight_time = 0
        wx.Frame.__init__(self, parent, -1, "Flight Recorder", size=(800, 600))
        #tworzy "layout" programu
        self.panel1 = wx.Panel(self,
                               -1,
                               style=wx.SUNKEN_BORDER,
                               size=(400, 300))
        self.panel2 = wx.Panel(self,
                               -1,
                               style=wx.SUNKEN_BORDER,
                               pos=(400, 0),
                               size=(400, 300))
        self.panel3 = wx.Panel(self,
                               -1,
                               style=wx.SUNKEN_BORDER,
                               pos=(0, 300),
                               size=(400, 300))
        self.panel4 = wx.Panel(self,
                               -1,
                               style=wx.SUNKEN_BORDER,
                               pos=(400, 300),
                               size=(400, 300))
        self.panel1.SetBackgroundColour("LIGHT GREY")
        self.panel2.SetBackgroundColour("LIGHT GREY")
        self.panel3.SetBackgroundColour("LIGHT GREY")
        self.panel4.SetBackgroundColour("LIGHT GREY")
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.panel1, 2, wx.EXPAND)
        box.Add(self.panel2, 1, wx.EXPAND)
        #predkosciomierz
        self.speed = SM.SpeedMeter(
            self.panel2,
            agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS
            | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS,
            pos=(0, 30),
            size=(400, 300))

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

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

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

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

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

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

        # Set The Colour For The Hand Indicator
        self.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!
        self.speed.DrawExternalArc(False)

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

        #wysokosciomierz
        self.alt = SM.SpeedMeter(self.panel3,
                                 agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS
                                 | SM.SM_DRAW_MIDDLE_TEXT
                                 | SM.SM_DRAW_SECONDARY_TICKS,
                                 pos=(0, 0),
                                 size=(350, 250))

        # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!)
        self.alt.SetAngleRange(-pi, pi)

        # Create The Intervals That Will Divide Our SpeedMeter In Sectors
        intervals = range(0, 11, 1)
        self.alt.SetIntervals(intervals)

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

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

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

        # Set The Text In The Center Of SpeedMeter
        self.alt.SetMiddleText("0")
        # Assign The Colour To The Center Text
        self.alt.SetMiddleTextColour(wx.WHITE)
        # Assign A Font To The Center Text
        self.alt.SetMiddleTextFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        # Set The Colour For The Hand Indicator
        self.alt.SetHandColour(wx.Colour(255, 255, 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!
        self.alt.DrawExternalArc(False)

        # Set The Current Value For The SpeedMeter
        self.alt.SetSpeedValue(0)

        #kompass
        self.com = SM.SpeedMeter(self.panel4,
                                 agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS
                                 | SM.SM_DRAW_MIDDLE_TEXT
                                 | SM.SM_DRAW_SECONDARY_TICKS,
                                 pos=(0, 0),
                                 size=(350, 250))

        # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!)
        self.com.SetAngleRange(-pi, pi)

        # Create The Intervals That Will Divide Our SpeedMeter In Sectors
        intervals = range(0, 9, 1)
        self.com.SetIntervals(intervals)

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

        # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
        ticks = ["W", "WS", "N", "NE", "E", "EW", "S", "SN", ""]
        self.com.SetTicks(ticks)
        # Set The Ticks/Tick Markers Colour
        self.com.SetTicksColour(wx.GREEN)
        # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
        self.com.SetNumberOfSecondaryTicks(2)

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

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

        # Set The Colour For The Hand Indicator
        self.com.SetHandColour(wx.Colour(255, 0, 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!
        self.com.DrawExternalArc(False)

        # Set The Current Value For The SpeedMeter
        self.com.SetSpeedValue(2)

        #zegar led pokazujacy czas lotu
        self.led = gizmos.LEDNumberCtrl(self.panel1,
                                        -1,
                                        pos=(10, 30),
                                        size=(350, 80),
                                        style=gizmos.LED_ALIGN_LEFT)
        # default colours are green on black
        self.led.SetBackgroundColour("black")
        self.led.SetForegroundColour("yellow")
        #self.on_timer(None)
        self.timer = wx.Timer(self, -1)
        # update clock digits every second (1000ms)
        self.timer.Start(1000)
        MyFrame.start_flight(self, time.time())
        self.Bind(wx.EVT_TIMER, self.since_start)

        #wywolanie obiektu plane i wystartowanie jako watku, czyli wlaczenie symulatoa
        self.plane = Plane(self, saver)
        self.plane.start()
Ejemplo n.º 4
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((400, 349))
        self.SetTitle("wx.lib.agw.speedmeter example")
        
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        
        self.panel_1 = wx.Panel(self, wx.ID_ANY)
        sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
        
        sizer_2 = wx.BoxSizer(wx.VERTICAL)
        
        #################################################################
        # the custom widget SpeedMeter:
        # we use the following styles:
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between the Main Ticks (Intervals)
        self.speed_meter = SM.SpeedMeter(self.panel_1, wx.ID_ANY, agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS)
        # see also extra properties
        
        intervals = list(range(0, 201, 20))
        self.speed_meter.SetIntervals(intervals)
        
        self.speed_meter.SetIntervalColours([wx.BLACK]*10)
        
        # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
        ticks = [str(interval) for interval in intervals]
        self.speed_meter.SetTicks(ticks)
        
        # 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!
        self.speed_meter.DrawExternalArc(False)
        #################################################################
        self.speed_meter.SetAngleRange(-pi/6, 7*pi/6)
        self.speed_meter.SetHandColour(wx.Colour(255, 50, 0))
        self.speed_meter.SetIntervalColours([wx.BLACK]*10)
        self.speed_meter.SetMiddleText("Km/h")
        self.speed_meter.SetMiddleTextColour(wx.WHITE)
        self.speed_meter.SetMiddleTextFont(wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
        self.speed_meter.SetSpeedValue(44)
        self.speed_meter.SetTicksColour(wx.WHITE)
        self.speed_meter.SetTicksFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
        sizer_2.Add(self.speed_meter, 1, wx.ALL | wx.EXPAND, 3)
        
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_2.Add(sizer_3, 0, wx.EXPAND, 0)
        
        label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "Drag this:")
        sizer_3.Add(label_1, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        
        self.slider_1 = wx.Slider(self.panel_1, wx.ID_ANY, 44, 0, 200)
        sizer_3.Add(self.slider_1, 1, wx.EXPAND, 0)
        
        self.panel_1.SetSizer(sizer_2)
        
        self.SetSizer(sizer_1)
        
        self.Layout()

        self.Bind(wx.EVT_COMMAND_SCROLL, lambda event: self.speed_meter.SetSpeedValue(event.GetEventObject().GetValue()), self.slider_1)
Ejemplo n.º 5
0
    def __init__(self, parent):
        # ----------------------------------------------------------------------
        # Images are either in directory of the .py or embedded in .exe
        # ----------------------------------------------------------------------
        if getattr(sys, 'frozen', False):
            dirname = sys._MEIPASS
        else:
            dirname = os.path.dirname(__file__)

        FortiusAnt_ico = os.path.join(dirname, "FortiusAnt.ico")
        FortiusAnt_jpg = os.path.join(dirname, "FortiusAnt.jpg")
        Heart_jpg = os.path.join(dirname, "Heart.jpg")

        # ----------------------------------------------------------------------
        # Default initial actions, bind functions to frame
        # ----------------------------------------------------------------------
        wx.Frame.__init__(self, parent, -1, WindowTitle, \
               style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))

        try:
            ico = wx.Icon(FortiusAnt_ico, wx.BITMAP_TYPE_ICO)
            self.SetIcon(ico)
        except:
            print('Cannot load ' + FortiusAnt_ico)
            pass

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_PAINT, self.OnPaint)  # Draw the bitmap
        self.Iconize(False)  # un-iconize
        #       print(self.GetPosition())
        #       self.Center()                                      # It does not center the frame on the screen...
        #       print(self.GetPosition())

        if True:
            TIMER_ID = 250
            self.timer = wx.Timer(self, TIMER_ID)
            self.Bind(wx.EVT_TIMER, self.OnTimer)
            self.timer.Start(250)

        # ----------------------------------------------------------------------
# Thread handling
# ----------------------------------------------------------------------
        self.RunningSwitch = False
        self.CloseButtonPressed = False

        # ----------------------------------------------------------------------
        # Load Background image
        # ----------------------------------------------------------------------
        self.BackgroundBitmap = False
        BitmapW = 900
        BitmapH = 600
        try:
            self.BackgroundBitmap = wx.Bitmap(
                FortiusAnt_jpg)  # Image on the window background
            BitmapW = self.BackgroundBitmap.Size.GetWidth()
            BitmapH = self.BackgroundBitmap.Size.GetHeight()
        except:
            print('Cannot load ' + FortiusAnt_jpg)
        # ----------------------------------------------------------------------
# Load HeartRate image
# ----------------------------------------------------------------------
        self.HeartRate = 123
        self.HeartRateWH = 40
        # 2020-02-07    # 2020-01-25
        self.HeartRateX = 25  # BitmapW - 25 - self.HeartRateWH
        self.HeartRateY = BitmapH - 50 - self.HeartRateWH
        self.HeartRateImage = False
        try:
            self.HeartRateImage = wx.Image(Heart_jpg)  # HeartRate

            img = self.HeartRateImage.Scale(36, 36, wx.IMAGE_QUALITY_HIGH)
            self.bmp36x36 = wx.Bitmap(img)

            img = self.HeartRateImage.Scale(40, 40, wx.IMAGE_QUALITY_HIGH)
            self.bmp40x40 = wx.Bitmap(img)

        except:
            # print('Cannot load ' + Heart_jpg)
            pass
        # ----------------------------------------------------------------------
# Calculate Width and X
# ----------------------------------------------------------------------
#
# x [button] x [speed] x [revs] x [power] x
#
        Margin = 4
        ButtonX = Margin
        ButtonW = 80

        SpeedWH = int((BitmapW - ButtonW - 5 * Margin) /
                      3)  # width/height equal (square)
        RevsWH = SpeedWH
        PowerWH = SpeedWH

        SpeedX = ButtonX + ButtonW + Margin
        RevsX = SpeedX + SpeedWH + Margin
        PowerX = RevsX + RevsWH + Margin

        SpeedY = Margin
        RevsY = Margin
        PowerY = Margin

        BitmapX = 0
        BitmapY = 0

        self.SetSize(BitmapX + BitmapW + 15, BitmapY + BitmapH)

        # ----------------------------------------------------------------------
        # Speedometer values and colours
        # ----------------------------------------------------------------------
        MiddleTextFontSize = 10
        TicksFontSize = 10
        bg = wx.Colour(220, 220,
                       220)  # Background colour for self.Speedometers
        colorTacxFortius = wx.Colour(120, 1940, 227)

        # ----------------------------------------------------------------------
        # self.Speedometer
        # ----------------------------------------------------------------------
        if True:
            self.Speed = SM.SpeedMeter(
                self,
                agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_GRADIENT
                | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS)
            self.Speed.SetSize(SpeedX, SpeedY, SpeedWH, SpeedWH)

            self.Speed.SetSpeedBackground(bg)
            self.Speed.SetFirstGradientColour(
                colorTacxFortius)  # Colours for SM_DRAW_GRADIENT
            self.Speed.SetSecondGradientColour(wx.WHITE)
            self.Speed.DrawExternalArc(
                True)  # Do (Not) Draw The External (Container) Arc.
            self.Speed.SetArcColour(wx.BLACK)

            self.Speed.SetAngleRange(
                -math.pi / 6, 7 * math.pi / 6
            )  # Set The Region Of Existence Of self.SpeedMeter (Always In Radians!!!!)
            self.Speed.SetHandColour(wx.Colour(
                255, 50, 0))  # Set The Colour For The Hand Indicator

            self.Speed.SetMiddleText(
                "Speed")  # Set The Text In The Center Of self.SpeedMeter
            self.Speed.SetMiddleTextColour(
                wx.BLUE)  # Assign The Colour To The Center Text
            self.Speed.SetMiddleTextFont(
                wx.Font(MiddleTextFontSize, wx.FONTFAMILY_SWISS,
                        wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
            # Assign A Font To The Center Text

            Min = 0
            NrIntervals = 10
            Step = 5
            Max = Min + Step * NrIntervals
            self.SpeedMax = Max

            intervals = range(
                Min, Max + 1, Step
            )  # Create The Intervals That Will Divide Our self.SpeedMeter In Sectors
            self.Speed.SetIntervals(intervals)

            #           colours = [wx.BLUE] * NrIntervals                               # Assign The Same Colours To All Sectors (We Simulate A Car Control For self.Speed)
            #           self.Speed.SetIntervalColours(colours)

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

            self.Speed.SetTicksFont(
                wx.Font(TicksFontSize, wx.FONTFAMILY_SWISS,
                        wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
            # Set The Font For The Ticks Markers

        # ----------------------------------------------------------------------
# self.Revs
# ----------------------------------------------------------------------
        if True:
            # SM_ROTATE_TEXT            Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions.
            # SM_DRAW_SECTORS           Different intervals are painted in differend colours (every sector of the circle has its own colour).
            # SM_DRAW_PARTIAL_SECTORS   Every interval has its own colour, but only a circle corona is painted near the ticks.
            # SM_DRAW_HAND              The hand (arrow indicator) is drawn.
            # SM_DRAW_SHADOW            A shadow for the hand is drawn.
            # SM_DRAW_PARTIAL_FILLER    A circle corona that follows the hand position is drawn near the ticks.
            # SM_DRAW_SECONDARY_TICKS   Intermediate (smaller) ticks are drawn between principal ticks.
            # SM_DRAW_MIDDLE_TEXT       Some text is printed in the middle of the control near the center.
            # SM_DRAW_MIDDLE_ICON       An icon is drawn in the middle of the control near the center.
            # SM_DRAW_GRADIENT          A gradient of colours will fill the control.
            # SM_DRAW_FANCY_TICKS       With this style you can use xml tags to create some custom text and draw it at the ticks position. See lib.fancytext for the tags.
            self.Revs = SM.SpeedMeter(
                self,
                agwStyle=SM.SM_DRAW_GRADIENT | SM.SM_DRAW_PARTIAL_SECTORS
                | SM.SM_DRAW_HAND | SM.SM_DRAW_SECONDARY_TICKS
                | SM.SM_DRAW_MIDDLE_TEXT)
            self.Revs.SetSize(RevsX, RevsY, RevsWH,
                              RevsWH)  # x,y and width, height

            self.Revs.SetSpeedBackground(bg)
            self.Revs.SetFirstGradientColour(
                wx.BLUE)  # Colours for SM_DRAW_GRADIENT
            self.Revs.SetSecondGradientColour(wx.WHITE)
            self.Revs.DrawExternalArc(
                True)  # Do (Not) Draw The External (Container) Arc.
            self.Revs.SetArcColour(wx.BLUE)

            self.Revs.SetAngleRange(
                -math.pi / 6, 7 * math.pi / 6
            )  # Set The Region Of Existence Of self.RevsMeter (Always In Radians!!!!)
            self.Revs.SetHandColour(wx.Colour(
                255, 50, 0))  # Set The Colour For The Hand Indicator

            self.Revs.SetMiddleText(
                "Cadence")  # Set The Text In The Center Of self.RevsMeter
            self.Revs.SetMiddleTextColour(
                wx.BLUE)  # Assign The Colour To The Center Text
            self.Revs.SetMiddleTextFont(
                wx.Font(MiddleTextFontSize, wx.FONTFAMILY_SWISS,
                        wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
            # Assign A Font To The Center Text

            Min = 0
            NrIntervals = 12
            Step = 10  # For me, 120/min is enough
            Max = Min + Step * NrIntervals
            self.RevsMax = Max

            intervals = range(
                Min, Max + 1, Step
            )  # Create The Intervals That Will Divide Our self.SpeedMeter In Sectors
            self.Revs.SetIntervals(intervals)

            colours = [wx.BLACK]  # Assign colours, per range
            i = 2
            while i <= NrIntervals:
                if i * Step <= 40:  # <= 40 is special case for resistance calculation
                    colours.append(wx.BLACK)
                elif i * Step <= 60:
                    colours.append(wx.BLUE)
                elif i * Step <= 90:
                    colours.append(wx.GREEN)
                elif i * Step <= 110:
                    colours.append(wx.Colour(244, 144, 44))  # Orange
                else:
                    colours.append(wx.RED)
                i += 1
            self.Revs.SetIntervalColours(colours)

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

            self.Revs.SetTicksFont(
                wx.Font(TicksFontSize, wx.FONTFAMILY_SWISS,
                        wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
            # Set The Font For The Ticks Markers

        # ----------------------------------------------------------------------
# self.Power
# ----------------------------------------------------------------------
        if True:
            self.Power = SM.SpeedMeter(
                self,
                agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_GRADIENT
                | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS)
            self.Power.SetSize(PowerX, PowerY, PowerWH,
                               PowerWH)  # x,y and width, height

            self.Power.SetSpeedBackground(bg)
            self.Power.SetFirstGradientColour(
                colorTacxFortius)  # Colours for SM_DRAW_GRADIENT
            self.Power.SetSecondGradientColour(wx.WHITE)
            self.Power.DrawExternalArc(
                True)  # Do (Not) Draw The External (Container) Arc.
            self.Power.SetArcColour(wx.BLACK)

            self.Power.SetAngleRange(
                -math.pi / 6, 7 * math.pi / 6
            )  # Set The Region Of Existence Of self.PowerMeter (Always In Radians!!!!)
            self.Power.SetHandColour(wx.Colour(
                255, 50, 0))  # Set The Colour For The Hand Indicator

            self.Power.SetMiddleText(
                "Power")  # Set The Text In The Center Of self.PowerMeter
            self.Power.SetMiddleTextColour(
                wx.BLUE)  # Assign The Colour To The Center Text
            self.Power.SetMiddleTextFont(
                wx.Font(MiddleTextFontSize, wx.FONTFAMILY_SWISS,
                        wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
            # Assign A Font To The Center Text

            Min = 0
            NrIntervals = 10
            Step = 40
            Max = Min + Step * NrIntervals
            self.PowerMax = Max
            self.PowerArray = numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 0,
                                           0])  # Array for running everage

            intervals = range(
                Min, Max + 1, Step
            )  # Create The Intervals That Will Divide Our self.SpeedMeter In Sectors
            self.Power.SetIntervals(intervals)

            #           colours = [wx.BLACK] * NrIntervals                              # Assign The Same Colours To All Sectors (We Simulate A Car Control For self.Speed)
            #           self.Power.SetIntervalColours(colours)

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

            self.Power.SetTicksFont(
                wx.Font(TicksFontSize, wx.FONTFAMILY_SWISS,
                        wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
            # Set The Font For The Ticks Markers

        # ----------------------------------------------------------------------
# Font sizing for all measurements
# 2020-02-07: LargeTexts implemented
# ----------------------------------------------------------------------
        if LargeTexts:
            TextCtrlFont = wx.Font(24, wx.FONTFAMILY_SWISS,
                                   wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
            TextCtrlH = 40
            TextCtrlW = int(SpeedWH / 2)
        else:
            TextCtrlFont = wx.Font(12, wx.FONTFAMILY_SWISS,
                                   wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
            TextCtrlH = 25
            TextCtrlW = int(SpeedWH / 2)

        # ----------------------------------------------------------------------
# self.Speed label & text
# ----------------------------------------------------------------------
        self.txtSpeed = wx.TextCtrl(self,
                                    value="99.9 km/h",
                                    size=(int(TextCtrlW * 1.2), TextCtrlH),
                                    style=wx.TE_CENTER | wx.TE_READONLY
                                    | wx.BORDER_NONE)
        self.txtSpeed.SetBackgroundColour(bg)
        self.txtSpeed.SetPosition((int(self.Speed.Position[0] + (self.Speed.Size[0] - self.txtSpeed.Size[0])/2), \
                                    self.Speed.Position[1] + self.Speed.Size[1] - 2 * self.txtSpeed.Size[1]))

        # ----------------------------------------------------------------------
        # self.Revs
        # ----------------------------------------------------------------------
        self.txtRevs = wx.TextCtrl(self,
                                   value="999/min",
                                   size=(int(TextCtrlW * 1.2), TextCtrlH),
                                   style=wx.TE_CENTER | wx.TE_READONLY
                                   | wx.BORDER_NONE)
        self.txtRevs.SetBackgroundColour(bg)
        self.txtRevs.SetPosition((int(self.Revs.Position[0] + (self.Revs.Size[0] - self.txtRevs.Size[0])/2), \
                                    self.Revs.Position[1] + self.Revs.Size[1] - 2 * self.txtRevs.Size[1]))

        # ----------------------------------------------------------------------
        # self.Power
        # ----------------------------------------------------------------------
        self.txtPower = wx.TextCtrl(self,
                                    value="999 Watt",
                                    size=(TextCtrlW, TextCtrlH),
                                    style=wx.TE_CENTER | wx.TE_READONLY
                                    | wx.BORDER_NONE)
        self.txtPower.SetBackgroundColour(bg)
        self.txtPower.SetPosition((int(self.Power.Position[0] + (self.Power.Size[0] - self.txtPower.Size[0])/2), \
                                    self.Power.Position[1] + self.Power.Size[1] - 2 * self.txtPower.Size[1]))

        self.txtTarget = wx.TextCtrl(self,
                                     value="Target=999 Watt",
                                     size=(int(TextCtrlW * 1.3), TextCtrlH),
                                     style=wx.TE_LEFT | wx.TE_READONLY
                                     | wx.BORDER_NONE)
        self.txtTarget.SetBackgroundColour(bg)
        self.txtTarget.SetPosition((self.Power.Position[0], \
                                    self.Power.Position[1] + self.Power.Size[1] - self.txtTarget.Size[1]))

        self.txtTacx = wx.TextCtrl(self,
                                   value="Tacx=9999",
                                   size=(int(TextCtrlW * 0.7), TextCtrlH),
                                   style=wx.TE_RIGHT | wx.TE_READONLY
                                   | wx.BORDER_NONE)
        self.txtTacx.SetBackgroundColour(bg)
        self.txtTacx.SetPosition((self.Power.Position[0] + self.Power.Size[0] - self.txtTacx.Size[0], \
                                    self.Power.Position[1] + self.Power.Size[1] - self.txtTacx.Size[1]))

        # ----------------------------------------------------------------------
        # USB Trainer
        # ----------------------------------------------------------------------
        self.txtUsbTrainer = wx.TextCtrl(self,
                                         value="txtUsbTrainer",
                                         size=(10, -1),
                                         style=wx.TE_LEFT | wx.TE_READONLY)
        self.txtUsbTrainer.SetSize(
            (self.Speed.Position[0] + self.Speed.Size[0] - Margin, -1))
        self.txtUsbTrainer.SetPosition(
            (Margin, self.Power.Position[1] + self.Power.Size[1] + 5))

        # ----------------------------------------------------------------------
        # ANT Dongle
        # ----------------------------------------------------------------------
        self.txtAntDongle = wx.TextCtrl(self,
                                        value="txtAntDongle",
                                        size=(10, -1),
                                        style=wx.TE_LEFT | wx.TE_READONLY)
        self.txtAntDongle.SetSize((self.txtUsbTrainer.Size[0], -1))
        self.txtAntDongle.SetPosition(
            (Margin,
             self.txtUsbTrainer.Position[1] + self.txtUsbTrainer.Size[1] + 5))

        # ----------------------------------------------------------------------
        # self.Power factor
        # ----------------------------------------------------------------------
        self.txtPowerFactor = wx.TextCtrl(self,
                                          value="txtPowerFactor",
                                          size=(10, -1),
                                          style=wx.TE_LEFT | wx.TE_READONLY)
        self.txtPowerFactor.SetSize((self.txtUsbTrainer.Size[0], -1))
        self.txtPowerFactor.SetPosition(
            (Margin,
             self.txtAntDongle.Position[1] + self.txtAntDongle.Size[1] + 5))

        # ----------------------------------------------------------------------
        # self.HeartRate
        # ----------------------------------------------------------------------
        self.txtHeartRate = wx.TextCtrl(self,
                                        value="123",
                                        size=(int(self.HeartRateWH * 2),
                                              TextCtrlH),
                                        style=wx.TE_CENTER | wx.TE_READONLY)
        self.txtHeartRate.SetBackgroundColour(bg)
        self.txtHeartRate.SetPosition(( self.HeartRateX - int((self.txtHeartRate.Size[0] - self.HeartRateWH)/2), \
                                        self.HeartRateY - self.txtHeartRate.Size[1] - 5))

        # ----------------------------------------------------------------------
        # Font setting for all measurements
        # ----------------------------------------------------------------------
        self.txtSpeed.SetFont(TextCtrlFont)
        self.txtRevs.SetFont(TextCtrlFont)
        self.txtPower.SetFont(TextCtrlFont)
        self.txtTarget.SetFont(TextCtrlFont)
        self.txtTacx.SetFont(TextCtrlFont)
        self.txtHeartRate.SetFont(TextCtrlFont)

        # ----------------------------------------------------------------------
        # Buttons
        # ----------------------------------------------------------------------
        self.btnLocateHW = wx.Button(self,
                                     label="Locate HW",
                                     size=(ButtonW, -1))
        self.btnLocateHW.SetPosition((ButtonX, self.btnLocateHW.Size[1]))
        self.btnLocateHW.SetFocus()
        self.Bind(wx.EVT_BUTTON, self.OnClick_btnLocateHW, self.btnLocateHW)

        self.btnRunoff = wx.Button(self, label="Runoff", size=(ButtonW, -1))
        self.btnRunoff.SetPosition(
            (ButtonX, self.btnLocateHW.Position[1] + self.btnLocateHW.Size[1]))
        self.btnRunoff.Disable()
        self.Bind(wx.EVT_BUTTON, self.OnClick_btnRunoff, self.btnRunoff)

        self.btnStart = wx.Button(self, label="Start", size=(ButtonW, -1))
        self.btnStart.SetPosition(
            (ButtonX, self.btnRunoff.Position[1] + self.btnRunoff.Size[1]))
        self.btnStart.Disable()
        self.Bind(wx.EVT_BUTTON, self.OnClick_btnStart, self.btnStart)

        self.btnStop = wx.Button(self, label="Stop", size=(ButtonW, -1))
        self.btnStop.SetPosition(
            (ButtonX, self.btnStart.Position[1] + self.btnStart.Size[1]))
        self.btnStop.Disable()
        self.Bind(wx.EVT_BUTTON, self.OnClick_btnStop, self.btnStop)

        # ----------------------------------------------------------------------
        # Set initial values
        # ----------------------------------------------------------------------
        self.ResetValues()
        self.SetMessages(Tacx="Tacx USB Trainer")
        self.SetMessages(Dongle="ANT+ Dongle")
        self.SetMessages(Factor=1)