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

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