Python wx.Bitmap() Examples
The following are 30
code examples of wx.Bitmap().
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: welcome.py From DeepLabCut with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, parent, gui_size): h = gui_size[0] w = gui_size[1] wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER, size=(h, w)) ## design the panel sizer = wx.GridBagSizer(10, 7) # Add image of DLC icon = wx.StaticBitmap(self, bitmap=wx.Bitmap(dlc)) sizer.Add(icon, pos=(0, 0), span=(0, 8), flag=wx.EXPAND | wx.BOTTOM, border=10) line = wx.StaticLine(self) sizer.Add(line, pos=(1, 0), span=(1, 8), flag=wx.EXPAND | wx.BOTTOM, border=10) # if editing this text make sure you add the '\n' to get the new line. The sizer is unable to format lines correctly. description = "DeepLabCut™ is an open source tool for markerless\npose estimation of user-defined body parts with deep learning.\nA. and M.W. Mathis Labs | http://www.deeplabcut.org\n \nWelcome to the DeepLabCut Project Manager GUI!\nTo get started, please click on the 'Manage Project'\n tab to create or load an existing project. \n " self.proj_name = wx.StaticText(self, label=description, style=wx.ALIGN_CENTRE) sizer.Add(self.proj_name, pos=(2, 3), border=10) sizer.AddGrowableCol(2) self.SetSizer(sizer) sizer.Fit(self)
Example #2
Source File: core.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, id=-1, colour=wx.BLACK, pos=wx.DefaultPosition, size=wx.DefaultSize, style = CLRP_DEFAULT_STYLE, validator = wx.DefaultValidator, name = "colourpickerwidget"): wx.BitmapButton.__init__(self, parent, id, wx.Bitmap(1,1), pos, size, style, validator, name) self.SetColour(colour) self.InvalidateBestSize() self.SetInitialSize(size) self.Bind(wx.EVT_BUTTON, self.OnButtonClick) global _colourData if _colourData is None: _colourData = wx.ColourData() _colourData.SetChooseFull(True) grey = 0 for i in range(16): c = wx.Colour(grey, grey, grey) _colourData.SetCustomColour(i, c) grey += 16
Example #3
Source File: wm_legend.py From wafer_map with GNU General Public License v3.0 | 6 votes |
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()
Example #4
Source File: backend_wx.py From Computable with MIT License | 6 votes |
def _load_bitmap(filename): """ Load a bitmap file from the backends/images subdirectory in which the matplotlib library is installed. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object """ basedir = os.path.join(rcParams['datapath'],'images') bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying'%bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp
Example #5
Source File: backend_wx.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def draw_image(self, gc, x, y, im): bbox = gc.get_clip_rectangle() if bbox is not None: l, b, w, h = bbox.bounds else: l = 0 b = 0 w = self.width h = self.height rows, cols = im.shape[:2] bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tostring()) gc = self.get_gc() gc.select() gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b), int(w), int(-h)) gc.unselect()
Example #6
Source File: backend_wx.py From matplotlib-4-abaqus with MIT License | 6 votes |
def _load_bitmap(filename): """ Load a bitmap file from the backends/images subdirectory in which the matplotlib library is installed. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object """ basedir = os.path.join(rcParams['datapath'],'images') bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying'%bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp
Example #7
Source File: wxPython_Wallpaper.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 6 votes |
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()
Example #8
Source File: MainUI.py From Model-Playgrounds with MIT License | 6 votes |
def launchFileDialog(self, evt): # defining wildcard for suppported picture formats wildcard = "JPEG (*.jpg)|*.jpg|" \ "PNG (*.png)|*.png|" \ "GIF (*.gif)|*.gif" # defining the dialog object dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="", wildcard=wildcard, style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW) # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog) if dialog.ShowModal() == wx.ID_OK: self.magic_collection[1].SetValue( "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....") paths = dialog.GetPaths() # This adds the selected picture to the Right region. Right region object is retrieved from UI object array modification_bitmap1 = wx.Bitmap(paths[0]) modification_image1 = modification_bitmap1.ConvertToImage() modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH) modification_bitmap2 = modification_image1.ConvertToBitmap() report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20)) self.processPicture(paths[0], "PROGRAM_INSTALL_FULLPATH\\resnet50_weights_tf_dim_ordering_tf_kernels.h5", "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json")
Example #9
Source File: MainUI.py From Model-Playgrounds with MIT License | 6 votes |
def launchFileDialog(self, evt): # defining wildcard for suppported picture formats wildcard = "JPEG (*.jpg)|*.jpg|" \ "PNG (*.png)|*.png|" \ "GIF (*.gif)|*.gif" # defining the dialog object dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="", wildcard=wildcard, style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW) # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog) if dialog.ShowModal() == wx.ID_OK: self.magic_collection[1].SetValue( "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....") paths = dialog.GetPaths() # This adds the selected picture to the Right region. Right region object is retrieved from UI object array modification_bitmap1 = wx.Bitmap(paths[0]) modification_image1 = modification_bitmap1.ConvertToImage() modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH) modification_bitmap2 = modification_image1.ConvertToBitmap() report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20)) self.processPicture(paths[0], "PROGRAM_INSTALL_FULLPATH\\squeezenet_weights_tf_dim_ordering_tf_kernels.h5", "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json")
Example #10
Source File: MainUI.py From Model-Playgrounds with MIT License | 6 votes |
def launchFileDialog(self, evt): # defining wildcard for suppported picture formats wildcard = "JPEG (*.jpg)|*.jpg|" \ "PNG (*.png)|*.png|" \ "GIF (*.gif)|*.gif" # defining the dialog object dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="", wildcard=wildcard, style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW) # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog) if dialog.ShowModal() == wx.ID_OK: self.magic_collection[1].SetValue( "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....") paths = dialog.GetPaths() # This adds the selected picture to the Right region. Right region object is retrieved from UI object array modification_bitmap1 = wx.Bitmap(paths[0]) modification_image1 = modification_bitmap1.ConvertToImage() modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH) modification_bitmap2 = modification_image1.ConvertToBitmap() report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20)) self.processPicture(paths[0], "PROGRAM_INSTALL_FULLPATH\\DenseNet-BC-121-32.h5", "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json")
Example #11
Source File: MainUI.py From Model-Playgrounds with MIT License | 6 votes |
def launchFileDialog(self, evt): # defining wildcard for suppported picture formats wildcard = "JPEG (*.jpg)|*.jpg|" \ "PNG (*.png)|*.png|" \ "GIF (*.gif)|*.gif" # defining the dialog object dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="", wildcard=wildcard, style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW) # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog) if dialog.ShowModal() == wx.ID_OK: self.magic_collection[1].SetValue( "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....") paths = dialog.GetPaths() # This adds the selected picture to the Right region. Right region object is retrieved from UI object array modification_bitmap1 = wx.Bitmap(paths[0]) modification_image1 = modification_bitmap1.ConvertToImage() modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH) modification_bitmap2 = modification_image1.ConvertToBitmap() report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20)) self.processPicture(paths[0], "PROGRAM_INSTALL_FULLPATH\\inception_v3_weights_tf_dim_ordering_tf_kernels.h5", "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json")
Example #12
Source File: GoSyncController.py From gosync with GNU General Public License v2.0 | 6 votes |
def CreateMenuItem(self, menu, label, func, icon=None, id=None): if id: item = wx.MenuItem(menu, id, label) else: item = wx.MenuItem(menu, -1, label) if icon: item.SetBitmap(wx.Bitmap(icon)) if id: self.Bind(wx.EVT_MENU, func, id=id) else: self.Bind(wx.EVT_MENU, func, id=item.GetId()) if wxgtk4 : menu.Append(item) else: menu.AppendItem(item) return item
Example #13
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def draw_image(self, gc, x, y, im): bbox = gc.get_clip_rectangle() if bbox is not None: l, b, w, h = bbox.bounds else: l = 0 b = 0 w = self.width h = self.height rows, cols = im.shape[:2] bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tostring()) gc = self.get_gc() gc.select() gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b), int(w), int(-h)) gc.unselect()
Example #14
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _load_bitmap(filename): """ Load a bitmap file from the backends/images subdirectory in which the matplotlib library is installed. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object """ basedir = os.path.join(rcParams['datapath'], 'images') bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying' % bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp
Example #15
Source File: gui.py From superpaper with MIT License | 6 votes |
def resize_displays(self, use_ppi_px): if use_ppi_px: for (disp, img_sz, bez_szs, st_bmp) in zip(self.display_rel_sizes, self.img_rel_sizes, self.bz_rel_sizes, self.preview_img_list): size, offs = disp bmp = wx.Bitmap.FromRGBA(img_sz[0], img_sz[1], red=0, green=0, blue=0, alpha=255) bmp_w_bez = self.bezels_to_bitmap(bmp, size, bez_szs) st_bmp.SetSize(size) st_bmp.SetPosition(offs) st_bmp.SetBitmap(bmp_w_bez) else: for disp, st_bmp in zip(self.display_rel_sizes, self.preview_img_list): size = disp[0] offs = disp[1] bmp = wx.Bitmap.FromRGBA(size[0], size[1], red=0, green=0, blue=0, alpha=255) st_bmp.SetBitmap(bmp) st_bmp.SetPosition(offs) st_bmp.SetSize(size) self.draw_monitor_numbers(use_ppi_px)
Example #16
Source File: gui.py From superpaper with MIT License | 6 votes |
def resize_and_bitmap(self, fname, size, enhance_color=False): """Take filename of an image and resize and center crop it to size.""" try: pil = resize_to_fill(Image.open(fname), size, quality="fast") except UnidentifiedImageError: msg = ("Opening image '%s' failed with PIL.UnidentifiedImageError." "It could be corrupted or is of foreign type.") % fname sp_logging.G_LOGGER.info(msg) # show_message_dialog(msg) black_bmp = wx.Bitmap.FromRGBA(size[0], size[1], red=0, green=0, blue=0, alpha=255) if enhance_color: return (black_bmp, black_bmp) return black_bmp img = wx.Image(pil.size[0], pil.size[1]) img.SetData(pil.convert("RGB").tobytes()) if enhance_color: converter = ImageEnhance.Color(pil) pilenh_bw = converter.enhance(0.25) brightns = ImageEnhance.Brightness(pilenh_bw) pilenh = brightns.enhance(0.45) imgenh = wx.Image(pil.size[0], pil.size[1]) imgenh.SetData(pilenh.convert("RGB").tobytes()) return (img.ConvertToBitmap(), imgenh.ConvertToBitmap()) return img.ConvertToBitmap()
Example #17
Source File: gui.py From superpaper with MIT License | 6 votes |
def draw_canvas(self, dc, draw=True): if self.st_bmp_canvas: pos = self.st_bmp_canvas.GetPosition() bmp = self.st_bmp_canvas.GetBitmap() bmp_sz = bmp.GetSize() if not draw: bmp = wx.Bitmap.FromRGBA(bmp_sz[0], bmp_sz[1], red=30, green=30, blue=30, alpha=255) op = wx.COPY if bmp.IsOk(): memDC = wx.MemoryDC() # memDC.SelectObject(wx.NullBitmap) memDC.SelectObject(bmp) dc.Blit(pos[0], pos[1], bmp_sz[0], bmp_sz[1], memDC, 0, 0, op, True) return True else: return False
Example #18
Source File: uicore.py From NXP-MCUBootUtility with Apache License 2.0 | 6 votes |
def updateConnectStatus( self, color='black' ): self.connectStatusColor = color if color == 'black': self.m_button_connect.SetLabel(uilang.kMainLanguageContentDict['button_connect_black'][self.languageIndex]) self.m_bitmap_connectLed.SetBitmap(wx.Bitmap( u"../img/led_black.png", wx.BITMAP_TYPE_ANY )) elif color == 'yellow': self.m_button_connect.SetLabel(uilang.kMainLanguageContentDict['button_connect_yellow'][self.languageIndex]) self.m_bitmap_connectLed.SetBitmap(wx.Bitmap( u"../img/led_yellow.png", wx.BITMAP_TYPE_ANY )) elif color == 'green': self.m_button_connect.SetLabel(uilang.kMainLanguageContentDict['button_connect_green'][self.languageIndex]) self.m_bitmap_connectLed.SetBitmap(wx.Bitmap( u"../img/led_green.png", wx.BITMAP_TYPE_ANY )) elif color == 'blue': self.m_button_connect.SetLabel(uilang.kMainLanguageContentDict['button_connect_blue'][self.languageIndex]) self.m_bitmap_connectLed.SetBitmap(wx.Bitmap( u"../img/led_blue.png", wx.BITMAP_TYPE_ANY )) self.playSoundEffect(uidef.kSoundEffectFilename_Progress) elif color == 'red': self.m_button_connect.SetLabel(uilang.kMainLanguageContentDict['button_connect_red'][self.languageIndex]) self.m_bitmap_connectLed.SetBitmap(wx.Bitmap( u"../img/led_red.png", wx.BITMAP_TYPE_ANY )) else: pass
Example #19
Source File: backend_wx.py From ImageFusion with MIT License | 6 votes |
def _load_bitmap(filename): """ Load a bitmap file from the backends/images subdirectory in which the matplotlib library is installed. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object """ basedir = os.path.join(rcParams['datapath'],'images') bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying'%bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp
Example #20
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def draw_image(self, gc, x, y, im): bbox = gc.get_clip_rectangle() if bbox is not None: l, b, w, h = bbox.bounds else: l = 0 b = 0 w = self.width h = self.height rows, cols = im.shape[:2] bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tostring()) gc = self.get_gc() gc.select() gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b), int(w), int(-h)) gc.unselect()
Example #21
Source File: backend_wx.py From neural-network-animation with MIT License | 6 votes |
def _load_bitmap(filename): """ Load a bitmap file from the backends/images subdirectory in which the matplotlib library is installed. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object """ basedir = os.path.join(rcParams['datapath'],'images') bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying'%bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp
Example #22
Source File: imageutil.py From me-ica with GNU Lesser General Public License v2.1 | 5 votes |
def _load_image(image_path): try: return wx.Bitmap(image_path) except: raise IOError('Invalid Image path')
Example #23
Source File: mathtext_wx_sgskip.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def mathtext_to_wxbitmap(s): ftimage, depth = mathtext_parser.parse(s, 150) return wx.Bitmap.FromBufferRGBA( ftimage.get_width(), ftimage.get_height(), ftimage.as_rgba_str()) ############################################################
Example #24
Source File: gui.py From superpaper with MIT License | 5 votes |
def draw_displays(self, use_ppi_px = False, use_multi_image = False): work_sz = self.GetSize() # draw canvas bmp_canv = wx.Bitmap.FromRGBA(self.dtop_canvas_relsz[0], self.dtop_canvas_relsz[1], red=0, green=0, blue=0, alpha=255) if not self.preview_img_list: # preview StaticBitmaps don't exist yet self.bmp_list.append(bmp_canv) self.st_bmp_canvas = wx.StaticBitmap(self, wx.ID_ANY, bmp_canv) self.st_bmp_canvas.SetPosition(self.dtop_canvas_pos) self.st_bmp_canvas.Hide() # draw monitor previews for disp in self.display_rel_sizes: size = disp[0] offs = disp[1] bmp = wx.Bitmap.FromRGBA(size[0], size[1], red=0, green=0, blue=0, alpha=255) self.bmp_list.append(bmp) st_bmp = wx.StaticBitmap(self, wx.ID_ANY, bmp) st_bmp.Hide() # st_bmp.SetScaleMode(wx.Scale_AspectFill) # New in wxpython 4.1 st_bmp.SetPosition(offs) self.preview_img_list.append(st_bmp) else: # previews exist and should be blanked self.current_preview_images = [] # drop chached image list self.st_bmp_canvas.SetBitmap(bmp_canv) self.st_bmp_canvas.SetPosition(self.dtop_canvas_pos) # self.st_bmp_canvas.Hide() # blank monitor previews for disp, st_bmp in zip(self.display_rel_sizes, self.preview_img_list): size = disp[0] offs = disp[1] bmp = wx.Bitmap.FromRGBA(size[0], size[1], red=0, green=0, blue=0, alpha=255) st_bmp.SetBitmap(bmp) st_bmp.SetPosition(offs) # st_bmp.Hide() self.draw_monitor_numbers(use_ppi_px) self.Refresh()
Example #25
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def CalcBoundingBox(self): ## this isn't exact, as fonts don't scale exactly. dc = wx.MemoryDC() bitmap = wx.Bitmap(1, 1) dc.SelectObject(bitmap) #wxMac needs a Bitmap selected for GetTextExtent to work. DrawingSize = 40 # pts This effectively determines the resolution that the BB is computed to. ScaleFactor = float(self.Size) / DrawingSize self.SetFont(DrawingSize, self.Family, self.Style, self.Weight, self.Underlined, self.FaceName) dc.SetFont(self.Font) (w,h) = dc.GetTextExtent(self.String) w = w * ScaleFactor h = h * ScaleFactor x, y = self.ShiftFun(self.XY[0], self.XY[1], w, h, world = 1) self.BoundingBox = BBox.asBBox(((x, y-h ),(x + w, y)))
Example #26
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def _cycleidxs(indexcount, maxvalue, step): """ Utility function used by _colorGenerator """ def colormatch(color): """Return True if the color comes back from the bitmap identically.""" if len(color) < 3: return True global _testBitmap dc = wx.MemoryDC() if not _testBitmap: _testBitmap = wx.Bitmap(1, 1) dc.SelectObject(_testBitmap) dc.SetBackground(wx.BLACK_BRUSH) dc.Clear() dc.SetPen(wx.Pen(wx.Colour(*color), 4)) dc.DrawPoint(0,0) if mac: # NOTE: can the Mac not just use the DC? del dc # Mac can't work with bitmap when selected into a DC. pdata = wx.AlphaPixelData(_testBitmap) pacc = pdata.GetPixels() pacc.MoveTo(pdata, 0, 0) outcolor = pacc.Get()[:3] else: outcolor = dc.GetPixel(0,0) return outcolor == color if indexcount == 0: yield () else: for idx in range(0, maxvalue, step): for tail in _cycleidxs(indexcount - 1, maxvalue, step): color = (idx, ) + tail if not colormatch(color): continue yield color
Example #27
Source File: gui.py From superpaper with MIT License | 5 votes |
def bezels_to_bitmap(self, bmp, disp_sz, bez_rects): """Add bezel rectangles ( right_bez , bottom_bez ) to given bitmap.""" sp_logging.G_LOGGER.info("bezels_to_bitmap: bez_rects: %s", bez_rects) right_bez, bottom_bez = bez_rects if (right_bez == (0, 0) and bottom_bez == (0, 0)): return bmp # bmp into wx.Image and new output img = bmp.ConvertToImage() img_sz = img.GetSize() img_out = wx.Image(disp_sz[0], disp_sz[1]) img_out.Paste(img, 0, 0) # Add bezels sequentially to the Image # bottom bez if bottom_bez != (0, 0): b_bez_bmp = wx.Bitmap.FromRGBA(bottom_bez[0], bottom_bez[1], red=5, green=5, blue=5, alpha=100) b_bez_img = b_bez_bmp.ConvertToImage() img_out.Paste(b_bez_img, 0, img_sz[1]) # right bez: is longer if bottom bez is present if right_bez != (0, 0): r_bez_bmp = wx.Bitmap.FromRGBA(right_bez[0], right_bez[1], red=5, green=5, blue=5, alpha=100) r_bez_img = r_bez_bmp.ConvertToImage() img_out.Paste(r_bez_img, img_sz[0], 0) # Convert Image back to wx.Bitmap return img_out.ConvertToBitmap()
Example #28
Source File: color_recognizer2.py From color_recognizer with MIT License | 5 votes |
def __init__(self, parent, title="Color Recognizer 2"): wx.Frame.__init__(self, parent, size=(800, 600), style=wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX) self.imgSizer = (800, 600) self.pnl = wx.Panel(self) self.vbox = wx.BoxSizer(wx.VERTICAL) self.image = wx.Image(self.imgSizer[0],self.imgSizer[1]) self.imageBit = wx.Bitmap(self.image) self.staticBit = wx.StaticBitmap(self.pnl, wx.ID_ANY, self.imageBit) self.vbox.Add(self.staticBit) self.capture = cv2.VideoCapture(0) ret, self.frame = self.capture.read() if ret: self.height, self.width = self.frame.shape[:2] self.bmp = wx.Bitmap.FromBuffer(self.width, self.height, self.frame) self.timex = wx.Timer(self) self.timex.Start(1000./24) self.Bind(wx.EVT_TIMER, self.redraw) self.SetSize(self.imgSizer) else: print("Error no webcam image") self.pnl.SetSizer(self.vbox) self.vbox.Fit(self) #Â Create buttons btn_black = wx.Button(self, -1, "Black", pos=(10,20)) btn_white = wx.Button(self, -1, "White", pos=(110,20)) btn_red = wx.Button(self, -1, "Red", pos=(210,20)) btn_green = wx.Button(self, -1, "Green", pos=(310,20)) btn_blue = wx.Button(self, -1, "Blue", pos=(410,20)) btn_orange = wx.Button(self, -1, "Orange", pos=(510,20)) btn_yellow = wx.Button(self, -1, "Yellow", pos=(610,20)) btn_purple = wx.Button(self, -1, "Purple", pos=(710,20)) self.Bind(wx.EVT_BUTTON, self.OnClick) # Create statusbar self.statusbar = self.CreateStatusBar(1) self.statusbar.SetStatusText('None') self.Show()
Example #29
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _onSize(self, evt): """ Called when wxEventSize is generated. In this application we attempt to resize to fit the window, so it is better to take the performance hit and redraw the whole window. """ DEBUG_MSG("_onSize()", 2, self) sz = self.GetParent().GetSizer() if sz: si = sz.GetItem(self) if sz and si and not si.Proportion and not si.Flag & wx.EXPAND: # managed by a sizer, but with a fixed size size = self.GetMinSize() else: # variable size size = self.GetClientSize() if getattr(self, "_width", None): if size == (self._width, self._height): # no change in size return self._width, self._height = size # Create a new, correctly sized bitmap self.bitmap = wx.Bitmap(self._width, self._height) self._isDrawn = False if self._width <= 1 or self._height <= 1: return # Empty figure dpival = self.figure.dpi winch = self._width / dpival hinch = self._height / dpival self.figure.set_size_inches(winch, hinch, forward=False) # Rendering will happen on the associated paint event # so no need to do anything here except to make sure # the whole background is repainted. self.Refresh(eraseBackground=False) FigureCanvasBase.resize_event(self)
Example #30
Source File: imageutil.py From pyFileFixity with MIT License | 5 votes |
def _load_image(image_path): try: return wx.Bitmap(image_path) except: raise IOError('Invalid Image path')