def __init__(self, nsHost, nsPort, bcAddr): """ :Parameters: - `nsHost`: the name server host to connect to. This is the name of the host or the ip. - `nsPort`: the name server port. By default the Pyro name server port is 9090 - `bcAddr`: override for the broadcast address. """ wx.Frame.__init__(self, None, -1, 'Pyro Name Server') self.nsHost = nsHost self.nsPort = nsPort self.bcAddr = bcAddr self.NS = None self._build() imageList = wx.ImageList(16, 16) self.__idGroup = imageList.Add(wx.BitmapFromXPMData(GROUP_XPM)) self.__idItem = imageList.Add(wx.BitmapFromXPMData(ITEM_XPM)) self.__idGroupOpen = imageList.Add( wx.BitmapFromXPMData(GROUP_OPEN_XPM)) self.treeCtrlItems.SetImageList(imageList) self.__imageList = imageList self._bindEvents() # binding stdout to my own txtCtrl Log. sys.stdout = self.txtCtrlLog self._log("Pyro version: " + Pyro.constants.VERSION) self.nsc_findNS() if self.NS: self.update()
def SetState(self, i): if i < 0: raise ValueError, 'Cannot have a negative state value.' elif i >= len(self._colors): raise IndexError, 'There is no state with an index of %d.' % i elif i == self._state: return self._state = i base_color = self._colors[i] light_color = change_intensity(base_color, 1.15) shadow_color = change_intensity(base_color, 1.07) highlight_color = change_intensity(base_color, 1.25) xpm = [ '17 17 5 1', # width height ncolors chars_per_pixel '0 c None', 'X c %s' % base_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii'), '- c %s' % light_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii'), '= c %s' % shadow_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii'), '* c %s' % highlight_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii') ] xpm += [s.strip() for s in self._ascii_led.splitlines()] self.bmp = wx.BitmapFromXPMData(xpm) self.Refresh()
def __init__(self, parent, tooltip='Image', image=None, size=None, scale=1): if image is None: image = defaultbmp bitmap = wx.BitmapFromXPMData(image) if scale > 1: img = wx.ImageFromBitmap(bitmap) bitmap = wx.BitmapFromImage(img.Scale(bitmap.GetWidth() * scale, bitmap.GetHeight() * scale)) wx.StaticBitmap.__init__(self, parent, -1, bitmap, (0, 0)) self.SetToolTipString(tooltip)
def _init_list_header_icons(self): fg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_CAPTIONTEXT ).GetAsString(wx.C2S_HTML_SYNTAX) header = ["16 16 2 1", ". m {}".format(fg), "m m none"] # Note that "gtk-sort-ascending" and "gtk-sort-descending" are for # menus, not list headings self.listsorticons = ( wx.BitmapFromXPMData(header + ["mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmm.mmmmmmmm", "mmmmmm...mmmmmmm", "mmmmm.....mmmmmm", "mmmm.......mmmmm", "mmm.........mmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm"]), wx.BitmapFromXPMData(header + ["mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmm.........mmmm", "mmmm.......mmmmm", "mmmmm.....mmmmmm", "mmmmmm...mmmmmmm", "mmmmmmm.mmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm", "mmmmmmmmmmmmmmmm"]) )
def __init__(self, w, h): wx.ImageList.__init__(self, w, h) self.list = {} data = ["%d %d 1 1" % (w, h), " c None"] empty = "" for _i in range(w): empty += " " for _i in range(h): data.append(empty) self.Add(wx.BitmapFromXPMData(data)) self.list[''] = 0 data = ["%d %d 1 1" % (w, h), " c #FFFFFF"] empty = "" for _i in range(w): empty += " " for _i in range(h): data.append(empty) self.Add(wx.BitmapFromXPMData(data)) self.list['white'] = 1
def __init__(self, parent, tooltip='Animation', images=None, size=None, scale=1, delay=0.1): if images is None: images = [defaultbmp] bitmaps = [] for im in images: bitmap = wx.BitmapFromXPMData(im) if scale > 1: img = wx.ImageFromBitmap(bitmap) bitmap = wx.BitmapFromImage(img.Scale(bitmap.GetWidth() * scale, bitmap.GetHeight() * scale)) bitmaps.append(bitmap) wx.lib.throbber.Throbber.__init__(self, parent, -1, bitmaps, frameDelay=delay) self.SetToolTipString(tooltip)
def InitializeCursor(self): """Initialize cursors.""" # get cursor image bmp = wx.BitmapFromXPMData(cursor_move) image = wx.ImageFromBitmap(bmp) # since this image didn't come from a .cur file, tell it where the hotspot is image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 8) image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 8) # make the image into a cursor self._cursormove = wx.CursorFromImage(image)
def CreateCursorFromXPMData(xpmdata, hotspot): """Return a wx.Cursor from a vectorized image.""" # get cursor image bmp = wx.BitmapFromXPMData(xpmdata) image = wx.ImageFromBitmap(bmp) # since this image didn't come from a .cur file, # tell it where the hotspot is image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, hotspot) image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, hotspot) # make the image into a cursor return wx.CursorFromImage(image)
def SetState(self, i): if i < 0: raise (ValueError, 'Cannot have a negative state value.') elif i >= len(self._colors): raise (IndexError, 'There is no state with an index of %d.' % i) elif i == self._state: return self._state = i base_color = self._colors[i] light_color = change_intensity(base_color, 1.15) shadow_color = change_intensity(base_color, 1.07) highlight_color = change_intensity(base_color, 1.25) ascii_led = b''' 000000-----000000 0000---------0000 000-----------000 00-----XXX----=00 0----XX**XXX-===0 0---X***XXXXX===0 ----X**XXXXXX==== ---X**XXXXXXXX=== ---XXXXXXXXXXX=== ---XXXXXXXXXXX=== ----XXXXXXXXX==== 0---XXXXXXXXX===0 0---=XXXXXXX====0 00=====XXX=====00 000===========000 0000=========0000 000000=====000000 '''.strip() xpm = [b'17 17 5 1', # width height ncolors chars_per_pixel b'0 c None', b'X c %s' % base_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii'), b'- c %s' % light_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii'), b'= c %s' % shadow_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii'), b'* c %s' % highlight_color.GetAsString(wx.C2S_HTML_SYNTAX).encode('ascii')] xpm += [s.strip() for s in ascii_led.splitlines()] if 'phoenix' in wx.PlatformInfo: self.bmp = wx.Bitmap(xpm) else: self.bmp = wx.BitmapFromXPMData(xpm) self.Refresh()
def XPMToPNG(image): ''' Convert XPM data to PNG image. @todo: I'd like to avoid creating temporary file, but even PIL doesn't seem to provide such functionality. ''' handle, name = tempfile.mkstemp() os.close(handle) bitmap = wx.BitmapFromXPMData(image) bitmap.SaveFile(name, wx.BITMAP_TYPE_PNG) f = file(name) data = f.read() f.close() os.unlink(name) return data
def __init__(self): """ Default class constructor. """ self.Init() isMac = wx.Platform == "__WXMAC__" if isMac: self._caption_font = wx.SMALL_FONT else: self._caption_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False) self.SetDefaultPaneBitmaps(isMac) self._restore_bitmap = wx.BitmapFromXPMData(restore_xpm) # default metric values self._sash_size = 4 if isMac: # This really should be implemented in wx.SystemSettings # There is no way to do this that I am aware outside of using # the cocoa python bindings. 8 pixels looks correct on my system # so hard coding it for now. # How do I translate this?!? Not sure of the below implementation... # SInt32 height; # GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height ); # self._sash_size = height; self._sash_size = 8 # Carbon.Appearance.kThemeMetricPaneSplitterHeight elif wx.Platform == "__WXGTK__": self._sash_size = wx.RendererNative.Get().GetSplitterParams( wx.GetTopLevelWindows()[0]).widthSash else: self._sash_size = 4 self._caption_size = 19 self._border_size = 1 self._button_size = 14 self._gripper_size = 9 self._gradient_type = AUI_GRADIENT_VERTICAL self._draw_sash = False
def get_xpm_bitmap(path): bmp = wx.NullBitmap if not os.path.exists(path): if '.zip' in path: import zipfile archive, name = path.split('.zip', 1) archive += '.zip' if name.startswith(os.sep): name = name.split(os.sep, 1)[1] if zipfile.is_zipfile(archive): # extract the XPM lines... try: data = zipfile.ZipFile(archive).read(name) data = [d[1:-1] for d in _get_xpm_bitmap_re.findall(data)] bmp = wx.BitmapFromXPMData(data) except: logging.exception(_('Internal Error')) bmp = wx.NullBitmap else: bmp = wx.Bitmap(path, wx.BITMAP_TYPE_XPM) return bmp
def GetIcon (self): """Return icon representing page on the toolbar. This is the default behaviour. GetIconData should return pickled, compressed and escaped string with the icon data. If you want to change the behaviour (because you want to load plugin icons from overseas via a satellite link or something you need to override this function in your plugin (class). Using this standard code also allows us to only import cPickle and zlib here and not in each and every plugin module which should speed up plugin load time :-) """ # FIXME: load from config which plugin we want # which_icon is a cookie stored on the backend by a config manager, # it tells the plugin which icon to return data for, which_icon = None icon_data = self.GetIconData(which_icon) if icon_data is None: return None else: return wx.BitmapFromXPMData(cPickle.loads(zlib.decompress(icon_data)))
def __init__(self, parent, part, cfg, use_unicode): GenericEditor.__init__(self, parent, part, cfg, use_unicode) self.sizer = wx.GridBagSizer() values = [] for x in Wammu.Data.PredefinedAnimations: values.append(x[0]) self.sizer.AddGrowableRow(0) self.sizer.AddGrowableCol(0) self.sizer.AddGrowableCol(1) self.sizer.AddGrowableCol(2) self.edit = wx.Choice(self, -1, choices=values) bitmap = wx.BitmapFromXPMData(Wammu.Data.UnknownPredefined) self.bitmap = wx.StaticBitmap(self, -1, bitmap, (0, 0)) wx.EVT_CHOICE(self.edit, self.edit.GetId(), self.OnChange) if 'Number' not in self.part: self.part['Number'] = 0 self.edit.SetSelection(self.part['Number']) self.OnChange() self.sizer.Add(wx.StaticText(self, -1, _('Select predefined animation:')), pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL) self.sizer.Add(self.edit, pos=(0, 1), flag=wx.ALIGN_CENTER) self.sizer.Add(self.bitmap, pos=(0, 2), flag=wx.ALIGN_CENTER) self.sizer.Fit(self) self.SetAutoLayout(True) self.SetSizer(self.sizer)
def get_xpm_bitmap(path): import os bmp = wx.NullBitmap if not os.path.exists(path): if '.zip' in path: import zipfile archive, name = path.split('.zip', 1) archive += '.zip' if name.startswith(os.sep): name = name.split(os.sep, 1)[1] if zipfile.is_zipfile(archive): # extract the XPM lines... try: data = zipfile.ZipFile(archive).read(name) data = [d[1:-1] for d in _get_xpm_bitmap_re.findall(data)] ## print "DATA:" ## for d in data: print d bmp = wx.BitmapFromXPMData(data) except: import traceback; traceback.print_exc() bmp = wx.NullBitmap else: bmp = wx.Bitmap(path, wx.BITMAP_TYPE_XPM) return bmp
def GetMinusBitmap(): return wx.BitmapFromXPMData(GetMinusData())
def getToolbar_ReferralsBitmap(): return wx.BitmapFromXPMData(getToolbar_ReferralsData())
def getToolbar_PrinterBitmap(): return wx.BitmapFromXPMData(getToolbar_PrinterData())
def GetHandBitmap(): return wx.BitmapFromXPMData(GetHandData())
def getToolbar_VerticalSeparatorBitmap(): return wx.BitmapFromXPMData(getToolbar_VerticalSeparatorData())
def getpadlock_unlockedBitmap(): return wx.BitmapFromXPMData(getpadlock_unlockedData())
def getToolbar_WebBitmap(): return wx.BitmapFromXPMData(getToolbar_WebData())
def getCustom_SeparatorBitmap(): return wx.BitmapFromXPMData(getCustom_SeparatorData())
def getdoctorBitmap(): return wx.BitmapFromXPMData(getdoctorData())
def getToolbar_SnapshotBitmap(): return wx.BitmapFromXPMData(getToolbar_SnapshotData())
def getToolbar_SingleManBitmap(): return wx.BitmapFromXPMData(getToolbar_SingleManData())
def getToolbar_ScriptBitmap(): return wx.BitmapFromXPMData(getToolbar_ScriptData())
def getToolbar_SaveBitmap(): return wx.BitmapFromXPMData(getToolbar_SaveData())
def getToolbar_RequestsBitmap(): return wx.BitmapFromXPMData(getToolbar_RequestsData())
def getToolbar_ProgressNotesBitmap(): return wx.BitmapFromXPMData(getToolbar_ProgressNotesData())