def login(self): """Asks teacher to login""" dialog = gtk.Dialog(_("Login"), self.window, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK) ) dialogLabel = gtk.Label(_("Please login")) dialog.vbox.add(dialogLabel) dialog.vbox.set_border_width(8) hbox = gtk.HBox() login = gtk.Label(_("Your name (teacher or class name):")) hbox.pack_start(login) entry_login = gtk.Entry() entry_login.set_text(system.get_user_name()) hbox.pack_start(entry_login) dialog.set_default_response(gtk.RESPONSE_OK) dialog.vbox.pack_start(hbox) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: self.class_name = entry_login.get_text() self.logger.info("Login: %s" % self.class_name) dialog.destroy() # Starting broadcasting service self.service.start_broadcast(self.class_name) self.service.start_multicast() self.service.server.start() return True else: dialog.destroy() sys.exit(0) self.logger.info("leaving..") return None
def login(self): """Asks teacher to login""" dialog = gtk.Dialog(_("Login"), self.window, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK)) dialogLabel = gtk.Label(_("Please login")) dialog.vbox.add(dialogLabel) dialog.vbox.set_border_width(8) hbox = gtk.HBox() login = gtk.Label(_("Your name (teacher or class name):")) hbox.pack_start(login) entry_login = gtk.Entry() entry_login.set_text(system.get_user_name()) hbox.pack_start(entry_login) dialog.set_default_response(gtk.RESPONSE_OK) dialog.vbox.pack_start(hbox) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: self.class_name = entry_login.get_text() self.logger.info("Login: %s" % self.class_name) dialog.destroy() # Starting broadcasting service self.service.start_broadcast(self.class_name) self.service.start_multicast() self.service.server.start() return True else: dialog.destroy() sys.exit(0) self.logger.info("leaving..") return None
def create_login_dialog(self, widget): """Asks student to login""" dialog = gtk.Dialog(_("Login"), None, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialogLabel = gtk.Label(_("Please login")) dialog.vbox.add(dialogLabel) dialog.vbox.set_border_width(8) hbox = gtk.HBox() login = gtk.Label(_("Your name:")) hbox.pack_start(login) self.entry_login = gtk.Entry() self.entry_login.set_text(system.get_user_name()) hbox.pack_start(self.entry_login) dialog.vbox.pack_start(hbox) # list of teachers hbox = gtk.HBox() teacher = gtk.Label(_("Your teacher:")) hbox.pack_start(teacher) # list of teachers hbox.pack_start(self.teachers) dialog.vbox.pack_start(hbox) dialog.show_all() self.login_dialog = dialog