root/Esgcet/trunk/esgcet/esgcet/ui/pub_controls.py

Revision 7417, 8.1 kB (checked in by drach1, 3 weeks ago)

- Initial version of LAS publication
- Added specification of parent in esgpublish

Line 
1 #!/usr/bin/env python
2 #
3 # The Publisher controls and miscellaneous functions -  pub_control module
4 #
5 ###############################################################################
6 #                                                                             #
7 # Module:       pub_control module                                            #
8 #                                                                             #
9 # Copyright:    "See file Legal.htm for copyright information."               #
10 #                                                                             #
11 # Authors:      PCMDI Software Team                                           #
12 #               Lawrence Livermore National Laboratory:                       #
13 #                                                                             #
14 # Description:  Publisher GUI controls and miscellaneous functons.            #
15 #                                                                             #
16 ###############################################################################
17
18 import Tkinter
19 import os, sys, string, types
20 import pub_busy
21
22 #------------------------------------------------------------------------
23 # Redirect the destination of sys.stderr to the "Error" tab window
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         # Remove the busy mouse
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 # Redirect the destination of sys.stdout to the "Output" tab window
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 # Event handling function that will allow the passing of arguments
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 # This is just an ordinary button with special image to remove the page.
84 # This button is used exclusively to remove pages from the top notebook.
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         #kw['background'] = 'green'
96         #kw['activebackground'] = 'red'
97         kw['image'] = photo1
98         apply(Tkinter.Button.__init__, (self, master, cnf), kw)
99         self.image = photo1 # save the image from garbage collection
100
101 #---------------------------------------------------------------------
102 # Controls for the GUI fonts: Font.family (Courier, Helvetica, Ariel,
103 #                             Cambria, Calibri)
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 #font_weight = "normal"
134
135 #---------------------------------------------------------------------
136 # Controls for the GUI colors
137 #---------------------------------------------------------------------
138 query_tab_color = "yellow"
139
140 #---------------------------------------------------------------------------------
141 # List of filetypes to search for in the "File Select" popup dialog window
142 #---------------------------------------------------------------------------------
143 filetypes = [
144         ("Python and text files", "*.py *.pyw *.txt", "TEXT"),
145         ("All text files", "*", "TEXT"),
146         ("All files", "*"),
147         ]
148
149 #---------------------------------------------------------------------------------
150 # List of filetypes to search for in the "File Select" popup dialog window
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:                # value = 1
169        return 'Scanned'
170     elif status==UPDATE_DATASET_EVENT:              # value = 2
171        return 'Updated'
172     elif status==PUBLISH_DATASET_EVENT:             # value = 3
173        return 'Published'
174     elif status==DELETE_DATASET_EVENT:              # value = 4
175        return 'Deleted'
176     elif status==ADD_FILE_EVENT:                    # value = 5
177        return 'Added'
178     elif status==DELETE_FILE_EVENT:                 # value = 6
179        return 'Deleted File'
180     elif status==UNPUBLISH_DATASET_EVENT:           # value = 7
181        return 'Unpublished'
182     elif status==WRITE_THREDDS_CATALOG_EVENT:       # value = 8
183        return 'Thredds...'
184     elif status==START_PUBLISH_DATASET_EVENT:       # value = 9
185        return 'Processing'
186     elif status==PUBLISH_FAILED_EVENT:              # value = 10
187        return 'Published Failed'
188     elif status==START_DELETE_DATASET_EVENT:        # value = 11
189        return 'Start Deleted Dataset'
190     elif status==DELETE_GATEWAY_DATASET_EVENT:      # value = 12
191        return 'GW Deletion'
192     elif status==DELETE_DATASET_FAILED_EVENT:       # value = 13
193        return 'Failed GW Deletion'
194     elif status==WRITE_LAS_CATALOG_EVENT:
195        return 'LAS...'
196     else:
197        return 'Error'
198
199 #---------------------------------------------------------------------
200 # End of File
201 #---------------------------------------------------------------------
202
Note: See TracBrowser for help on using the browser.