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