當前位置: 首頁>>代碼示例>>Python>>正文


Python wx.PaintDC方法代碼示例

本文整理匯總了Python中wx.PaintDC方法的典型用法代碼示例。如果您正苦於以下問題:Python wx.PaintDC方法的具體用法?Python wx.PaintDC怎麽用?Python wx.PaintDC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wx的用法示例。


在下文中一共展示了wx.PaintDC方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: gui_repaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def gui_repaint(self, drawDC=None, origin='WX'):
        """
        Performs update of the displayed image on the GUI canvas, using the
        supplied wx.PaintDC device context.

        The 'WXAgg' backend sets origin accordingly.
        """
        DEBUG_MSG("gui_repaint()", 1, self)
        if self.IsShownOnScreen():
            if not drawDC:
                # not called from OnPaint use a ClientDC
                drawDC = wx.ClientDC(self)

            # following is for 'WX' backend on Windows
            # the bitmap can not be in use by another DC,
            # see GraphicsContextWx._cache
            if wx.Platform == '__WXMSW__' and origin == 'WX':
                img = self.bitmap.ConvertToImage()
                bmp = img.ConvertToBitmap()
                drawDC.DrawBitmap(bmp, 0, 0)
            else:
                drawDC.DrawBitmap(self.bitmap, 0, 0) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:24,代碼來源:backend_wx.py

示例2: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, evt):
        dc = wx.PaintDC(self)
        # Hiding bitmap widgets, probably unnecessary
        # for st_bmp in self.preview_img_list:
            # st_bmp.Hide()
        
        # Canvas drawing
        if (not self.config_mode
            and not self.use_multi_image
            and self.current_preview_images):
            # print("Drawing canvas: ", self.config_mode, not self.use_multi_image, self.current_preview_images)
            self.draw_canvas(dc)
        else:
            # print("Skipping canvas: ", self.config_mode, not self.use_multi_image, self.current_preview_images)
            self.draw_canvas(dc, False)

        # Display drawing
        if self.config_mode:
            self.draw_shapes(dc)
        else:
            self.draw_st_bmps(dc) 
開發者ID:hhannine,項目名稱:superpaper,代碼行數:23,代碼來源:gui.py

示例3: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, evt):
        # this doesnt appear to work at all...
        width,height = self.GetSizeTuple()

        # get drawing canvas
        dc = wx.PaintDC(self)

        dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
        dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))

        # build rect
        size = max(2, (width-10)*self.progress)
        rect = wx.Rect(5,8, size ,5)

        # draw rect
        dc.Clear()
        dc.BeginDrawing()
        dc.DrawRoundedRectangleRect(rect, 2)
        dc.EndDrawing() 
開發者ID:collingreen,項目名稱:chronolapse,代碼行數:21,代碼來源:chronolapse.py

示例4: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, evt):
        # this doesnt appear to work at all...

        width,height = self.GetSizeTuple()

        # get drawing shit
        dc = wx.PaintDC(self)

        dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
        dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))

        # build rect
        size = max(2, (width-10)*self.progress)
        rect = wx.Rect(5,8, size ,5)

        # draw rect
        dc.Clear()
        dc.BeginDrawing()
        dc.DrawRoundedRectangleRect(rect, 2)
        dc.EndDrawing()
# end wxGlade 
開發者ID:collingreen,項目名稱:chronolapse,代碼行數:23,代碼來源:chronolapsegui.py

示例5: DotifyOnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def DotifyOnPaint(self, event):
        self.dc = wx.PaintDC(self)
        self.dc.SetFont(self.GetFont())

        width = self.GetSize().width
        str_width = self.dc.GetTextExtent(self._string)[0]
        max_width = self.dc.GetTextExtent(self.label)[0]

        if width >= max_width:
            self._string = self.label
        elif width != str_width:
            string = self.dotdotdot(self.label, width, max_width)
            self._string = string
        wx.StaticText.SetLabel(self, self._string)

        event.Skip() 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:18,代碼來源:__init__.py

示例6: on_paint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def on_paint(self, event):
        dc = wx.PaintDC(self.widget)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.BLACK_PEN)
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()
        w, h = self.widget.GetClientSize()
        dc.DrawLine(0, 0, w, h)
        dc.DrawLine(w, 0, 0, h)
        text = _('Custom Widget: %s') % self.instance_class
        tw, th = dc.GetTextExtent(text)
        x = (w - tw)//2
        y = (h - th)//2
        dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 0, wx.TRANSPARENT))
        dc.DrawRectangle(x-1, y-1, tw+2, th+2)
        dc.DrawText(text, x, y) 
開發者ID:wxGlade,項目名稱:wxGlade,代碼行數:18,代碼來源:custom_widget.py

示例7: on_paint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def on_paint(self, event):
        dc = wx.PaintDC(self.widget)
        brush = wx.TheBrushList.FindOrCreateBrush( self.widget.GetBackgroundColour() )
        dc.SetBrush(brush)
        dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 1, wx.SOLID))
        dc.SetBackground(brush)
        dc.Clear()
        w, h = self.widget.GetClientSize()
        dc.DrawLine(0, 0, w, h)
        dc.DrawLine(w, 0, 0, h)
        text = _('Spacer')
        tw, th = dc.GetTextExtent(text)
        x = (w - tw) // 2
        y = (h - th) // 2
        dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 0, wx.TRANSPARENT))
        dc.DrawRectangle(x-1, y-1, tw+2, th+2)
        dc.DrawText(text, x, y) 
開發者ID:wxGlade,項目名稱:wxGlade,代碼行數:19,代碼來源:spacer.py

示例8: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, evt):
            dc = wx.PaintDC(self)
            inset = (20, 20, 20, 20)
            rect = [inset[0], inset[1], self.GetSize().width-(inset[0]+inset[2]), self.GetSize().height-(inset[1]+inset[3])]

            # Calculate exactly how high the wrapped is going to be and put a frame around it.
            dc.SetFont(self.font)
            dc.SetPen(wx.RED_PEN)
            rect[3] = WordWrapRenderer.CalculateHeight(dc, self.text, rect[2])
            dc.DrawRectangle(*rect)
            WordWrapRenderer.DrawString(dc, self.text, rect, wx.ALIGN_LEFT)
            #WordWrapRenderer.DrawTruncatedString(dc, self.text, rect, wx.ALIGN_CENTER_HORIZONTAL,s ellipse=wx.CENTER)

            #bmp = wx.EmptyBitmap(rect[0]+rect[2], rect[1]+rect[3])
            #mdc = wx.MemoryDC(bmp)
            #mdc.SetBackground(wx.Brush("white"))
            #mdc.Clear()
            #mdc.SetFont(self.font)
            #mdc.SetPen(wx.RED_PEN)
            #rect[3] = WordWrapRenderer.CalculateHeight(mdc, self.text, rect[2])
            #mdc.DrawRectangle(*rect)
            #WordWrapRenderer.DrawString(mdc, self.text, rect, wx.ALIGN_LEFT)
            #del mdc
            #dc = wx.ScreenDC()
            #dc.DrawBitmap(bmp, 20, 20) 
開發者ID:JackonYang,項目名稱:bookhub,代碼行數:27,代碼來源:WordWrapRenderer.py

示例9: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, event):
        dc = wx.PaintDC(self)

        dc.SetFont(self.font)
        dc.SetTextForeground(self.textColor)

        if self.pic.Ok():
            dc.DrawBitmap(self.pic, 0, 0, False)

        util.drawText(dc, "Version %s" % (misc.version),
                      200, 170, util.ALIGN_RIGHT)

        util.drawText(dc, "http://www.trelby.org/", 200, 185, util.ALIGN_RIGHT)

        if self.quote:
            dc.SetFont(self.sourceFont)
            dc.DrawText(self.quote.source, 50, 280)

            dc.SetFont(self.quoteFont)

            for i,line in enumerate(self.quote.lines):
                x = 10
                y = 260 - (len(self.quote.lines) - i - 1) * 17

                if i == 0:
                    dc.DrawText(u"“", x - 5, y)

                if i == (len(self.quote.lines) - 1):
                    line = line + u"”"

                dc.DrawText(line, x, y) 
開發者ID:trelby,項目名稱:trelby,代碼行數:33,代碼來源:splash.py

示例10: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, event):
        dc = wx.PaintDC(self)

        w, h = self.GetClientSizeTuple()
        br = wx.Brush(self.GetBackgroundColour())
        dc.SetBrush(br)
        dc.DrawRectangle(0, 0, w, h)

# Custom "exit fullscreen" button for our tab bar. Used so that we have
# full control over the button's size. 
開發者ID:trelby,項目名稱:trelby,代碼行數:12,代碼來源:misc.py

示例11: processPaintEvent

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def processPaintEvent(self, event):
        dc = wx.PaintDC(self)
        self.SetCurrent(self.context)
        if not self.GLinitialized:
            self.initGL()
            self.GLinitialized = True
        self.repaint() 
開發者ID:bmershon,項目名稱:laplacian-meshes,代碼行數:9,代碼來源:MeshCanvas.py

示例12: _on_paint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def _on_paint(self, event):
        """Push the MemoryDC bitmap to the displayed PaintDC."""
        dc = wx.PaintDC(self)
        dc.Blit(0, 0, self.dc_w, self.dc_h, self.mdc, 0, 0) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:6,代碼來源:wm_legend.py

示例13: _onPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def _onPaint(self, evt):
        """
        Called when wxPaintEvt is generated
        """

        DEBUG_MSG("_onPaint()", 1, self)
        drawDC = wx.PaintDC(self)
        if not self._isDrawn:
            self.draw(drawDC=drawDC)
        else:
            self.gui_repaint(drawDC=drawDC)
        evt.Skip() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:14,代碼來源:backend_wx.py

示例14: _onPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def _onPaint(self, evt):
        """
        Called when wxPaintEvt is generated
        """

        DEBUG_MSG("_onPaint()", 1, self)
        drawDC = wx.PaintDC(self)
        if not self._isDrawn:
            self.draw(drawDC=drawDC)
        else:
            self.gui_repaint(drawDC=drawDC)
        drawDC.Destroy() 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:14,代碼來源:backend_wx.py

示例15: OnPaint

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import PaintDC [as 別名]
def OnPaint(self, event):
        dc = wx.PaintDC(self)
        self.SetCurrent(self.context)       # <== this was missing when I wrote the book in 2015...
        if not self.init:
            self.InitGL()
            self.init = True
        self.OnDraw() 
開發者ID:PacktPublishing,項目名稱:Python-GUI-Programming-Cookbook-Second-Edition,代碼行數:9,代碼來源:import_OpenGL_cube_and_cone.py


注:本文中的wx.PaintDC方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。