コード例 #1
0
ファイル: starcal.py プロジェクト: ubuntu-ir/starcal
	def statusIconUpdateIcon(self, ddate):## FIXME
		from scal3.utils import toBytes
		imagePath = ui.statusIconImageHoli if ui.todayCell.holiday else ui.statusIconImage
		ext = os.path.splitext(imagePath)[1][1:].lower()
		loader = GdkPixbuf.PixbufLoader.new_with_type(ext)
		if ui.statusIconFixedSizeEnable:
			try:
				width, height = ui.statusIconFixedSizeWH
				loader.set_size(width, height)
			except:
				myRaise()
		data = open(imagePath, 'rb').read()
		if ext == 'svg':
			dayNum = locale_man.numEncode(
				ddate[2],
				mode=calTypes.primary,  # FIXME
			)
			if ui.statusIconFontFamilyEnable:
				if ui.statusIconFontFamily:
					family = ui.statusIconFontFamily
				else:
					family = ui.getFont()[0]
				dayNum = '<tspan style="font-family:%s">%s</tspan>'%(family, dayNum)
			data = data.replace(
				b'TX',
				toBytes(dayNum),
			)
		loader.write(data)
		loader.close()
		pixbuf = loader.get_pixbuf()
		self.sicon.set_from_pixbuf(pixbuf)
コード例 #2
0
ファイル: multi_spin.py プロジェクト: goodosuser/starcal
class IntField(NumField):
    def __init__(self, _min, _max, fill=0):
        self._min = _min
        self._max = _max
        self.fill = fill
        self.myKeys = locale_man.getAvailableDigitKeys()
        self.setDefault()
    def setText(self, text):
        try:
            num = int(float(textNumDecode(text)))
        except:
            myRaise()
            self.setDefault()
        else:
            self.setValue(num)
    setValue = lambda self, v: NumField.setValue(self, int(v))
    getText = lambda self: numEncode(self.value, fillZero=self.fill)
    getMaxWidth = lambda self: max(
        len(str(self._min)),
        len(str(self._max)),
    )
    plus = lambda self, p: self.setValue(self.value + p)
コード例 #3
0
ファイル: starcal.py プロジェクト: ilius/starcal
	def statusIconUpdateIcon(self, ddate):  # FIXME
		from scal3.utils import toBytes
		imagePath = (
			ui.statusIconImageHoli if ui.todayCell.holiday
			else ui.statusIconImage
		)
		ext = os.path.splitext(imagePath)[1][1:].lower()
		loader = GdkPixbuf.PixbufLoader.new_with_type(ext)
		if ui.statusIconFixedSizeEnable:
			try:
				width, height = ui.statusIconFixedSizeWH
				loader.set_size(width, height)
			except:
				myRaise()
		data = open(imagePath, "rb").read()
		if ext == "svg":
			dayNum = locale_man.numEncode(
				ddate[2],
				mode=calTypes.primary,  # FIXME
			)
			if ui.statusIconFontFamilyEnable:
				if ui.statusIconFontFamily:
					family = ui.statusIconFontFamily
				else:
					family = ui.getFont()[0]
				dayNum = "<tspan style=\"font-family:%s\">%s</tspan>" % (
					family,
					dayNum,
				)
			data = data.replace(
				b"TX",
				toBytes(dayNum),
			)
		loader.write(data)
		loader.close()
		pixbuf = loader.get_pixbuf()
		self.sicon.set_from_pixbuf(pixbuf)
コード例 #4
0
	def getText(self):
		return numEncode(self.value, fillZero=self.fill)