Python wx 模块,Bitmap() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.Bitmap()

项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        imageFile = 'Tile.bmp'
        self.bmp = wx.Bitmap(imageFile)
        # react to a resize event and redraw image
        parent.Bind(wx.EVT_SIZE, self.canvasCallback)

        menu = wx.Menu()
        menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
        menu.AppendSeparator()
        menu.Append(wx.ID_EXIT, "Exit", " Exit the GUI")
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File") 
        parent.SetMenuBar(menuBar)  

        self.textWidget = wx.TextCtrl(self, size=(280, 80), style=wx.TE_MULTILINE)

        button = wx.Button(self, label="Create OpenGL 3D Cube", pos=(60, 100))
        self.Bind(wx.EVT_BUTTON, self.buttonCallback, button)  

        parent.CreateStatusBar()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def resize(self, event=None):
        """Handle wx resize events.

        Notes:
            This method may be called outside the wx event buffer
            in order to initialize the panel or reset the drawing
            buffer.
        """
        size = self.winWidth, self.winHeight = self.GetSize()
        if size != self.lastSize: # hack to mitigate multiple consecutive resize events
            self.winRadius = min((self.winWidth/2.0, self.winHeight/2.0))
            #self.drawingBuffer = wx.Bitmap(self.winWidth, self.winHeight) # wxpython3
            self.drawingBuffer = wx.EmptyBitmap(self.winWidth, self.winHeight) # wxpython3
            self.lastSize = size
            self.refresh()

        if event is not None:
            event.Skip()
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def __init__(self):
        '''
        @summary: Constructor
        @param config_dict: The build configuration, if present
        @param load_config: Handle to a config loader method/object
        '''
        self.language = DEFAULT_LANGUAGE
        self.__builder = None
        self.config_file_path = None

        # Init super - MainFrame
        MainFrame.__init__( self, parent=None )
        self.console = Console(self.ConsoleTextCtrl)
        self.StatusBar.SetStatusText("Ready...")
        self.SetIcon(wx.IconFromBitmap(wx.Bitmap("ExeBuilder\\static\\builder_logo.bmp", wx.BITMAP_TYPE_ANY)))

        # Update GUI Visuals
        self.update_gui_visuals()

        # Set initial event handlers
        self.set_events()
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def update_gui_visuals(self):
        '''
        @summary: Updates the GUI with any aesthetic changes following initialising. This
        inludes updating labels and other widgets
        '''

        # Version
        self.TitleLabel.SetLabel(TITLE)
        self.SetTitle(TITLE)

        # Set Logo Image
        self.LogoBitmap.SetBitmap(
            wx.Bitmap(
                "ExeBuilder\\static\\builder_logo.bmp"
                )
            )
        # Set debug to default level
        self.DebugLevelChoice.SetSelection(
            self.DebugLevelChoice.FindString(
                BUILDER_CONFIG_ITEMS["debug_level"]["default"]
                )
            )
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def _drawPointLabel(self, mDataDict):
        """Draws and erases pointLabels"""
        width = self._Buffer.GetWidth()
        height = self._Buffer.GetHeight()
        if sys.platform != "darwin":
            tmp_Buffer = wx.Bitmap(width, height)
            dcs = wx.MemoryDC()
            dcs.SelectObject(tmp_Buffer)
            dcs.Clear()
        else:
            tmp_Buffer = self._Buffer.GetSubBitmap((0, 0, width, height))
            dcs = wx.MemoryDC(self._Buffer)
        self._pointLabelFunc(dcs, mDataDict)  # custom user pointLabel function
        dc = wx.ClientDC(self.canvas)
        dc = wx.BufferedDC(dc, self._Buffer)
        # this will erase if called twice
        dc.Blit(0, 0, width, height, dcs, 0, 0, self._logicalFunction)
        if sys.platform == "darwin":
            self._Buffer = tmp_Buffer
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
def DrawFromSelectedNode(self, msg):
        t = msg.replace("][", ",").replace("[", "").replace("]", "").split(",")
        osx = int(t[0])
        osy = int(t[1])
        oex = int(t[2])
        oey = int(t[3])
        i = wx.Bitmap(os.path.join(self.screenShotDir, "screenshot.png"))
        dc = wx.MemoryDC(i)
        dc.SetPen(wx.Pen(wx.RED, 1))
        #???(wxpython????drawline?drawlines, ??drawrect??????)
        dc.DrawLine(osx, osy, osx, oey)
        dc.DrawLine(osx, osy, oex, osy)
        dc.DrawLine(oex, osy, oex, oey)
        dc.DrawLine(osx, oey, oex, oey)
        dc.SelectObject(wx.NullBitmap)
        self.screenShot.SetBitmap(i) 
        self.Refresh(eraseBackground=True, rect=None)
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
def updateStatus(self, msg):
#         siz = self.GetSize()
        if os.path.isfile(msg):
            if ".png" in msg:
                self.clearScreenShot(self.defaultScreenShotImage)
                newScreenShotPath = os.path.join(self.screenShotDir, "screenshot.png")
                self.newScreenShot = wx.Bitmap(newScreenShotPath)
                print("????????",self.newScreenShot.GetSize())
                self.screenShot.SetBitmap(self.newScreenShot)
                self.Refresh(eraseBackground=True, rect=None)
                self.notUseDetaul = 1
            else:
                pass
        else:
            if msg == "?????????PC??":
                self.statusBar.ForegroundColour = "red"
                self.statusBar.SetLabel(msg)
            else:
                self.statusBar.ForegroundColour = "blue"
                if "ERROR: could not get idle state." in msg:
                    self.statusBar.SetLabel(msg)
                self.statusBar.SetLabel(msg)
项目:pyDataView    作者:edwardsmith999    | 项目源码 | 文件源码
def __init__(self, parent=None, fdir='./', title='pyDataViewer', 
                 size=(800,600), **kwargs):

        wx.Frame.__init__(self,parent,title=title,size=size)
        try:
            _icon = wx.EmptyIcon()
            _icon.CopyFromBitmap(
                # postproclib.visualiser.__path__ (pplvpath) is a list
                wx.Bitmap(pplvpath[0]+"/logo.gif", wx.BITMAP_TYPE_ANY)
            )
            self.SetIcon(_icon)
        except IOError:
            print('Couldn\'t load icon')

        self.dirchooser = DirectoryChooserPanel(self, fdir)

        self.vbox = wx.BoxSizer(wx.VERTICAL)
        self.vbox.Add(self.dirchooser, 0, wx.EXPAND, 0)
        self.SetSizer(self.vbox)

        self.visualiserpanel = None
        self.new_visualiserpanel(fdir)
        self.fdir = fdir

        self.set_bindings()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def HitTest(self, x, y):
        """
        Test if point is inside button
        @param x: X coordinate of point
        @param y: Y coordinate of point
        @return: True if button is active and displayed and point is inside
        button
        """
        # Return immediately if button is hidden or inactive
        if not (self.IsShown() and self.IsEnabled()):
            return False

        # Test if point is inside button
        w, h = self.Bitmap.GetSize()
        rect = wx.Rect(self.Position.x, self.Position.y, w, h)
        return rect.InsideXY(x, y)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def buildToolsBar(parent, datas):    
    box = wx.BoxSizer( wx.HORIZONTAL )
    #toolsbar =  wx.ToolBar( parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TB_HORIZONTAL ) 
    toolsbar = wx.Panel( parent, wx.ID_ANY, 
                         wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )

    toolsbar.SetSizer( box )
    add_tools(toolsbar, datas[1][0][1], None)

    gifpath = os.path.join(root_dir, "tools/drop.gif")
    btn = wx.BitmapButton(toolsbar, wx.ID_ANY, make_bitmap(wx.Bitmap(gifpath)),
                          wx.DefaultPosition, (32, 32), wx.BU_AUTODRAW|wx.RAISED_BORDER)

    box.Add(btn)
    btn.Bind(wx.EVT_LEFT_DOWN, lambda x:menu_drop(parent, toolsbar, datas, btn, x))
    add_tools(toolsbar, datas[1][1][1])
    return toolsbar
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw_image(self, dc, ndarr, back, mode, rect, scale, dirty):
        win = cross(self.box, rect)
        win2 = trans(rect, win)
        sx = sy = 1.0/scale
        box = multiply(win2, sx, sy)

        M = np.array([sx, sy])
        O = (win2[1]*sx, win2[0]*sy)
        shape = (win2[3], win2[2])

        if dirty:
            start = time()
            rst = self.merge(ndarr, back, M, O, mode, shape, win2, self.ips.lookup)
            self.bmp = wx.Bitmap.FromBuffer(win2[2], win2[3], memoryview(rst))
            print(time()-start)
        dc.DrawBitmap(self.bmp, win[0], win[1])
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: Login.__set_properties
        self.SetTitle("Login")
        #_icon = wx.EmptyIcon()
        #_icon.CopyFromBitmap(wx.Bitmap("/media/f67bc164-f440-4c0f-9e9b-3ad70ff1adc2/home/asif/Desktop/waiter animation/2.gif", wx.BITMAP_TYPE_ANY))
        #self.SetIcon(_icon)
        self.SetSize((462, 239))
        self.SetFocus()
        self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.combo_box_1.SetSelection(0)
        self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_1.SetMinSize((185, 30))
        self.button_1.SetMinSize((85, 35))
        self.button_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Ubuntu"))
        self.button_2.SetMinSize((85, 35))
        self.button_2.Disable()
        # end wxGlade
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def onView(self):
        """
        Attempts to load the image and display it
        """
        filepath = self.photoTxt.GetValue()
        img = wx.Image(filepath, wx.BITMAP_TYPE_ANY)
        # scale the image, preserving the aspect ratio
        W = img.GetWidth()
        H = img.GetHeight()
        if W > H:
            NewW = self.PhotoMaxSize
            NewH = self.PhotoMaxSize * H / W
        else:
            NewH = self.PhotoMaxSize
            NewW = self.PhotoMaxSize * W / H
        img = img.Scale(NewW,NewH)

        self.imageCtrl.SetBitmap(wx.Bitmap(img))
        self.panel.Refresh()
        self.mainSizer.Fit(self.frame)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        imageFile = 'Tile.bmp'
        self.bmp = wx.Bitmap(imageFile)
        # react to a resize event and redraw image
        parent.Bind(wx.EVT_SIZE, self.canvasCallback)

        button = wx.Button(self, label="Quit")
        self.Bind(wx.EVT_BUTTON, self.buttonCallback, button)  

        parent.CreateStatusBar()
项目:FestEngine    作者:Himura2la    | 项目源码 | 文件源码
def load_zad(self, file_path, fit=True):
        img = wx.Image(file_path, wx.BITMAP_TYPE_ANY)
        if fit:
            w, h = img.GetWidth(), img.GetHeight()
            max_w, max_h = self.images_panel.GetSize()
            target_ratio = min(max_w / float(w), max_h / float(h))
            new_w, new_h = [int(x * target_ratio) for x in (w, h)]
            img = img.Scale(new_w, new_h, wx.IMAGE_QUALITY_HIGH)
        self.images_panel.drawable_bitmap = wx.Bitmap(img)
        self.images_panel.Refresh()
项目:FestEngine    作者:Himura2la    | 项目源码 | 文件源码
def no_show(self):
        self.images_panel.drawable_bitmap = \
            wx.Bitmap(wx.Image(*self.images_panel.drawable_bitmap.GetSize()))
        self.images_panel.Refresh()
项目:fmc-dialer    作者:sguron    | 项目源码 | 文件源码
def AssignImages(self, active, inactive):
        self.active_tab_bitmap = wx.Bitmap(active)
        self.inactive_tab_bitmap = wx.Bitmap(inactive)

        self._nImgSize = max(self.active_tab_bitmap.GetHeight(), self.inactive_tab_bitmap.GetHeight() )
项目:fmc-dialer    作者:sguron    | 项目源码 | 文件源码
def AssignForeground(self, fg):
        self.foreground = wx.Bitmap(fg)
项目:fmc-dialer    作者:sguron    | 项目源码 | 文件源码
def AssignIllst(self, image, pos):
        self.illst.append( (wx.Bitmap(image), pos) )
项目:fritzchecksum    作者:mementum    | 项目源码 | 文件源码
def CreateBitmap(self, artid, client, size):
        if not artid.startswith('priv'):
            return wx.NullBitmap

        artid = artid.split('/')[1:]  # Split path and remove 'priv'
        artid = '/'.join(artid)  # rejoin remaining parts

        fpath = appconstants.getdatapath(artid)
        return wx.Bitmap(fpath, wx.BITMAP_TYPE_ANY)
项目:MaTags    作者:hastelloy    | 项目源码 | 文件源码
def __init__(self, parent, title):
        style = wx.DEFAULT_FRAME_STYLE & ~(
            wx.RESIZE_BORDER | wx.MAXIMIZE_BOX |
            wx.MINIMIZE_BOX|wx.CLOSE_BOX)

        wx.Frame.__init__(self, parent, title=title, 
            style=style, size=(400,60))
        self.textbox = wx.TextCtrl(self)

        img = wx.Image("matags.png", wx.BITMAP_TYPE_ANY)
        bmp = wx.Bitmap(img)
        self.icon = wx.Icon()
        self.icon.CopyFromBitmap(bmp)
        self.SetIcon(self.icon)

        self.tbIcon = wx.adv.TaskBarIcon()
        self.tbIcon.SetIcon(self.icon)

        self.Show(True)
        self.Centre()

        self.reg_hot_keys()        
        self.Bind(wx.EVT_HOTKEY, self.on_extract_tag, 
            id=self.hotkeys['extract_tag'][0])
        self.Bind(wx.EVT_HOTKEY, self.on_close, 
            id=self.hotkeys['quit'][0])
        self.Bind(wx.EVT_HOTKEY, self.on_activate, 
            id=self.hotkeys['activate'][0])
        self.Bind(wx.EVT_HOTKEY, self.on_refresh, 
            id=self.hotkeys['refresh'][0])
        self.textbox.Bind(wx.EVT_CHAR, self.check_key)
        # do not use EVT_KEY_DOWN, 
        # it becomes difficult to get lower case
        # self.textbox.Bind(wx.EVT_KEY_DOWN, self.check_key)
        # self.Bind(wx.EVT_CLOSE, self.on_close)
        self.Bind(wx.EVT_ICONIZE, self.on_iconify)
        self.matags = MaTags()
        # try:
        # except Exception as e:
        #     self.textbox.ChangeValue(e.args[0].decode('utf8', 'ignore'))
        #     self.textbox.Disable()
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        wx.Frame.__init__(self, *args, **kwds)
        self.label_5 = wx.StaticText(self, wx.ID_ANY, "Cadena Busqueda:")
        self.text_ctrl_bucar = wx.TextCtrl(self, wx.ID_ANY, "")
        self.button_buscar = wx.Button(self, wx.ID_ANY, "Buscar")
        self.label_6 = wx.StaticText(self, wx.ID_ANY, "total VM: 333")
        self.bitmap_button_1 = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap("/home/mario/pyvmwareclient/wxglade/recicla.png", wx.BITMAP_TYPE_ANY))
        self.list_ctrl_1 = wx.ListCtrl(self, wx.ID_ANY)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
项目:squaremap3    作者:kawaiicthulhu    | 项目源码 | 文件源码
def OnSize(self, event):
        # The buffer is initialized in here, so that the buffer is always
        # the same size as the Window.
        if event is None:
            return 0,0
        width, height = self.GetClientSize()
        if width <= 0 or height <=0:
            return 0,0
        # Make new off-screen bitmap: this bitmap will always have the
        # current drawing in it, so it can be used to save the image to
        # a file, or whatever.
        if width and height:
            # Macs can generate events with 0-size values
            self._buffer = wx.Bitmap(width, height)
            self.UpdateDrawing()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def UpdateImage(self, axis, position):
        object = self.object
        idx = position - 1
        if axis == 1:
            imagedata = object[idx,:,:]
        elif axis == 2:
            imagedata = object[:,idx,:]
        else:
            imagedata = object[:,:,idx]
        imagedata[imagedata < 1e-6] = 1.0
        imagedata = numpy.log(imagedata)
        imagedata = imagedata - imagedata.min()
        if imagedata.max() > 0:
            imagedata = (255.0/imagedata.max())*imagedata
        else:
            imagedata = 255.0*imagedata
        imagedatalow = numpy.uint8(imagedata)
        self.impil = Image.fromarray(imagedatalow, 'L').resize((self.sx,self.sy))
        if IsNotWX4():
            self.imwx = wx.EmptyImage( self.impil.size[0], self.impil.size[1] )
        else:
            self.imwx = wx.Image( self.impil.size[0], self.impil.size[1] )
        self.imwx.SetData( self.impil.convert( 'RGB' ).tobytes() )
        if IsNotWX4():
            bitmap = wx.BitmapFromImage(self.imwx)
        else:
            bitmap = wx.Bitmap(self.imwx)
        if IsNotWX4():
            self.bmp = wx.BitmapFromImage(self.imwx)
        else:
            self.bmp = wx.Bitmap(self.imwx)
        self.image.SetBitmap(bitmap)
        self.Refresh()
        self.Layout()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def UpdateImage(self, axis, position):
        object = self.object
        idx = position - 1
        if axis == 1:
            imagedata = numpy.array(object[idx,:,:])
        elif axis == 2:
            imagedata = numpy.array(object[:,idx,:])
        else:
            imagedata = numpy.array(object[:,:,idx])
        imagedata[imagedata < 1e-6] = 1.0
        imagedata = numpy.log(imagedata)
        imagedata = imagedata - imagedata.min()
        if imagedata.max() > 0:
            imagedata = (255.0/imagedata.max())*imagedata
        else:
            imagedata = 255.0*imagedata
        imagedatalow = numpy.uint8(imagedata)
        self.impil = Image.fromarray(imagedatalow, 'L').resize((self.sx,self.sy))
        if IsNotWX4():
            self.imwx = wx.EmptyImage( self.impil.size[0], self.impil.size[1] )
        else:
            self.imwx = wx.Image( self.impil.size[0], self.impil.size[1] )
        self.imwx.SetData( self.impil.convert( 'RGB' ).tobytes() )
        if IsNotWX4():
            bitmap = wx.BitmapFromImage(self.imwx)
        else:
            bitmap = wx.Bitmap(self.imwx)
        self.bmp = bitmap
        self.image.SetBitmap(bitmap)
        self.Refresh()
        self.Layout()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnSize(self, event):
        # The Buffer init is done here, to make sure the buffer is always
        # the same size as the Window
        Size = self.canvas.GetClientSize()
        if Size.width <= 0 or Size.height <= 0:
            return
        Size.width = max(1, Size.width)
        Size.height = max(1, Size.height)
        # Make new offscreen bitmap: this bitmap will always have the
        # current drawing in it, so it can be used to save the image to
        # a file, or whatever.
        #self._Buffer = wx.Bitmap(Size.width, Size.height)
        if IsNotWX4():
            self._img = wx.EmptyImage(Size.width,Size.height)
            self._Buffer = wx.BitmapFromImage(self._img)
        else:
            self._img = wx.Image(Size.width,Size.height)
            self._Buffer = wx.Bitmap(self._img)
        self._Buffer.SetHeight(Size.height)
        self._Buffer.SetWidth(Size.width)
        self._setSize()
        self.last_PointLabel = None  # reset pointLabel
        if self.last_draw is None:
            self.Clear()
        else:
            graphics, xSpec, ySpec = self.last_draw
            self._Draw(graphics, xSpec, ySpec)
项目:pinder    作者:dhharris    | 项目源码 | 文件源码
def display_matches(self):
        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.images = []
        self.labels = []
        m = self.session.matches()

        for i in range(len(m)):
            match = m[i]
            # Thumb
            fd = urlopen(match.user.thumbnails[0])
            file = io.BytesIO(fd.read())
            img = wx.Image(file, wx.BITMAP_TYPE_ANY)
            self.images.append(wx.StaticBitmap(self.panel, wx.ID_ANY,
                                         wx.Bitmap(img)))
            self.images[i].Bind(wx.EVT_BUTTON, self.onClick)
            # Label for name
            self.labels.append(wx.StaticText(self.panel, label=match.user.name))

            # Add to sizer
            self.mainSizer.Add(self.labels[i], 0, wx.ALL, 5)
            self.mainSizer.Add(self.images[i], 0, wx.ALL, 5)

        self.mainSizer.Add(self.sizer, 0, wx.ALL, 5)
        self.panel.SetSizer(self.mainSizer)
        self.panel.Layout()
        self.panel.Refresh()
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def draw_box(self):
        x1, x2 = self.plot._point2ClientCoord(*self.selected)[::2]
        dc = wx.ClientDC(self.plot.canvas)
        dc.SetLogicalFunction(wx.INVERT)
        dc.DrawRectangle(x1, 0, x2, dc.GetSize()[1])
        dc.SetLogicalFunction(wx.COPY)

    # def clear(self):
    #     # An experimental way to clear the canvas without redrawing the plot every time
    #     # dc.Blit() usage from SOF.
    #     if self.selection_drawn:
    #         self.draw_box()  # clear old
    #         self.selection_drawn = False
    #     dc = wx.ClientDC(self.plot.canvas)
    #     size = dc.GetSize()
    #     bmp = wx.Bitmap(size.width, size.height)
    #     prev_dc = wx.MemoryDC()
    #     prev_dc.SelectObject(bmp)
    #     prev_dc.Blit(
    #         0,  # Copy to this X coordinate
    #         0,  # Copy to this Y coordinate
    #         size.width,  # Copy this width
    #         size.height,  # Copy this height
    #         dc,  # From where do we copy?
    #         0,  # What's the X offset in the original DC?
    #         0  # What's the Y offset in the original DC?
    #     )
    #     prev_dc.SelectObject(wx.NullBitmap)
    #     dc.Clear()
    #     dc.DrawBitmap(bmp, 0, 0)
    #     # if self.plot.last_draw is not None:
    #     #     self.plot.Draw(self.plot.last_draw[0])
项目:GoPiGo3    作者:DexterInd    | 项目源码 | 文件源码
def OnEraseBackground(self, evt):
        """
        Add a picture to the background
        """
        # yanked from ColourDB.py
        dc = evt.GetDC()

        if not dc:
            dc = wx.ClientDC(self)
            rect = self.GetUpdateRegion().GetBox()
            dc.SetClippingRect(rect)
        dc.Clear()  
        # bmp = wx.Bitmap("/home/pi/Desktop/GoBox/Troubleshooting_GUI/dex.png") # Draw the photograph.
        # dc.DrawBitmap(bmp, 0, 400)                        # Absolute position of where to put the picture
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def SetPageBitmap(self, idx, bitmap):
        """Function that fix difference in setting picture on tab between
        wx.Notebook and wx.aui.AUINotebook.

        :param idx: Tab index.
        :param bitmap: wx.Bitmap to define on tab.
        :returns: True if operation succeeded
        """
        return self.TabsOpened.SetPageBitmap(idx, bitmap)

    # -------------------------------------------------------------------------------
    #                         Dialog Message Functions
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def SetBitmap(self, bitmap):
        """
        Set bitmap to use for button
        @param bitmap: Name of bitmap to use for button
        """
        # Get wx.Bitmap object corresponding to bitmap
        self.Bitmap = GetBitmap(bitmap)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GetSize(self):
        """
        Return size of button
        @return: wx.Size object containing button size
        """
        # Button size is size of bitmap
        return self.Bitmap.GetSize()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def Draw(self, dc):
        """
        Draw button in Graphic Viewer
        @param dc: wx.DC object corresponding to Graphic Viewer device context
        """
        # Only draw button if button is active and displayed
        if self.Shown and self.Enabled:
            dc.DrawBitmap(self.Bitmap, self.Position.x, self.Position.y, True)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GetBitmap(bmp_name1, bmp_name2=None, size=None):
    bmp = BitmapLibrary.get((bmp_name1, bmp_name2, size))
    if bmp is not None:
        return bmp

    if bmp_name2 is None:
        bmp = SearchBitmap(bmp_name1)
    else:
        # Bitmap with two icon
        bmp1 = SearchBitmap(bmp_name1)
        bmp2 = SearchBitmap(bmp_name2)

        if bmp1 is not None and bmp2 is not None:
            # Calculate bitmap size
            width = bmp1.GetWidth() + bmp2.GetWidth() - 1
            height = max(bmp1.GetHeight(), bmp2.GetHeight())

            # Create bitmap with both icons
            bmp = wx.EmptyBitmap(width, height)
            dc = wx.MemoryDC()
            dc.SelectObject(bmp)
            dc.Clear()
            dc.DrawBitmap(bmp1, 0, 0)
            dc.DrawBitmap(bmp2, bmp1.GetWidth() - 1, 0)
            dc.Destroy()

        elif bmp1 is not None:
            bmp = bmp1
        elif bmp2 is not None:
            bmp = bmp2

    if bmp is not None:
        BitmapLibrary[(bmp_name1, bmp_name2, size)] = bmp

    return bmp
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def save_bitmap(self, path):
        context = wx.ClientDC( self )
        memory = wx.MemoryDC( )
        x, y = self.ClientSize
        bitmap = wx.Bitmap( x, y, -1 )
        memory.SelectObject( bitmap )
        memory.Blit( 0, 0, x, y, context, 0, 0)
        memory.SelectObject( wx.NullBitmap)
        bitmap.SaveFile( path, wx.BITMAP_TYPE_PNG )
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def init_buf(self):
        box = self.GetClientSize()
        self.buffer = wx.Bitmap(box.width, box.height)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def build_tools(parent, toolspath):
    global host
    host = parent
    ## get tool datas from the loader.build_tools(toolspath)
    ## then generate toolsbar
    datas = loader.build_tools(toolspath)
    toolsbar = buildToolsBar(parent, datas)
    gifpath = os.path.join(root_dir, "tools/drop.gif")
    #btn = wx.BitmapButton(parent, wx.ID_ANY, wx.Bitmap(gifpath), wx.DefaultPosition, (30,30), wx.BU_AUTODRAW)
    #btn.Bind(wx.EVT_LEFT_DOWN, lambda x:menu_drop(parent, toolsbar, datas, btn, x))   
    return toolsbar#, btn
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def add_tools(bar, datas, curids=[]):
    ##! TODO: 
    ## datas? dirpath tree to generate menus/toolsbar?
    ## curids? ??
    box = bar.GetSizer() 
    if curids!=None:
        for curid in curids:
            bar.RemoveChild(curid)
            box.Hide(curid)
            box.Detach(curid)
    if curids!=None:
        del curids[:]
    for data in datas:
        btn = wx.BitmapButton(bar, wx.ID_ANY, 
                              make_bitmap(wx.Bitmap(data[1])), 
                              wx.DefaultPosition, (32,32), 
                              wx.BU_AUTODRAW|wx.RAISED_BORDER )        
        if curids!=None:
            curids.append(btn)        
        if curids==None:
            box.Add(btn)
        else: 
            box.Insert(len(box.GetChildren())-2, btn)

        btn.Bind( wx.EVT_LEFT_DOWN, lambda x, p=data[0]:f(p(), x))
        btn.Bind( wx.EVT_ENTER_WINDOW, 
                  lambda x, p='"{}" Tool'.format(data[0].title): set_info(p))        
        if not isinstance(data[0], Macros) and issubclass(data[0], Tool):
            btn.Bind(wx.EVT_LEFT_DCLICK, lambda x, p=data[0]:p().show())
        btn.SetDefault()
    box.Layout()
    bar.Refresh()
    if curids==None:
        sp = wx.StaticLine( bar, wx.ID_ANY, 
                            wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
        box.Add( sp, 0, wx.ALL|wx.EXPAND, 2 )
        box.AddStretchSpacer(1)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def init_buf(self):
        box = self.GetClientSize()
        self.width, self.height = box.width, box.height
        self.buffer = wx.Bitmap(self.width, self.height)
项目:ChiantiPy    作者:chianti-atomic    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: ui_choice2Dialog.__set_properties
        self.SetTitle("ChiantiPy")
        _icon = wx.EmptyIcon()
        imagefile = os.path.join(chianti.__path__[0], "images/chianti2.png")
        _icon.CopyFromBitmap(wx.Bitmap(imagefile, wx.BITMAP_TYPE_ANY))
        self.SetIcon(_icon)
        self.SetSize((448, 556))
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: sampoorna_win.__init__
        kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.MAXIMIZE | wx.MAXIMIZE_BOX | wx.STAY_ON_TOP | wx.SYSTEM_MENU | wx.RESIZE_BORDER | wx.CLIP_CHILDREN
        wx.Frame.__init__(self, *args, **kwds)
        self.panel_1 = wx.ScrolledWindow(self, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
        self.panel_warning = wx.Panel(self.panel_1, wx.ID_ANY, style=wx.RAISED_BORDER | wx.STATIC_BORDER | wx.TAB_TRAVERSAL)
        self.label_1 = wx.StaticText(self.panel_warning, wx.ID_ANY, _("label_1"))
        self.panel_login = wx.Panel(self.panel_1, wx.ID_ANY)
        self.bitmap_1 = wx.StaticBitmap(self.panel_login, wx.ID_ANY, wx.Bitmap("/home/ghssvythiri/Desktop/about.jpeg", wx.BITMAP_TYPE_ANY))
        self.label_2 = wx.StaticText(self.panel_login, wx.ID_ANY, _("label_2"))
        self.text_ctrl_1 = wx.TextCtrl(self.panel_login, wx.ID_ANY, "")
        self.label_3 = wx.StaticText(self.panel_login, wx.ID_ANY, _("label_3"))
        self.text_ctrl_2 = wx.TextCtrl(self.panel_login, wx.ID_ANY, "", style=wx.TE_PASSWORD)
        self.button_1 = wx.Button(self.panel_login, wx.ID_ANY, _("button_1"))
        self.panel_class = wx.Panel(self.panel_1, wx.ID_ANY)
        self.checkbox_1 = wx.CheckBox(self.panel_class, wx.ID_ANY, _("checkbox_1"))
        self.checkbox_2 = wx.CheckBox(self.panel_class, wx.ID_ANY, _("checkbox_2"))
        self.checkbox_3 = wx.CheckBox(self.panel_class, wx.ID_ANY, _("checkbox_3"))
        self.button_2 = wx.Button(self.panel_class, wx.ID_ANY, _("button_2"))
        self.panel_progress = wx.Panel(self.panel_1, wx.ID_ANY)
        self.panel_report = wx.Panel(self.panel_1, wx.ID_ANY)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_next, self.button_2)
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def reset_photo(self,default=False):

        print "changing photo"
        cur_dir=os.path.dirname(os.path.abspath((sys.argv[0])))


        if default:    


            path=cur_dir+"/Resources/img/browse.jpg"


        else:

            path=cur_dir+"/Resources/profile_pic/"+str(self.current_admission_no)+".jpg"

            if not os.path.isfile(path):

                path=cur_dir+"/Resources/img/browse.jpg"


        if self.path!=path:# changes only if it has changed
            self.bitmap_photo = wx.BitmapButton(self.panel_1, wx.ID_ANY,wx.Bitmap(path, wx.BITMAP_TYPE_ANY))

            #self.bitmap_photo.SetBitmapSelected( wx.Bitmap(path, wx.BITMAP_TYPE_ANY))
            selected_index=0
            print self.combo_box_adno.GetSelection()
            if self.combo_box_adno.GetSelection()>0:
                selected_index=self.combo_box_adno.GetItems().index(self.current_admission_no)
            self.__set_properties()
            self.__do_layout()
            self.combo_box_adno.SetSelection(selected_index)
            self.bitmap_photo.Enable(True)
            self.path=path
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def on_photo(self, event):  # wxGlade: student_profie.<event_handler>
        #wcd="Image Files(*.jpeg)|*.jpeg| JPG Files(*.jpg)|*.jpg| PNG Files(*.png)|*.png"
        #return 0
        print "on photo"
        wcd="Image Files(*.jpeg,*.jpg,*.png)|*.jpeg;*.jpg;*.png"
        dir = "/home"
        open_dlg = wx.FileDialog(self, message='Select Photo', defaultDir=dir, defaultFile= '', wildcard=wcd, style=wx.OPEN)
        if open_dlg.ShowModal() == wx.ID_OK:
            path = open_dlg.GetPath()

            result=self.VALID.validate_photo(path)
            if result[0]:

                self.bitmap_photo = wx.BitmapButton(self.panel_1, wx.ID_ANY,wx.Bitmap(path, wx.BITMAP_TYPE_ANY))
                self.__set_properties()
                self.__do_layout()
                self.button_save.Enable(True)
                self.prof_pic_path=path


                open_dlg.Destroy
                self.combo_box_adno.SetValue(str(self.current_admission_no))


            else:
                open_dlg.Destroy
                msg=result[1]
                icon=wx.ICON_ERROR

                dlg = wx.MessageDialog(self, msg, 'Size Error',wx.OK | wx.ICON_ERROR)                  
                dlg.ShowModal()
                dlg.Destroy()
        else:
            open_dlg.Destroy()

        event.Skip()
项目:jasper-modules    作者:mattcurrycom    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("/home/john/Pictures/jasper gui jarvis/jarvisrotator.png", wx.BITMAP_TYPE_ANY))

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
项目:jasper-modules    作者:mattcurrycom    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle(_("frame_1"))
        _icon = wx.EmptyIcon()
        _icon.CopyFromBitmap(wx.Bitmap("/home/john/Pictures/jasper gui jarvis/jarvisrotator.png", wx.BITMAP_TYPE_ANY))
        self.SetIcon(_icon)
        # end wxGlade
项目:baroness    作者:ulrichknecht    | 项目源码 | 文件源码
def switchPanels(self):
        active = self.active
        self.panelStart.Hide()
        self.panelDrinks.Hide()
        self.panelUsers.Hide()
        self.panelThanks.Hide()
        self.panelSorry.Hide()
        self.panelRFID.Hide()
        if active == 0:
            if settings.enableRFID:
                self.rfid.start()
            self.panelStart.Show()
        elif active == 1:
            if not settings.onlyOneDrink:
                self.panelDrinks.l_amount.SetLabel("%02d" % 1)
            self.panelDrinks.l_user.SetLabel(self.user.longname)
            self.panelDrinks.Show()
        elif active == 2:
            self.panelUsers.Show()
        elif active == 3:
            self.panelThanks.label_1.SetLabel(self.user.longname + "\n" + "%02d x " % int(self.panelDrinks.GetAmount()) + self.drinkl.split('\n')[0])
            self.panelThanks.label_1.Wrap(340)
            try:
                self.panelThanks.bitmap_2.SetBitmap(wx.Bitmap("./app/static/product_%s.png" % self.drinkl.split('\n')[0], wx.BITMAP_TYPE_ANY))
            except:
                logging.error("no picture for drink: " + self.drinkl.split('\n')[0])
            self.panelThanks.Show()
            self.delayExit()
        elif active == 4:
            self.panelSorry.label_1.SetLabel(self.user.longname)
            self.panelSorry.Show()
        else: #active == 5:
            self.panelRFID.label_1.SetLabel(self.rfidid)
            self.panelRFID.Show()
项目:baroness    作者:ulrichknecht    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=(0, 0), size=(480, 320))
        self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("./gui/start.png", wx.BITMAP_TYPE_ANY), pos=(0, 0))
        if not settings.hideGuiList:
            self.Bind(wx.EVT_LEFT_DOWN, parent.onStart)
            self.bitmap_1.Bind(wx.EVT_LEFT_DOWN, parent.onStart)
项目:baroness    作者:ulrichknecht    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=(0, 0), size=(480, 320))

        self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("./gui/thanks.png", wx.BITMAP_TYPE_ANY), pos=(0, 0))
        self.bitmap_2 = wx.StaticBitmap(self, wx.ID_ANY, wx.NullBitmap, pos=(10, 10))

        self.label_1 = wx.StaticText(self, wx.ID_ANY, 'bla blub', pos=(120, 50), size=(340, 100))
        self.label_1.SetFont(wx.Font(25, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
        self.label_1.SetForegroundColour("white")
项目:baroness    作者:ulrichknecht    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=(0, 0), size=(480, 320))
        self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("./gui/sorry.png", wx.BITMAP_TYPE_ANY), pos=(0, 0))
        self.bitmap_1.Bind(wx.EVT_LEFT_DOWN, parent.onExit)
        self.label_1 = wx.StaticText(self, wx.ID_ANY, 'bla blub', pos=(100,100))
        self.label_1.SetFont(wx.Font(30, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
项目:baroness    作者:ulrichknecht    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=(0, 0), size=(480, 320))
        self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("./gui/rfid.png", wx.BITMAP_TYPE_ANY), pos=(0, 0))
        self.bitmap_1.Bind(wx.EVT_LEFT_DOWN, parent.onExit)
        self.label_1 = wx.StaticText(self, wx.ID_ANY, 'bla blub', pos=(100,100), size=(100,220))
        self.label_1.SetFont(wx.Font(30, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))