Exemplo n.º 1
0
    def OnPaint(self, event: PaintEvent):
        """
        Callback.
        Refresh the screen when a paint event is issued by the system.

        @param event
        """
        dc = PaintDC(self)
        w, h = self.GetSize()
        mem = self.CreateDC(False, w, h)
        mem.SetBackground(Brush(self.GetBackgroundColour()))
        mem.Clear()
        self.Redraw(mem)

        if __version__ > "2.3.2":
            x, y = self.CalcUnscrolledPosition(0, 0)
            dc.Blit(0, 0, w, h, mem, x, y)
        else:
            dc.Blit(0, 0, w, h, mem, 0, 0)
Exemplo n.º 2
0
    def OnPaint(self, event: PaintEvent):
        """
        Refresh the screen when a paint event is issued by the system.

        Args:
            event:
        """
        dc = PaintDC(self)
        w, h = self.GetSize()
        mem = self.CreateDC(False, w, h)
        mem.SetBackground(Brush(self.GetBackgroundColour()))
        mem.Clear()

        x, y = self.CalcUnscrolledPosition(0, 0)
        #
        # self.clsLogger.warning(f'OnPaint - {w=}, {h=} {x=} {y=}')
        # Paint events don't seem to be generated when Pyut is built for deployment;  So code duplicated in .Redraw()
        #
        if self._prefs.backgroundGridEnabled is True:
            self._drawGrid(memDC=mem, width=w, height=h, startX=x, startY=y)
        self.Redraw(mem)

        dc.Blit(0, 0, w, h, mem, x, y)
Exemplo n.º 3
0
    def OnRefreshPanel(self, event):
        """
        Refresh dialog box

        """
        import time
        # constants
        backRed: int = 230
        backGreen: int = 255
        backBlue: int = 230  # Background color

        frontRed: int = 64
        frontGreen: int = 0
        frontBlue: int = 64  # Foreground color

        FADE_IN_LENGTH: int = 63
        self.logger.debug(f'Enter OnRefreshPanel')
        # Init memory buffer
        tdc: MemoryDC = MemoryDC()
        tdc.SelectObject(Bitmap(FrameWidth, FrameHeight))
        while not tdc.IsOk():
            time.sleep(0.05)
            tdc = MemoryDC()
            tdc.SelectObject(Bitmap(FrameWidth, FrameHeight))

        tdc.SetTextForeground(Colour(frontRed, frontGreen, frontBlue))
        tdc.SetBackground(
            Brush(Colour(backRed, backGreen, backBlue), BRUSHSTYLE_SOLID))
        tdc.Clear()
        font = tdc.GetFont()
        font.SetFamily(FONTFAMILY_MODERN)
        font.SetPointSize(12)
        tdc.SetFont(font)

        # Fade-in
        position = self.textPosition
        if position < FADE_IN_LENGTH:
            n = float(position) / float(FADE_IN_LENGTH)
            r = backRed - n * (backRed - frontRed)
            g = backGreen - n * (backGreen - frontGreen)
            b = backBlue - n * (backBlue - frontBlue)
            r = int(r)
            g = int(g)
            b = int(b)
            tdc.SetTextForeground(Colour(r, g, b))

        # Display text
        for j in range(1, len(self._textToShow)):
            # Draw text ?
            if position > FADE_IN_LENGTH:
                y = y0 + j * dy - (position - FADE_IN_LENGTH)
                if -dy < y < FrameHeight:
                    tdc.DrawText(self._textToShow[j], x0, y)
            else:  # Draw initial screen with fade in
                y = y0 + j * dy
                if -dy < y < FrameHeight:
                    tdc.DrawText(self._textToShow[j], x0, y)

        # Show memory dc to current dc (blit)
        dc = PaintDC(self._panel)
        dc.Blit(0, 0, FrameWidth, FrameHeight, tdc, 0, 0)
        tdc.SelectObject(NullBitmap)
        self.logger.debug(f'Exit OnRefreshPanel')