diff --git a/examples/pywmgeneric.py b/examples/pywmgeneric.py index 68a34a3..b0a81c2 100644 --- a/examples/pywmgeneric.py +++ b/examples/pywmgeneric.py @@ -42,8 +42,6 @@ import popen2 import wmdocklib -from wmdocklib import char_width, char_height - prevStat = {'user':0, 'nice':0, 'sys':0, @@ -113,6 +111,9 @@ class UserMethods: f.close() return lambda: 'sys: %s' % temp + def ls(self): + return lambda: 'boh' + def showDnWithoutDescs(self, entry): """Strip descriptions from some text where the descs are indented. @@ -372,15 +373,12 @@ class Entry: Or nothing if we can't come up with something good. Could be nice to extend this function with chars more fitting for your language. """ - fromChars = 'áéíóúàèìòùâêîôûäëïöü' - toChars = 'aeiouaeiouaeiouaeiou' - deleteChars = [] - for c in text.lower(): - if not (c in letters or c in digits or c in fromChars): - deleteChars.append(c) - deleteChars = ''.join(deleteChars) - trans = string.maketrans(fromChars, toChars) - text = string.translate(text.lower(), trans, deleteChars) + fromChars = u'ñźńśćżłáéíóúàèìòùâêîôûäëïöüãẽĩõũ' + toChars = u'nznsczlaeiouaeiouaeiouaeiouaeiou' + for frm, to in zip(fromChars, toChars): + text = text.replace(frm, to) + text = text.replace(frm.upper(), to.upper()) + text = ''.join([i for i in text if 32 <= ord(i) < 128]) return text def getAllText(self): @@ -541,35 +539,6 @@ def parseCommandLine(argv): d['configfile'] = a 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): - err( - "Can't read the RGB file, try setting it differently using -r,\n") - err( - "Ignoring your color settings, using the defaults.\n") - useColors = 0 - if useColors: - # Colors is a list with (, ) pairs. - colors = (('barfgcolor', 'graph'), - ('barbgcolor', 'graphbg'), - ('textcolor', '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: - err('Bad colorcode for %s, ignoring.\n' % key) - else: - wmdocklib.setColor(xpm, value, code) - def readConfigFile(fileName): """Read the config file. @@ -595,105 +564,113 @@ def readConfigFile(fileName): l[i][o] = cp.get(strI, o, raw=1) return l +background = \ +[ + ' ...............................................................................................', + ' .///..___..ooo..___..___.......................................................................', + ' .///..___..ooo..___..___.......................................................................', + ' .///..___..ooo..___..___.......................................................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///.._________________________________________________________................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..___..ooo.......................................................................', + ' .///..___..___..___..ooo.......................................................................', + ' .///..___..___..___..ooo.......................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...........................................................................................', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' ...............................................................................................', + ' ...............................................................................................', + ] def main(): clConfig = parseCommandLine(sys.argv) + + palette = { + ' ': '#208120812081', + '.': '#00000000FFFF', + 'o': '#C71BC30BC71B', + 'O': '#861782078E38', + '+': '#EFBEF3CEEFBE', + '@': '#618561856185', + '#': '#9E79A2899E79', + '$': '#410341034103', + } + palette['o'] = clConfig.get('indicator', '#2020b2b2aaaa') + palette['/'] = clConfig.get('graph', '#2020b2b2aaaa') + palette['-'] = clConfig.get('graphbg', '#707070707070') + palette['_'] = clConfig.get('background', '#000000000000') + palette['%'] = clConfig.get('text', '#2081B2CAAEBA') + configFile = clConfig.get('configfile', defaultConfigFile) if not configFile.count(os.sep): configFile = os.sep.join(sys.argv[0].split(os.sep)[:-1]) + os.sep + configFile configFile = os.path.expanduser(configFile) config = readConfigFile(configFile) - parseColors(defaultRGBFiles, clConfig, xpm) try: programName = sys.argv[0].split(os.sep)[-1] except IndexError: programName = '' sys.argv[0] = programName - wmdocklib.setDefaultPixmap(xpm) + + global char_width, char_height + char_width, char_height = wmdocklib.initPixmap(background, + font_name='8x8', + bg='f', fg='9', + palette=palette) + wmdocklib.openXwindow(sys.argv, width, height) pywmgeneric = PywmGeneric(config) pywmgeneric.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.......................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...', - ' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...', - ' .///////////////////////////////////////////////////////////////////////////////////////////...', - ' .///////////////////////////////////////////////////////////////////////////////////////////...', - ' ...............................................................................................', - ' ...............................................................................................', - ] + wmdocklib.char_map - if __name__ == '__main__': main()