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

Source Code for Module iceprod.client.gtk.GtkFileChooser

  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 File chooser for saving and opening files in  GtkIcetraConfig 
 10  #       application 
 11  ######################################################################### 
 12  import pygtk 
 13  pygtk.require('2.0') 
 14  import gtk 
 15  from os.path import expandvars 
 16   
17 -class GtkSaveFileChooser:
18 # Get the selected filename and print it to the console
19 - def file_ok_sel(self, w):
20 filename = self.filew.get_filename() 21 self.parent.configfile = filename 22 self.parent.savefile(None,filename) 23 self.filew.destroy()
24
25 - def destroy(self, widget):
26 self.filew.destroy()
27
28 - def __init__(self,parent):
29 # Create a new file selection widget 30 self.parent = parent 31 self.filew = gtk.FileSelection("File selection") 32 33 self.filew.connect("destroy", self.destroy) 34 # Connect the ok_button to file_ok_sel method 35 self.filew.ok_button.connect("clicked", self.file_ok_sel) 36 37 # Connect the cancel_button to destroy the widget 38 self.filew.cancel_button.connect("clicked", 39 lambda w: self.filew.destroy()) 40 41 # Lets set the filename, as if this were a save dialog, 42 # and we are giving a default filename 43 self.filew.set_filename(self.parent.GetConfigFile() or "myconfig.xml") 44 45 self.filew.show()
46
47 -class GtkOpenFileChooser:
48 # Get the selected filename and print it to the console
49 - def file_ok_sel(self, w):
50 self.filename = self.filew.get_filename() 51 self.parent.getconfig(self.filename) 52 self.filew.destroy()
53
54 - def destroy(self, widget):
55 self.filew.destroy()
56
57 - def __init__(self,parent,filename):
58 # Create a new file selection widget 59 self.parent = parent 60 self.filew = gtk.FileSelection("File selection") 61 self.filename = filename 62 63 self.filew.connect("destroy", self.destroy) 64 # Connect the ok_button to file_ok_sel method 65 self.filew.ok_button.connect("clicked", self.file_ok_sel) 66 67 # Connect the cancel_button to destroy the widget 68 self.filew.cancel_button.connect("clicked", 69 lambda w: self.filew.destroy()) 70 71 self.filew.show()
72 73
74 -class GtkOpenDBFileChooser:
75 # Get the selected filename and print it to the console
76 - def file_ok_sel(self, w):
77 filename = self.filew.get_filename() 78 self.parent.pdb.loadfile(filename) 79 self.filew.destroy()
80
81 - def destroy(self, widget):
82 self.filew.destroy()
83
84 - def __init__(self,parent):
85 # Create a new file selection widget 86 self.parent = parent 87 self.filew = gtk.FileSelection("File selection") 88 89 self.filew.connect("destroy", self.destroy) 90 # Connect the ok_button to file_ok_sel method 91 self.filew.ok_button.connect("clicked", self.file_ok_sel) 92 93 # Connect the cancel_button to destroy the widget 94 self.filew.cancel_button.connect("clicked", 95 lambda w: self.filew.destroy()) 96 97 self.filew.show()
98
99 -class GtkSaveDBFileChooser:
100 # Get the selected filename and print it to the console
101 - def file_ok_sel(self, w):
102 filename = self.filew.get_filename() 103 self.parent.pdb.savefile(filename) 104 self.filew.destroy()
105
106 - def destroy(self, widget):
107 self.filew.destroy()
108
109 - def __init__(self,parent):
110 # Create a new file selection widget 111 self.parent = parent 112 self.filew = gtk.FileSelection("File selection") 113 114 self.filew.connect("destroy", self.destroy) 115 # Connect the ok_button to file_ok_sel method 116 self.filew.ok_button.connect("clicked", self.file_ok_sel) 117 118 # Connect the cancel_button to destroy the widget 119 self.filew.cancel_button.connect("clicked", 120 lambda w: self.filew.destroy()) 121 122 # Lets set the filename, as if this were a save dialog, 123 # and we are giving a default filename 124 self.filew.set_filename(expandvars("$HOME/paramdb.xml")) 125 126 self.filew.show()
127
128 -def main():
129 gtk.main() 130 return 0
131 132 if __name__ == "__main__": 133 GtkFileChooser(None) 134 main() 135