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

updated the example with the latest library.

This commit is contained in:
mfrasca
2006-10-13 13:52:15 +00:00
parent db4f53d257
commit 84f7b15e81
2 changed files with 172 additions and 201 deletions

View File

@@ -39,8 +39,6 @@ import os
import wmdocklib import wmdocklib
from wmdocklib import char_width, char_height
width = 64 width = 64
height = 64 height = 64
@@ -370,6 +368,89 @@ def parseColors(defaultRGBFileNames, config, xpm):
else: else:
wmdocklib.setColor(xpm, value, code) wmdocklib.setColor(xpm, value, code)
palette = {
' ': '#208120812081',
'.': '#00000000FFFF',
'o': '#C71BC30BC71B',
'O': '#861782078E38',
'+': '#EFBEF3CEEFBE',
'@': '#618561856185',
'#': '#9E79A2899E79',
'$': '#410341034103',
'o': '#2020b2b2aaaa',
'/': '#2020b2b2aaaa',
'-': '#707070707070',
'_': '#000000000000',
'%': '#2081B2CAAEBA',
}
background = \
[' ...............................................................................................',
' .///..___..ooo..___..___.......................................................................',
' .///..___..ooo..___..___.......................................................................',
' .///..___..ooo..___..___.......................................................................',
' .///..___..___..___..___.......................................................................',
' .///..___..___..___..___.......................................................................',
' .///..___..___..___..___.......................................................................',
' .///..___..___..ooo..___.......................................................................',
' .///..___..___..ooo..___.......................................................................',
' .///..___..___..ooo..___.......................................................................',
' .///..___..___..___..___.......................................................................',
' .///..___..___..___..___.......................................................................',
' .///..___..___..___..___.......................................................................',
' .///..___..___..___..ooo.......................................................................',
' .///..___..___..___..ooo.......................................................................',
' .///..___..___..___..ooo.......................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...........................................................................................',
' .///...-------------------------------------------------------------------------------------...',
' .///...-------------------------------------------------------------------------------------...',
' .///...-------------------------------------------------------------------------------------...',
' .///...-------------------------------------------------------------------------------------...',
' .///...........................................................................................',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' ...............................................................................................',
' ...............................................................................................',
]
def main(): def main():
clConfig = parseCommandLine(sys.argv) clConfig = parseCommandLine(sys.argv)
configFile = clConfig.get('configfile', defaultConfigFile) configFile = clConfig.get('configfile', defaultConfigFile)
@@ -381,7 +462,6 @@ def main():
for i in clConfig.iteritems(): for i in clConfig.iteritems():
config[i[0]] = i[1] config[i[0]] = i[1]
# Get the configurations # Get the configurations
parseColors(defaultRGBFiles, config, xpm)
setiDir = config.get('setidir') setiDir = config.get('setidir')
if setiDir is None: if setiDir is None:
sys.stderr.write( sys.stderr.write(
@@ -409,94 +489,14 @@ def main():
except IndexError: except IndexError:
programName = '' programName = ''
sys.argv[0] = programName sys.argv[0] = programName
wmdocklib.setDefaultPixmap(xpm) wmdocklib.initPixmap(background,
palette=palette)
wmdocklib.openXwindow(sys.argv, width, height) wmdocklib.openXwindow(sys.argv, width, height)
wmdocklib.addMouseRegion(0, xOffset, yOffset, width - 2 * xOffset, wmdocklib.addMouseRegion(0, xOffset, yOffset, width - 2 * xOffset,
height - 2 * yOffset) height - 2 * yOffset)
pwms = PywmSeti(statePath, uinfoPath, pidPath, execCmd) pwms = PywmSeti(statePath, uinfoPath, pidPath, execCmd)
pwms.mainLoop() pwms.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
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@@ -38,8 +38,6 @@ import os
import wmdocklib import wmdocklib
from wmdocklib import char_width, char_height
width = 64 width = 64
height = 64 height = 64
@@ -282,41 +280,98 @@ def parseCommandLine(argv):
sys.exit(2) sys.exit(2)
return d return d
def parseColors(defaultRGBFileList, config, xpm):
rgbFileName = ''
for fn in defaultRGBFileList:
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 = (('barfgcolor', 'graph'),
('barbgcolor', 'graphbg'),
('background', 'background'),
('graphforeground', 'vgraph'),
('graphbackground', 'vgraphbg'))
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)
palette = {
' ': '#208120812081',
'.': '#00000000FFFF',
'o': '#C71BC30BC71B',
'O': '#861782078E38',
'+': '#EFBEF3CEEFBE',
'@': '#618561856185',
'#': '#9E79A2899E79',
'$': '#410341034103',
'o': '#2020b2b2aaaa',
'/': '#2020b2b2aaaa',
'-': '#707070707070',
'|': '#2020b2b2aaaa',
'I': '#707070707070',
'_': '#000000000000',
'%': '#2081B2CAAEBA',
}
background = \
[' ...............................................................................................',
' .///..___..ooo..___..___......|.I..............................................................',
' .///..___..ooo..___..___......|.I..............................................................',
' .///..___..ooo..___..___......|.I..............................................................',
' .///..___..___..___..___......|.I..............................................................',
' .///..___..___..___..___......|.I..............................................................',
' .///..___..___..___..___......|.I..............................................................',
' .///..___..___..ooo..___......|.I..............................................................',
' .///..___..___..ooo..___......|.I..............................................................',
' .///..___..___..ooo..___......|.I..............................................................',
' .///..___..___..___..___......|.I..............................................................',
' .///..___..___..___..___......|.I..............................................................',
' .///..___..___..___..___......|.I..............................................................',
' .///..___..___..___..ooo......|.I..............................................................',
' .///..___..___..___..ooo......|.I..............................................................',
' .///..___..___..___..ooo......|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///..........................|.I..............................................................',
' .///...........................................................................................',
' .///...-------------------------------------------------------------------------------------...',
' .///...-------------------------------------------------------------------------------------...',
' .///...-------------------------------------------------------------------------------------...',
' .///...-------------------------------------------------------------------------------------...',
' .///...........................................................................................',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' ...............................................................................................',
' ...............................................................................................',
]
def main(): def main():
global char_width, char_height
char_width, char_height = wmdocklib.initPixmap(background,
font_name='6x8',
palette=palette)
config = parseCommandLine(sys.argv) config = parseCommandLine(sys.argv)
parseColors(defaultRGBFiles, config, xpm)
procStat = config.get('procstat', defaultProcStat) procStat = config.get('procstat', defaultProcStat)
if not os.access(procStat, os.R_OK): if not os.access(procStat, os.R_OK):
sys.stderr.write( sys.stderr.write(
@@ -334,95 +389,11 @@ def main():
except IndexError: except IndexError:
programName = '' programName = ''
sys.argv[0] = programName sys.argv[0] = programName
wmdocklib.setDefaultPixmap(xpm)
wmdocklib.openXwindow(sys.argv, width, height) wmdocklib.openXwindow(sys.argv, width, height)
pywmsysmon = PywmSysMon(procMeminfo, procStat, ignoreNice, updateDelay) pywmsysmon = PywmSysMon(procMeminfo, procStat, ignoreNice, updateDelay)
pywmsysmon.mainLoop() pywmsysmon.mainLoop()
xpm = \
['160 100 15 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 #2020b2b2aaaa s vgraph',
'I\tc #707070707070 s vgraphbg',
'_\tc #000000000000 s background',
'%\tc #2081B2CAAEBA s text',
' ...............................................................................................',
' .///..___..ooo..___..___......|.I..............................................................',
' .///..___..ooo..___..___......|.I..............................................................',
' .///..___..ooo..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..ooo..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..ooo..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..ooo..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..ooo......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..ooo......|.I..............................................................',
' ________________________________________________________ .///..___..___..___..ooo......|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///..........................|.I..............................................................',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
' ________________________________________________________ .///...........................................................................................',
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' .///////////////////////////////////////////////////////////////////////////////////////////...',
' ...............................................................................................',
' ...............................................................................................',
] + wmdocklib.char_map
if __name__ == '__main__': if __name__ == '__main__':
main() main()