1
0
mirror of https://github.com/gryf/wmdocklib.git synced 2025-12-19 12:28:10 +01:00

1575762: initialization of pixmask

this is an important modification.  I hope it won't break too many programs
based on this library, or at least not in such a way that will make you
upset with me and my work...

well: the library offers now three charsets and a 16 colours palette.
but: you must use them.

there is no support yet for named colours.

the only working examples are pywmdatetime and pywmhdmon.
This commit is contained in:
mfrasca
2006-10-12 17:29:17 +00:00
parent c1508bdbcd
commit ed4b557ab0
4 changed files with 338 additions and 274 deletions

View File

@@ -49,8 +49,6 @@ import os
import wmdocklib
from wmdocklib import char_width, char_height
width = 64
height = 64
@@ -72,6 +70,9 @@ def addString(s, x, y):
width, height)
except ValueError, e:
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
sys.stderr.write('test %s' % ((s, x, y, xOffset, yOffset,
width, height),))
raise
sys.exit(3)
def clearLine(y):
@@ -186,33 +187,6 @@ def mainLoop(timeFmt, dateFmt, dayFmt, weekFmt):
wmdocklib.redraw()
time.sleep(0.1)
def parseColors(defaultRGBFileNames, config, xpm):
rgbFileName = ''
for fn in defaultRGBFileNames:
if os.access(fn, os.R_OK):
rgbFileName = fn
break
rgbFileName = config.get('rgbfile', rgbFileName)
useColors = 1
if not os.access(rgbFileName, os.R_OK):
sys.stderr.write(
"Can't read the RGB file, try setting it differently using -r,\n")
sys.stderr.write(
"Ignoring your color settings, using the defaults.\n")
useColors = 0
if useColors:
# Colors is a list with (<config_key>, <xpm-key>) pairs.
colors = (('foreground', 'text'),
('background', 'background'))
for key, value in colors:
col = config.get(key)
if not col is None:
code = wmdocklib.getColorCode(col, rgbFileName)
if code is None:
sys.stderr.write('Bad colorcode for %s, ignoring.\n' % key)
else:
wmdocklib.setColor(xpm, value, code)
def main():
clConfig = parseCommandLine(sys.argv)
configFile = clConfig.get('configfile', defaultConfigFile)
@@ -224,8 +198,6 @@ def main():
for i in clConfig.iteritems():
config[i[0]] = i[1]
parseColors(defaultRGBFiles, config, xpm)
wmdocklib.setDefaultPixmap(xpm)
timeFmt = config.get('timeformat', timeDefaultFormat)
dateFmt = config.get('dateformat', dateDefaultFormat)
dayFmt = config.get('weekdayformat', dayDefaultFormat)
@@ -241,84 +213,8 @@ def main():
wmdocklib.openXwindow(sys.argv, width, height)
mainLoop(timeFmt, dateFmt, dayFmt, weekFmt)
xpm = \
['160 100 11 1',
' \tc #208120812081',
'.\tc #00000000FFFF',
'o\tc #C71BC30BC71B',
'O\tc #861782078E38',
'+\tc #EFBEF3CEEFBE',
'@\tc #618561856185',
'#\tc #9E79A2899E79',
'$\tc #410341034103',
'/\tc #2020b2b2aaaa s graph',
'_\tc #000000000000 s background',
'%\tc #2081B2CAAEBA s text',
' ________________________________________________________________________________________________',
' __///___________________________________________________________________________________________',
' __///___________________________________________________________________________________________',
' __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///___________________________________________________________________________________________',
' ________________________________________________________ __///////////////////////////////////////////////////////////////////////////////////////////___',
' ________________________________________________________ __///////////////////////////////////////////////////////////////////////////////////////////___',
' __///////////////////////////////////////////////////////////////////////////////////////////___',
' ________________________________________________________________________________________________',
' ________________________________________________________________________________________________',
' ________________________________________________________________________________________________',
] + wmdocklib.char_map
char_width, char_height = wmdocklib.initPixmap(font_name='6x8',
bg='f', fg='9')
if __name__ == '__main__':
main()

View File

@@ -57,8 +57,6 @@ import os
import wmdocklib
from wmdocklib import char_width, char_height
width = 64
height = 64
@@ -425,7 +423,7 @@ def main():
config = fileConfig
for i in clConfig.iteritems():
config[i[0]] = i[1]
parseColors(defaultRGBFiles, config, xpm)
#parseColors(defaultRGBFiles, config, xpm)
pathsToMonitor = []
for i in range(1,1000):
@@ -450,7 +448,7 @@ def main():
58, 4 + i * (char_height + 1))
procStat = config.get('procstat', defaultProcStat)
skipping = int(config.get('skipconf', 0))
actMonEnabled = int(config.get('monitoring'))
actMonEnabled = int(config.get('monitoring',0))
if not os.access(procStat, os.R_OK):
sys.stderr.write(
"Can't read your procstat file, try setting it with -p. ")
@@ -461,7 +459,6 @@ def main():
except IndexError:
programName = ''
sys.argv[0] = programName
wmdocklib.setDefaultPixmap(xpm)
wmdocklib.openXwindow(sys.argv, width, height)
signal.signal(signal.SIGCHLD, handler)
@@ -472,86 +469,76 @@ def main():
hdmon = PywmHDMon(pathsToMonitor, procStat, actMonEnabled, skipping)
hdmon.mainLoop()
xpm = \
['160 100 13 1',
' \tc #208120812081',
'.\tc #00000000FFFF',
'o\tc #C71BC30BC71B',
'O\tc #861782078E38',
'+\tc #EFBEF3CEEFBE',
'@\tc #618561856185',
'#\tc #9E79A2899E79',
'$\tc #410341034103',
'o\tc #2020b2b2aaaa s indicator',
'/\tc #2020b2b2aaaa s graph',
'-\tc #707070707070 s graphbg',
'_\tc #000000000000 s background',
'%\tc #2081B2CAAEBA s text',
' ...............................................................................................',
' .///..___..ooo..___..___.......................................................................',
' .///..___..ooo..___..___.......................................................................',
' .///..___..ooo..___..___.......................................................................',
' ________________________________________________________ .///..___..___..___..___.......................................................................',
' ________________________________________________________ .///..___..___..___..___.......................................................................',
' ________________________________________________________ .///..___..___..___..___.......................................................................',
' ________________________________________________________ .///..___..___..ooo..___.......................................................................',
' ________________________________________________________ .///..___..___..ooo..___.......................................................................',
' ________________________________________________________ .///..___..___..ooo..___.......................................................................',
' ________________________________________________________ .///..___..___..___..___.......................................................................',
' ________________________________________________________ .///..___..___..___..___.......................................................................',
' ________________________________________________________ .///..___..___..___..___.......................................................................',
' ________________________________________________________ .///..___..___..___..ooo.......................................................................',
' ________________________________________________________ .///..___..___..___..ooo.......................................................................',
' ________________________________________________________ .///..___..___..___..ooo.......................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' ...............................................................................................',
' ...............................................................................................',
] + wmdocklib.char_map
background = \
['0000000000000000000000000000000000000000000000000000000000000000',
'0044400555002220055500555000000000000000000000000000000000000000',
'0044400555002220055500555000000000000000000000000000000000000000',
'0044400555002220055500555000000000000000000000000000000000000000',
'0044400555005550055500555000000000000000000000000000000000000000',
'0044400555005550055500555000000000000000000000000000000000000000',
'0044400555005550055500555000000000000000000000000000000000000000',
'0044400555005550022200555000000000000000000000000000000000000000',
'0044400555005550022200555000000000000000000000000000000000000000',
'0044400555005550022200555000000000000000000000000000000000000000',
'0044400555005550055500555000000000000000000000000000000000000000',
'0044400555005550055500555000000000000000000000000000000000000000',
'0044400555005550055500555000000000000000000000000000000000000000',
'0044400555005550055500222000000000000000000000000000000000000000',
'0044400555005550055500222000000000000000000000000000000000000000',
'0044400555005550055500222000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044400077777777777777777777777777777777777777777777777777777777',
'0044400077777777777777777777777777777777777777777777777777777777',
'0044400077777777777777777777777777777777777777777777777777777777',
'0044400077777777777777777777777777777777777777777777777777777777',
'0044400000000000000000000000000000000000000000000000000000000000',
'0044444444444444444444444444444444444444444444444444444444444444',
'0044444444444444444444444444444444444444444444444444444444444444',
'0044444444444444444444444444444444444444444444444444444444444444',
'0044444444444444444444444444444444444444444444444444444444444444',
'0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
]
char_width, char_height = wmdocklib.initPixmap(background,
font_name='6x8',
bg='7', fg='a')
if __name__ == '__main__':
main()