You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
6.4 KiB
174 lines
6.4 KiB
13 years ago
|
#!/usr/bin/env python
|
||
|
|
||
|
import os, sys, string
|
||
8 years ago
|
from python_tqt.qt import *
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
if TQT_VERSION < 0x030100:
|
||
2 years ago
|
print("This example requires TQt v3.1.0 or later.")
|
||
13 years ago
|
sys.exit(1)
|
||
|
|
||
|
|
||
|
FALSE = 0
|
||
|
TRUE = 1
|
||
|
|
||
|
hasmail_bmp_data = [
|
||
|
"48 48 3 1",
|
||
|
" c None",
|
||
|
". c #000000",
|
||
|
"+ c #FFFFFF",
|
||
|
"................................................",
|
||
|
".............................++++++++++.........",
|
||
|
".............................++++++++++.........",
|
||
|
"........................++++.+++.+.+.++.........",
|
||
|
"......................++++.++++.+.+.+++.........",
|
||
|
".....................+++.....+++.+.+.++.........",
|
||
|
"....................++.......++.+.+.+++.........",
|
||
|
"...................++........++++++++++.........",
|
||
|
"..................++.........++++++++++.........",
|
||
|
".................++..........+++..+.............",
|
||
|
"................++...........+++..+.............",
|
||
|
"...............++............+++.++.............",
|
||
|
"..............+++++++........++++++.............",
|
||
|
".............++++++++++......++++++.............",
|
||
|
"............+++......+++.....++++.+.............",
|
||
|
"...........+++.........++....+++..+.............",
|
||
|
"...........++..........++...++++..+.............",
|
||
|
"..........++............++.+++++..+.............",
|
||
|
"..........++............++++++++..+.............",
|
||
|
".........++....++++++....+++.+++..+.............",
|
||
|
".........++......++......++..+++..+.............",
|
||
|
".........++..............++..+++..+.............",
|
||
|
".........++..............++..+++..+.............",
|
||
|
".........++..............++..++...+.............",
|
||
|
"+++++++..++.+.+..+..+.+..++.......+..+++++++++++",
|
||
|
".........++.+++.+.+.+.+..++.......+.............",
|
||
|
".........++.+.+.+++.+.+..++.......+.............",
|
||
|
".........++.+.+.+.+.+.+..++......++.............",
|
||
|
".........++.+.+.+.+.+.++.++.....++..............",
|
||
|
".........++..............++....++...............",
|
||
|
"..+.+.+..++..............++...++..+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.++..............++..++..+.+.+.+.+.+.+..",
|
||
|
"..+.+.+..++..............++.++..+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.++..............+++++.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+..+++++++++++++++++++.++.+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+..+++++++++++++++++..+.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+.+..........+...+.....++.+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.+.+.+.+.+.+...+.....+.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+.+.+.+.+.+.++...+.....++.+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.+.+.+.+.+.+...+.....+.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+.+.+.+.+.+.++...+.....++.+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.+.+.+.+.+.+...+.....+.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+.+.+.+.+.+.++...+....+.+.+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.+.+.+.+.+.+...+...+.+.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+.+.+.+.+.+.+.+..+..+.+.+.+.+.+.+.+.+.+.+.",
|
||
|
".+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+..",
|
||
|
"..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+...",
|
||
|
"................................................"
|
||
|
]
|
||
|
|
||
|
nomail_bmp_data = [
|
||
|
"48 48 3 1",
|
||
|
" c None",
|
||
|
". c #FFFFFF",
|
||
|
"+ c #000000",
|
||
|
"................................................",
|
||
|
"................................................",
|
||
|
"................................................",
|
||
|
".........................++++...................",
|
||
|
".......................++++++++.................",
|
||
|
".....................++++....+++................",
|
||
|
"....................+++........++...............",
|
||
|
"...................++...........++..............",
|
||
|
"..................++............++..............",
|
||
|
".................++..............++.......+.....",
|
||
|
"................++...............++......++.....",
|
||
|
"...............++................++.....+++.....",
|
||
|
"..............+++++++...........+++....++++.....",
|
||
|
".............++++++++++........++++...+++++.....",
|
||
|
"............+++......+++......+++.+..++++++.....",
|
||
|
"...........+++.........++....+++..+.+++.+++.....",
|
||
|
"...........++..........++...+++...++++..+++.....",
|
||
|
"..........++............++.+++...++++...++......",
|
||
|
"..........++............+++++...++++............",
|
||
|
".........++....++++++....+++...++++.............",
|
||
|
".........++......++......++...+++.+.............",
|
||
|
".........++..............++...+++.+.............",
|
||
|
".........++..............++...++..+.............",
|
||
|
".........++..............++.......+.............",
|
||
|
"+++++++..++..............++.......+..+++++++++++",
|
||
|
".........++..............++.......+.............",
|
||
|
".........++..............++.......+.............",
|
||
|
".........++..............++......++.............",
|
||
|
".........++..............++.....++..............",
|
||
|
".........++..............++....++...............",
|
||
|
".........++..............++...++................",
|
||
|
".........++..............++..++.................",
|
||
|
".........++..............++.++..................",
|
||
|
".........++..............+++++..................",
|
||
|
".........+++++++++++++++++++.+..................",
|
||
|
"..........+++++++++++++++++..+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"...................+...+.....+..................",
|
||
|
"+++.++++++++++.+.+++...+..+++++++++++.++...+++++",
|
||
|
"+.+++..+++.+.+++++.++..+.++.+++..+..+.++.+.++++.",
|
||
|
".++...+.....++...+...+++++++....+....++++++...+.",
|
||
|
"++++++++++++++++++++++++++++++++++++++++++++++++"
|
||
|
]
|
||
|
|
||
13 years ago
|
class Biff(TQWidget):
|
||
13 years ago
|
def __init__(self):
|
||
13 years ago
|
TQWidget.__init__(self, None, "Biff - example application")
|
||
13 years ago
|
|
||
|
mail = os.getenv("MAIL")
|
||
13 years ago
|
fi = TQFileInfo(mail);
|
||
13 years ago
|
if not fi.exists():
|
||
|
s = "/var/spool/mail/"+os.getenv("USER")
|
||
|
fi.setFile(s)
|
||
|
|
||
|
if fi.exists():
|
||
|
self.mailbox = fi.absFilePath()
|
||
|
self.startTimer(1000)
|
||
|
|
||
|
self.setMinimumSize(48, 48)
|
||
|
self.setMaximumSize(48, 48)
|
||
|
self.resize(48, 48)
|
||
|
|
||
13 years ago
|
self.hasNewMail = TQPixmap(hasmail_bmp_data)
|
||
|
self.noNewMail = TQPixmap(nomail_bmp_data)
|
||
13 years ago
|
|
||
|
self.gotMail = FALSE
|
||
|
self.lastModified = fi.lastModified()
|
||
|
|
||
|
def timerEvent(self, te):
|
||
13 years ago
|
fi = TQFileInfo(self.mailbox)
|
||
13 years ago
|
newState = ( fi.lastModified().toTime_t() != self.lastModified.toTime_t() and fi.lastModified().toTime_t() > fi.lastRead().toTime_t())
|
||
|
if newState != self.gotMail:
|
||
|
if self.gotMail == TRUE:
|
||
|
self.lastModified = fi.lastModified()
|
||
|
self.gotMail = newState
|
||
|
self.repaint(FALSE)
|
||
|
|
||
|
def paintEvent(self, pe):
|
||
|
if self.gotMail:
|
||
|
bitBlt(self, 0, 0, self.hasNewMail)
|
||
|
else:
|
||
|
bitBlt(self, 0, 0, self.noNewMail)
|
||
|
|
||
|
def mousePressEvent(self, me):
|
||
13 years ago
|
fi = TQFileInfo(self.mailbox)
|
||
13 years ago
|
lastModified = fi.lastModified()
|
||
|
|
||
|
|
||
13 years ago
|
a = TQApplication(sys.argv)
|
||
13 years ago
|
b = Biff()
|
||
|
a.setMainWidget(b)
|
||
|
b.show()
|
||
|
a.exec_loop()
|