Package iceprod :: Package client :: Package gtk :: Module GtkAuth
[hide private]
[frames] | no frames]

Source Code for Module iceprod.client.gtk.GtkAuth

  1  #!/bin/env python 
  2  #   copyright  (c) 2005 
  3  #   the icecube collaboration 
  4  #   $Id: $ 
  5  # 
  6  #   @version $Revision: $ 
  7  #   @date $Date: $ 
  8  #   @author Juan Carlos Diaz Velez <juancarlos@icecube.wisc.edu> 
  9  #       @brief icetray connections frame for GtkIcetraConfig application 
 10  ######################################################################### 
 11   
 12  import pygtk 
 13  import threading 
 14  import getpass 
 15  pygtk.require('2.0') 
 16  import gtk 
 17   
 18   
19 -class GtkAuth:
20
21 - def __init__(self,submit,cancel=None):
22 23 self.dialog = gtk.Dialog(title='authentication', parent=None, flags=0 ); 24 25 username_label = gtk.Label("Username:") 26 username_label.show() 27 28 username_entry = gtk.Entry() 29 username_entry.set_text(getpass.getuser()) 30 username_entry.show() 31 username_entry.connect("activate", self.go,submit) 32 self.username_entry = username_entry 33 34 password_label = gtk.Label("Password:") 35 password_label.show() 36 37 password_entry = gtk.Entry() 38 password_entry.set_visibility(False) 39 password_entry.show() 40 password_entry.connect("activate", self.go,submit) 41 self.password_entry = password_entry 42 43 host_label = gtk.Label("Host:") 44 host_label.show() 45 46 host_entry = gtk.Entry() 47 host_entry.set_text(getpass.getuser()) 48 host_entry.show() 49 host_entry.connect("activate", self.go,submit) 50 self.host_entry = host_entry 51 52 database_label = gtk.Label("Database:") 53 database_label.show() 54 55 database_entry = gtk.Entry() 56 database_entry.set_text(getpass.getuser()) 57 database_entry.show() 58 database_entry.connect("activate", self.go,submit) 59 self.database_entry = database_entry 60 61 cancel_button = gtk.Button('Cancel') 62 cancel_button.show() 63 cancel_button.connect("clicked", self.bail,cancel) 64 65 66 submit_button = gtk.Button('Submit') 67 submit_button.show() 68 submit_button.connect("clicked", self.go,submit) 69 70 71 self.dialog.vbox.pack_start(username_label, True, True, 0) 72 self.dialog.vbox.pack_start(username_entry, True, True, 0) 73 self.dialog.vbox.pack_start(password_label, True, True, 0) 74 self.dialog.vbox.pack_start(password_entry, True, True, 0) 75 self.dialog.vbox.pack_start(host_label, True, True, 0) 76 self.dialog.vbox.pack_start(host_entry, True, True, 0) 77 self.dialog.vbox.pack_start(database_label, True, True, 0) 78 self.dialog.vbox.pack_start(database_entry, True, True, 0) 79 self.dialog.action_area.pack_start(cancel_button, True, True, 0) 80 self.dialog.action_area.pack_start(submit_button, True, True, 0) 81 self.dialog.show()
82
83 - def go(self,widget,submit):
84 submit( 85 self.host_entry.get_text(), 86 self.username_entry.get_text(), 87 self.username_entry.get_text(), 88 self.password_entry.get_text(), 89 self.database_entry.get_text()) 90 self.dialog.destroy()
91
92 - def bail(self,widget,cancel):
93 if cancel: 94 cancel() 95 self.dialog.destroy()
96 97 98
99 -def echo(*str):
100 print str
101 102 #gtkauth = GtkAuth(echo) 103 #gtk.main() 104