当前位置: 首页>>代码示例>>Python>>正文


Python wx.ClientDC方法代码示例

本文整理汇总了Python中wx.ClientDC方法的典型用法代码示例。如果您正苦于以下问题:Python wx.ClientDC方法的具体用法?Python wx.ClientDC怎么用?Python wx.ClientDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wx的用法示例。


在下文中一共展示了wx.ClientDC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gui_repaint

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def gui_repaint(self, drawDC=None):
        """
        Performs update of the displayed image on the GUI canvas, using the
        supplied device context.  If drawDC is None, a ClientDC will be used to
        redraw the image.
        """
        DEBUG_MSG("gui_repaint()", 1, self)
        if self.IsShownOnScreen():
            if drawDC is None:
                drawDC=wx.ClientDC(self)

            drawDC.BeginDrawing()
            drawDC.DrawBitmap(self.bitmap, 0, 0)
            drawDC.EndDrawing()
            #wx.GetApp().Yield()
        else:
            pass 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:backend_wx.py

示例2: gui_repaint

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [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

示例3: DoGetBestSize

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def DoGetBestSize(self):
        """
        Overridden base class virtual. Determines the best size of the
        button based on the label and bezel size.
        """

        label = self.GetLabel()
        if not label:
            return wx.Size(32, 32)
        
        dc = wx.ClientDC(self)
        dc.SetFont(self.GetFont())
        retWidth, retHeight = dc.GetTextExtent(label)
        
        width = int(max(retWidth, retHeight) * 1.5)
        return wx.Size(width, width) 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-577951.py

示例4: Wrap

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def Wrap(self, width):
        """
        This functions wraps the controls label so that each of its lines becomes at
        most `width` pixels wide if possible (the lines are broken at words boundaries
        so it might not be the case if words are too long).

        If `width` is negative, no wrapping is done.

        :param integer `width`: the maximum available width for the text, in pixels.

        :note: Note that this `width` is not necessarily the total width of the control,
         since a few pixels for the border (depending on the controls border style) may be added.
        """

        if width < 0:
            return

        self.Freeze()

        dc = wx.ClientDC(self)
        dc.SetFont(self.GetFont())
        text = wordwrap(self.label, width, dc)
        self.SetLabel(text, wrapped=True)

        self.Thaw() 
开发者ID:chriskiehl,项目名称:Gooey,代码行数:27,代码来源:wrapped_static_text.py

示例5: set_default_widths

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def set_default_widths(self):
        # must be called before *any* data is put into the control.
        sample_data = {}
        for name in self.column_order:
            sample_data[name] = self.columns[name].sample_data
        sample_row = BTListRow(None, sample_data)

        self.InsertRow(-1, sample_row)
        for name in self.column_order:
            column = self.columns[name]
            if name in self.enabled_columns:
                self.SetColumnWidth(column.GetColumn(), wx.LIST_AUTOSIZE)
                column.width = self.GetColumnWidth(column.GetColumn())
            dc = wx.ClientDC(self)
            header_width = dc.GetTextExtent(column.GetText())[0]
            header_width += 4 # arbitrary allowance for header decorations
            column.width = max(column.width, header_width)
            if name in self.enabled_columns:
                self.SetColumnWidth(column.GetColumn(), column.width)
        self.default_rect = self.GetItemRect(0)
        self.DeleteRow(-1) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:23,代码来源:ListCtrl.py

示例6: OnAboutClick

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def OnAboutClick(self, event=None):
        info = wx.adv.AboutDialogInfo()
        info.SetName('RS485 MODBUS GUI')
        info.SetVersion('v{}'.format(relay_boards.VERSION))
        info.SetCopyright('(C) 2018 by Erriez')
        ico_path = resource_path('images/R421A08.ico')
        if os.path.exists(ico_path):
            info.SetIcon(wx.Icon(ico_path))
        info.SetDescription(wordwrap(
            "This is an example application to control a R421A08 relay board using wxPython!",
            350, wx.ClientDC(self)))
        info.SetWebSite(SOURCE_URL,
                        "Source & Documentation")
        info.AddDeveloper('Erriez')
        info.SetLicense(wordwrap("MIT License: Completely and totally open source!", 500,
                                 wx.ClientDC(self)))
        wx.adv.AboutBox(info)


# --------------------------------------------------------------------------------------------------
# Relay panel
# -------------------------------------------------------------------------------------------------- 
开发者ID:Erriez,项目名称:R421A08-rs485-8ch-relay-board,代码行数:24,代码来源:relay_board_gui.py

示例7: OnMenuAbout

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def OnMenuAbout(self, event):
        """
            Display an About Dialog
        :param event:
        :return:
        """
        info = wx.adv.AboutDialogInfo()
        info.SetName('RS485 MODBUS GUI')
        info.SetVersion('v{}'.format(relay_modbus.VERSION))
        info.SetCopyright('(C) 2018 by Erriez')
        ico_path = resource_path('images/modbus.ico')
        if os.path.exists(ico_path):
            info.SetIcon(wx.Icon(ico_path))
        info.SetDescription(wordwrap(
            "This is an example application to monitor and send MODBUS commands using wxPython!",
            350, wx.ClientDC(self)))
        info.SetWebSite("https://github.com/Erriez/R421A08-rs485-8ch-relay-board",
                        "Source & Documentation")
        info.AddDeveloper('Erriez')
        info.SetLicense(wordwrap("MIT License: Completely and totally open source!", 500,
                                 wx.ClientDC(self)))
        # Then we call wx.AboutBox giving it that info object
        wx.adv.AboutBox(info) 
开发者ID:Erriez,项目名称:R421A08-rs485-8ch-relay-board,代码行数:25,代码来源:relay_modbus_gui.py

示例8: draw_rubberband

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            if wxc.is_phoenix:
                dc.DrawRectangle(self._rect)
            else:
                dc.DrawRectangleRect(self._rect) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:20,代码来源:backend_wx.py

示例9: OnEraseBackground

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def OnEraseBackground(self, evt):
        """Add a picture to the background"""
        dc = evt.GetDC()
        if not dc:
            dc = wx.ClientDC(self)
            rect = self.GetUpdateRegion().GetBox()
            dc.SetClippingRect(rect)
        dc.Clear()
        bmp = wx.Bitmap(self.img_path)
        dc.DrawBitmap(bmp, 0, 0) 
开发者ID:jantman,项目名称:python-wifi-survey-heatmap,代码行数:12,代码来源:ui.py

示例10: on_paint

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def on_paint(self, event=None):
        dc = wx.ClientDC(self)
        for p in self.survey_points:
            p.draw(dc) 
开发者ID:jantman,项目名称:python-wifi-survey-heatmap,代码行数:6,代码来源:ui.py

示例11: draw_rubberband

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def draw_rubberband(self, event, x0, y0, x1, y1):
        'adapted from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744'
        canvas = self.canvas
        dc =wx.ClientDC(canvas)

        # Set logical function to XOR for rubberbanding
        dc.SetLogicalFunction(wx.XOR)

        # Set dc brush and pen
        # Here I set brush and pen to white and grey respectively
        # You can set it to your own choices

        # The brush setting is not really needed since we
        # dont do any filling of the dc. It is set just for
        # the sake of completion.

        wbrush =wx.Brush(wx.Colour(255,255,255), wx.TRANSPARENT)
        wpen =wx.Pen(wx.Colour(200, 200, 200), 1, wx.SOLID)
        dc.SetBrush(wbrush)
        dc.SetPen(wpen)


        dc.ResetBoundingBox()
        dc.BeginDrawing()
        height = self.canvas.figure.bbox.height
        y1 = height - y1
        y0 = height - y0

        if y1<y0: y0, y1 = y1, y0
        if x1<y0: x0, x1 = x1, x0

        w = x1 - x0
        h = y1 - y0

        rect = int(x0), int(y0), int(w), int(h)
        try: lastrect = self.lastrect
        except AttributeError: pass
        else: dc.DrawRectangle(*lastrect)  #erase last
        self.lastrect = rect
        dc.DrawRectangle(*rect)
        dc.EndDrawing() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:43,代码来源:backend_wx.py

示例12: draw_rubberband

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def draw_rubberband(self, x0, y0, x1, y1):
            # Use an Overlay to draw a rubberband-like bounding box.
            if self.wxoverlay is None:
                self.wxoverlay = wx.Overlay()
            dc = wx.ClientDC(self.canvas)
            odc = wx.DCOverlay(self.wxoverlay, dc)
            odc.Clear()

            dc = wx.GCDC(dc)

            height = self.canvas.figure.bbox.height
            y1 = height - y1
            y0 = height - y0

            if y1 < y0:
                y0, y1 = y1, y0
            if x1 < x0:
                x0, x1 = x1, x0

            w = x1 - x0
            h = y1 - y0
            rect = wx.Rect(x0, y0, w, h)

            rubberBandColor = '#C0C0FF'  # or load from config?

            # Set a pen for the border
            color = wx.Colour(rubberBandColor)
            dc.SetPen(wx.Pen(color, 1))

            # use the same color, plus alpha for the brush
            r, g, b, a = color.Get(True)
            color.Set(r, g, b, 0x60)
            dc.SetBrush(wx.Brush(color))
            dc.DrawRectangle(rect) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:36,代码来源:backend_wx.py

示例13: remove_rubberband

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def remove_rubberband(self, dc=None):
            if not self._rect:
                return
            if self.canvas.bitmap:
                if dc is None:
                    dc = wx.ClientDC(self.canvas)
                dc.DrawBitmap(self.canvas.bitmap, 0, 0)
                #  for testing the method on Windows, use this code instead:
                # img = self.canvas.bitmap.ConvertToImage()
                # bmp = img.ConvertToBitmap()
                # dc.DrawBitmap(bmp, 0, 0)
            self._rect = None 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:14,代码来源:backend_wx.py

示例14: canvasCallback

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def canvasCallback(self, event=None):
        # create the device context
        dc = wx.ClientDC(self)
        brushBMP = wx.Brush(self.bmp)
        dc.SetBrush(brushBMP)
        width, height = self.GetClientSize()
        dc.DrawRectangle(0, 0, width, height)
                            
#================================================================================= 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:11,代码来源:wxPython_Wallpaper.py

示例15: draw_rubberband

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ClientDC [as 别名]
def draw_rubberband(self, event, x0, y0, x1, y1):
        # Use an Overlay to draw a rubberband-like bounding box.

        dc = wx.ClientDC(self.canvas)
        odc = wx.DCOverlay(self.wxoverlay, dc)
        odc.Clear()

        # Mac's DC is already the same as a GCDC, and it causes
        # problems with the overlay if we try to use an actual
        # wx.GCDC so don't try it.
        if 'wxMac' not in wx.PlatformInfo:
            dc = wx.GCDC(dc)

        height = self.canvas.figure.bbox.height
        y1 = height - y1
        y0 = height - y0

        if y1<y0: y0, y1 = y1, y0
        if x1<y0: x0, x1 = x1, x0

        w = x1 - x0
        h = y1 - y0
        rect = wx.Rect(x0, y0, w, h)

        rubberBandColor = '#C0C0FF' # or load from config?

        # Set a pen for the border
        color = wx.NamedColour(rubberBandColor)
        dc.SetPen(wx.Pen(color, 1))

        # use the same color, plus alpha for the brush
        r, g, b = color.Get()
        color.Set(r,g,b, 0x60)
        dc.SetBrush(wx.Brush(color))
        dc.DrawRectangleRect(rect) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:37,代码来源:backend_wx.py


注:本文中的wx.ClientDC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。