コード例 #1
0
    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()
コード例 #2
0
    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()
コード例 #3
0
ファイル: Image.py プロジェクト: thegala/wammu
 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)
コード例 #4
0
 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"])
     )
コード例 #5
0
    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
コード例 #6
0
ファイル: Image.py プロジェクト: thegala/wammu
 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)
コード例 #7
0
    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)
コード例 #8
0
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)
コード例 #9
0
ファイル: Led4Radmax.py プロジェクト: aboulle/RaDMaX
    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()
コード例 #10
0
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
コード例 #11
0
ファイル: dockart.py プロジェクト: wangdyna/wxPython
    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
コード例 #12
0
ファイル: misc.py プロジェクト: kilarionov/GUI_Examples
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
コード例 #13
0
ファイル: gmPlugin_Patient.py プロジェクト: weeksjm/gnumed
	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)))
コード例 #14
0
    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)
コード例 #15
0
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
コード例 #16
0
def GetMinusBitmap():
    return wx.BitmapFromXPMData(GetMinusData())
コード例 #17
0
def getToolbar_ReferralsBitmap():
    return wx.BitmapFromXPMData(getToolbar_ReferralsData())
コード例 #18
0
def getToolbar_PrinterBitmap():
    return wx.BitmapFromXPMData(getToolbar_PrinterData())
コード例 #19
0
def GetHandBitmap():
    return wx.BitmapFromXPMData(GetHandData())
コード例 #20
0
def getToolbar_VerticalSeparatorBitmap():
    return wx.BitmapFromXPMData(getToolbar_VerticalSeparatorData())
コード例 #21
0
def getpadlock_unlockedBitmap():
    return wx.BitmapFromXPMData(getpadlock_unlockedData())
コード例 #22
0
def getToolbar_WebBitmap():
    return wx.BitmapFromXPMData(getToolbar_WebData())
コード例 #23
0
def getCustom_SeparatorBitmap():
    return wx.BitmapFromXPMData(getCustom_SeparatorData())
コード例 #24
0
def getdoctorBitmap():
    return wx.BitmapFromXPMData(getdoctorData())
コード例 #25
0
def getToolbar_SnapshotBitmap():
    return wx.BitmapFromXPMData(getToolbar_SnapshotData())
コード例 #26
0
def getToolbar_SingleManBitmap():
    return wx.BitmapFromXPMData(getToolbar_SingleManData())
コード例 #27
0
def getToolbar_ScriptBitmap():
    return wx.BitmapFromXPMData(getToolbar_ScriptData())
コード例 #28
0
def getToolbar_SaveBitmap():
    return wx.BitmapFromXPMData(getToolbar_SaveData())
コード例 #29
0
def getToolbar_RequestsBitmap():
    return wx.BitmapFromXPMData(getToolbar_RequestsData())
コード例 #30
0
def getToolbar_ProgressNotesBitmap():
    return wx.BitmapFromXPMData(getToolbar_ProgressNotesData())