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:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -285,7 +285,7 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
|
||||
&(wmgen->mask), &(wmgen->attributes));
|
||||
|
||||
if (err != XpmSuccess) {
|
||||
fprintf(stderr, "Not enough free colorcells.\n");
|
||||
fprintf(stderr, "Not enough free colorcells. %d\n", err);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ Licensed under the GNU General Public License
|
||||
|
||||
|
||||
Changes:
|
||||
|
||||
2006-10-10 Mario Frasca
|
||||
redesigned xpm initialization
|
||||
|
||||
2003-06-25 Kristoffer Erlandsson
|
||||
Updated documentation
|
||||
|
||||
@@ -66,33 +70,24 @@ def getCenterStartPos(s, areaWidth, offset):
|
||||
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
|
||||
ValueError if we try to paint a char not in letters or digits
|
||||
or if we get out of bounds during painting. digits is really
|
||||
just another line of chars, it's unlucky called digits everywhere
|
||||
I used it since it contained only digits in the start. However,
|
||||
now it contains various special chars too everywhere I use it. But
|
||||
the name remains in too many places so I haven't gotten to change
|
||||
it.
|
||||
Return the (width, height) of the character painted. (will be useful if
|
||||
we implement proportional char sets)
|
||||
|
||||
the library only supports lower ascii: 32-127. any other will cause a
|
||||
ValueError exception.
|
||||
|
||||
if the character being painted falls partly out of the boundary, it will
|
||||
be clipped without causing an exception. this works even if the
|
||||
character starts out of the boundary.
|
||||
"""
|
||||
chX = None
|
||||
for line in range(3):
|
||||
chIndex = char_list[line].find(ch)
|
||||
if chIndex != -1:
|
||||
chX = char_startx + chIndex * char_width
|
||||
chY = char_starty + line * char_height
|
||||
break
|
||||
if chX is None:
|
||||
raise ValueError, "Unsupported char: '%s'" % ch
|
||||
|
||||
if not (32 <= ord(ch) <= 127):
|
||||
raise ValueError, "Unsupported Char: '%s'(%d)" % (ch, ord(ch))
|
||||
stringsize = 128 - (128 % char_width)
|
||||
pos = (ord(ch)-32) * char_width
|
||||
chY, chX = (pos / stringsize) * char_height + 64, pos % stringsize
|
||||
targX = x + xOffset
|
||||
targY = y + yOffset
|
||||
if targX + char_width > width - xOffset or targY + char_height > height - yOffset\
|
||||
or targX < 0 or targY < 0:
|
||||
raise ValueError, "Out of bounds. %s %s %s %s" % (
|
||||
targX + char_width > width - xOffset,
|
||||
targY + char_height > height - yOffset,
|
||||
targX < 0,
|
||||
targY < 0)
|
||||
pywmgeneral.copyXPMArea(chX, chY, char_width, char_height, targX, targY)
|
||||
return (char_width, char_height)
|
||||
|
||||
@@ -158,16 +153,78 @@ def setColor(xpm, name, newColor):
|
||||
xpm[index] = '%s\tc %s s %s' % (letter, color, comment)
|
||||
index += 1
|
||||
|
||||
def setDefaultPixmap(xpm):
|
||||
"""Set the pixmap of the program.
|
||||
def initPixmap(xpm_background=None,
|
||||
font_name='6x8',
|
||||
bg='0', fg='7',
|
||||
width=64, height=64,
|
||||
palette=None):
|
||||
"""builds and sets the pixmap of the program.
|
||||
|
||||
xpm is an XPM represented as a list of strings, possible gotten
|
||||
from readXPM(). This is what we use all the time later. The XBM
|
||||
mask is created out of the XPM. If I understand correctly how it
|
||||
works we use the upper left rectangle as mask. This is the
|
||||
simplest way to do it and is the desired behaviour in most cases.
|
||||
a wmdockapp has a 128x112 pixmap
|
||||
|
||||
the 64x64 upper left area is the work area in which we put what we want
|
||||
to be displayed.
|
||||
|
||||
the 64x64 upper right area contains the pattern for blanking the area.
|
||||
this is initialized using the xpm_background parameter. xpm_background
|
||||
must contain a list of 64 strings of length 64.
|
||||
|
||||
the remaining lower area defines the character set. this is initialized
|
||||
using the corresponding named character set. a file with this name must
|
||||
be found somewhere in the path.
|
||||
|
||||
xpm_background and the font must share the same palette. the font must
|
||||
be black/white.
|
||||
|
||||
The XBM mask is created out of the XPM.
|
||||
"""
|
||||
|
||||
if xpm_background is None:
|
||||
xpm_background = [bg*width]*height
|
||||
if palette is None:
|
||||
palette = {
|
||||
0: ('#000000','black'),
|
||||
1: ('#000080','blue'),
|
||||
2: ('#008080','cyan'),
|
||||
3: ('#008000','green'),
|
||||
4: ('#808000','yellow'),
|
||||
5: ('#800000','red'),
|
||||
6: ('#800080','purple'),
|
||||
7: ('#c0c0c0','light_gray'),
|
||||
8: ('#808080','dark_gray'),
|
||||
9: ('#0000ff','light_blue'),
|
||||
10: ('#00ffff','light_cyan'),
|
||||
11: ('#00ff00','light_green'),
|
||||
12: ('#ffff00','light_yellow'),
|
||||
13: ('#ff0000','light_red'),
|
||||
14: ('#ff00ff','light_purple'),
|
||||
15: ('#ffffff','white'),
|
||||
}
|
||||
|
||||
global char_width, char_height, char_map
|
||||
global tile_width, tile_height
|
||||
|
||||
char_width = char_defs[font_name]['width']
|
||||
char_height = char_defs[font_name]['height']
|
||||
char_map = char_defs[font_name]['map']
|
||||
|
||||
tile_width = width
|
||||
tile_height = height
|
||||
|
||||
xpm = [
|
||||
'128 112 %d 1' % len(palette),
|
||||
] + [
|
||||
'%x\tc %s s %s' % (k, v[0], v[-1])
|
||||
for k,v in palette.items()
|
||||
] + [
|
||||
bg*64 + item for item in xpm_background
|
||||
] + [
|
||||
line.replace('%', fg).replace(' ', bg)
|
||||
for line in char_map
|
||||
]
|
||||
|
||||
pywmgeneral.includePixmap(xpm)
|
||||
return char_width, char_height
|
||||
|
||||
def openXwindow(argv, w, h):
|
||||
"""Open the X window of given width and height.
|
||||
@@ -242,52 +299,176 @@ def getColorCode(colorName, rgbFileName):
|
||||
return rgbstr
|
||||
return None
|
||||
|
||||
char_list = [
|
||||
'0123456789:/-%. ',
|
||||
'abcdefghijklmnopqrstuvwxyz',
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
char_defs = {
|
||||
'5x7': {
|
||||
'width': 5,
|
||||
'height': 7,
|
||||
'map': [
|
||||
" % % % % % % % % % %% %%%% % %%%% %% %%%% %% ",
|
||||
" % % % % % %%% % % % % % % % % % % % % %% % % % %% % % % % % ",
|
||||
" % % % %%%%%% % % % % % % % % % % % % % % %% % % %%% %%% % %% ",
|
||||
" % % % %%% % % % % %%% %%%%% %%%% % % % % % % %%%% % % % % % % ",
|
||||
" %%%%% % %% % % % % % % % %% %% % % % % % % % % % % % % % % % ",
|
||||
" % % % %%% % % % % % % % % % %% % %%% %%%% %% % %% %% % %% ",
|
||||
" % ",
|
||||
" %% % %% %% %%% %% %%% %%%% %%%% %% % % %%% % % % % % % % % %% %%% %% ",
|
||||
"% % %% %% % % % % % % % % % % % % % % % % % % % % % % % % % %%%% %% % % % % % % % ",
|
||||
"% % %% %% % %%%% % % % %% % % %%% % % % %%% %%% % %%%% % % %% % %%%% %% % % % % % % % ",
|
||||
" %%% % % % % %% %%%% % % % % % % % % %% % % % % %% % % % % %% % % %%% % % ",
|
||||
" % %% %% % %%%% % % % % % % % % % % % % % % % % % % % % % % % % % %% % % % %% % ",
|
||||
" %% %% % % % % %% % % %%% %% %%% %%%% % %%% % % %%% %% % % %%%% % % % % %% % %% ",
|
||||
" % % ",
|
||||
"%%% %% %%% % % % % % % % % % % %%%% %%% %%% % % % % % % % % ",
|
||||
"% % % % % % % % % % % % % % % % % % % % % % % % % % % ",
|
||||
"% % % % % % % % % % %% % % % % % % %%% %%% %% %%% %% % %%% %%% %% % ",
|
||||
"%%% % % % % % % %%%% %% % % % % % % % % % % % % % %% %%% % % % % % % ",
|
||||
"% % % % % % % %% %%%% % % % % % % % % %% % % % % % %% % %% % % % % ",
|
||||
"% % %% % %% %% % % % % % %%%% %%% %%% %%%% % % %%% %% %%% %% % % % % %%% % % ",
|
||||
" %%% % ",
|
||||
"% %% % % % % % % ",
|
||||
"% % % % % % % % % % % ",
|
||||
"% % % % % %%% %% %%% %%% %%% %%% %%% % % % % % % % % % % %%%% %% % %% ",
|
||||
"%% % %%%% % % % % % % % % % % %% % % % % % % % %% % % % % % % % % ",
|
||||
"% % % % % % % % % % % % % % %% % % % % % %%%% %% % % % % % % ",
|
||||
"% % %%% % % % % %% %%% %%% % %%% %% %%% % %%%% % % % %%%% % % % % % % ",
|
||||
" % % % ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
]
|
||||
},
|
||||
'6x8': {
|
||||
'width': 6,
|
||||
'height': 8,
|
||||
'map': [
|
||||
" % % % % % % % % %% % % % %%% % %%% %%% % ",
|
||||
" % % % % % %%%% % % % % % % % % % % % % %% % % % % %% ",
|
||||
" % % % %%%%% % % %% % % % % % % % % %% % % % % % ",
|
||||
" % % % %%% % % % % %%%%% %%%%% %%%%% % % % % % %% %% % % ",
|
||||
" %%%%% % % % % % % % % % % % %% % % % % %%%%% ",
|
||||
" % % %%%% % % % % % % % % % % %% % % % % % % % % ",
|
||||
" % % % % % % %% % % % % %% % %%% %%% %%%%% %%% % ",
|
||||
" % ",
|
||||
"%%%%% %%% %%%%% %%% %%% %% %% %%% %%% % %%%% %%% %%% %%%%% %%%%% %%% % % %%% ",
|
||||
"% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
|
||||
"%%%% % % % % % % % % % %%%%% % % % %%% % % % % % % % % % % % % % ",
|
||||
" % %%%% % %%% %%%% % % % % % % %%%%% %%%% % % % %%%% %%% % %% %%%%% % ",
|
||||
" % % % % % % % % %%%%% % % % %%% % % % % % % % % % % % % % % ",
|
||||
"% % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
|
||||
" %%% %%% % %%% %%% % %% %% % %%% % % %%%% %%% %%% %%%%% % %%% % % %%% ",
|
||||
" % ",
|
||||
" %%% % % % % % % % %%% %%%% %%% %%%% %%% %%%%% % % % % % % % % % % %%%%% %%% %%% % ",
|
||||
" % % % % %% %% % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
|
||||
" % % % % % % % %% % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
|
||||
" % %% % % % % % % % % %%%% % % %%%% %%% % % % % % % % % % % % % % % ",
|
||||
" % % % % % % % %% % % % % % % % % % % % % % % % % % % % % % % % ",
|
||||
"% % % % % % % % % % % % %%% % % % % % % % % % %% %% % % % % % % % ",
|
||||
" %% % % %%%%% % % % % %%% % %% % % %%% % %%% % % % % % % %%%%% %%% % %%% ",
|
||||
" ",
|
||||
" % % % %% % % % %% ",
|
||||
" % % % % % % % ",
|
||||
" % %%% % %%%% % %%% % %%%% % %% %% % % %% % %%%% %%% %%%% %%%% %%%% %%%% ",
|
||||
" % %%%% % %%%% % % %%%% % % %%%% % % % %% % % % % % % % % % % % % % % % ",
|
||||
" %%%% % % % % % %%%%% % % % % % % % %% % % % % % % % % % % % % % %%% ",
|
||||
" % % % % % % % % % %%%% % % % % % % % % % % % % % % %%%% %%%% % % ",
|
||||
" %%%% %%%% %%%% %%%% %%% % % % % %%% % % %% %%% % % % % % %%% % % % %%%% ",
|
||||
"%%%%% %%%% %%% % % ",
|
||||
" %%% % %%% ",
|
||||
" % % % % ",
|
||||
"%%%%% % % % % % % % % % % %%%%% % % % ",
|
||||
" % % % % % % % % % % % % % % % % %% % ",
|
||||
" % % % % % % % % % % % % % % % % %% ",
|
||||
" % % % % % % % % % % %%%% % % % % ",
|
||||
" %% %%%% % % % % % % %%%%% %%% % %%% ",
|
||||
" %%% ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
]
|
||||
},
|
||||
'8x8': {
|
||||
'width': 8,
|
||||
'height': 8,
|
||||
'map': [
|
||||
" %% %% %% %% %% %% %% % %%%% %% %% %% ",
|
||||
" %% %% %% %% %% %%%%% %% %% %% %% %% %% %% %% %% %% %%",
|
||||
" %% %% %% %%%%%%%% %% %% %%%% %% %% %% %%%% %% %% ",
|
||||
" %% %% %% %%%% %% %%% %% %% %%%%%%%% %%%%%% %%%%%% %% ",
|
||||
" %%%%%%%% %% %% %% %%% %% %% %%%% %% %% ",
|
||||
" %% %% %%%%% %% %% %% %% %% %% %% %% %% %% %% %% ",
|
||||
" %% %% %% %% % %% %%%%%% %% %% %% %% %% ",
|
||||
" %% ",
|
||||
" %%%% %% %%%% %%%% %% %%%%%% %%%% %%%%%% %%%% %%%% %%% %%% %%%% ",
|
||||
" %% %% %% %% %% %% %% %%% %% %% %% %% %% %% %% %% %% %% %% %% %% ",
|
||||
" %% %%% %%% %% %% %%%% %%%%% %% %% %% %% %% %% %% %% %% %%%%%% %% %% ",
|
||||
" %%% %% %% %% %%% %% %% %% %%%%% %% %%%% %%%%% %% %% %% ",
|
||||
" %% %% %% %% %% %%%%%%% %% %% %% %% %% %% %% %% %%%%%% %% %% ",
|
||||
" %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% ",
|
||||
" %%%% %%%%%% %%%%%% %%%% %% %%%% %%%% %% %%%% %%%% %% %%% %%% %% ",
|
||||
" %% ",
|
||||
" %%%% %% %%%%% %%%% %%%% %%%%%% %%%%%% %%%% %% %% %%%% %%%% %% %% %% %% %% %% %% %%%% ",
|
||||
" %% %% %%%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%% %%% %%% %% %% %% ",
|
||||
" %% %%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%%% %% %%%%%%% %%%%%% %% %% ",
|
||||
" %% %%% %%%%%% %%%%% %% %% %% %%%% %%%% %% %%% %%%%%% %% %% %%% %% %% % %% %%%%%% %% %% ",
|
||||
" %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%%% %% %% %% %% %%% %% %% ",
|
||||
" %% % %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% ",
|
||||
" %%%% %% %% %%%%% %%%% %%%% %%%%%% %% %%%% %% %% %%%% %%% %% %% %%%%%% %% %% %% %% %%%% ",
|
||||
" ",
|
||||
" %%%%% %%%% %%%%% %%%% %%%%%% %% %% %% %% %% %% %% %% %% %% %%%%%% %%% %%% ",
|
||||
" %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% ",
|
||||
" %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%%% %% %% %% %% %% %% ",
|
||||
" %%%%% %% %% %%%%% %%%% %% %% %% %% %% %% % %% %% %%%% %% %% %% %% %%% %% ",
|
||||
" %% %% %% %%%% %% %% %% %% %% %% %%%%%%% %%%% %% %% %% %% %% %% %%% ",
|
||||
" %% %%%% %% %% %% %% %% %% %% %%%% %%% %%% %% %% %% %% %% %% %% ",
|
||||
" %% %%% %% %% %%%% %% %%%% %% %% %% %% %% %% %%%%%% %%% %% %%% ",
|
||||
" ",
|
||||
" %% ",
|
||||
" %% %% %% %%% %% %% %% %% %%% ",
|
||||
" %% %%%% %% %%%% %% %%%% %% %%%%% %% %% %% %% %% %%%%% %%%% ",
|
||||
" %% %%%%% %% %%%%% %% %% %%%%% %% %% %%%%% %%% %% %% %% %% %%%%%%% %% %% %% %% ",
|
||||
" %%%%% %% %% %% %% %% %%%%%% %% %% %% %% %% %% %% %%%% %% %%%%%%% %% %% %% %% ",
|
||||
" %% %% %% %% %% %% %% %% %% %%%%% %% %% %% %% %% %% %% %% % %% %% %% %% %% ",
|
||||
" %%%%% %%%%% %%%% %%%%% %%%% %% %% %% %% %%%% %% %% %% %%%% %% %% %% %% %%%% ",
|
||||
" %%%%% %%%% ",
|
||||
" %%%% %%%% ",
|
||||
" %% %% %% %% %% ",
|
||||
" %%%%% %%%%% %%%%% %%%%% %%%%%% %% %% %% %% %% %% %% %% %% %% %%%%%% %% %% %% %%%% ",
|
||||
" %% %% %% %% %% %% %% %% %% %% %% %% %% % %% %%%% %% %% %% %% %% %% %% %% ",
|
||||
" %% %% %% %% %% %%%% %% %% %% %% %% %%%%%%% %% %% %% %% %% %% %% ",
|
||||
" %%%%% %%%%% %% %% %% %% %% %%%% %%%%% %%%% %%%%% %% %% %% %% ",
|
||||
" %% %% %% %%%%% %%% %%%%% %% %% %% %% %% %% %%%%%% %%%% %% %%%% %%%%%%%%",
|
||||
" %% %% %%%% ",
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
default_xpm_header = [
|
||||
'128 112 4 1',
|
||||
'_\tc #7f260a',
|
||||
' \tc #000000 s background',
|
||||
'/\tc #2020b2 s graph',
|
||||
'%\tc #2081B2 s text',
|
||||
]
|
||||
|
||||
char_startx = 0
|
||||
char_starty = 64
|
||||
char_width = 6
|
||||
char_height = 9
|
||||
|
||||
char_map = [
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'__%%%____%____%%%___%%%_____%__%%%%%__%%%__%%%%%__%%%___%%%___________%________%%__%________________________________________________............................',
|
||||
'_%___%__%%___%___%_%___%___%%__%_____%___%_%___%_%___%_%___%__%%______%________%%_%%________________________________________________............................',
|
||||
'_%___%___%_______%_____%__%_%__%%%%__%________%__%___%_%___%__%%_____%%__________%%_________________________________________________............................',
|
||||
'_%___%___%______%____%%__%__%______%_%%%%____%____%%%___%%%%_________%___%%%%%___%__________________________________________________............................',
|
||||
'_%___%___%_____%_______%_%%%%%_____%_%___%___%___%___%_____%________%%__________%%__________________________________________________............................',
|
||||
'_%___%___%____%____%___%____%__%___%_%___%___%___%___%_%___%__%%____%__________%%_%%__%%____________________________________________............................',
|
||||
'__%%%___%%%__%%%%%__%%%_____%___%%%___%%%____%____%%%___%%%___%%____%__________%__%%__%%____________________________________________............................',
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'_______%______________%__________%%________%______%_______%__%______%___________________________________________________________________________________________',
|
||||
'_______%______________%_________%__________%_________________%______%_______________________________________________%___________________________________________',
|
||||
'__%%___%%%____%%____%%%___%%____%_____%%%__%%%____%_______%__%__%___%____%%_%__%%%____%%___%%%____%%%__%%%____%%%__%%%___%__%__%__%__%___%_%___%_%__%__%%%%%____',
|
||||
'____%__%__%__%_____%__%__%__%___%%___%__%__%__%___%_______%__%_%____%____%_%_%_%__%__%__%__%__%__%__%__%__%__%______%____%__%__%__%__%_%_%__%_%__%__%_____%_____',
|
||||
'__%%%__%__%__%_____%__%__%%%%___%____%__%__%__%___%_______%__%%_____%____%_%_%_%__%__%__%__%__%__%__%__%______%%____%____%__%__%__%__%_%_%___%___%__%____%______',
|
||||
'_%__%__%__%__%_____%__%__%______%_____%%%__%__%___%_______%__%_%____%____%_%_%_%__%__%__%__%%%____%%%__%________%___%____%__%___%%___%_%_%__%_%___%%%___%_______',
|
||||
'__%%%__%%%____%%____%%%___%%____%_______%__%__%___%_______%__%__%___%____%_%_%_%__%___%%___%________%__%_____%%%_____%%___%%%___%%____%_%__%___%___%___%%%%%____',
|
||||
'_____________________________________%%%________________%%_________________________________%________%____________________________________________%%_____________',
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'___%___%%%%___%%%__%%%%__%%%%%_%%%%%__%%%__%___%__%%%____%%%_%___%_%_____%___%_%___%__%%%__%%%%___%%%__%%%%___%%%__%%%%%_%___%_%___%_%___%_%___%_%___%_%%%%%____',
|
||||
'__%_%__%___%_%___%_%___%_%_____%_____%___%_%___%___%______%__%__%__%_____%%_%%_%%__%_%___%_%___%_%___%_%___%_%___%___%___%___%_%___%_%___%_%___%_%___%_____%____',
|
||||
'_%___%_%___%_%_____%___%_%_____%_____%_____%___%___%______%__%_%___%_____%_%_%_%%%_%_%___%_%___%_%___%_%___%_%_______%___%___%_%___%_%___%__%_%__%___%____%_____',
|
||||
'_%___%_%%%%__%_____%___%_%%%___%%%___%__%%_%%%%%___%______%__%%____%_____%_%_%_%_%%%_%___%_%%%%__%___%_%%%%___%%%____%___%___%_%___%_%_%_%___%____%_%____%______',
|
||||
'_%%%%%_%___%_%_____%___%_%_____%_____%___%_%___%___%______%__%_%___%_____%___%_%__%%_%___%_%_____%_%_%_%_%_______%___%___%___%_%___%_%_%_%__%_%____%____%_______',
|
||||
'_%___%_%___%_%___%_%___%_%_____%_____%___%_%___%___%___%__%__%__%__%_____%___%_%___%_%___%_%_____%__%__%__%__%___%___%___%___%__%_%__%%_%%_%___%___%___%________',
|
||||
'_%___%_%%%%___%%%__%%%%__%%%%%_%______%%%__%___%__%%%___%%___%___%_%%%%%_%___%_%___%__%%%__%______%%_%_%___%__%%%____%____%%%____%___%___%_%___%___%___%%%%%____',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'________________________________________________________________________________________________________________________________________________________________',
|
||||
'____________________________________________________________________________________________________________________________________............................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
'................................................................................................................................................................',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user