• R/O
  • SSH
  • HTTPS

twitturn: Commit


Commit MetaInfo

Revision80 (tree)
Zeit2010-02-28 16:30:43
Autoryoucharmanums

Log Message

* ticker2.py geometry command line option added.

Ändern Zusammenfassung

Diff

--- trunk/ticker2.py (revision 79)
+++ trunk/ticker2.py (revision 80)
@@ -1,6 +1,6 @@
11 #!/usr/bin/env python
22
3-import sys, os
3+import sys, os, re
44
55 from PyQt4.QtCore import *
66 from PyQt4.QtGui import *
@@ -103,7 +103,7 @@
103103
104104 def read(self):
105105 self.tweetsQueue.append(
106- QString.fromUtf8( self.sock.readAll()).replace( '\n' , ' '))
106+ QString.fromUtf8( self.sock.readAll()).replace( '\n' , ' '))
107107
108108 if not self.timer.isActive():
109109 self.tickerNext()
@@ -117,7 +117,7 @@
117117 self.displayStringBoundRect.setWidth(
118118 self.fontMetrics().width(
119119 self.displayString))
120- self.timer.start(30, self)
120+ self.timer.start(20, self)
121121
122122 def paintEnactiveIndicator(p, rect):
123123 p.setPen( QPen( Qt.black, 1, Qt.SolidLine))
@@ -150,6 +150,7 @@
150150 )
151151 pass
152152
153+
153154 if __name__=="__main__":
154155 app = QApplication(sys.argv)
155156 client = IpcOutputClientGUI2()
@@ -159,7 +160,44 @@
159160 | Qt.WindowStaysOnTopHint
160161 | Qt.WindowSystemMenuHint
161162 )
162- #client.setWindowOpacity(0.8)
163- client.resize(400,20)
163+
164+ USAGE = """Usage: %s [options] keyword
165+ Options:
166+ -h, --help show this help message and exit
167+ -geometry [WxH][-/+X-/+Y] size and position
168+ """ % sys.argv[0]
169+ WIDTH = 400
170+ HEIGHT = 20
171+
172+ if '-h' in sys.argv or '--help' in sys.argv:
173+ print USAGE
174+ sys.exit(-1)
175+ if '-geometry' in sys.argv:
176+ geomIndex = sys.argv.index('-geometry') + 1
177+ if geomIndex < len(sys.argv):
178+ p = re.compile('^((\d+)x(\d+))?(([+-])(\d+)([+-])(\d+))?$')
179+ m = p.match(sys.argv[geomIndex])
180+ if m:
181+ if m.group(1):
182+ client.resize(int(m.group(2)), int(m.group(3)))
183+ else:
184+ client.resize(WIDTH,HEIGHT)
185+ if m.group(4):
186+ x = int(m.group(6))
187+ y = int(m.group(8))
188+ rec = QDesktopWidget().screenGeometry()
189+ if m.group(5) == '-':
190+ x = rec.width() - (client.width() + x)
191+ if m.group(7) == '-':
192+ y = rec.height() - (client.height() + y)
193+ client.move(x, y)
194+ else:
195+ print USAGE
196+ sys.exit(-1)
197+ else:
198+ print USAGE
199+ sys.exit(-1)
200+ else:
201+ client.resize(WIDTH,HEIGHT)
164202 client.show()
165203 sys.exit(app.exec_())
Show on old repository browser