def createCharBitmaps(self): dc = MemoryDC() dc.SetFont(self.fonts['monospace']) cw, ch = dc.GetTextExtent(' ') self.charSize = cw, ch self.normalChars = {} for c in self.charSet: bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH) dc.SelectObject(bitmap) dc.SetBackground(self.brushes['bkgd']) dc.Clear() dc.SetTextForeground(Colour(230, 230, 230)) dc.DrawText(c, 0, 0) self.normalChars[c] = bitmap self.selectedChars = {} for c in self.charSet: bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH) dc.SelectObject(bitmap) dc.SetBackground(Brush(Colour(70, 80, 90))) dc.Clear() dc.SetTextForeground(Colour(160, 160, 180)) if c == ' ': dc.DrawText(c, 0, 0) else: dc.DrawText(c, 0, 0) self.selectedChars[c] = bitmap self.numberChars = {} for c in ' 0123456789': bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH) dc.SelectObject(bitmap) dc.SetBackground(self.brushes['bkgd']) dc.Clear() dc.SetTextForeground(Colour(150, 150, 200)) dc.DrawText(c, 0, 0) self.numberChars[c] = bitmap dc.SelectObject(NullBitmap) return
def start_seedwatcher(app, cb_wallet): app.frame_sw = SeedWatcherFrame(app.gui_frame) app.frame_sw.SetIcons(IconBundle(file_path("gui/uniblow.ico"))) HAND_CURSOR = Cursor(CURSOR_HAND) app.gui_panel.devices_choice.SetSelection(0) app.gui_frame.Hide() app.panel_sw = SeedWatcherPanel(app.frame_sw) app.panel_sw.m_textCtrl_mnemo.SetFocus() if sys.platform.startswith("darwin"): app.panel_sw.m_staticTextcopy.SetLabel( "Select asset line, then right click on it to open menu") app.panel_sw.m_button_gen.SetBitmap( Bitmap(file_path("gui/GenSeed.png"), BITMAP_TYPE_PNG)) app.panel_sw.m_button_gen.SetBitmapPressed( Bitmap(file_path("gui/GenSeeddn.png"), BITMAP_TYPE_PNG)) app.panel_sw.m_btnseek.SetBitmap( Bitmap(file_path("gui/SeekAssets.png"), BITMAP_TYPE_PNG)) app.panel_sw.m_btnseek.SetBitmapPressed( Bitmap(file_path("gui/SeekAssetsdn.png"), BITMAP_TYPE_PNG)) app.panel_sw.m_button_gen.SetCursor(HAND_CURSOR) app.panel_sw.m_choice_nwords.SetCursor(HAND_CURSOR) app.panel_sw.m_typechoice.SetCursor(HAND_CURSOR) app.panel_sw.m_btnseek.SetCursor(HAND_CURSOR) app.panel_sw.initialize(cb_wallet) app.frame_sw.Show()
def CreateDC(self, loadBackground: bool, w: int, h: int) -> DC: """ Create a DC, load the background on demand. @param loadBackground @param w : width of the frame. @param h : height of the frame. @return DC """ dc = MemoryDC() bm = self.__workingBitmap # cache the bitmap, to avoid creating a new at each refresh. # only recreate it if the size of the window has changed if (bm.GetWidth(), bm.GetHeight()) != (w, h): bm = self.__workingBitmap = Bitmap(w, h) dc.SelectObject(bm) if loadBackground: self.LoadBackground(dc, w, h) else: dc.SetBackground(Brush(self.GetBackgroundColour())) dc.Clear() self.PrepareDC(dc) return dc
def __init__(self, columns, rows): # get geometry sl, sr, st, sb = self._borders # record parameters self.screenSize = columns+sl+sr, rows+st+sb # create character set self.CS = CharacterSet() # get character geometry _cw, _ch = self.CS.get(' ').GetSize() print(_cw, _ch) # record parameters self.charSize = _cw, _ch # create pens self.createSolidPen('_borders', 80, 80, 80) self.createSolidPen('_borderLeft', 150, 50, 50) self.createSolidPen('_cursor', 255, 180, 100, width = 2) # define bitmap parameters w, h, d = (columns+sl+sr)*_cw, (rows+st+sb)*_ch, BITMAP_SCREEN_DEPTH # create screen bitmap self.bitmapBuffer = Bitmap(w, h, d) # create blank bitmap (see comment for _BlankScreen) self.bitmapBlank = self._BlankScreen(w, h, d) # create empty buffer self.textBuffer = [''] # done self._refresh() return
def write(self, oglObjects: List[OglClass]): """ Write data Args: oglObjects: list of exported objects """ mediator: Mediator = self._ctrl mediator.deselectAllShapes() imageType: BitmapType = WxImageFormat.toWxBitMapType(self._imageFormat) window: ScrolledWindow = self._umlFrame context: ClientDC = ClientDC(window) memory: MemoryDC = MemoryDC() x, y = window.GetSize() emptyBitmap: Bitmap = Bitmap(x, y, -1) memory.SelectObject(emptyBitmap) memory.Blit(source=context, xsrc=0, height=y, xdest=0, ydest=0, ysrc=0, width=x) memory.SelectObject(NullBitmap) img: Image = emptyBitmap.ConvertToImage() extension: str = self._imageFormat.__str__() filename: str = f'{self._outputFileName}.{extension}' status: bool = img.SaveFile(filename, imageType) if status is False: self.logger.error(f'Error on image write to {filename}')
def _BlankScreen(self, w, h, d): b = Bitmap(w, h, d) dc = MemoryDC() dc.SelectObject(b) self._clear(dc) dc.SelectObject(NullBitmap) return b
def createCharBitmap(setName, fontName, frgd, bkgd): global _cw, _ch # create device context dc = MemoryDC() # set font dc.SetFont(_fonts[fontName]) # get font size _cw, _ch = dc.GetTextExtent(' ') BitmapSet = {} for c in _printableCharSet: # create bitmap bitmap = Bitmap(_cw, _ch, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(bitmap) # set background dc.SetBackground(_brushes[bkgd]) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(_colours[frgd]) # write character dc.DrawText(c, 0, 0) # record BitmapSet[c] = bitmap # release bitmap dc.SelectObject(NullBitmap) # record set _printableCharBitmaps[setName] = BitmapSet # done return
def __init__(self, rows, colums): self.bitmap = Bitmap(colums * _cw, rows * _ch, BITMAP_SCREEN_DEPTH) dc = MemoryDC() dc.SelectObject(self.bitmap) dc.SetBackground(_brushes['bgd']) dc.Clear() dc.SelectObject(NullBitmap) return
def GetIcons() -> dict: if not __iconCache: iconsPath = ResPath("icons") files = os.listdir(iconsPath) for file in files: if file.endswith(".png"): __iconCache[file.split(".")[0]] = Bitmap( ResPath("icons/%s" % file), BITMAP_TYPE_PNG) return __iconCache
def initialize(self, cb_wallet): self.GOOD_BMP = Bitmap(file_path("gui/good.bmp")) self.BAD_BMP = Bitmap(file_path("gui/bad.bmp")) self.m_choice_nwords.Set(WORDSLEN_LIST) self.m_choice_nwords.SetSelection(0) ctab = self.m_dataViewListCtrl1 dv1 = dataview.DataViewColumn("Name", dataview.DataViewTextRenderer(), 0) dv1.SetWidth(125) ctab.AppendColumn(dv1) dv2 = dataview.DataViewColumn("Account", dataview.DataViewTextRenderer(), 1) dv2.SetWidth(372) ctab.AppendColumn(dv2) dv3 = dataview.DataViewColumn("Balance", dataview.DataViewTextRenderer(), 2) dv3.SetWidth(86) ctab.AppendColumn(dv3) self.cb_wallet = cb_wallet
def hd_setup(self, proposal): """Call the HD device option window.""" self.gui_hdframe = gui.window.HDDialog(self.gui_frame) self.gui_hdpanel = HDsetting_panel(self.gui_hdframe) HAND_CURSOR = Cursor(CURSOR_HAND) if proposal: # LocalFile wallet init setup self.gui_hdpanel.GOOD_BMP = Bitmap(file_path("gui/good.bmp")) self.gui_hdpanel.BAD_BMP = Bitmap(file_path("gui/bad.bmp")) self.gui_hdpanel.m_bitmapHDwl.SetBitmap(self.gui_hdpanel.BAD_BMP) self.gui_hdpanel.m_bitmapHDcs.SetBitmap(self.gui_hdpanel.BAD_BMP) self.gui_hdpanel.m_checkBox_secboost.SetCursor(HAND_CURSOR) self.gui_hdpanel.m_textCtrl_mnemo.SetValue(proposal) self.gui_hdpanel.m_usertxt.SetLabel( "Validate this first proposal,\n" "or insert your mnemonic and settings to import\n" "an existing HD wallet.") else: # hardware wallet options self.gui_hdframe.SetTitle("Open hardware wallet options") self.gui_hdpanel.title_text.SetLabel( "Hardware wallet account options") self.gui_hdpanel.m_textwl.Destroy() self.gui_hdpanel.m_textcs.Destroy() self.gui_hdpanel.m_textCtrl_mnemo.Destroy() self.gui_hdpanel.m_bwptxt.Destroy() self.gui_hdpanel.m_textCtrl_pwd.Destroy() self.gui_hdpanel.m_checkBox_secboost.Destroy() self.gui_hdpanel.m_usertxt.SetLabel( "Choose account and index for the key to use.") self.gui_hdframe.SetSize(480, 320) self.gui_hdpanel.m_butOK.SetCursor(HAND_CURSOR) self.gui_hdpanel.m_butcancel.SetCursor(HAND_CURSOR) ret = self.gui_hdframe.ShowModal() if ret == ID_OK: wallet_settings = self.gui_hdpanel.hd_wallet_settings # Removal of stored settings self.gui_hdframe.DestroyChildren() self.gui_hdframe.Destroy() del self.gui_hdframe return wallet_settings else: return None
def __init__(self, title): # init window Frame.__init__(self, None, ID_ANY, title, size=(800, 800)) self.Bind(EVT_CLOSE, lambda x: self.Destroy()) loc = Icon() loc.CopyFromBitmap(Bitmap('icon.ico', BITMAP_TYPE_ANY)) self.SetIcon(loc) with SimpleSizer(self, VERTICAL) as sizer: new_element = OpenGLCanvas(self) sizer.Add(new_element)
def main(default=True): app = App() screen = ScreenDC() size = screen.GetSize() if default: size = (round(size[0] * 2.5), round(size[1] * 2.5)) bmp = Bitmap(size[0], size[1]) mem = MemoryDC(bmp) mem.Blit(0, 0, size[0], size[1], screen, 0, 0) del mem name = '{}.png'.format(str(randrange(1000))) fname = os.path.join(os.getcwd(), name) bmp.SaveFile(fname, BITMAP_TYPE_PNG) return fname
def createBufferBitmap(self, width, height): cw, ch = self.charSize self.bmpBuf = Bitmap( width * cw, # bitmap width height * ch, # bitmap heigh BITMAP_SCREEN_DEPTH) # bitmap depth dc = MemoryDC() dc.SelectObject(self.bmpBuf) dc.SetBackground(self.brushes['bkgd']) dc.Clear() dc.SelectObject(NullBitmap) self.Panel.BackgroundBitmap = self.bmpBuf self.screenSize = width, height return
def load_image(self, path, area=None): self.Scroll(0, 0) self.img_path = path self.wx_image = Image(path, BITMAP_TYPE_ANY) width = self.wx_image.GetWidth() height = self.wx_image.GetHeight() if area: x, y, w, h = area bitmap = Bitmap(self.wx_image) bitmap_to_draw = bitmap.GetSubBitmap(Rect(x, y, w, h)) bitmap = bitmap.ConvertToImage().ConvertToGreyscale( 0.156, 0.308, 0.060).ConvertToBitmap() self.original_bitmap = self._get_bitmap(bitmap, bitmap_to_draw, x, y, w, h, False) else: self.original_bitmap = Bitmap(self.wx_image) self.greyscaled_bitmap = self.original_bitmap.ConvertToImage( ).ConvertToGreyscale(0.209, 0.411, 0.080).ConvertToBitmap() self.static_bitmap.SetBitmap(self.original_bitmap) self.SetScrollbars(self.MIN_SCROLL, self.MIN_SCROLL, width / self.MIN_SCROLL, height / self.MIN_SCROLL)
def SaveBackground(self, dc: DC): """ Args: dc: The DC to save """ w, h = self.GetSize() bb = self.__backgroundBitmap if (bb.GetWidth(), bb.GetHeight()) != (w, h): bb = self.__backgroundBitmap = Bitmap(w, h) mem = MemoryDC() mem.SelectObject(bb) x, y = self.CalcUnscrolledPosition(0, 0) mem.Blit(0, 0, w, h, dc, x, y) mem.SelectObject(NullBitmap)
def onDrawMe(self, event: CommandEvent): extension: str = 'png' imageType: BitmapType = BITMAP_TYPE_PNG window: ScrolledWindow = self._diagramFrame context: ClientDC = ClientDC(window) memory: MemoryDC = MemoryDC() x, y = window.ClientSize emptyBitmap: Bitmap = Bitmap(x, y, -1) memory.SelectObject(emptyBitmap) memory.Blit(source=context, xsrc=0, height=y, xdest=0, ydest=0, ysrc=0, width=x) memory.SelectObject(NullBitmap) img: Image = emptyBitmap.ConvertToImage() filename: str = f'DiagramDump.{extension}' status: bool = img.SaveFile(filename, imageType)
def SaveBackground(self, dc): """ Save the given dc as the new background image. @param DC dc : the dc to save """ w, h = self.GetSize() bb = self.__backgroundBitmap if (bb.GetWidth(), bb.GetHeight()) != (w, h): bb = self.__backgroundBitmap = Bitmap(w, h) mem = MemoryDC() mem.SelectObject(bb) if __version__ > "2.3.2": x, y = self.CalcUnscrolledPosition(0, 0) mem.Blit(0, 0, w, h, dc, x, y) else: mem.Blit(0, 0, w, h, dc, 0, 0) mem.SelectObject(NullBitmap)
def OnInit(self): icon_path = file_path(ICON_FILE) wicon = IconBundle(icon_path) HAND_CURSOR = Cursor(CURSOR_HAND) self.gui_frame = gui.window.TopFrame(None) self.gui_frame.Bind(EVT_CLOSE, self.OnClose) if sys.platform.startswith("darwin"): self.gui_frame.SetSize((996, 418)) self.gui_panel = gui.window.TopPanel(self.gui_frame) self.gui_frame.SetIcons(wicon) self.gui_panel.hist_button.SetBitmap( Bitmap(file_path("gui/histo.png"), BITMAP_TYPE_PNG)) self.gui_panel.hist_button.SetBitmapPressed( Bitmap(file_path("gui/histodn.png"), BITMAP_TYPE_PNG)) self.gui_panel.copy_button.SetBitmap( Bitmap(file_path("gui/copy.png"), BITMAP_TYPE_PNG)) self.gui_panel.copy_button.SetBitmapPressed( Bitmap(file_path("gui/copydn.png"), BITMAP_TYPE_PNG)) self.gui_panel.send_button.SetBitmap( Bitmap(file_path("gui/send.png"), BITMAP_TYPE_PNG)) self.gui_panel.send_button.SetBitmapPressed( Bitmap(file_path("gui/senddn.png"), BITMAP_TYPE_PNG)) self.gui_panel.send_all.SetBitmap( Bitmap(file_path("gui/swipe.png"), BITMAP_TYPE_PNG)) self.gui_panel.send_all.SetBitmapPressed( Bitmap(file_path("gui/swipedn.png"), BITMAP_TYPE_PNG)) self.gui_panel.devices_choice.SetCursor(HAND_CURSOR) self.gui_panel.coins_choice.SetCursor(HAND_CURSOR) self.gui_panel.network_choice.SetCursor(HAND_CURSOR) self.gui_panel.wallopt_choice.SetCursor(HAND_CURSOR) self.gui_panel.hist_button.SetCursor(HAND_CURSOR) self.gui_panel.copy_button.SetCursor(HAND_CURSOR) self.gui_panel.send_button.SetCursor(HAND_CURSOR) self.gui_panel.send_all.SetCursor(HAND_CURSOR) self.gui_panel.btn_chkaddr.SetCursor(HAND_CURSOR) self.SetTopWindow(self.gui_frame) return True
def CreatePopupMenu(self): menu = Menu() appMenuItem = menu.Append(ID_ANY, "mHosts v" + Settings.version()) if sys.platform != "linux": appMenuItem.Enable(False) appMenuItem.SetBitmap( Bitmap(ResPath("icons/logo.png"), BITMAP_TYPE_PNG)) menu.Append(self.ID_TOGGLE, r"%s主窗口" % ("隐藏" if self.__window.IsShown() else "显示")) menu.AppendSeparator() for hosts in Settings.settings["hosts"]: item = MenuItem(menu, hosts["id"], hosts["name"], kind=ITEM_CHECK) item.Enable(not hosts['alwaysApply']) menu.Append(item) menu.Check(hosts["id"], hosts["active"] or hosts["alwaysApply"]) self.Bind(EVT_MENU, self.__window.OnTaskBarHostsMenuClicked, id=hosts["id"]) newHostMenu = Menu() newHostMenu.Append(self.ID_NEW, "新建") if sys.platform != "linux": newHostMenu.Append(self.ID_IMPORT, "导入").Enable(False) menu.Append(-1, "新建Hosts方案", newHostMenu) menu.AppendSeparator() menu.Append(self.ID_REFRESH_DNS, u"刷新DNS缓存") if os.path.exists(Settings.settings["chromePath"]): chromeMenu = Menu() chromeMenu.Append(self.ID_LUNCH_CHROME, "直接启动") chromeMenu.Append(self.ID_LUNCH_CHROME_CROS, "允许跨域请求") chromeMenu.Append(self.ID_LUNCH_CHROME_NO_PLUGINS, "禁用所有插件") menu.Append(-1, "启动 Google Chrome 浏览器", chromeMenu) menu.AppendSeparator() menu.Append(self.ID_ABOUT, "关于") menu.Append(self.ID_EXIT, "退出") self.menu = menu return menu
def _createCharBitmap(self, name, font, foreground, background): # create device context dc = MemoryDC() # set font dc.SetFont(self._fonts[font]) # get font size _cw, _ch = dc.GetTextExtent(' ') BitmapSet = {} for c in self._CharSet: # create bitmap bitmap = Bitmap(_cw, _ch, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(bitmap) # set background dc.SetBackground(self._brushes[background]) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(self._colours[foreground]) # record reference BitmapSet[c] = bitmap # check alternate drawing 1 if name == 'nrm' and c == '¶': dc.DrawText(' ',0,0) continue # check alternate drawing 2 if name == 'sel' and c == ' ': dc.DrawText('·',0,0) continue # draw character dc.DrawText(c,0,0) # release bitmap dc.SelectObject(NullBitmap) # record set self._CharBitmaps[name] = BitmapSet # done return
def createBufferBitmap(self, width, height): # get geometry cw, ch = self.charSize # create bitmap buffer self.bmpBuf = Bitmap( width *cw, # bitmap width height*ch, # bitmap heigh BITMAP_SCREEN_DEPTH) # bitmap depth # create device context dc = MemoryDC() # select buffer dc.SelectObject(self.bmpBuf) # set background dc.SetBackground(self.brushes['bkgd']) # clear buffer dc.Clear() # release bitmap dc.SelectObject(NullBitmap) # hook BackgroundBitmap to bitmapBuffer handle self.Panel.BackgroundBitmap = self.bmpBuf # record geometry self.screenSize = width, height # done return
def __init__(self, parent: Window): """ Args: parent: parent window """ super().__init__(parent, style=SUNKEN_BORDER) self._diagram = Diagram(self) self.__keepMoving: bool = False self._selectedShapes: List[Shape] = [ ] # list of the shapes that are selected self._lastMousePosition: Tuple[int, int] = cast(Tuple[int, int], None) self._selector: RectangleShape = cast(RectangleShape, None) # rectangle selector shape self._clickedShape: Shape = cast(Shape, None) # last clicked shape self._moving: bool = False # a drag has been initiated self._xOffset: float = 0.0 # abscissa offset between the view and the model self._yOffset: float = 0.0 # ordinate offset between the view and the model self._zoomStack: List[float] = [] # store all zoom factors applied self._zoomLevel = 0 # number of zoom factors applied self._maxZoomFactor = 6 # can zoom in beyond 600% self._minZoomFactor = 0.2 # can zoom out beyond 20% self._defaultZoomFactor = 1.5 # used when only a point is selected # margins define a perimeter around the work area that must remains # blank and hidden. if we scroll beyond the limits, the diagram is # resized. # self._leftMargin = DEFAULT_MARGIN_VALUE # self._rightMargin = DEFAULT_MARGIN_VALUE # self._topMargin = DEFAULT_MARGIN_VALUE # self._bottomMargin = DEFAULT_MARGIN_VALUE self._isInfinite = False # to know if the frame is infinite or not # paint related w, h = self.GetSize() self.__workingBitmap = Bitmap(w, h) # double buffering self.__backgroundBitmap = Bitmap(w, h) DEFAULT_FONT_SIZE = 12 self._defaultFont = Font(DEFAULT_FONT_SIZE, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL) self.SetBackgroundColour(WHITE) self._prefs: PyutPreferences = PyutPreferences() # Mouse events self.Bind(EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(EVT_LEFT_UP, self.OnLeftUp) self.Bind(EVT_LEFT_DCLICK, self.OnLeftDClick) self.Bind(EVT_MIDDLE_DOWN, self.OnMiddleDown) self.Bind(EVT_MIDDLE_UP, self.OnMiddleUp) self.Bind(EVT_MIDDLE_DCLICK, self.OnMiddleDClick) self.Bind(EVT_RIGHT_DOWN, self.OnRightDown) self.Bind(EVT_RIGHT_UP, self.OnRightUp) self.Bind(EVT_RIGHT_DCLICK, self.OnRightDClick) self.Bind(EVT_PAINT, self.OnPaint) if self._prefs.debugDiagramFrame is True: self._debugDialog: DlgDebugDiagramFrame = DlgDebugDiagramFrame( self, ID_ANY) self._debugDialog.startMonitor() self._debugDialog.Show(True)
def Start(self): # define colors self.colours = {} self.colours['bkgd'] = Colour(52, 61, 70) self.colours['text'] = Colour(255, 255, 255) self.colours['numb'] = Colour(160, 160, 160) self.colours['sepr'] = Colour(200, 120, 120) self.colours['selbgd'] = Colour(92, 101, 110) self.colours['seltxt'] = Colour(255, 255, 255) # brushes self.brushes = {} # normal background b = Brush() b.SetStyle(BRUSHSTYLE_SOLID) b.SetColour(self.colours['bkgd']) self.brushes['bkgd'] = b # selected background b = Brush() b.SetStyle(BRUSHSTYLE_SOLID) b.SetColour(self.colours['selbgd']) self.brushes['selbgd'] = b # pens self.pens = {} p = Pen() p.SetColour(self.colours['sepr']) p.SetWidth(1) p.SetStyle(PENSTYLE_SOLID) self.pens['sepr'] = p # create device context to work on bitmaps dc = MemoryDC() # define font self.fonts = {} f = Font() f.SetFamily(FONTFAMILY_ROMAN) f.SetFaceName("Monospace") f.SetEncoding(FONTENCODING_DEFAULT) f.SetStyle(FONTSTYLE_NORMAL) f.SetWeight(FONTWEIGHT_NORMAL) f.SetUnderlined(False) f.SetPointSize(10) self.fonts['monospace'] = f # select font f = 'monospace' # get font size dc.SetFont(self.fonts[f]) w, h = dc.GetTextExtent(' ') # build character dictionary self.rawChars = {} # standard printable ascii table for c in range(32, 126): self.rawChars[chr(c)] = None # extra characters (UK) self.rawChars['£'] = None # save character size self.rawChars['Size'] = w, h # set background color dc.SetBackground(self.brushes['bkgd']) # build characters bitmaps for C in self.rawChars.keys(): if C == 'Size': continue # instanciate character bitmap self.rawChars[C] = Bitmap(w, h, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(self.rawChars[C]) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(self.colours['text']) # draw character shape and color dc.DrawText(C, 0, 0) # done dc.SelectObject(NullBitmap) # build selected dictionary self.selChars = {} # standard printable ascii table for c in range(32, 126): self.selChars[chr(c)] = None # extra characters (UK) self.selChars['£'] = None # save character size self.selChars['Size'] = w, h # set background color dc.SetBackground(self.brushes['selbgd']) # build selected bitmaps for C in self.selChars.keys(): if C == 'Size': continue # instanciate character bitmap self.selChars[C] = Bitmap(w, h, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(self.selChars[C]) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(self.colours['seltxt']) # draw character shape and color dc.DrawText(C, 0, 0) # done dc.SelectObject(NullBitmap) # create bitmap buffer display and clear buffer self.bitmapBuffer = Bitmap( 128 * w, # bitmap width 10 * h, # bitmap height BITMAP_SCREEN_DEPTH) # bitmap depth dc.SelectObject(self.bitmapBuffer) dc.SetBackground(self.brushes['bkgd']) dc.Clear() dc.SelectObject(NullBitmap) # reference BackgroundBitmap to bitmapBuffer self.Panel.BackgroundBitmap = self.bitmapBuffer # adjust frame position scrw, scrh = 3840, 1200 # screen size w, h = self.Panel.BackgroundBitmap.GetSize() self.Frame.SetPosition(Point(scrw / 4 - 128 * 8 / 2, 800)) # draw text string dc.SelectObject(self.bitmapBuffer) t = list("hello") # select buffer # draw text X = 0 w, h = self.rawChars['Size'] for c in t: dc.DrawBitmap(self.rawChars[c], X, 0) X += w t = list("World!") # select buffer # draw text X = 0 w, h = self.selChars['Size'] for c in t: dc.DrawBitmap(self.selChars[c], X, h) X += w # release bitmap dc.SelectObject(NullBitmap) # done return
def createCharBitmaps(self): # create device context dc = MemoryDC() # set font dc.SetFont(self.fonts['monospace']) # get font size (monospace) cw, ch = dc.GetTextExtent(' ') # record geometry self.charSize = cw, ch # NORMAL CHARACTERS self.normalChars = {} # create bitmaps for c in self.charSet: # create black and white bitmap bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(bitmap) # set background dc.SetBackground(self.brushes['bkgd']) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(Colour(230,230,230)) # write character dc.DrawText(c,0,0) # create reference to bitmap self.normalChars[c] = bitmap # SELECTED CHARACTERS self.selectedChars = {} # create bitmaps for c in self.charSet: # create black and white bitmap bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(bitmap) # set background dc.SetBackground(Brush(Colour(70, 80, 90))) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(Colour(160,160,180)) # write character dc.DrawText(c,0,0) # create reference to bitmap self.selectedChars[c] = bitmap # NUMBER CHARACTERS self.numberChars = {} # create bitmaps for c in ' 0123456789': # create black and white bitmap bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH) # select bitmap dc.SelectObject(bitmap) # set background dc.SetBackground(self.brushes['bkgd']) # clear bitmap dc.Clear() # set text color dc.SetTextForeground(Colour(150,150,200)) # write character dc.DrawText(c,0,0) # create reference to bitmap self.numberChars[c] = bitmap # release bitmap dc.SelectObject(NullBitmap) # done return
def OnRefreshPanel(self, event): """ Refresh dialog box """ import time # constants backRed: int = 230 backGreen: int = 255 backBlue: int = 230 # Background color frontRed: int = 64 frontGreen: int = 0 frontBlue: int = 64 # Foreground color FADE_IN_LENGTH: int = 63 self.logger.debug(f'Enter OnRefreshPanel') # Init memory buffer tdc: MemoryDC = MemoryDC() tdc.SelectObject(Bitmap(FrameWidth, FrameHeight)) while not tdc.IsOk(): time.sleep(0.05) tdc = MemoryDC() tdc.SelectObject(Bitmap(FrameWidth, FrameHeight)) tdc.SetTextForeground(Colour(frontRed, frontGreen, frontBlue)) tdc.SetBackground( Brush(Colour(backRed, backGreen, backBlue), BRUSHSTYLE_SOLID)) tdc.Clear() font = tdc.GetFont() font.SetFamily(FONTFAMILY_MODERN) font.SetPointSize(12) tdc.SetFont(font) # Fade-in position = self.textPosition if position < FADE_IN_LENGTH: n = float(position) / float(FADE_IN_LENGTH) r = backRed - n * (backRed - frontRed) g = backGreen - n * (backGreen - frontGreen) b = backBlue - n * (backBlue - frontBlue) r = int(r) g = int(g) b = int(b) tdc.SetTextForeground(Colour(r, g, b)) # Display text for j in range(1, len(self._textToShow)): # Draw text ? if position > FADE_IN_LENGTH: y = y0 + j * dy - (position - FADE_IN_LENGTH) if -dy < y < FrameHeight: tdc.DrawText(self._textToShow[j], x0, y) else: # Draw initial screen with fade in y = y0 + j * dy if -dy < y < FrameHeight: tdc.DrawText(self._textToShow[j], x0, y) # Show memory dc to current dc (blit) dc = PaintDC(self._panel) dc.Blit(0, 0, FrameWidth, FrameHeight, tdc, 0, 0) tdc.SelectObject(NullBitmap) self.logger.debug(f'Exit OnRefreshPanel')
def getBitmap( ): """Return the data from the resource as a wxBitmap""" return Bitmap(getImage())
def getBitmap(): return Bitmap(getImage())
wxEVT_PG_ITEM_COLLAPSED = 10464 wxEVT_PG_ITEM_EXPANDED = 10463 wxEVT_PG_LABEL_EDIT_BEGIN = 10466 wxEVT_PG_LABEL_EDIT_ENDING = 10467 wxEVT_PG_PAGE_CHANGED = 10462 wxEVT_PG_RIGHT_CLICK = 10461 wxEVT_PG_SELECTED = 10457 EVT_PG_CHANGED = PyEventBinder() EVT_PG_CHANGING = PyEventBinder() EVT_PG_COL_BEGIN_DRAG = PyEventBinder() EVT_PG_COL_DRAGGING = PyEventBinder() EVT_PG_COL_END_DRAG = PyEventBinder() EVT_PG_DOUBLE_CLICK = PyEventBinder() EVT_PG_HIGHLIGHTED = PyEventBinder() EVT_PG_ITEM_COLLAPSED = PyEventBinder() EVT_PG_ITEM_EXPANDED = PyEventBinder() EVT_PG_LABEL_EDIT_BEGIN = PyEventBinder() EVT_PG_LABEL_EDIT_ENDING = PyEventBinder() EVT_PG_PAGE_CHANGED = PyEventBinder() EVT_PG_RIGHT_CLICK = PyEventBinder() EVT_PG_SELECTED = PyEventBinder() PGEditor_CheckBox = PGEditor() PGEditor_Choice = PGEditor() PGEditor_ChoiceAndButton = PGEditor() PGEditor_ComboBox = PGEditor() PGEditor_DatePickerCtrl = PGEditor() PGEditor_SpinCtrl = PGEditor() PGEditor_TextCtrl = PGEditor() PGEditor_TextCtrlAndButton = PGEditor() PG_NULL_BITMAP = Bitmap()
def __init__(self): self.files = [] self.path = None # init window Frame.__init__(self, None, ID_ANY, "CUT", size=(688, 800)) self.Bind(EVT_CLOSE, lambda x: self.Destroy()) loc = Icon() loc.CopyFromBitmap(Bitmap('icon.ico', BITMAP_TYPE_ANY)) self.SetIcon(loc) self.panel = Panel(self, EXPAND) self.sizer = BoxSizer(VERTICAL) self.sizer.Add( FileInput(self.panel, text_button="Open File", callback=self._set_file, file_type=file_exts, text_title="OPEN", text_open_file="File"), 1, EXPAND) # Create Input fields self._start_input = TimeInput(self.panel, label='START') self._end_input = TimeInput(self.panel, label='END') self._scale_input = SimpleInput(self.panel, label='Width:Height', initial='-1:-1') self._webm_input = SimpleInput(self.panel, label='WEBM Quality', initial='36') self._framerate_input = SimpleInput(self.panel, label='INPUT FRAMES FRAMERATE', initial='') # Create check inputs font = Font(20, MODERN, NORMAL, NORMAL, False, u'Consolas') self._audio_select = StandardSelection(parent=self.panel, options=list( audio_options.keys()), callback=None, title='Audio codec') self._video_select = StandardSelection(parent=self.panel, options=list( video_options.keys()), callback=None, title='Video format') # Add inputs to self.sizer self.sizer.Add(self._video_select, 1, EXPAND) self.sizer.Add(self._audio_select, 1, EXPAND) self.sizer.Add( FileInput(self.panel, text_button="Clone time", callback=self._clone_time, file_type=file_exts, text_title="OPEN", text_open_file="File"), 1, EXPAND) self.sizer.Add(self._start_input, 1, EXPAND) self.sizer.Add(self._end_input, 1, EXPAND) self.sizer.Add(self._scale_input, 1, EXPAND) self.sizer.Add(self._webm_input, 1, EXPAND) self.sizer.Add(self._framerate_input, 1, EXPAND) # Add Button self.sizer.Add( SimpleButton(self.panel, text_button='CUT', callback=self._submit_task), 1, EXPAND) self.panel.SetSizer(self.sizer)