Python wx.BitmapFromImage() Examples

The following are 30 code examples of wx.BitmapFromImage(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 7 votes vote down vote up
def __init__(self, parent, id, evtList, ix, plugin):
        width = 205
        wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT |
            wx.LC_NO_HEADER | wx.LC_SINGLE_SEL, size = (width, -1))
        self.parent = parent
        self.id = id
        self.evtList = evtList
        self.ix = ix
        self.plugin = plugin
        self.sel = -1
        self.il = wx.ImageList(16, 16)
        self.il.Add(wx.BitmapFromImage(wx.Image(join(eg.imagesDir, "event.png"), wx.BITMAP_TYPE_PNG)))
        self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
        self.InsertColumn(0, '')
        self.SetColumnWidth(0, width - 5 - SYS_VSCROLL_X)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect)
        self.Bind(wx.EVT_SET_FOCUS, self.OnChange)
        self.Bind(wx.EVT_LIST_INSERT_ITEM, self.OnChange)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnChange)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.SetToolTipString(self.plugin.text.toolTip) 
Example #2
Source File: make_timelapse.py    From Pigrow with GNU General Public License v3.0 6 votes vote down vote up
def updateUI(self, capsdir):
        print("---UPDATING USER INTERFACE ---")
        capsdir = self.capsfolder_box.GetValue()
        fframe = self.firstframe_box.GetValue()
        lframe = self.lastframe_box.GetValue()
        if fframe == '':
            fframe = 0
        if lframe == '':
            lframe = len(cap_files) - 1
        last_pic  = str(capsdir + cap_files[lframe])
        first_pic = str(capsdir + cap_files[fframe])
        self.firstframe_box.SetValue(str(fframe))
        self.lastframe_box.SetValue(str(lframe))
        self.updatelastpic(lframe)
        self.updatefirstpic(fframe)
     #Cap graph
        cap_size_graph = self.graph_caps(cap_files, graphdir)
        scale_size_graph = first_pic = self.scale_pic(cap_size_graph, 300)
        try:
            self.cap_thumb.SetBitmap(wx.BitmapFromImage(scale_size_graph))
        except:
            print("no graph to work with, sorry") 
Example #3
Source File: ListCtrl.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #4
Source File: ImagePicker.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def SetValue(self, imageString):
        self.imageString = imageString
        if imageString:
            stream = StringIO(b64decode(imageString))
            image = wx.ImageFromStream(stream)
            stream.close()
            boxWidth, boxHeight = (10, 10)
            width, height = image.GetSize()
            if width > boxWidth:
                height *= 1.0 * boxWidth / width
                width = boxWidth
            if height > boxHeight:
                width *= 1.0 * boxHeight / height
                height = boxHeight
            image.Rescale(width, height)
            bmp = wx.BitmapFromImage(image)
            self.imageBox.SetBitmap(bmp)
            self.imageBox.SetSize((30, 30)) 
Example #5
Source File: AnimatedWindow.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Draw(self, deviceContext):
        deviceContext.BeginDrawing()
        deviceContext.DrawBitmap(self.backbuffer, 0, 0, False)
        t = clock() / 2.0
        y3 = self.y3
        x3 = self.x3
        y = (sin(t) + sin(1.8 * t)) * y3 + y3 * 2.0
        x = (sin(t * 0.8) + sin(1.9 * t)) * x3 + x3 * 2.0
        alpha = sin(t) / 2.0 + 0.5
        image = self.image.AdjustChannels(1.0, 1.0, 1.0, alpha)
        bmp = wx.BitmapFromImage(image, 24)
        deviceContext.DrawBitmap(bmp, x, y, True)
        deviceContext.EndDrawing() 
Example #6
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeDefaultBitmap():
    return BitmapFromImage(getTreeDefaultImage()) 
Example #7
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeDialogBitmap():
    return BitmapFromImage(getTreeDialogImage()) 
Example #8
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeMenuBitmap():
    return BitmapFromImage(getTreeMenuImage()) 
Example #9
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeMenuBarBitmap():
    return BitmapFromImage(getTreeMenuBarImage()) 
Example #10
Source File: make_timelapse.py    From Pigrow with GNU General Public License v3.0 5 votes vote down vote up
def updatefirstpic(self, fframe):
        capsdir = self.capsfolder_box.GetValue()
        first_pic = str(capsdir + cap_files[fframe])
        if os.path.exists(first_pic):
            first_pic = wx.Image(first_pic, wx.BITMAP_TYPE_ANY)
            first_pic = self.scale_pic(first_pic, 500)
            fpicdate = self.date_from_fn(cap_files[fframe])
            self.fpic_text.SetLabel('Frame ' + str(fframe) + '  -  ' + str(fpicdate))
            self.first_pic.SetBitmap(wx.BitmapFromImage(first_pic))
        else:
            self.first_pic.SetBitmap(wx.EmptyBitmap(10,10))
            self.fpic_text.SetLabel('start') 
Example #11
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeToolBarBitmap():
    return BitmapFromImage(getTreeToolBarImage()) 
Example #12
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolToolBarBitmap():
    return BitmapFromImage(getToolToolBarImage()) 
Example #13
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Draw(
        self,
        dc,
        foregroundColour,
        backgroundColour,
        display=0, # deprecated
    ):
        image = FOCUS_IMAGE.Copy()
        image.ConvertToMono(255, 255, 255)
        bmp = wx.BitmapFromImage(image, 1)
        bmpWidth, bmpHeight = bmp.GetSize()
        #bmp.SetMask(None)

        mdc = wx.MemoryDC()
        bmp2 = wx.EmptyBitmap(bmpWidth, bmpHeight, 1)
        mdc.SelectObject(bmp2)
        mdc.SetTextForeground((255, 255, 255))
        mdc.SetTextBackground((0, 0, 0))
        mdc.DrawBitmap(bmp, 0, 0, False)
        mdc.SelectObject(wx.NullBitmap)
        bmp = bmp2

        dc.SetTextForeground(backgroundColour)
        dc.SetTextBackground(foregroundColour)
        w, h = dc.GetSizeTuple()
        startX = (bmpWidth - (w % bmpWidth)) / 2
        startY = (bmpHeight - (h % bmpHeight)) / 2
        for x in range(-startX, w, bmpWidth):
            for y in range(-startY, h, bmpHeight):
                dc.DrawBitmap(bmp, x, y, False) 
Example #14
Source File: make_timelapse.py    From Pigrow with GNU General Public License v3.0 5 votes vote down vote up
def updatelastpic(self, lframe):
        capsdir = self.capsfolder_box.GetValue()
        last_pic = str(capsdir + cap_files[lframe])
        if os.path.exists(last_pic):
            last_pic = wx.Image(last_pic, wx.BITMAP_TYPE_ANY)
            last_pic = self.scale_pic(last_pic, 500)
            self.last_pic.SetBitmap(wx.BitmapFromImage(last_pic))
            lpicdate = self.date_from_fn(cap_files[lframe])
            self.lpic_text.SetLabel('Frame ' + str(lframe) + '  -  ' + str(lpicdate))
        else:
            self.last_pic.SetBitmap(wx.EmptyBitmap(10,10))
            self.fpic_text.SetLabel('end') 
Example #15
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def _getSmallUpArrowBitmap():
    stream = cStringIO.StringIO(_getSmallUpArrowData())
    return wx.BitmapFromImage(wx.ImageFromStream(stream)) 
Example #16
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def _getSmallDownArrowBitmap():
    stream = cStringIO.StringIO(_getSmallDownArrowData())
    return wx.BitmapFromImage(wx.ImageFromStream(stream))


#
#######################################################################
# TESTING ONLY 
Example #17
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeToolBitmap():
    return BitmapFromImage(getTreeToolImage()) 
Example #18
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolUnknownBitmap():
    return BitmapFromImage(getToolUnknownImage()) 
Example #19
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolTreeCtrlBitmap():
    return BitmapFromImage(getToolTreeCtrlImage()) 
Example #20
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getTreeRootBitmap():
    return BitmapFromImage(getTreeRootImage()) 
Example #21
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolTextCtrlBitmap():
    return BitmapFromImage(getToolTextCtrlImage()) 
Example #22
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolStaticTextBitmap():
    return BitmapFromImage(getToolStaticTextImage()) 
Example #23
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolStaticLineBitmap():
    return BitmapFromImage(getToolStaticLineImage()) 
Example #24
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolStaticBoxSizerBitmap():
    return BitmapFromImage(getToolStaticBoxSizerImage()) 
Example #25
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolStaticBoxBitmap():
    return BitmapFromImage(getToolStaticBoxImage()) 
Example #26
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolSplitterWindowBitmap():
    return BitmapFromImage(getToolSplitterWindowImage()) 
Example #27
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolSpinCtrlBitmap():
    return BitmapFromImage(getToolSpinCtrlImage()) 
Example #28
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolSpinButtonBitmap():
    return BitmapFromImage(getToolSpinButtonImage()) 
Example #29
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolSpacerBitmap():
    return BitmapFromImage(getToolSpacerImage()) 
Example #30
Source File: images.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def getToolSliderBitmap():
    return BitmapFromImage(getToolSliderImage())