Hello all.
I have a questin. I understaand gui as dependant on user action.
It waits and does nothing until it responds.
I have an small script that I want to show a clock couting down.
or really what I want is I have a small scrits that starts counting down
and then at a certain time left, a small window pops up and says one
minute left. Unfortuatenly, at the point, time can run out, but the
session will not end, unless the gui window is killed or the Ok button
is clicked on and it kills it self.
I am not sure in what direction to go in.
all help appreciate. these are the lines of code
#!/usr/bin/python2.2
""" Track user time by writing to the NFS mounted home"""
import time
import sys
import killXinit
import guiWarning
def fileTimeStamp():
fileTimeStamp = time.localtime()[0], time.localtime()[1],time.localtime()[2],
time.localtime()[3], time.localtime()[4]
return fileTimeStamp
timeFile = open(".RTuserTimeStamp", "r+")
timeFileData = timeFile.readlines()
#Determine user
userData = timeFileData[1].split()
user = userData[2]
#Determine TimePaid
timePaidData = timeFileData[2].split()
timePaid = timePaidData[2]
#Detemine TimeUSED
timeUsedData = timeFileData[3].split()
print timeUsedData
timeUsed = timeUsedData[2]
#BEGIN CLOCK
timeStart = time.time()
timeLeft = 10
print "TIME LEFT", timeLeft
while timeLeft > (time.time() - timeStart):
if int(time.time() - timeStart) == 4:
guiWarning.startWindow()
print time.time()
time.sleep(1)
else:
timeFile.writelines("last written %s\n"%str(fileTimeStamp()))
# killXinit.killX()
print "DONE!"
# sys.exit()
timeFile.close()
""" Ok, have a profiler of who is logged on. It seems that when people log on via NFS
its hard to figure out who is current being exported out. Loggin in and mounting the
home terminal does not show up on bubs"""
#!/usr/bin/python2.2
import pygtk
pygtk.require('2.0')
import gtk
import time
import commands
def startWindow():
timeStart = time.time()
timeLeft = 2
if time.time() - timeStart > timeLeft:
whatPID = commands.getoutput('ps -A')
PIDlist = whatPID.split('\n')
for x in PIDlist:
if x.find('XFree86') >0:
Xfound = x
parseXfound = Xfound.split()
report = commands.getstatusoutput('kill %s 1'%parseXfound[0])
print report
class Window:
def quit(self, widget, data = None):
gtk.main_quit()
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("TEST")
self.window.set_border_width(10)
self.VBoxMain = gtk.VBox(gtk.FALSE,0)
self.VBoxMain.show()
self.window.add(self.VBoxMain)
self.label = gtk.Label("USER ACCOUNT INFO")
self.label.show()
self.VBoxMain.pack_start(self.label)
self.HBox1 = gtk.HBox(gtk.FALSE,0)
self.HBox1.show()
self.VBoxMain.pack_start(self.HBox1)
self.timeLabel = gtk.Label("Current time: ")
self.timeLabel.set_justify(gtk.JUSTIFY_LEFT)
self.timeLabel.show()
self.HBox1.pack_start(self.timeLabel)
self.timeDisplayLabel = gtk.Label()
self.timeDisplayLabel.set_markup('YOU HAVE ONE MINUTE BEFORE BEING LOGGED
OUT.' )
self.timeDisplayLabel.show()
self.HBox1.pack_start(self.timeDisplayLabel)
self.HBox2 = gtk.HBox(gtk.FALSE,0)
self.HBox2.show()
self.VBoxMain.add(self.HBox2)
self.okButton = gtk.Button("OK?")
self.okButton.connect("clicked", self.quit)
self.okButton.show()
self.HBox2.pack_start(self.okButton, gtk.TRUE, gtk.TRUE,0)
self.window.show()
def main(self):
gtk.main()
window = Window()
window.main()
#!/usr/bin/python2.2
""" Determine what xinit is and kill it
Most likely needs to run as root"""
def killX():
import commands
whatPID = commands.getoutput('ps -A')
PIDlist = whatPID.split('\n')
for x in PIDlist:
if x.find('XFree86') >0:
Xfound = x
print "FOUND"
print Xfound
parseXfound = Xfound.split()
report = commands.getstatusoutput('kill %s 1'%parseXfound[0])
print report
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/