本文整理汇总了Python中wx.EmptyBitmap方法的典型用法代码示例。如果您正苦于以下问题:Python wx.EmptyBitmap方法的具体用法?Python wx.EmptyBitmap怎么用?Python wx.EmptyBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.EmptyBitmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_background
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def draw_background(self):
"""
Draw the background box.
If I don't do this, then the background is black.
Could I change wx.EmptyBitmap() so that it defaults to white rather
than black?
"""
# TODO: change the bitmap background to be transparent
c = wx.Colour(200, 230, 230, 0)
c = wx.Colour(255, 255, 255, 0)
pen = wx.Pen(c)
brush = wx.Brush(c)
self.mdc.SetPen(pen)
self.mdc.SetBrush(brush)
self.mdc.DrawRectangle(0, 0, self.dc_w, self.dc_h)
示例2: on_color_change
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def on_color_change(self, event):
"""
Change the plot colors.
This is done by updating self.gradient and calling self.draw_scale()
"""
if event['low'] is not None:
self.low_color = event['low']
if event['high'] is not None:
self.high_color = event['high']
self.gradient = wm_utils.LinearGradient(self.low_color,
self.high_color)
# self._clear_scale()
self.hbox.Remove(0)
self.hbox.Add((self.dc_w, self.dc_h))
# self.mdc.SelectObject(wx.EmptyBitmap(self.dc_w, self.dc_h))
self.mdc.SelectObject(wx.Bitmap(self.dc_w, self.dc_h))
self.draw_scale()
示例3: add_image
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def add_image(self, image):
b = wx.BitmapFromImage(image)
if not b.Ok():
raise Exception("The image (%s) is not valid." % image)
if (sys.platform == "darwin" and
(b.GetWidth(), b.GetHeight()) == (self.icon_size, self.icon_size)):
return self.il.Add(b)
b2 = wx.EmptyBitmap(self.icon_size, self.icon_size)
dc = wx.MemoryDC()
dc.SelectObject(b2)
dc.SetBackgroundMode(wx.TRANSPARENT)
dc.Clear()
x = (b2.GetWidth() - b.GetWidth()) / 2
y = (b2.GetHeight() - b.GetHeight()) / 2
dc.DrawBitmap(b, x, y, True)
dc.SelectObject(wx.NullBitmap)
b2.SetMask(wx.Mask(b2, (255, 255, 255)))
return self.il.Add(b2)
# Arrow drawing
示例4: draw_sort_arrow
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def draw_sort_arrow(self, direction):
b = wx.EmptyBitmap(self.icon_size, self.icon_size)
w, h = b.GetSize()
ho = (h - 5) / 2
dc = wx.MemoryDC()
dc.SelectObject(b)
colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_GRAYTEXT)
dc.SetBackgroundMode(wx.TRANSPARENT)
dc.Clear()
dc.SetPen(wx.Pen(colour))
for i in xrange(5):
if direction == 'down':
j = 4 - i
else:
j = i
dc.DrawLine(i,j+ho,9-i,j+ho)
dc.SelectObject(wx.NullBitmap)
b.SetMask(wx.Mask(b, (255, 255, 255)))
return b
示例5: get_preview_obj_bitmap
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def get_preview_obj_bitmap(self, bitmap=None):
"""Create a wx.Bitmap or wx.EmptyBitmap from the given statement.
If no statement is given, the instance variable named "bitmap" is used.
bitmap: Bitmap definition (str or None)
see: get_preview_obj_artprovider(), get_preview_obj_emptybitmap()"""
if bitmap is None:
bitmap = getattr(self, 'bitmap', None)
if not bitmap:
return compat.wx_EmptyBitmap(1, 1)
if bitmap.startswith('var:') or bitmap.startswith('code:'):
return compat.wx_EmptyBitmap(16, 16)
elif bitmap.startswith('empty:'):
return self.get_preview_obj_emptybitmap(bitmap)
elif bitmap.startswith('art:'):
return self.get_preview_obj_artprovider(bitmap)
else:
bitmap = misc.get_absolute_path(bitmap)
return wx.Bitmap(bitmap, wx.BITMAP_TYPE_ANY)
示例6: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def __init__(self, parent):
wx.Frame.__init__(
self,
parent,
-1,
"OSD Window",
size=(0, 0),
style=(
wx.FRAME_SHAPED |
wx.NO_BORDER |
wx.FRAME_NO_TASKBAR |
wx.STAY_ON_TOP
)
)
self.hwnd = self.GetHandle()
self.bitmap = wx.EmptyBitmap(0, 0)
# we need a timer to possibly cancel it
self.timer = threading.Timer(0.0, eg.DummyFunc)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_CLOSE, self.OnClose)
示例7: Draw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def Draw(self, dc, scale=128):
dc.Clear()
width, height = dc.GetSizeTuple()
sineTab = [
int(127.5 * sin(math.pi * (i - 127.5) / 127.5) + 127.5)
for i in range(256)
]
cx = width / 2
cy = height / 2
bmp = wx.EmptyBitmap(width, height, 24)
pixelData = wx.NativePixelData(bmp)
pixels = pixelData.GetPixels()
y = -cy
for i in range(height):
x = -cx
for j in range(width):
d = ((x * x + y * y) * scale) >> 8
val = sineTab[d & 0xFF]
pixels.Set(val, val, val)
pixels.nextPixel()
x += 1
y += 1
pixels.MoveTo(pixelData, 0, y + cy)
dc.DrawBitmap(bmp, 0, 0, False)
示例8: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def __init__(self, size=(-1, -1), pic_path=None, display=0):
wx.Frame.__init__(
self,
None,
-1,
"ShowPictureFrame",
style=wx.NO_BORDER | wx.FRAME_NO_TASKBAR #| wx.STAY_ON_TOP
)
self.SetBackgroundColour(wx.Colour(0, 0, 0))
self.Bind(wx.EVT_LEFT_DCLICK, self.LeftDblClick)
self.Bind(wx.EVT_CLOSE, self.OnClose)
bitmap = wx.EmptyBitmap(1, 1)
self.staticBitmap = wx.StaticBitmap(self, -1, bitmap)
self.staticBitmap.Bind(wx.EVT_LEFT_DCLICK, self.LeftDblClick)
self.staticBitmap.Bind(wx.EVT_MOTION, self.ShowCursor)
self.timer = Timer(2.0, self.HideCursor)
示例9: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [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)
示例10: AddNamedImages
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def AddNamedImages(self, name, smallImage=None, normalImage=None):
"""
Add the given images to the list of available images. Return the index of the image.
If a name is given, that name can later be used to refer to the images rather
than having to use the returned index.
"""
if isinstance(smallImage, basestring):
smallImage = wx.Bitmap(smallImage)
if isinstance(normalImage, basestring):
normalImage = wx.Bitmap(normalImage)
# We must have image lists for images to be added to them
if self.smallImageList is None or self.normalImageList is None:
self.SetImageLists()
# There must always be the same number of small and normal bitmaps,
# so if we aren't given one, we have to make an empty one of the right size
smallImage = smallImage or wx.EmptyBitmap(*self.smallImageList.GetSize(0))
normalImage = normalImage or wx.EmptyBitmap(*self.normalImageList.GetSize(0))
self.smallImageList.AddNamedImage(name, smallImage)
return self.normalImageList.AddNamedImage(name, normalImage)
示例11: OnSize
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def OnSize(self, event=None):
"""Create a new off-screen buffer to hold drawn data."""
(width, height) = self.GetClientSizeTuple() if WX3 else self.GetClientSize()
if width == 0:
width = 1
if height == 0:
height = 1
self.buffer = wx.EmptyBitmap(width, height)
self.view_width = width
self.view_height = height
# call onSize callback, if registered
if self.onSizeCallback:
self.onSizeCallback()
# Now update the screen
self.Update()
######
# Base class for a tile object - handles access to tiles.
######
示例12: OnSize
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def OnSize(self, event):
size = self.GetClientSize()
self.screenBuf = wx.EmptyBitmap(size.width, size.height)
示例13: OnSize
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def OnSize(self, event):
if misc.doDblBuf:
size = self.GetClientSize()
sb = wx.EmptyBitmap(size.width, size.height)
old = getattr(self.__class__, "screenBuf", None)
if (old == None) or (old.GetDepth() != sb.GetDepth()) or \
(old.GetHeight() != sb.GetHeight()) or \
(old.GetWidth() != sb.GetWidth()):
self.__class__.screenBuf = sb
self.makeLineVisible(self.sp.line)
示例14: saveImage
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def saveImage(canvas, filename):
s = wx.ScreenDC()
w, h = canvas.size.Get()
b = wx.EmptyBitmap(w, h)
m = wx.MemoryDCFromDC(s)
m.SelectObject(b)
m.Blit(0, 0, w, h, s, 70, 0)
m.SelectObject(wx.NullBitmap)
b.SaveFile(filename, wx.BITMAP_TYPE_PNG)
示例15: _on_size
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EmptyBitmap [as 别名]
def _on_size(self, event):
"""Redraw everything with the new sizes."""
# TODO: Also reduce number of ticks when text starts to overlap
# or add ticks when there's extra space.
self.set_sizes()
self.hbox.Remove(0)
self.hbox.Add((self.dc_w, self.dc_h))
# self.mdc.SelectObject(wx.EmptyBitmap(self.dc_w, self.dc_h))
self.mdc.SelectObject(wx.Bitmap(self.dc_w, self.dc_h))
self.draw_scale()
self.Refresh()