#!/usr/bin/python import os import gtk import gtk.glade from user import User from camera import Camera class Zork(object): def __init__(self): self.gladefile = "ui.glade" self.wTree = gtk.glade.XML(self.gladefile) self.window = self.wTree.get_widget("MainWindow") self.camera = Camera() self.user = None def run(self): self.window.show_all() while True: # refreshing UI if gtk.events_pending(): while gtk.events_pending(): gtk.main_iteration() else: #time.sleep(0.1) if self.camera.process_one_frame(): self.login("glibersat") else: self.logout() def logout(self): if self.user == None: return self.user = None # update UI label = self.wTree.get_widget("user_label") label.set_label("Anonymous user") os.system("echo \"Goodbye !\" | aoss flite") def login(self, username): if self.user != None: return r = User.select(User.q.username==username) try: self.user = r[0] # update UI label = self.wTree.get_widget("user_label") label.set_label(self.user.username) os.system("echo \"Hi Guillaume !\" | aoss flite") except: print "Unable to login" if __name__ == "__main__": #User(username="glibersat", # jid="glibersat@im.linux62.org") z = Zork() z.login("glibersat") z.run()