mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 04:20:17 +01:00
1293224: char font
just preparing for a bigger change... extended the global font (just one), it has lower and upper case.
This commit is contained in:
@@ -49,8 +49,7 @@ import os
|
||||
|
||||
import wmdocklib
|
||||
|
||||
from wmdocklib import letters, lettersStartX, lettersStartY, letterWidth, letterHeight
|
||||
from wmdocklib import digits, digitsStartX, digitsStartY, digitWidth, digitHeight
|
||||
from wmdocklib import char_width, char_height
|
||||
|
||||
width = 64
|
||||
height = 64
|
||||
@@ -61,7 +60,7 @@ yOffset = 4
|
||||
timeDefaultFormat = '%H:%M:%S'
|
||||
dateDefaultFormat = '%d-%m-%y'
|
||||
dayDefaultFormat = '%A'
|
||||
weekDefaultFormat = 'wk %q' # %q added by me for different week calculation.
|
||||
weekDefaultFormat = 'wk %q' # %q added by Kristoffer for different week calculation.
|
||||
|
||||
defaultConfigFile = '~/.pywmdatetimerc'
|
||||
defaultRGBFiles = ['/usr/lib/X11/rgb.txt', '/usr/X11R6/lib/X11/rgb.txt']
|
||||
@@ -69,9 +68,7 @@ maxCharsPerLine = 9
|
||||
|
||||
def addString(s, x, y):
|
||||
try:
|
||||
wmdocklib.addString(s, x, y, letterWidth, letterHeight, lettersStartX,
|
||||
lettersStartY, letters, digitWidth, digitHeight,
|
||||
digitsStartX, digitsStartY, digits, xOffset, yOffset,
|
||||
wmdocklib.addString(s, x, y, xOffset, yOffset,
|
||||
width, height)
|
||||
except ValueError, e:
|
||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||
@@ -79,15 +76,14 @@ def addString(s, x, y):
|
||||
|
||||
def clearLine(y):
|
||||
'''Clear a line of text at position y.'''
|
||||
wmdocklib.copyXPMArea(73, yOffset, width - 2 * xOffset, letterHeight,
|
||||
wmdocklib.copyXPMArea(73, yOffset, width - 2 * xOffset, char_height,
|
||||
xOffset, y + yOffset)
|
||||
|
||||
def getCenterStartPos(s):
|
||||
return wmdocklib.getCenterStartPos(s, letterWidth, width, xOffset)
|
||||
return wmdocklib.getCenterStartPos(s, width, xOffset)
|
||||
|
||||
def getVertSpacing(numLines, margin):
|
||||
return wmdocklib.getVertSpacing(numLines, margin, height, letterHeight,
|
||||
yOffset)
|
||||
return wmdocklib.getVertSpacing(numLines, margin, height, yOffset)
|
||||
|
||||
def calculateWeek(localTime):
|
||||
"""Calculate the week number as we do, for example in Sweden.
|
||||
@@ -174,16 +170,16 @@ def mainLoop(timeFmt, dateFmt, dayFmt, weekFmt):
|
||||
weekX = getCenterStartPos(weekStr)
|
||||
dayX = getCenterStartPos(dayStr)
|
||||
if lastStrs[1] != dateStr:
|
||||
clearLine(margin + spacing + letterWidth)
|
||||
addString(dateStr, dateX, margin + spacing + letterWidth)
|
||||
clearLine(margin + spacing + char_width)
|
||||
addString(dateStr, dateX, margin + spacing + char_width)
|
||||
lastStrs[1] = dateStr
|
||||
if lastStrs[2] != dayStr:
|
||||
clearLine(margin + 2 * (spacing + letterWidth))
|
||||
addString(dayStr, dayX, margin + 2 * (spacing + letterWidth))
|
||||
clearLine(margin + 2 * (spacing + char_width))
|
||||
addString(dayStr, dayX, margin + 2 * (spacing + char_width))
|
||||
lastStrs[2] = dayStr
|
||||
if lastStrs[3] != weekStr:
|
||||
clearLine(margin + 3 * (spacing + letterWidth))
|
||||
addString(weekStr, weekX, margin + 3 * (spacing + letterWidth))
|
||||
clearLine(margin + 3 * (spacing + char_width))
|
||||
addString(weekStr, weekX, margin + 3 * (spacing + char_width))
|
||||
lastStrs[3] = weekStr
|
||||
if counter == 999999:
|
||||
counter = -1
|
||||
@@ -258,71 +254,71 @@ xpm = \
|
||||
'/\tc #2020b2b2aaaa s graph',
|
||||
'_\tc #000000000000 s background',
|
||||
'%\tc #2081B2CAAEBA s text',
|
||||
' ................................................................................................',
|
||||
' ..///...........................................................................................',
|
||||
' ..///...........................................................................................',
|
||||
' ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///....________________________________________________________...............................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///...........................................................................................',
|
||||
' ________________________________________________________ ..///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ________________________________________________________ ..///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ..///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ................................................................................................',
|
||||
' ................................................................................................',
|
||||
' ................................................................................................',
|
||||
] + wmdocklib.alfabet
|
||||
' ________________________________________________________________________________________________',
|
||||
' __///___________________________________________________________________________________________',
|
||||
' __///___________________________________________________________________________________________',
|
||||
' __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///___________________________________________________________________________________________',
|
||||
' ________________________________________________________ __///////////////////////////////////////////////////////////////////////////////////////////___',
|
||||
' ________________________________________________________ __///////////////////////////////////////////////////////////////////////////////////////////___',
|
||||
' __///////////////////////////////////////////////////////////////////////////////////////////___',
|
||||
' ________________________________________________________________________________________________',
|
||||
' ________________________________________________________________________________________________',
|
||||
' ________________________________________________________________________________________________',
|
||||
] + wmdocklib.char_map
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -42,8 +42,7 @@ import popen2
|
||||
|
||||
import wmdocklib
|
||||
|
||||
from wmdocklib import letters, lettersStartX, lettersStartY, letterWidth, letterHeight
|
||||
from wmdocklib import digits, digitsStartX, digitsStartY, digitWidth, digitHeight
|
||||
from wmdocklib import char_width, char_height
|
||||
|
||||
prevStat = {'user':0,
|
||||
'nice':0,
|
||||
@@ -150,22 +149,20 @@ err = sys.stderr.write
|
||||
def addString(s, x, y):
|
||||
"""Convenience function around pwymhelpers.addString."""
|
||||
try:
|
||||
wmdocklib.addString(s, x, y, letterWidth, letterHeight, lettersStartX,
|
||||
lettersStartY, letters, digitWidth, digitHeight,
|
||||
digitsStartX, digitsStartY, digits, xOffset, yOffset,
|
||||
width, height)
|
||||
wmdocklib.addString(s, x, y, xOffset, yOffset,
|
||||
width, height)
|
||||
except ValueError, e:
|
||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||
sys.exit(3)
|
||||
|
||||
def clearLine(y):
|
||||
"""Clear a line of text at position y."""
|
||||
wmdocklib.copyXPMArea(72, yOffset, width - 2 * xOffset, letterHeight,
|
||||
wmdocklib.copyXPMArea(72, yOffset, width - 2 * xOffset, char_height,
|
||||
xOffset, y + yOffset)
|
||||
|
||||
def getXY(line):
|
||||
"""Return the x and y positions to be used at line line."""
|
||||
return 0, line * (letterHeight + 3) + 1
|
||||
return 0, line * (char_height + 3) + 1
|
||||
|
||||
def isTrue(s):
|
||||
"""Return true if the string s can be interpreted as a true value.
|
||||
@@ -473,7 +470,7 @@ class PywmGeneric:
|
||||
x, y = getXY(i)
|
||||
if not self._entrys[i] is None:
|
||||
wmdocklib.addMouseRegion(i, x + xOffset, y + yOffset,
|
||||
width - 2 * xOffset, y + yOffset + letterHeight)
|
||||
width - 2 * xOffset, y + yOffset + char_height)
|
||||
|
||||
def parseTimeStr(self, timeStr):
|
||||
"""Take a string on a form like 10h and return the number of seconds.
|
||||
@@ -696,7 +693,7 @@ xpm = \
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ...............................................................................................',
|
||||
' ...............................................................................................',
|
||||
] + wmdocklib.alfabet
|
||||
] + wmdocklib.char_map
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -57,8 +57,7 @@ import os
|
||||
|
||||
import wmdocklib
|
||||
|
||||
from wmdocklib import letters, lettersStartX, lettersStartY, letterWidth, letterHeight
|
||||
from wmdocklib import digits, digitsStartX, digitsStartY, digitWidth, digitHeight
|
||||
from wmdocklib import char_width, char_height
|
||||
|
||||
width = 64
|
||||
height = 64
|
||||
@@ -99,10 +98,7 @@ class PywmHDMon:
|
||||
|
||||
def addString(self, s, x, y):
|
||||
try:
|
||||
wmdocklib.addString(s, x, y, letterWidth, letterHeight,
|
||||
lettersStartX, lettersStartY, letters, digitWidth,
|
||||
digitHeight, digitsStartX, digitsStartY, digits,
|
||||
xOffset, yOffset, width, height)
|
||||
wmdocklib.addString(s, x, y, xOffset, yOffset, width, height)
|
||||
except ValueError, e:
|
||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||
sys.exit(3)
|
||||
@@ -151,14 +147,14 @@ class PywmHDMon:
|
||||
x + paintWidth + xOffset, y + yOffset)
|
||||
|
||||
def getY(self, line):
|
||||
return 2 + (line - 1) * (letterHeight + 3)
|
||||
return 2 + (line - 1) * (char_height + 3)
|
||||
|
||||
def paintLabel(self, line, label):
|
||||
self.addString(label, 1, self.getY(line))
|
||||
|
||||
def paintHdData(self, line, data, mode):
|
||||
total, free = data
|
||||
xStart = width - xOffset - 6 * letterWidth - 1
|
||||
xStart = width - xOffset - 6 * char_width - 1
|
||||
if total==0:
|
||||
self.addString(' ', xStart, self.getY(line))
|
||||
self.paintGraph(0, xStart, self.getY(line) + 4,
|
||||
@@ -450,8 +446,8 @@ def main():
|
||||
displayMode = defaultMode
|
||||
pathsToMonitor.append((label[:3], path, displayMode, action))
|
||||
wmdocklib.addMouseRegion(i,
|
||||
8, 8 + (i - 1) * (letterHeight + 3),
|
||||
58, 4 + i * (letterHeight + 3))
|
||||
8, 8 + (i - 1) * (char_height + 3),
|
||||
58, 4 + i * (char_height + 3))
|
||||
procStat = config.get('procstat', defaultProcStat)
|
||||
skipping = int(config.get('skipconf', 0))
|
||||
actMonEnabled = int(config.get('monitoring'))
|
||||
@@ -555,7 +551,7 @@ xpm = \
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ...............................................................................................',
|
||||
' ...............................................................................................',
|
||||
] + wmdocklib.alfabet
|
||||
] + wmdocklib.char_map
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -39,8 +39,7 @@ import os
|
||||
|
||||
import wmdocklib
|
||||
|
||||
from wmdocklib import letters, lettersStartX, lettersStartY, letterWidth, letterHeight
|
||||
from wmdocklib import digits, digitsStartX, digitsStartY, digitWidth, digitHeight
|
||||
from wmdocklib import char_width, char_height
|
||||
|
||||
width = 64
|
||||
height = 64
|
||||
@@ -86,20 +85,17 @@ class PywmSeti:
|
||||
|
||||
def addString(self, s, x, y):
|
||||
try:
|
||||
wmdocklib.addString(s, x, y, letterWidth, letterHeight,
|
||||
lettersStartX, lettersStartY, letters, digitWidth,
|
||||
digitHeight, digitsStartX, digitsStartY, digits,
|
||||
wmdocklib.addString(s, x, y, digits,
|
||||
xOffset, yOffset, width, height)
|
||||
except ValueError, e:
|
||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||
sys.exit(3)
|
||||
|
||||
def getCenterStartPos(self, s):
|
||||
return wmdocklib.getCenterStartPos(s, letterWidth, width, xOffset)
|
||||
return wmdocklib.getCenterStartPos(s, width, xOffset)
|
||||
|
||||
def getVertSpacing(self, numLines, margin):
|
||||
return wmdocklib.getVertSpacing(numLines, margin, height,
|
||||
letterHeight, yOffset)
|
||||
return wmdocklib.getVertSpacing(numLines, margin, height, yOffset)
|
||||
|
||||
def getProgress(self, lines):
|
||||
"""Return the progess of the current workunit.
|
||||
@@ -499,7 +495,7 @@ xpm = \
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ...............................................................................................',
|
||||
' ...............................................................................................',
|
||||
] + wmdocklib.alfabet
|
||||
] + wmdocklib.char_map
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -38,8 +38,7 @@ import os
|
||||
|
||||
import wmdocklib
|
||||
|
||||
from wmdocklib import letters, lettersStartX, lettersStartY, letterWidth, letterHeight
|
||||
from wmdocklib import digits, digitsStartX, digitsStartY, digitWidth, digitHeight
|
||||
from wmdocklib import char_width, char_height
|
||||
|
||||
width = 64
|
||||
height = 64
|
||||
@@ -163,10 +162,7 @@ class PywmSysMon:
|
||||
|
||||
def addString(self, s, x, y):
|
||||
try:
|
||||
wmdocklib.addString(s, x, y, letterWidth, letterHeight,
|
||||
lettersStartX, lettersStartY, letters, digitWidth,
|
||||
digitHeight, digitsStartX, digitsStartY, digits,
|
||||
xOffset, yOffset, width, height)
|
||||
wmdocklib.addString(s, x, y, digits, xOffset, yOffset, width, height)
|
||||
except ValueError, e:
|
||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||
sys.exit(3)
|
||||
@@ -425,7 +421,7 @@ xpm = \
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ...............................................................................................',
|
||||
' ...............................................................................................',
|
||||
] + wmdocklib.alfabet
|
||||
] + wmdocklib.char_map
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -57,15 +57,13 @@ def readConfigFile(fileName, errOut):
|
||||
errOut.write('Using defaults.\n')
|
||||
return defaults
|
||||
|
||||
def getCenterStartPos(s, letterWidth, areaWidth, offset):
|
||||
def getCenterStartPos(s, areaWidth, offset):
|
||||
"""Get the x starting position if we want to paint s centred."""
|
||||
w = len(s) * letterWidth
|
||||
w = len(s) * char_width
|
||||
textArea = areaWidth - offset * 2 - 1
|
||||
return (textArea - w) / 2
|
||||
|
||||
def addChar(ch, x, y, letterWidth, letterHeight, lettersStartX, lettersStartY,
|
||||
letters, digitWidth, digitHeight, digitsStartX, digitsStartY,
|
||||
digits, xOffset, yOffset, width, height):
|
||||
def addChar(ch, x, y, xOffset, yOffset, width, height):
|
||||
"""Paint the character ch at position x, y in the window.
|
||||
|
||||
Return the (width, height) of the character painted. Raise
|
||||
@@ -77,48 +75,38 @@ def addChar(ch, x, y, letterWidth, letterHeight, lettersStartX, lettersStartY,
|
||||
the name remains in too many places so I haven't gotten to change
|
||||
it.
|
||||
"""
|
||||
chIndex = letters.find(ch.lower())
|
||||
if chIndex != -1:
|
||||
chX = lettersStartX + chIndex * letterWidth
|
||||
chY = lettersStartY
|
||||
w = letterWidth
|
||||
h = letterHeight
|
||||
else:
|
||||
chIndex = digits.find(ch)
|
||||
chX = None
|
||||
for line in range(3):
|
||||
chIndex = char_list[line].find(ch)
|
||||
if chIndex != -1:
|
||||
chX = digitsStartX + chIndex * digitWidth
|
||||
chY = digitsStartY
|
||||
w = digitWidth
|
||||
h = digitHeight
|
||||
else:
|
||||
raise ValueError, "Unsupported char: '%s'" % ch
|
||||
chX = char_startx + chIndex * char_width
|
||||
chY = char_starty + line * char_height
|
||||
break
|
||||
if chX is None:
|
||||
raise ValueError, "Unsupported char: '%s'" % ch
|
||||
targX = x + xOffset
|
||||
targY = y + yOffset
|
||||
if targX + w > width - xOffset or targY + h > height - yOffset\
|
||||
if targX + char_width > width - xOffset or targY + char_height > height - yOffset\
|
||||
or targX < 0 or targY < 0:
|
||||
raise ValueError, "Out of bounds."
|
||||
pywmgeneral.copyXPMArea(chX, chY, w, h, targX, targY)
|
||||
return (w, h)
|
||||
pywmgeneral.copyXPMArea(chX, chY, char_width, char_height, targX, targY)
|
||||
return (char_width, char_height)
|
||||
|
||||
def addString(s, x, y, letterWidth, letterHeight, lettersStartX, lettersStartY,
|
||||
letters, digitWidth, digitHeight, digitsStartX, digitsStartY,
|
||||
digits, xOffset, yOffset, width, height):
|
||||
def addString(s, x, y, xOffset, yOffset, width, height):
|
||||
"""Add a string at the given x and y positions.
|
||||
|
||||
Call addChar repeatedely, so the same exception rules apply."""
|
||||
lastW = 0
|
||||
for letter in s:
|
||||
w, h = addChar(letter, x + lastW, y, letterWidth, letterHeight,
|
||||
lettersStartX, lettersStartY, letters, digitWidth,
|
||||
digitHeight, digitsStartX, digitsStartY, digits,
|
||||
w, h = addChar(letter, x + lastW, y,
|
||||
xOffset, yOffset, width, height)
|
||||
lastW += w
|
||||
|
||||
def getVertSpacing(numLines, margin, height, letterHeight, yOffset):
|
||||
def getVertSpacing(numLines, margin, height, yOffset):
|
||||
"""Return the optimal spacing between a number of lines.
|
||||
|
||||
margin is the space we want between the first line and the top."""
|
||||
h = height - numLines * letterHeight - yOffset * 2 - margin
|
||||
h = height - numLines * char_height - yOffset * 2 - margin
|
||||
return h / (numLines - 1)
|
||||
|
||||
|
||||
@@ -250,32 +238,27 @@ def getColorCode(colorName, rgbFileName):
|
||||
return rgbstr
|
||||
return None
|
||||
|
||||
char_list = [
|
||||
'0123456789:/-%. ',
|
||||
'abcdefghijklmnopqrstuvwxyz',
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
]
|
||||
|
||||
digits = '0123456789:/-%. '
|
||||
letters = 'abcdefghijklmnopqrstuvwxyz'
|
||||
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
char_startx = 0
|
||||
char_starty = 64
|
||||
char_width = 6
|
||||
char_height = 9
|
||||
|
||||
lettersStartX = 0
|
||||
lettersStartY = 74
|
||||
letterWidth = 6
|
||||
letterHeight = 8
|
||||
|
||||
digitsStartX = 0
|
||||
digitsStartY = 64
|
||||
digitWidth = 6
|
||||
digitHeight = 8
|
||||
|
||||
alfabet = [\
|
||||
char_map = [
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'__%%%____%____%%%___%%%_____%__%%%%%__%%%__%%%%%__%%%___%%%___________%________%%__%________________________________________________............................',
|
||||
'_%___%__%%___%___%_%___%___%%__%_____%___%_%___%_%___%_%___%__%%______%________%%_%%________________________________________________............................',
|
||||
'_%__%%___%_______%_____%__%_%__%%%%__%________%__%___%_%___%__%%_____%%__________%%_________________________________________________............................',
|
||||
'_%_%_%___%______%____%%__%__%______%_%%%%____%____%%%___%%%%_________%___%%%%%___%__________________________________________________............................',
|
||||
'_%%__%___%_____%_______%_%%%%%_____%_%___%___%___%___%_____%________%%__________%%__________________________________________________............................',
|
||||
'_%___%___%_______%_____%__%_%__%%%%__%________%__%___%_%___%__%%_____%%__________%%_________________________________________________............................',
|
||||
'_%___%___%______%____%%__%__%______%_%%%%____%____%%%___%%%%_________%___%%%%%___%__________________________________________________............................',
|
||||
'_%___%___%_____%_______%_%%%%%_____%_%___%___%___%___%_____%________%%__________%%__________________________________________________............................',
|
||||
'_%___%___%____%____%___%____%__%___%_%___%___%___%___%_%___%__%%____%__________%%_%%__%%____________________________________________............................',
|
||||
'__%%%___%%%__%%%%%__%%%_____%___%%%___%%%____%____%%%___%%%___%%____%__________%__%%__%%____________________________________________............................',
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'................................................................................................................................................................',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'_______%______________%__________%%________%______%_______%__%______%___________________________________________________________________________________________',
|
||||
'_______%______________%_________%__________%_________________%______%_______________________________________________%___________________________________________',
|
||||
@@ -285,8 +268,7 @@ alfabet = [\
|
||||
'_%__%__%__%__%_____%__%__%______%_____%%%__%__%___%_______%__%_%____%____%_%_%_%__%__%__%__%%%____%%%__%________%___%____%__%___%%___%_%_%__%_%___%%%___%_______',
|
||||
'__%%%__%%%____%%____%%%___%%____%_______%__%__%___%_______%__%__%___%____%_%_%_%__%___%%___%________%__%_____%%%_____%%___%%%___%%____%_%__%___%___%___%%%%%____',
|
||||
'_____________________________________%%%________________%%_________________________________%________%____________________________________________%%_____________',
|
||||
'................................................................................................................................................................',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'___%___%%%%___%%%__%%%%__%%%%%_%%%%%__%%%__%___%__%%%____%%%_%___%_%_____%___%_%___%__%%%__%%%%___%%%__%%%%___%%%__%%%%%_%___%_%___%_%___%_%___%_%___%_%%%%%____',
|
||||
'__%_%__%___%_%___%_%___%_%_____%_____%___%_%___%___%______%__%__%__%_____%%_%%_%%__%_%___%_%___%_%___%_%___%_%___%___%___%___%_%___%_%___%_%___%_%___%_____%____',
|
||||
'_%___%_%___%_%_____%___%_%_____%_____%_____%___%___%______%__%_%___%_____%_%_%_%%%_%_%___%_%___%_%___%_%___%_%_______%___%___%_%___%_%___%__%_%__%___%____%_____',
|
||||
@@ -295,10 +277,13 @@ alfabet = [\
|
||||
'_%___%_%___%_%___%_%___%_%_____%_____%___%_%___%___%___%__%__%__%__%_____%___%_%___%_%___%_%_____%__%__%__%__%___%___%___%___%__%_%__%%_%%_%___%___%___%________',
|
||||
'_%___%_%%%%___%%%__%%%%__%%%%%_%______%%%__%___%__%%%___%%___%___%_%%%%%_%___%_%___%__%%%__%______%%_%_%___%__%%%____%____%%%____%___%___%_%___%___%___%%%%%____',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................']
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user