1 |
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
import Tkinter |
---|
19 |
import os, sys, string, types |
---|
20 |
import pub_busy |
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 |
class standard_err: |
---|
26 |
""" |
---|
27 |
Show all warning, error, debug, critical, and exception messages in the 'Error' tab window located in the bottom right. |
---|
28 |
""" |
---|
29 |
def __init__( self, master ): |
---|
30 |
self.parent = master |
---|
31 |
|
---|
32 |
def write(self,s): |
---|
33 |
self.parent.bottom_notebook.selectpage('Error') |
---|
34 |
self.parent.log_error_window.appendtext( s ) |
---|
35 |
self.parent.log_error_window.yview("moveto", 1) |
---|
36 |
self.parent.log_error_window.configure(vscrollmode ='dynamic') |
---|
37 |
|
---|
38 |
|
---|
39 |
pub_busy.busyEnd( self.parent.parent ) |
---|
40 |
|
---|
41 |
def flush(self): |
---|
42 |
err = open('/dev/null', 'a+', 0) |
---|
43 |
os.dup2(err.fileno(), 2) |
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
class standard_out: |
---|
49 |
""" |
---|
50 |
Show all information messages in the 'Output' tab window located in the bottom right. |
---|
51 |
""" |
---|
52 |
def __init__( self, master ): |
---|
53 |
self.parent = master |
---|
54 |
|
---|
55 |
def write(self,s): |
---|
56 |
self.parent.bottom_notebook.selectpage('Output') |
---|
57 |
self.parent.log_output_window.appendtext( s ) |
---|
58 |
self.parent.log_output_window.yview("moveto", 1) |
---|
59 |
self.parent.log_output_window.configure(vscrollmode ='dynamic') |
---|
60 |
|
---|
61 |
def flush(self): |
---|
62 |
out = open('/dev/null', 'a+', 0) |
---|
63 |
os.dup2(out.fileno(), 2) |
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 |
class Command: |
---|
69 |
""" |
---|
70 |
Event handling function that will allow the passing of arguments. |
---|
71 |
""" |
---|
72 |
def __init__(self, func, *args, **kw): |
---|
73 |
self.func = func |
---|
74 |
self.args = args |
---|
75 |
self.kw = kw |
---|
76 |
|
---|
77 |
def __call__(self, *args, **kw): |
---|
78 |
args = self.args + args |
---|
79 |
kw.update(self.kw) |
---|
80 |
return apply(self.func, args, kw) |
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
class MyButton(Tkinter.Button): |
---|
87 |
""" |
---|
88 |
A Tkinter button with the special image to remove tab pages. |
---|
89 |
""" |
---|
90 |
def __init__(self, master=None, cnf={}, **kw): |
---|
91 |
from pkg_resources import resource_filename |
---|
92 |
remove_gif = resource_filename('esgcet.ui', 'remove.gif') |
---|
93 |
photo1 = Tkinter.PhotoImage(file=remove_gif) |
---|
94 |
self.__toggle = 0 |
---|
95 |
|
---|
96 |
|
---|
97 |
kw['image'] = photo1 |
---|
98 |
apply(Tkinter.Button.__init__, (self, master, cnf), kw) |
---|
99 |
self.image = photo1 |
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 |
menu_font_type = 'Helvetica' |
---|
106 |
menu_font_size = -16 |
---|
107 |
|
---|
108 |
button_font_type = 'Helvetica' |
---|
109 |
button_font_size = -16 |
---|
110 |
|
---|
111 |
collection_font_type = 'Helvetica' |
---|
112 |
collection_font_size= -13 |
---|
113 |
|
---|
114 |
button_group_font_type = 'Helvetica' |
---|
115 |
button_group_font_size = -16 |
---|
116 |
|
---|
117 |
combobox_font_type = 'Helvetica' |
---|
118 |
combobox_font_size = -14 |
---|
119 |
|
---|
120 |
label_button_font_type = 'Helvetica' |
---|
121 |
label_button_font_size = -14 |
---|
122 |
|
---|
123 |
text_font_type = 'Helvetica' |
---|
124 |
text_font_size = -14 |
---|
125 |
|
---|
126 |
tab_font_type = 'Helvetica' |
---|
127 |
tab_font_size = -14 |
---|
128 |
|
---|
129 |
splash_font_size = -14 |
---|
130 |
font_weight = "normal" |
---|
131 |
bnfont_weight = "normal" |
---|
132 |
mnfont_weight = "normal" |
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 |
query_tab_color = "yellow" |
---|
139 |
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 |
filetypes = [ |
---|
144 |
("Python and text files", "*.py *.pyw *.txt", "TEXT"), |
---|
145 |
("All text files", "*", "TEXT"), |
---|
146 |
("All files", "*"), |
---|
147 |
] |
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 |
datatypes = [ |
---|
153 |
("Search for netCDF files", "*.nc"), |
---|
154 |
("Search for GrADS files", "*.ctl"), |
---|
155 |
("Search for CDMS files", "*.cdms"), |
---|
156 |
("Search for DRS files", "*.dic"), |
---|
157 |
("Search for PP files", "*.pp"), |
---|
158 |
("Search for HDF files", "*.hdf"), |
---|
159 |
("Search for XML files", "*.xml"), |
---|
160 |
("Search for XML files", "*.cdml"), |
---|
161 |
("Search for PSQL files", "*.cdms"), |
---|
162 |
("All files", "*") |
---|
163 |
] |
---|
164 |
|
---|
165 |
def return_status_text( status ): |
---|
166 |
from esgcet.model import CREATE_DATASET_EVENT, UPDATE_DATASET_EVENT, PUBLISH_DATASET_EVENT, DELETE_DATASET_EVENT, ADD_FILE_EVENT, DELETE_FILE_EVENT, UNPUBLISH_DATASET_EVENT, WRITE_THREDDS_CATALOG_EVENT, START_PUBLISH_DATASET_EVENT, PUBLISH_FAILED_EVENT, START_DELETE_DATASET_EVENT, DELETE_GATEWAY_DATASET_EVENT, DELETE_DATASET_FAILED_EVENT, WRITE_LAS_CATALOG_EVENT |
---|
167 |
|
---|
168 |
if status==CREATE_DATASET_EVENT: |
---|
169 |
return 'Scanned' |
---|
170 |
elif status==UPDATE_DATASET_EVENT: |
---|
171 |
return 'Updated' |
---|
172 |
elif status==PUBLISH_DATASET_EVENT: |
---|
173 |
return 'Published' |
---|
174 |
elif status==DELETE_DATASET_EVENT: |
---|
175 |
return 'Deleted' |
---|
176 |
elif status==ADD_FILE_EVENT: |
---|
177 |
return 'Added' |
---|
178 |
elif status==DELETE_FILE_EVENT: |
---|
179 |
return 'Deleted File' |
---|
180 |
elif status==UNPUBLISH_DATASET_EVENT: |
---|
181 |
return 'Unpublished' |
---|
182 |
elif status==WRITE_THREDDS_CATALOG_EVENT: |
---|
183 |
return 'Thredds...' |
---|
184 |
elif status==START_PUBLISH_DATASET_EVENT: |
---|
185 |
return 'Processing' |
---|
186 |
elif status==PUBLISH_FAILED_EVENT: |
---|
187 |
return 'Published Failed' |
---|
188 |
elif status==START_DELETE_DATASET_EVENT: |
---|
189 |
return 'Start Deleted Dataset' |
---|
190 |
elif status==DELETE_GATEWAY_DATASET_EVENT: |
---|
191 |
return 'GW Deletion' |
---|
192 |
elif status==DELETE_DATASET_FAILED_EVENT: |
---|
193 |
return 'Failed GW Deletion' |
---|
194 |
elif status==WRITE_LAS_CATALOG_EVENT: |
---|
195 |
return 'LAS...' |
---|
196 |
else: |
---|
197 |
return 'Error' |
---|
198 |
|
---|
199 |
|
---|
200 |
|
---|
201 |
|
---|
202 |
|
---|