Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
f45f25dd9d | |||
3ccb9c9b60 | |||
03ca9b0a48 | |||
26de7e1d61 | |||
bd595d03b8 | |||
970bb33b46 | |||
259f902f75 | |||
667724990c | |||
d4d7fdf761 | |||
b30c989858 | |||
b72b9d2f3e | |||
9ed8c863ec |
1
.gitignore
vendored
1
.gitignore
vendored
@ -124,6 +124,7 @@ celerybeat.pid
|
|||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
.venv
|
.venv
|
||||||
|
.envrc
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
ENV/
|
ENV/
|
||||||
|
11
README.txt
11
README.txt
@ -19,10 +19,15 @@ the sample scripts are described in the examples/README
|
|||||||
a small set of samples are provided. all of them make use of the module
|
a small set of samples are provided. all of them make use of the module
|
||||||
pywmgeneral.
|
pywmgeneral.
|
||||||
|
|
||||||
|
[REQUIREMENTS DEBIAN/UBUNTU]
|
||||||
|
apt-get install mplayer python3-setuptools libx11-dev libxpm-dev libxext-dev
|
||||||
|
|
||||||
[INSTALLATION]
|
[INSTALLATION]
|
||||||
python ./setup install
|
sudo python ./setup install
|
||||||
|
|
||||||
[CONTACT]
|
[CONTACT]
|
||||||
Anything related to this piece of software can be e-mailed to me, Mario
|
This project was originally started as as a Python 2 application. By Mario
|
||||||
Frasca <mfrasca@interia.pl>.
|
Fransca <mfrasca@interia.pl>. I thank him for all the hard work.
|
||||||
|
|
||||||
|
The project has been ported to Python 3 and now maintained by Fredrick
|
||||||
|
Warren <fwarren@fastmail.com>
|
||||||
|
@ -28,7 +28,7 @@ First workingish version
|
|||||||
"""
|
"""
|
||||||
usage = """pywmdatetime.py [options]
|
usage = """pywmdatetime.py [options]
|
||||||
Available options are:
|
Available options are:
|
||||||
-h, --help print this help
|
-h, --help asprint this help
|
||||||
-f, --foreground <color> set the foreground color
|
-f, --foreground <color> set the foreground color
|
||||||
-b, --background <color> set the background color
|
-b, --background <color> set the background color
|
||||||
-F, --font <file> set the font name
|
-F, --font <file> set the font name
|
||||||
@ -69,7 +69,7 @@ def addString(s, x, y):
|
|||||||
try:
|
try:
|
||||||
wmdocklib.addString(s, x, y, xOffset, yOffset,
|
wmdocklib.addString(s, x, y, xOffset, yOffset,
|
||||||
width, height)
|
width, height)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||||
sys.stderr.write('test %s' % ((s, x, y, xOffset, yOffset,
|
sys.stderr.write('test %s' % ((s, x, y, xOffset, yOffset,
|
||||||
width, height),))
|
width, height),))
|
||||||
@ -119,7 +119,7 @@ def parseCommandLine(argv):
|
|||||||
'weekdayformat=', 'weekformat=', 'rgbfile=', 'configfile=', 'font=']
|
'weekdayformat=', 'weekformat=', 'rgbfile=', 'configfile=', 'font=']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError as e:
|
||||||
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
||||||
sys.stderr.write(usage)
|
sys.stderr.write(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -247,7 +247,7 @@ def main():
|
|||||||
# Merge the two configs, let the commandline options overwrite those in the
|
# Merge the two configs, let the commandline options overwrite those in the
|
||||||
# configuration file.
|
# configuration file.
|
||||||
config = fileConfig
|
config = fileConfig
|
||||||
for i in clConfig.iteritems():
|
for i in clConfig.items():
|
||||||
config[i[0]] = i[1]
|
config[i[0]] = i[1]
|
||||||
|
|
||||||
timeFmt = config.get('timeformat', timeDefaultFormat)
|
timeFmt = config.get('timeformat', timeDefaultFormat)
|
||||||
@ -282,7 +282,7 @@ def main():
|
|||||||
bg=0, fg=2, palette=palette,
|
bg=0, fg=2, palette=palette,
|
||||||
background=background,
|
background=background,
|
||||||
debug=debug)
|
debug=debug)
|
||||||
maxCharsPerLine = (width-2*xOffset) / char_width
|
maxCharsPerLine = (width-2*xOffset) // char_width
|
||||||
antialiased = clConfig.get('antialiased', False)
|
antialiased = clConfig.get('antialiased', False)
|
||||||
|
|
||||||
wmdocklib.openXwindow(sys.argv, width, height)
|
wmdocklib.openXwindow(sys.argv, width, height)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""pywmgeneric.py
|
"""pywmgeneric.py
|
||||||
|
|
||||||
@ -37,11 +37,13 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import string
|
import string
|
||||||
import ConfigParser
|
import configparser
|
||||||
import getopt
|
import getopt
|
||||||
import popen2
|
import subprocess
|
||||||
|
|
||||||
import wmdocklib
|
import wmdocklib
|
||||||
|
import wmdocklib.pywmgeneral as pywmgeneral
|
||||||
|
import wmdocklib.pywmhelpers as pywmhelpers
|
||||||
|
|
||||||
prevStat = {'user':0,
|
prevStat = {'user':0,
|
||||||
'nice':0,
|
'nice':0,
|
||||||
@ -76,15 +78,13 @@ class UserMethods:
|
|||||||
def result():
|
def result():
|
||||||
global prevStat
|
global prevStat
|
||||||
try:
|
try:
|
||||||
f = file('/proc/stat', 'r')
|
with open('/proc/stat', 'r') as f:
|
||||||
except IOError:
|
|
||||||
return 'error'
|
|
||||||
|
|
||||||
currStat = dict(
|
currStat = dict(
|
||||||
[(k, int(v))
|
[(k, int(v))
|
||||||
for (k,v) in cpuinfo.match(f.readline()).groupdict().items()]
|
for (k,v) in cpuinfo.match(f.readline()).groupdict().items()]
|
||||||
)
|
)
|
||||||
f.close()
|
except IOError:
|
||||||
|
return 'error'
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
for k,v in currStat.items():
|
for k,v in currStat.items():
|
||||||
@ -105,11 +105,10 @@ class UserMethods:
|
|||||||
|
|
||||||
def getSysTemp(self):
|
def getSysTemp(self):
|
||||||
try:
|
try:
|
||||||
f = file('/proc/sys/dev/sensors/w83697hf-isa-0290/temp1', 'r')
|
with open('/proc/sys/dev/sensors/w83697hf-isa-0290/temp1', 'r') as f:
|
||||||
|
temp = f.readline().split()[2]
|
||||||
except IOError:
|
except IOError:
|
||||||
return lambda: 'error'
|
return lambda: 'error'
|
||||||
temp = f.readline().split()[2]
|
|
||||||
f.close()
|
|
||||||
return lambda: 'sys: %s' % temp
|
return lambda: 'sys: %s' % temp
|
||||||
|
|
||||||
def ls(self):
|
def ls(self):
|
||||||
@ -153,8 +152,8 @@ def addString(s, x, y):
|
|||||||
try:
|
try:
|
||||||
wmdocklib.addString(s, x, y, xOffset, yOffset,
|
wmdocklib.addString(s, x, y, xOffset, yOffset,
|
||||||
width, height)
|
width, height)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
sys.stderr.write(f'Error when painting string:\n{e}\n')
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
def clearLine(y):
|
def clearLine(y):
|
||||||
@ -194,7 +193,7 @@ class Entry:
|
|||||||
|
|
||||||
self._glue = ' ... '
|
self._glue = ' ... '
|
||||||
self._scrollPos = 0
|
self._scrollPos = 0
|
||||||
self._tickCount = 0L
|
self._tickCount = 0
|
||||||
|
|
||||||
self._runningProcs = []
|
self._runningProcs = []
|
||||||
self._actionProc = None
|
self._actionProc = None
|
||||||
@ -220,7 +219,7 @@ class Entry:
|
|||||||
"""Exec an external command in the background.
|
"""Exec an external command in the background.
|
||||||
|
|
||||||
Return the running process as created by Popen3()."""
|
Return the running process as created by Popen3()."""
|
||||||
proc = popen2.Popen3(command)
|
proc = subprocess.Popen(command)
|
||||||
self._runningProcs.append(proc)
|
self._runningProcs.append(proc)
|
||||||
return proc
|
return proc
|
||||||
|
|
||||||
@ -480,7 +479,7 @@ class PywmGeneric:
|
|||||||
timeNum = float(timeStr[:-1].strip())
|
timeNum = float(timeStr[:-1].strip())
|
||||||
numSecs = timeNum * multiplier
|
numSecs = timeNum * multiplier
|
||||||
return numSecs
|
return numSecs
|
||||||
raise ValueError, 'Invalid literal'
|
raise ValueError('Invalid literal')
|
||||||
|
|
||||||
def _checkForEvents(self):
|
def _checkForEvents(self):
|
||||||
event = wmdocklib.getEvent()
|
event = wmdocklib.getEvent()
|
||||||
@ -517,7 +516,7 @@ def parseCommandLine(argv):
|
|||||||
'font=', 'debug']
|
'font=', 'debug']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError as e:
|
||||||
err('Error when parsing commandline: ' + str(e) + '\n')
|
err('Error when parsing commandline: ' + str(e) + '\n')
|
||||||
err(usage)
|
err(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -551,10 +550,10 @@ def readConfigFile(fileName):
|
|||||||
err("Can't read the configuration file %s.\n" % fileName)
|
err("Can't read the configuration file %s.\n" % fileName)
|
||||||
# We can't do much without a configuration file
|
# We can't do much without a configuration file
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
cp.read(fileName)
|
cp.read(fileName)
|
||||||
except ConfigParser.Error, e:
|
except configparser.Error as e:
|
||||||
err("Error when reading configuration file:\n%s\n" % str(e))
|
err("Error when reading configuration file:\n%s\n" % str(e))
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
l = [{}, {}, {}, {}, {}]
|
l = [{}, {}, {}, {}, {}]
|
||||||
|
@ -89,7 +89,7 @@ class PywmHDMon:
|
|||||||
self._pathsToMonitor = pathsToMonitor
|
self._pathsToMonitor = pathsToMonitor
|
||||||
self._actMonEnabled = actMonEnabled
|
self._actMonEnabled = actMonEnabled
|
||||||
self._skipping = skipping
|
self._skipping = skipping
|
||||||
self._lineCount = (height - yOffset*2 - 2) / (char_height+1)
|
self._lineCount = (height - yOffset*2 - 2) // (char_height+1)
|
||||||
|
|
||||||
self._statFile = procStat
|
self._statFile = procStat
|
||||||
self._maxIODiff = 0
|
self._maxIODiff = 0
|
||||||
@ -102,7 +102,7 @@ class PywmHDMon:
|
|||||||
def addString(self, s, x, y):
|
def addString(self, s, x, y):
|
||||||
try:
|
try:
|
||||||
wmdocklib.addString(s, x, y, xOffset, yOffset, width, height)
|
wmdocklib.addString(s, x, y, xOffset, yOffset, width, height)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ class PywmHDMon:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# check if is mounted <- st_dev(/mount/point) == st_dev(/mount)
|
# check if is mounted <- st_dev(/mount/point) == st_dev(/mount)
|
||||||
if path is not '/':
|
if path != '/':
|
||||||
statOwn = os.stat(path)
|
statOwn = os.stat(path)
|
||||||
|
|
||||||
# the following is a bit ugly: it removes the trailing
|
# the following is a bit ugly: it removes the trailing
|
||||||
@ -151,7 +151,7 @@ class PywmHDMon:
|
|||||||
|
|
||||||
def getY(self, line):
|
def getY(self, line):
|
||||||
"returns the y coordinate of the top line for the box"
|
"returns the y coordinate of the top line for the box"
|
||||||
interlinea = (height - yOffset*2 - 2 - self._lineCount * char_height) / (self._lineCount-1)
|
interlinea = (height - yOffset*2 - 2 - self._lineCount * char_height) // (self._lineCount-1)
|
||||||
interlinea += char_height
|
interlinea += char_height
|
||||||
lastBaseline = yOffset + self._lineCount * interlinea
|
lastBaseline = yOffset + self._lineCount * interlinea
|
||||||
from math import ceil
|
from math import ceil
|
||||||
@ -163,7 +163,7 @@ class PywmHDMon:
|
|||||||
|
|
||||||
def paintHdData(self, line, data, mode):
|
def paintHdData(self, line, data, mode):
|
||||||
total, free = data
|
total, free = data
|
||||||
xStart = (width*2)/5
|
xStart = (width*2)//5
|
||||||
if total==0:
|
if total==0:
|
||||||
self.addString(' ', width-yOffset*2-5*char_width-1, self.getY(line))
|
self.addString(' ', width-yOffset*2-5*char_width-1, self.getY(line))
|
||||||
self.paintGraph(0, xStart, self.getY(line) + 4,
|
self.paintGraph(0, xStart, self.getY(line) + 4,
|
||||||
@ -244,7 +244,7 @@ class PywmHDMon:
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif event['type'] == 'buttonrelease':
|
elif event['type'] == 'buttonrelease':
|
||||||
area = wmdocklib.checkMouseRegion(event['x'],event['y'])
|
area = wmdocklib.checkMouseRegion(event['x'],event['y'])
|
||||||
if area is not -1:
|
if area != -1:
|
||||||
self.toggleMount(area-1+self._skipping)
|
self.toggleMount(area-1+self._skipping)
|
||||||
event = wmdocklib.getEvent()
|
event = wmdocklib.getEvent()
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ class PywmHDMon:
|
|||||||
mounted = True
|
mounted = True
|
||||||
except NotMounted:
|
except NotMounted:
|
||||||
mounted = False
|
mounted = False
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
return
|
return
|
||||||
if mounted:
|
if mounted:
|
||||||
if action == 'mount':
|
if action == 'mount':
|
||||||
@ -282,7 +282,7 @@ class PywmHDMon:
|
|||||||
hdData = self.getHdInfo(path)
|
hdData = self.getHdInfo(path)
|
||||||
except NotMounted:
|
except NotMounted:
|
||||||
hdData = (0, 0)
|
hdData = (0, 0)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"Can't get hd data from %s: %s\n" % (path, str(e)))
|
"Can't get hd data from %s: %s\n" % (path, str(e)))
|
||||||
hdData = (0, 0)
|
hdData = (0, 0)
|
||||||
@ -313,7 +313,7 @@ def parseCommandLine(argv):
|
|||||||
'skipconf=','font=', 'debug']
|
'skipconf=','font=', 'debug']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError as e:
|
||||||
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
||||||
sys.stderr.write(usage)
|
sys.stderr.write(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -406,7 +406,7 @@ def main():
|
|||||||
configFile = os.path.expanduser(configFile)
|
configFile = os.path.expanduser(configFile)
|
||||||
fileConfig = wmdocklib.readConfigFile(configFile, sys.stderr)
|
fileConfig = wmdocklib.readConfigFile(configFile, sys.stderr)
|
||||||
config = fileConfig
|
config = fileConfig
|
||||||
for i in clConfig.iteritems():
|
for i in clConfig.items():
|
||||||
config[i[0]] = i[1]
|
config[i[0]] = i[1]
|
||||||
|
|
||||||
palette = {}
|
palette = {}
|
||||||
|
@ -2,16 +2,21 @@
|
|||||||
|
|
||||||
"""pywmnop.py
|
"""pywmnop.py
|
||||||
|
|
||||||
WindowMaker dockapp doing nothing
|
WindowMaker dockapp internet radio player
|
||||||
|
|
||||||
Copyright (C) 2006 Mario Frasca
|
Copyright (C) 2006 Mario Frasca
|
||||||
|
|
||||||
Licensed under the GNU General Public License.
|
Licensed under the GNU General Public License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, time
|
from codecs import open
|
||||||
from wmdocklib import wmoo
|
from fcntl import fcntl, F_GETFL, F_SETFL
|
||||||
devnull = file('/dev/null')
|
from os import environ, sep, O_NONBLOCK
|
||||||
|
from re import compile
|
||||||
|
from select import select
|
||||||
|
from signal import signal, SIGCHLD
|
||||||
|
from subprocess import Popen, DEVNULL, PIPE
|
||||||
|
from wmdocklib import wmoo as wmoo
|
||||||
|
|
||||||
class Application(wmoo.Application):
|
class Application(wmoo.Application):
|
||||||
|
|
||||||
@ -34,16 +39,12 @@ class Application(wmoo.Application):
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
self._buffered = ''
|
self._buffered = ''
|
||||||
import re
|
self._feedback = compile(r'.+A:.*?% ([0-9\.]+)%')
|
||||||
self._feedback = re.compile(r'.+A:.*?% ([0-9\.]+)%')
|
|
||||||
|
|
||||||
import fileinput, os
|
configfile = sep.join([environ['HOME'], '.pyradiorc'])
|
||||||
configfile = os.sep.join([os.environ['HOME'], '.pyradiorc'])
|
|
||||||
|
|
||||||
import codecs
|
with open(configfile, 'r', 'utf-8') as f:
|
||||||
f = codecs.open(configfile, 'r', 'utf-8')
|
|
||||||
t = f.read()
|
t = f.read()
|
||||||
f.close()
|
|
||||||
for i in t.split(u'\n'):
|
for i in t.split(u'\n'):
|
||||||
radiodef = i.split('\t')
|
radiodef = i.split('\t')
|
||||||
radioname = radiodef[0].lower()
|
radioname = radiodef[0].lower()
|
||||||
@ -58,7 +59,6 @@ class Application(wmoo.Application):
|
|||||||
|
|
||||||
def handler(self, num, frame):
|
def handler(self, num, frame):
|
||||||
if self._expectdying:
|
if self._expectdying:
|
||||||
print self._expectdying
|
|
||||||
self._expectdying -= 1
|
self._expectdying -= 1
|
||||||
else:
|
else:
|
||||||
self.reset()
|
self.reset()
|
||||||
@ -66,42 +66,46 @@ class Application(wmoo.Application):
|
|||||||
self._colour = 1
|
self._colour = 1
|
||||||
|
|
||||||
def startPlayer(self):
|
def startPlayer(self):
|
||||||
import os, subprocess, signal
|
|
||||||
commandline = [mplayer,
|
commandline = [mplayer,
|
||||||
'-cache', self.radioList[self.currentRadio][2],
|
'-cache',
|
||||||
|
str(abs(int(self.radioList[self.currentRadio][2]))),
|
||||||
self.radioList[self.currentRadio][1]
|
self.radioList[self.currentRadio][1]
|
||||||
]
|
]
|
||||||
self.child = subprocess.Popen(commandline,
|
# if cache is negative then this is a playlist
|
||||||
stdin =subprocess.PIPE,
|
if int(self.radioList[self.currentRadio][2]) < 0:
|
||||||
stdout=subprocess.PIPE,
|
commandline.insert(2, '-playlist')
|
||||||
stderr=devnull)
|
self.child = Popen(commandline,
|
||||||
signal.signal(signal.SIGCHLD, self.handler)
|
stdin =PIPE,
|
||||||
|
stdout=PIPE,
|
||||||
|
stderr=DEVNULL)
|
||||||
|
signal(SIGCHLD, self.handler)
|
||||||
self._flash = 0
|
self._flash = 0
|
||||||
self._paused = False
|
self._paused = False
|
||||||
self._buffered = ''
|
self._buffered = ''
|
||||||
self._buffering = 1
|
self._buffering = 1
|
||||||
self._cacheLevel = 0
|
self._cacheLevel = 0
|
||||||
import fcntl
|
flags = fcntl(self.child.stdout, F_GETFL)
|
||||||
flags = fcntl.fcntl(self.child.stdout, fcntl.F_GETFL)
|
fcntl(self.child.stdout, F_SETFL, flags | O_NONBLOCK)
|
||||||
fcntl.fcntl(self.child.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
flags = fcntl(self.child.stdin, F_GETFL)
|
||||||
flags = fcntl.fcntl(self.child.stdin, fcntl.F_GETFL)
|
fcntl(self.child.stdin, F_SETFL, flags | O_NONBLOCK)
|
||||||
fcntl.fcntl(self.child.stdin, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
|
||||||
|
|
||||||
def stopPlayer(self):
|
def stopPlayer(self):
|
||||||
if self.child:
|
if self.child:
|
||||||
print self._expectdying
|
# print(self._expectdying)
|
||||||
self.child.stdin.write('q')
|
self.child.stdin.write(b'q')
|
||||||
|
self.child.stdin.flush()
|
||||||
self._expectdying += 1
|
self._expectdying += 1
|
||||||
self.child = None
|
self.child = None
|
||||||
|
|
||||||
def muteStream(self, event):
|
def muteStream(self, event):
|
||||||
if self.child and self._buffering == 0:
|
if self.child and self._buffering == 0:
|
||||||
self.child.stdin.write('m')
|
self.child.stdin.write(b'm')
|
||||||
|
self.child.stdin.flush()
|
||||||
self.putPattern(9*self._muting, 0, 9, 11, 30, 29)
|
self.putPattern(9*self._muting, 0, 9, 11, 30, 29)
|
||||||
self._muting = 1 - self._muting
|
self._muting = 1 - self._muting
|
||||||
|
|
||||||
def printevent(self, event):
|
def printevent(self, event):
|
||||||
print event
|
print(event)
|
||||||
|
|
||||||
def previousRadio(self, event):
|
def previousRadio(self, event):
|
||||||
if self.currentRadio == 0: self.currentRadio = len(self.radioList)
|
if self.currentRadio == 0: self.currentRadio = len(self.radioList)
|
||||||
@ -128,7 +132,8 @@ class Application(wmoo.Application):
|
|||||||
|
|
||||||
def pauseStream(self, event):
|
def pauseStream(self, event):
|
||||||
if self.child and not self._buffering:
|
if self.child and not self._buffering:
|
||||||
self.child.stdin.write(' ')
|
self.child.stdin.write(b' ')
|
||||||
|
self.child.stdin.flush()
|
||||||
self._paused = not self._paused
|
self._paused = not self._paused
|
||||||
if self._paused:
|
if self._paused:
|
||||||
self._colour = 1
|
self._colour = 1
|
||||||
@ -164,10 +169,9 @@ class Application(wmoo.Application):
|
|||||||
return
|
return
|
||||||
self._count = 0
|
self._count = 0
|
||||||
if self.child:
|
if self.child:
|
||||||
import select
|
[i, o, e] = select([self.child.stdout], [], [], 0)
|
||||||
[i, o, e] = select.select([self.child.stdout], [], [], 0)
|
|
||||||
if i:
|
if i:
|
||||||
line = self.child.stdout.read(102400)
|
line = self.child.stdout.read(102400).decode("utf-8")
|
||||||
self._buffered += line
|
self._buffered += line
|
||||||
npos = self._buffered.rfind('\n')+1
|
npos = self._buffered.rfind('\n')+1
|
||||||
rpos = self._buffered.rfind('\r')+1
|
rpos = self._buffered.rfind('\r')+1
|
||||||
|
@ -85,7 +85,7 @@ class PywmSeti:
|
|||||||
try:
|
try:
|
||||||
wmdocklib.addString(s, x, y, digits,
|
wmdocklib.addString(s, x, y, digits,
|
||||||
xOffset, yOffset, width, height)
|
xOffset, yOffset, width, height)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class PywmSeti:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
os.kill(pid, 0)
|
os.kill(pid, 0)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
if e.errno == 1:
|
if e.errno == 1:
|
||||||
return -1
|
return -1
|
||||||
return 0
|
return 0
|
||||||
@ -146,7 +146,7 @@ class PywmSeti:
|
|||||||
def openFileRead(self, fileName):
|
def openFileRead(self, fileName):
|
||||||
try:
|
try:
|
||||||
f = file(fileName, 'r')
|
f = file(fileName, 'r')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
sys.stderr.write('Error when opening %s: %s\n' % (fileName, str(e)))
|
sys.stderr.write('Error when opening %s: %s\n' % (fileName, str(e)))
|
||||||
return None
|
return None
|
||||||
return f
|
return f
|
||||||
@ -265,7 +265,7 @@ class PywmSeti:
|
|||||||
if self._running:
|
if self._running:
|
||||||
try:
|
try:
|
||||||
os.kill(self._pid, 15)
|
os.kill(self._pid, 15)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"Error when ending process: "+str(e)+'\n')
|
"Error when ending process: "+str(e)+'\n')
|
||||||
else:
|
else:
|
||||||
@ -309,7 +309,7 @@ def parseCommandLine(argv):
|
|||||||
'indicatorcolor=']
|
'indicatorcolor=']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError as e:
|
||||||
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
||||||
sys.stderr.write(usage)
|
sys.stderr.write(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -459,7 +459,7 @@ def main():
|
|||||||
# Merge the two configs, let the commandline options overwrite those in the
|
# Merge the two configs, let the commandline options overwrite those in the
|
||||||
# configuration file.
|
# configuration file.
|
||||||
config = fileConfig
|
config = fileConfig
|
||||||
for i in clConfig.iteritems():
|
for i in clConfig.items():
|
||||||
config[i[0]] = i[1]
|
config[i[0]] = i[1]
|
||||||
# Get the configurations
|
# Get the configurations
|
||||||
setiDir = config.get('setidir')
|
setiDir = config.get('setidir')
|
||||||
@ -472,7 +472,7 @@ def main():
|
|||||||
setiDir = os.path.expanduser(setiDir)
|
setiDir = os.path.expanduser(setiDir)
|
||||||
try:
|
try:
|
||||||
os.chdir(setiDir)
|
os.chdir(setiDir)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
sys.stderr.write('Error when accessing seti directory: %s\n' % str(e))
|
sys.stderr.write('Error when accessing seti directory: %s\n' % str(e))
|
||||||
sys.exit(4)
|
sys.exit(4)
|
||||||
statePath = os.path.join(setiDir, stateFileName)
|
statePath = os.path.join(setiDir, stateFileName)
|
||||||
|
@ -95,8 +95,8 @@ class PywmSysMon:
|
|||||||
Return a tuple with (total_mem, used_mem, buffered_mem, cached_mem).
|
Return a tuple with (total_mem, used_mem, buffered_mem, cached_mem).
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
meminfoFile = file(self._procMeminfo, 'r')
|
meminfoFile = open(self._procMeminfo, 'r')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
sys.stderr.write("Can't open meminfo file: %s.\n" % str(e))
|
sys.stderr.write("Can't open meminfo file: %s.\n" % str(e))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
total = used = free = shared = buffers = cached = theLine = None
|
total = used = free = shared = buffers = cached = theLine = None
|
||||||
@ -105,17 +105,17 @@ class PywmSysMon:
|
|||||||
theLine = line
|
theLine = line
|
||||||
break
|
break
|
||||||
if line.startswith('MemTotal:'):
|
if line.startswith('MemTotal:'):
|
||||||
total = long(line.split()[1])
|
total = int(line.split()[1])
|
||||||
if line.startswith('MemFree:'):
|
if line.startswith('MemFree:'):
|
||||||
free = long(line.split()[1])
|
free = int(line.split()[1])
|
||||||
if line.startswith('Buffers:'):
|
if line.startswith('Buffers:'):
|
||||||
buffers = long(line.split()[1])
|
buffers = int(line.split()[1])
|
||||||
if line.startswith('Cached:'):
|
if line.startswith('Cached:'):
|
||||||
cached = long(line.split()[1])
|
cached = int(line.split()[1])
|
||||||
if free and total:
|
if free and total:
|
||||||
used = total - free
|
used = total - free
|
||||||
if theLine is not None:
|
if theLine is not None:
|
||||||
parts = [long(x) for x in theLine.split()[1]]
|
parts = [int(x) for x in theLine.split()[1]]
|
||||||
total, used, free, shared, buffers, cached = parts[:6]
|
total, used, free, shared, buffers, cached = parts[:6]
|
||||||
if None in [total, used, buffers, cached]:
|
if None in [total, used, buffers, cached]:
|
||||||
sys.stderr.write("Can't find memory information in %s.\n" %
|
sys.stderr.write("Can't find memory information in %s.\n" %
|
||||||
@ -138,13 +138,13 @@ class PywmSysMon:
|
|||||||
file. Return the usage in percent.
|
file. Return the usage in percent.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
statFile = file(self._procStat, 'r')
|
statFile = open(self._procStat, 'r')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
sys.stderr.write("Can't open statfile: %s.\n" % str(e))
|
sys.stderr.write("Can't open statfile: %s.\n" % str(e))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
line = statFile.readline()
|
line = statFile.readline()
|
||||||
statFile.close()
|
statFile.close()
|
||||||
cpu, nice, system, idle = [long(x) for x in line.split()[1:]][:4]
|
cpu, nice, system, idle = [int(x) for x in line.split()[1:]][:4]
|
||||||
used = cpu + system
|
used = cpu + system
|
||||||
if not self._ignoreNice:
|
if not self._ignoreNice:
|
||||||
used += nice
|
used += nice
|
||||||
@ -161,7 +161,7 @@ class PywmSysMon:
|
|||||||
def addString(self, s, x, y):
|
def addString(self, s, x, y):
|
||||||
try:
|
try:
|
||||||
wmdocklib.addString(s, x, y, digits, xOffset, yOffset, width, height)
|
wmdocklib.addString(s, x, y, digits, xOffset, yOffset, width, height)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
sys.stderr.write('Error when painting string:\n' + str(e) + '\n')
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ def parseCommandLine(argv):
|
|||||||
'procmeminfo=', 'ignorenice', 'updatedelay=']
|
'procmeminfo=', 'ignorenice', 'updatedelay=']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError as e:
|
||||||
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
sys.stderr.write('Error when parsing commandline: ' + str(e) + '\n')
|
||||||
sys.stderr.write(usage)
|
sys.stderr.write(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
@ -16,3 +16,10 @@ bbcws rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/worldservice/liveinfent.
|
|||||||
bbc3 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio3/live/r3_dsat_g2.ra 256
|
bbc3 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio3/live/r3_dsat_g2.ra 256
|
||||||
bbc4 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio4/live/r4_dsat_g2.ra 256
|
bbc4 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio4/live/r4_dsat_g2.ra 256
|
||||||
|
|
||||||
|
# lines starting with # is ignored OR
|
||||||
|
# lines without exactly two tabs \t in it is ignored
|
||||||
|
# lines with \t<variable>\t<value> becomes a global variable
|
||||||
|
# lines with <name>\t<url>\t<bytes-cached> become a station
|
||||||
|
# <bytes-cached> must be 32 or larger
|
||||||
|
# positve <bytes-cached> ( 32) are stream urls
|
||||||
|
# negative <bytes-cached> (-32) are playlist urls
|
||||||
|
34
setup.py
34
setup.py
@ -1,37 +1,27 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Set these so they match your system.
|
# Set these so they match your system.
|
||||||
XLibDir = '/usr/X11R6/lib'
|
from __future__ import absolute_import
|
||||||
XIncludes = '/usr/X11R6/include'
|
XLibDir = '/usr/lib/x11'
|
||||||
|
XIncludes = '/usr/include/x11'
|
||||||
|
|
||||||
from distutils.core import setup, Extension
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
module1 = Extension('wmdocklib.pywmgeneral',
|
pywmgeneral = Extension('wmdocklib.pywmgeneral',
|
||||||
libraries = ['Xpm', 'Xext', 'X11'],
|
libraries = ['Xpm', 'Xext', 'X11'],
|
||||||
library_dirs = [XLibDir],
|
library_dirs = [XLibDir],
|
||||||
include_dirs = [XIncludes],
|
include_dirs = [XIncludes],
|
||||||
sources = ['wmdocklib/pywmgeneral.c'])
|
sources = ['wmdocklib/pywmgeneral.c'])
|
||||||
|
|
||||||
setup(name="pywmdockapps",
|
setup(
|
||||||
version = "$Revision: 1.21 $"[11:-2],
|
name="pywmdockapps",
|
||||||
|
version = "$Revision: 1.99 $"[11:-2],
|
||||||
description='''
|
description="This helper functions for windowmaker dockapps\nRead the whole story at http://pywmdockapps.sourceforge.net/",
|
||||||
read the whole story at http://pywmdockapps.sourceforge.net/''',
|
|
||||||
|
|
||||||
author="Kristoffer Erlandsson & al.",
|
author="Kristoffer Erlandsson & al.",
|
||||||
author_email="mfrasca@zonnet.nl",
|
author_email="mfrasca@zonnet.nl",
|
||||||
url="http://pywmdockapps.sourceforge.net",
|
url="http://pywmdockapps.sourceforge.net",
|
||||||
license="(L)GPL",
|
license="(L)GPL",
|
||||||
packages=['wmdocklib',
|
packages=['wmdocklib'],
|
||||||
],
|
|
||||||
scripts=['examples/pywmdatetime.py',
|
|
||||||
'examples/pywmhdmon.py',
|
|
||||||
'examples/pywmseti.py',
|
|
||||||
'examples/pywmsysmon.py',
|
|
||||||
'examples/pywmphoto.py',
|
|
||||||
'examples/pywmwet.py',
|
|
||||||
'examples/pywmradio.py',
|
|
||||||
'examples/pywmgeneric.py'],
|
|
||||||
package_data={'wmdocklib': ['*.xpm']},
|
package_data={'wmdocklib': ['*.xpm']},
|
||||||
ext_modules = [module1])
|
ext_modules=[pywmgeneral],
|
||||||
|
)
|
||||||
|
@ -6,7 +6,7 @@ wmgeneral.c, but some new functions are added too.
|
|||||||
to get help about a contained package, try:
|
to get help about a contained package, try:
|
||||||
help(wmdocklib.<name>)
|
help(wmdocklib.<name>)
|
||||||
"""
|
"""
|
||||||
from pywmgeneral import *
|
from .pywmgeneral import *
|
||||||
from pywmhelpers import *
|
from .pywmhelpers import *
|
||||||
|
|
||||||
__all__ = ['wmoo']
|
__all__ = ['wmoo']
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
*
|
*
|
||||||
* History:
|
* History:
|
||||||
*
|
*
|
||||||
|
* 2024-09-08 Fredrick W. Warren
|
||||||
|
* Ported from python 2 to python 3
|
||||||
|
*
|
||||||
* 2003-06-24 Kristoffer Erlandsson
|
* 2003-06-24 Kristoffer Erlandsson
|
||||||
* Added some additional event handling.
|
* Added some additional event handling.
|
||||||
*
|
*
|
||||||
@ -29,10 +32,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Python.h>
|
|
||||||
#include "structmember.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#define PY_SSIZE_T_CLEAN
|
||||||
|
#include <Python.h>
|
||||||
|
#include "structmember.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -83,11 +87,12 @@ char **pyListToStrs(PyObject *l) {
|
|||||||
s = PySequence_GetItem(l, i);
|
s = PySequence_GetItem(l, i);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL; /* Shouldn't happen. */
|
return NULL; /* Shouldn't happen. */
|
||||||
if (!PyString_Check(s)) {
|
if (!PyUnicode_Check(s)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "String expected.");
|
PyErr_SetString(PyExc_TypeError, "String expected.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
target[i] = PyString_AsString(s);
|
// target[i] = strdup(PyUnicode_AsString(s));
|
||||||
|
target[i] = strdup(PyUnicode_AsUTF8(s));
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -363,8 +368,7 @@ static PyMethodDef Drawable_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject drawable_DrawableType = {
|
static PyTypeObject drawable_DrawableType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /*ob_size*/
|
|
||||||
"pyywmgeneral.Drawable", /*tp_name*/
|
"pyywmgeneral.Drawable", /*tp_name*/
|
||||||
sizeof(drawable_DrawableObject), /*tp_basicsize*/
|
sizeof(drawable_DrawableObject), /*tp_basicsize*/
|
||||||
0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
@ -787,23 +791,29 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
|
static struct PyModuleDef pywmgeneral_module = {
|
||||||
#define PyMODINIT_FUNC void
|
PyModuleDef_HEAD_INIT, /* m_base */
|
||||||
#endif
|
"pywmgeneral", /* m_name */
|
||||||
|
NULL, /* m_doc */
|
||||||
|
-1, /* m_size */
|
||||||
|
PyWmgeneralMethods /* m_methods */
|
||||||
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
PyMODINIT_FUNC
|
||||||
initpywmgeneral(void) {
|
PyInit_pywmgeneral(void)
|
||||||
|
{
|
||||||
PyObject* m;
|
PyObject* m;
|
||||||
|
|
||||||
drawable_DrawableType.tp_new = PyType_GenericNew;
|
drawable_DrawableType.tp_new = PyType_GenericNew;
|
||||||
if (PyType_Ready(&drawable_DrawableType) < 0)
|
if (PyType_Ready(&drawable_DrawableType) < 0)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
m = Py_InitModule3("pywmgeneral", PyWmgeneralMethods,
|
m = PyModule_Create(&pywmgeneral_module);
|
||||||
"base C module for wmdocklib");
|
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
Py_INCREF(&drawable_DrawableType);
|
Py_INCREF(&drawable_DrawableType);
|
||||||
PyModule_AddObject(m, "Drawable", (PyObject *)&drawable_DrawableType);
|
PyModule_AddObject(m, "Drawable", (PyObject *)&drawable_DrawableType);
|
||||||
|
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@ Some changes to handle the additional event handling in pywmgeneral
|
|||||||
First workingish version
|
First workingish version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, re, types
|
import os, re
|
||||||
import ConfigParser
|
import configparser
|
||||||
|
|
||||||
charset_start = None
|
charset_start = None
|
||||||
charset_width = None
|
charset_width = None
|
||||||
pattern_start = None
|
pattern_start = None
|
||||||
|
|
||||||
import pywmgeneral
|
import wmdocklib.pywmgeneral as pywmgeneral
|
||||||
defaultRGBFileList = [
|
defaultRGBFileList = [
|
||||||
'/etc/X11/rgb.txt',
|
'/etc/X11/rgb.txt',
|
||||||
'/usr/lib/X11/rgb.txt',
|
'/usr/lib/X11/rgb.txt',
|
||||||
@ -55,10 +55,10 @@ def readConfigFile(fileName, errOut):
|
|||||||
errOut.write(
|
errOut.write(
|
||||||
'Configuration file is not readable. Using defaults.\n')
|
'Configuration file is not readable. Using defaults.\n')
|
||||||
return {}
|
return {}
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
cp.read(fileName)
|
cp.read(fileName)
|
||||||
except ConfigParser.Error, e:
|
except configparser.Error as e:
|
||||||
if errOut:
|
if errOut:
|
||||||
errOut.write('Error in configuration file:\n')
|
errOut.write('Error in configuration file:\n')
|
||||||
errOut.write(str(e) + '\nUsing defaults.')
|
errOut.write(str(e) + '\nUsing defaults.')
|
||||||
@ -75,7 +75,7 @@ def getCenterStartPos(s, areaWidth, offset):
|
|||||||
"""Get the x starting position if we want to paint s centred."""
|
"""Get the x starting position if we want to paint s centred."""
|
||||||
w = len(s) * char_width
|
w = len(s) * char_width
|
||||||
textArea = areaWidth - offset * 2 - 1
|
textArea = areaWidth - offset * 2 - 1
|
||||||
return (textArea - w) / 2
|
return (textArea - w) // 2
|
||||||
|
|
||||||
def addChar(ch, x, y, xOffset, yOffset, width, height, drawable=None):
|
def addChar(ch, x, y, xOffset, yOffset, width, height, drawable=None):
|
||||||
"""Paint the character ch at position x, y in the window.
|
"""Paint the character ch at position x, y in the window.
|
||||||
@ -102,7 +102,7 @@ def addChar(ch, x, y, xOffset, yOffset, width, height, drawable=None):
|
|||||||
pos = (ord(ch)-32) * char_width
|
pos = (ord(ch)-32) * char_width
|
||||||
# translate pos into chX, chY, rolling back and down each linelength
|
# translate pos into chX, chY, rolling back and down each linelength
|
||||||
# bits. character definition start at row 64, column 0.
|
# bits. character definition start at row 64, column 0.
|
||||||
chY = (pos / linelength) * char_height + charset_start
|
chY = (pos // linelength) * char_height + charset_start
|
||||||
chX = pos % linelength
|
chX = pos % linelength
|
||||||
targX = x + xOffset
|
targX = x + xOffset
|
||||||
targY = y + yOffset
|
targY = y + yOffset
|
||||||
@ -131,7 +131,7 @@ def getVertSpacing(numLines, margin, height, yOffset):
|
|||||||
|
|
||||||
margin is the space we want between the first line and the top."""
|
margin is the space we want between the first line and the top."""
|
||||||
h = height - (numLines * char_height + 1) - yOffset * 2 - margin
|
h = height - (numLines * char_height + 1) - yOffset * 2 - margin
|
||||||
return h / (numLines - 1)
|
return h // (numLines - 1)
|
||||||
|
|
||||||
|
|
||||||
def readXPM(fileName):
|
def readXPM(fileName):
|
||||||
@ -145,7 +145,7 @@ def readXPM(fileName):
|
|||||||
Raise IOError if we run into trouble when trying to read the file. This
|
Raise IOError if we run into trouble when trying to read the file. This
|
||||||
function has not been tested extensively. do not try to use more than
|
function has not been tested extensively. do not try to use more than
|
||||||
"""
|
"""
|
||||||
f = file(fileName, 'r')
|
with open(fileName, 'r') as f:
|
||||||
lines = [l.rstrip('\n') for l in f.readlines()]
|
lines = [l.rstrip('\n') for l in f.readlines()]
|
||||||
s = ''.join(lines)
|
s = ''.join(lines)
|
||||||
res = []
|
res = []
|
||||||
@ -260,7 +260,7 @@ def initPixmap(background=None,
|
|||||||
] + [
|
] + [
|
||||||
' '*width for item in range(margin)
|
' '*width for item in range(margin)
|
||||||
]
|
]
|
||||||
elif isinstance(background, types.ListType) and not isinstance(background[0], types.StringTypes):
|
elif isinstance(background, list) and not isinstance(background[0], str):
|
||||||
nbackground = [[' ']*width for i in range(height)]
|
nbackground = [[' ']*width for i in range(height)]
|
||||||
for ((left, top),(right, bottom)) in background:
|
for ((left, top),(right, bottom)) in background:
|
||||||
for x in range(left, right+1):
|
for x in range(left, right+1):
|
||||||
@ -329,7 +329,7 @@ def initPixmap(background=None,
|
|||||||
origRgb = [int(origColor[i*2:i*2+2],16)/256. for i in range(3)]
|
origRgb = [int(origColor[i*2:i*2+2],16)/256. for i in range(3)]
|
||||||
intensity = sum(origRgb) / 3
|
intensity = sum(origRgb) / 3
|
||||||
newRgb = [i * intensity + base for i,base in zip(fg_vec, bg_point)]
|
newRgb = [i * intensity + base for i,base in zip(fg_vec, bg_point)]
|
||||||
new_font_palette[k] = '#'+''.join(["%02x"%i for i in newRgb])
|
new_font_palette[k] = '#'+''.join(["%02x"%int(i) for i in newRgb])
|
||||||
|
|
||||||
return new_font_palette
|
return new_font_palette
|
||||||
|
|
||||||
@ -364,10 +364,10 @@ def initPixmap(background=None,
|
|||||||
for line in fontdef
|
for line in fontdef
|
||||||
]
|
]
|
||||||
if debug:
|
if debug:
|
||||||
print '/* XPM */\nstatic char *_x_[] = {'
|
print('/* XPM */\nstatic char *_x_[] = {')
|
||||||
for item in xpm:
|
for item in xpm:
|
||||||
print '"%s",' % item
|
print('"%s",' % item)
|
||||||
print '};'
|
print('};')
|
||||||
pywmgeneral.includePixmap(xpm)
|
pywmgeneral.includePixmap(xpm)
|
||||||
return char_width, char_height
|
return char_width, char_height
|
||||||
|
|
||||||
@ -436,9 +436,8 @@ def getColorCode(colorName, rgbFileName=None):
|
|||||||
if rgbFileName is None:
|
if rgbFileName is None:
|
||||||
raise ValueError('cannot find rgb file')
|
raise ValueError('cannot find rgb file')
|
||||||
|
|
||||||
f = file(rgbFileName, 'r')
|
with open(rgbFileName, 'r') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
f.close()
|
|
||||||
for l in lines:
|
for l in lines:
|
||||||
if l[0] != '!':
|
if l[0] != '!':
|
||||||
words = l.split()
|
words = l.split()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import sys, time
|
import sys, time
|
||||||
import pywmhelpers
|
import wmdocklib.pywmhelpers as pywmhelpers
|
||||||
|
import wmdocklib.pywmgeneral as pywmgeneral
|
||||||
|
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ class Application:
|
|||||||
if size is None:
|
if size is None:
|
||||||
size = (self._char_width * len(text), self._char_height)
|
size = (self._char_width * len(text), self._char_height)
|
||||||
pixmapwidth = self._char_width * len(text)
|
pixmapwidth = self._char_width * len(text)
|
||||||
import pywmgeneral
|
# import pywmgeneral
|
||||||
labelPixmap = pywmgeneral.Drawable(pixmapwidth, self._char_height)
|
labelPixmap = pywmgeneral.Drawable(pixmapwidth, self._char_height)
|
||||||
self._elements[labelId] = [orig, size, pixmapwidth, 0, labelPixmap]
|
self._elements[labelId] = [orig, size, pixmapwidth, 0, labelPixmap]
|
||||||
self.setLabelText(labelId, text)
|
self.setLabelText(labelId, text)
|
||||||
@ -55,7 +56,6 @@ class Application:
|
|||||||
(orig_x,orig_y), (size_x, size_y), width, offset, pixmap = self._elements[labelId]
|
(orig_x,orig_y), (size_x, size_y), width, offset, pixmap = self._elements[labelId]
|
||||||
newwidth = self._char_width * len(text)
|
newwidth = self._char_width * len(text)
|
||||||
if newwidth > width:
|
if newwidth > width:
|
||||||
import pywmgeneral
|
|
||||||
pixmap = pywmgeneral.Drawable(newwidth, self._char_height)
|
pixmap = pywmgeneral.Drawable(newwidth, self._char_height)
|
||||||
self._elements[labelId][4] = pixmap
|
self._elements[labelId][4] = pixmap
|
||||||
self._elements[labelId][2] = newwidth
|
self._elements[labelId][2] = newwidth
|
||||||
@ -101,7 +101,7 @@ class Application:
|
|||||||
mouse or keyboard event. all fields may be left to their 'None'
|
mouse or keyboard event. all fields may be left to their 'None'
|
||||||
default value, in which case the callback is activated on any event.
|
default value, in which case the callback is activated on any event.
|
||||||
"""
|
"""
|
||||||
if area is not None and len(area) is not 4:
|
if area is not None and len(area) != 4:
|
||||||
area = None
|
area = None
|
||||||
self._events.append( (type, key, area, callback,) )
|
self._events.append( (type, key, area, callback,) )
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user