F:/thesis_austausch/dissertation/code_docu_doxygen/Visualiser/gui_classes.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 '''
00004 This module contains the classes for the display tool. It is needed by the module "gui.py".
00005 
00006 Reading University
00007 MSc in Network Centred Computing
00008 a.weise - a.weise@reading.ac.uk - December 2005
00009 '''
00010 
00011 from gui_utils import find_item, complete_days, complete_hours, complete_ticks
00012 import Tkinter
00013 import tkFileDialog
00014 import tkMessageBox
00015 import Graphs
00016 import tooltips
00017 from gui_utils import second, second_string_to_int, second_string_only
00018 
00019 
00020 class Colour:
00021     '''
00022     This class uses the ANSI escape sequences to color the output !
00023     '''
00024     color = {"reset":"\x1b[0m",
00025             "bold":"\x1b[01m",
00026             "teal":"\x1b[36;06m",
00027             "turquoise":"\x1b[36;01m",
00028             "fuscia":"\x1b[35;01m",
00029             "purple":"\x1b[35;06m",
00030             "blue":"\x1b[34;01m",
00031             "darkblue":"\x1b[34;06m",
00032             "green":"\x1b[32;01m",
00033             "darkgreen":"\x1b[32;06m",
00034             "yellow":"\x1b[33;01m",
00035             "brown":"\x1b[33;06m",
00036             "red":"\x1b[31;01m",
00037             "darkred":"\x1b[31;06m"}
00038     
00039     def __init__(self):
00040         '''
00041         Constructor 
00042         '''
00043         pass
00044     
00045     def green(self, text):
00046         '''
00047         dye green
00048         '''
00049         return self.color['green']+text+self.color['reset']
00050         
00051     def red(self, text):
00052         '''
00053         dye red
00054         '''
00055         return self.color['red']+text+self.color['reset']
00056     
00057     def bold(self, text):
00058         '''
00059         dye bold
00060         '''
00061         return self.color['bold']+text+self.color['reset']
00062     
00063     def teal(self, text):
00064         '''
00065         dye teal
00066         '''
00067         return self.color['teal']+text+self.color['reset']
00068     
00069     def turquoise(self, text):
00070         '''
00071         dye turquoise
00072         '''
00073         return self.color['turquoise']+text+self.color['reset']
00074     
00075     def fuscia(self, text):
00076         '''
00077         dye fuscia
00078         '''
00079         return self.color['fuscia']+text+self.color['reset']
00080     
00081     def purple(self, text):
00082         '''
00083         dye purple
00084         '''
00085         return self.color['purple']+text+self.color['reset']
00086     
00087     def darkred(self, text):
00088         '''
00089         dye darkred
00090         '''
00091         return self.color['darkred']+text+self.color['reset']    
00092     
00093     def darkblue(self, text):
00094         '''
00095         dye darkblue
00096         '''
00097         return self.color['darkblue']+text+self.color['reset']
00098 
00099     def blue(self, text):
00100         '''
00101         dye blue
00102         '''
00103         return self.color['blue']+text+self.color['reset']
00104     
00105     def darkgreen(self, text):
00106         '''
00107         dye darkgreen
00108         '''
00109         return self.color['darkgreen']+text+self.color['reset']
00110     
00111     def yellow(self, text):
00112         '''
00113         dye yellow
00114         '''
00115         return self.color['yellow']+text+self.color['reset']
00116     
00117     def brown(self, text):
00118         '''
00119         dye brown
00120         '''
00121         return self.color['brown']+text+self.color['reset']    
00122     
00123     
00124 class Picture(Tkinter.Tk):
00125     '''
00126     This class provides functions around the "diplay diagrams" issues.
00127     '''
00128     
00129     def __init__(self, color, windows):
00130         '''
00131         Constructor
00132         '''
00133         self._col = color
00134         self._windows = []
00135         # needed to close all windows properly
00136         self._all_windows = windows
00137         # needed for deactivate and activate all window buttons properly
00138         self._all_windows.append(self)
00139         # initialise tkinter
00140         Tkinter.Tk.__init__(self)
00141         # set min size
00142         self.minsize(width=500, height=400)
00143         #create frame, where the diagram is drawn later
00144         self.framus = Tkinter.Frame(self)
00145         # add frame to dialog
00146         self.framus.grid(
00147             column = 0,
00148             row = 0,
00149             columnspan = 7,
00150             sticky = "news" #north east west south
00151             )
00152         # "QUIT" BUTTON
00153         self.button_quit = Tkinter.Button(self, text="quit")
00154         self.button_quit.grid(
00155             column = 6,
00156             row = 1,
00157             columnspan = 1,
00158             sticky = "e"
00159                          )
00160         # tooltips for "QUIT" button        
00161         tooltips.ToolTip(self.button_quit, follow_mouse=1, text="Please press \"quit\" to close this window. Note, all windows, which are opened from this window (child windows) are closed as well !", delay=3500)
00162         self.button_quit.configure(command = self.pre_shutdown)
00163         # "SAVE AS" BUTTON
00164         self.button_save = Tkinter.Button(self, text = "save as")
00165         self.button_save.grid(
00166             column = 5,
00167             row = 1,
00168             columnspan = 1,
00169             sticky = "e"
00170                         )
00171         self.button_save.configure(command = self.save_as)
00172         # status bar
00173         self.status = Tkinter.Label(self)
00174         self.status.grid(
00175             column = 0,
00176             row = 3,
00177             columnspan = 7,
00178             sticky = "w"
00179                         )
00180         # configure grid
00181         self.grid_columnconfigure(0, weight = 1)
00182         self.grid_rowconfigure(0, weight = 1)
00183         
00184         # overwrite function
00185         self.protocol("WM_DELETE_WINDOW", self.shutdown)
00186         
00187         # saves as button hoover method
00188         self.button_save.bind("<Enter>", self._show_save_as_description)
00189         self.button_save.bind("<Leave>", self._hide_description)
00190         # tooltips for "SAVE AS" button        
00191         tooltips.ToolTip(self.button_save, follow_mouse = 1, text = "Please press \"save as\" to save the diagram as a postscript file.",  delay = 3500)
00192         
00193     def deactivate(self):
00194         '''
00195         This function deactivates all buttons.
00196         '''
00197         self.protocol("WM_DELETE_WINDOW", self._dummy)
00198         self.button_quit.configure(command = self._dummy)
00199         self.button_save.configure(command = self._dummy)
00200         if self._select_type == 'error' or self._select_type == 'date':
00201             self.button_select.configure(command = self._dummy)
00202     
00203     def activate(self):
00204         '''
00205         This function activates all buttons.
00206         '''
00207         self.protocol("WM_DELETE_WINDOW", self.shutdown)
00208         self.button_quit.configure(command = self.pre_shutdown)
00209         self.button_save.configure(command = self.save_as)
00210         if self._select_type == 'error':
00211             self.button_select.configure(command = self._select_error)
00212         elif self._select_type == 'date':
00213             self.button_select.configure(command = self._select_date)
00214         
00215     def save_as(self):
00216         '''
00217         This function saves the diagram picture as postscript.
00218         '''
00219         # deactivate all buttons
00220         try:
00221             for i in range(len(self._all_windows)):
00222                 self._all_windows[i].deactivate()
00223         except Tkinter.TclError:
00224             pass
00225         # save as dialog
00226         result = tkFileDialog.asksaveasfilename(filetypes = [('postscript', '*.ps')], title = 'Save graph as ... ')
00227         # activate all buttons
00228         try:
00229             for i in range(len(self._all_windows)):
00230                 self._all_windows[i].activate()
00231         except Tkinter.TclError:
00232             pass
00233 
00234         if result != '':
00235             # save diagram in file
00236             self.graph.canvas.postscript(file = result, colormode = 'color')
00237             ###Graphs.canvas.postscript(file = result, colormode = 'color')
00238         
00239     def _dummy(self, event = None):
00240         '''
00241         This function is doing nothing, it serves as a dummy.
00242         '''
00243         return 'break'
00244     
00245     def show_barchart(self, window_name, listus, label, xlabel, ylabel,  data, select_type=None, filus_fd = None, descript = None):
00246         '''
00247         This function shows a barchart diagram.
00248         '''
00249         self.title(window_name)
00250         self._data = data
00251         self._file_fd = filus_fd
00252         self._select_type = select_type
00253         # generate barchart diagram
00254         line = Graphs.GraphBars(listus, color  ='green', size = 6)
00255         graphObject = Graphs.GraphObjects([line])
00256         self.graph = Graphs.GraphBase(self.framus, 400, 400, relief = 'sunken', border = 2, listerus = label, x_label = xlabel, y_label = ylabel, header = window_name, description = descript, label_interval = 10)
00257         self.graph.pack(side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = Tkinter.YES)
00258         self.graph.draw(graphObject, 'automatic', 'automatic')
00259         
00260         # sort items for listbox
00261         self.items = []
00262         self.search_label = []
00263         self.search_value = []
00264         for i in range(len(label)):
00265             self.items.append(label[i][1])
00266             self.search_value.append(listus[i])
00267             self.search_label.append(label[i])
00268 
00269         self.create_listbox()
00270         
00271     def show_line(self, window_name, listus, label, xlabel, ylabel,  data, select_type = None, error = None, labelamount = 10,  filus_fd = None, descript = None, typ = None):
00272         '''
00273         This functions shows a line chart diagram.
00274         
00275         window_name = name of the new window
00276         listus = value list
00277         label = label list for x-axis
00278         xlabel = description of x-axis
00279         ylabel = description of y-axis
00280         select_type = type of items are listed in listbox
00281         data = dataset which comes from the database query
00282         error = chosen error from listbox
00283         labelamount = amount of possible labels for the x-axis
00284         '''
00285         self.title(window_name)
00286         self._data = data
00287         self._file_fd = filus_fd
00288         self._select_type = select_type
00289         
00290         values = []
00291         
00292         # only draw a dot where is a real value
00293         for i in range(len(listus)):
00294             if listus[i][1] != 0 :
00295                 values.append(listus[i])
00296       
00297         dot = Graphs.GraphSymbols(values,  color = 'green', marker = 'dot', fillcolor = 'darkgreen')
00298         
00299         if len(listus) > 1:
00300             line = Graphs.GraphLine(listus, color='green', size=6)
00301             graphObject = Graphs.GraphObjects([line, dot])
00302         else:
00303             graphObject = Graphs.GraphObjects([dot])
00304         
00305         self.graph = Graphs.GraphBase(self.framus, 600, 400, relief = 'sunken', border = 2, listerus = label, x_label = xlabel, y_label = ylabel, header = window_name, description = descript, label_interval = labelamount, type = typ)
00306         self.graph.pack(side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = Tkinter.YES)
00307         self.graph.draw(graphObject, 'automatic', 'automatic')
00308         
00309         if select_type == "date":
00310             
00311             self.items = []
00312             self.search_label = []
00313             self.search_value = []
00314             #rearrange labels for listbox
00315             for i in range(len(label)):
00316                 if listus[i][1] != 0 :
00317                     self.items.append(label[i][1])
00318                     self.search_value.append(listus[i])
00319                     self.search_label.append(label[i])
00320 
00321             # create listbox with dates
00322             self.create_listbox(error)
00323 
00324     def create_listbox(self,  error = None):
00325         '''
00326         This function creates a listbox with the given items.
00327         '''
00328          # listbox
00329         list_scrollbar = Tkinter.Scrollbar(self, orient=Tkinter.VERTICAL)
00330         list_scrollbar.grid ( row = 1, column = 1, columnspan = 1, sticky = "ns" )
00331          
00332         self.listbox = Tkinter.Listbox(self, height = 4, cursor = "plus", bg = "#ffffff", bd = 1, highlightcolor = "#00ff00",  yscrollcommand=list_scrollbar.set)
00333         self.listbox.grid(
00334             column = 0,
00335             row = 1,
00336             columnspan = 1,
00337             sticky = "news"
00338                          )
00339             
00340         self.listbox.bind("<Enter>", self._show_description)
00341         self.listbox.bind("<Leave>", self._hide_description)
00342         
00343         list_scrollbar["command"] = self.listbox.yview
00344 
00345         # "PLOT" button
00346         self.button_select = Tkinter.Button(self, text = "plot")
00347         self.button_select.grid(
00348             column = 3,
00349             row = 1,
00350             columnspan = 1,
00351             sticky = "w"
00352                         )
00353         
00354         self._the_error = error
00355         
00356         if self._select_type == 'error':
00357             self.button_select.configure(command = self._select_error)
00358         elif self._select_type == 'date':
00359             self.button_select.configure(command = self._select_date)
00360             
00361         self.button_select.bind("<Enter>", self._show_plot_description)
00362         self.button_select.bind("<Leave>", self._hide_description)
00363         # tooltips for "PLOT" button
00364         tooltips.ToolTip(self.button_select, follow_mouse = 1, text = "Please press \"plot\" to generate a new diagram with the selected item from the listbox.", delay = 3500)
00365         
00366         # OPTION (dropdown) menu
00367         if self._select_type == 'error':
00368             self._ldate = "%15s" % ("error")
00369             tooltips.ToolTip(self.listbox, follow_mouse = 1, text = "Please select an error and then press \"plot\" to view this error number only.")
00370             tooltips.ToolTip(self.listbox, follow_mouse = 1, text = "Please select an error and then press \"plot\" to view this error number only.")
00371         elif self._select_type == 'date':
00372             self._ldate = "%15s" % ("date")
00373             tooltips.ToolTip(self.listbox, follow_mouse = 1, text = "Please select a date and then press \"plot\" to view this date only.")
00374         self._lfreq = "%12s" % ("frequency")
00375         self.var = Tkinter.StringVar(self)
00376         # activate a trace, which monitores the changes, so in case the drop down menu is used a function is called
00377         self.var.trace('w', self.menu_change)
00378         self.var.set(self._ldate) # initial value
00379         
00380         option = Tkinter.OptionMenu(self, self.var, self._ldate, self._lfreq)
00381 
00382         option.bind("<Enter>", self._show_dropdown_description)
00383         option.bind("<Leave>", self._hide_description)
00384         
00385         if self._select_type == 'error':
00386             tooltips.ToolTip(option, follow_mouse = 1, text = "Select \"error\" or \"frequency\" to change the order in the listbox:\nerror -> order by error numbers (ascending)\nfrequency -> order by frequency (ascending).")
00387         elif self._select_type == 'date':
00388             tooltips.ToolTip(option, follow_mouse = 1, text = "Select \"date\" or \"frequency\" to change the order in the listbox:\ndate -> order by dates (ascending)\nfrequency -> order by frequency (ascending).")
00389         
00390         option.grid(
00391             column = 2,
00392             row = 1,
00393             columnspan = 1,
00394             sticky = "w"
00395                    )
00396         
00397         # SPACE LABEL
00398         labelus = Tkinter.Label(self)
00399         labelus.grid(
00400             column = 4,
00401             row = 1,
00402             columnspan = 1,
00403             sticky = "news"
00404                     )
00405  
00406     def menu_change(self, name, index, mode):
00407         '''
00408         This function changes the order in the listbox according to the chosen item in the drop down menu.
00409         '''
00410         temp_listus = []
00411         temp_search_label = []
00412         
00413         change = self.var.get()
00414         # for dates
00415         if change == self._ldate:
00416 
00417             if self._select_type == 'error':
00418                 self.search_label.sort(second_string_to_int)
00419                 self._dropdown_description = "change order in listbox, currently ordered by \"error number\""
00420             elif self._select_type == 'date':
00421                 self.search_label.sort(second_string_only)
00422                 self._dropdown_description = "change order in listbox, currently ordered by \"date\""
00423             
00424 
00425             for i in range(len(self.search_label)):
00426                 # save label
00427                 temp = self.search_label[i][1]
00428                  # search for corresponding label in label array
00429                 for j in range(len(self.search_value)):
00430                     if self.search_label[i][0] == self.search_value[j][0]:
00431                         # save corresponding label
00432                         temp_listus.append([i+1, self.search_value[j][1]])
00433                 # adjust items
00434                 temp_search_label.append([i+1, temp])
00435                 
00436                 self.items[i] = "%s  (%s)" % (temp_search_label[len(temp_search_label)-1][1], temp_listus[len(temp_listus)-1][1])
00437             
00438             self.search_value = temp_listus[:]
00439             self.search_label = temp_search_label[:]
00440  
00441             # delete old items and write new items in listbox
00442             self.listbox.delete(0, Tkinter.END)
00443             for i in range(len(self.items)):
00444                 self.listbox.insert(Tkinter.END, self.items[i])
00445         
00446         # for frequency
00447         elif change == self._lfreq:
00448 
00449             self._dropdown_description = "change order in listbox, currently ordered by \"frequency\""
00450             self.search_value.sort(second)
00451             
00452             # rearrange order of array
00453             for i in range(len(self.search_value)):
00454                 #save value
00455                 temp = self.search_value[i][1]
00456                 # search for corresponding label in label array
00457                 for j in range(len(self.search_label)):
00458                     if self.search_label[j][0] == self.search_value[i][0]:
00459                         # save corresponding label
00460                         self.items[i] = "%s  (%s)" % (self.search_label[j][1], self.search_value[i][1])
00461                         temp_search_label.append([i+1, self.search_label[j][1]])
00462                 # adjust number in value array
00463                 self.search_value[i][0] = i+1
00464                 self.search_value[i][1] = temp
00465                 
00466             # rearrange label array description
00467             self.search_label = temp_search_label[:]
00468                 
00469             # delete old items and write new items in listbox
00470             self.listbox.delete(0, Tkinter.END)
00471             for i in range(len(self.items)):
00472                 self.listbox.insert(Tkinter.END, self.items[i])
00473 
00474     def pre_shutdown(self):
00475         '''
00476         This function calls a message box and make sure the user really wants to shutdown.
00477         '''
00478         # deactivate all buttons
00479         try:
00480             for i in range(len(self._all_windows)):
00481                 self._all_windows[i].deactivate()
00482         except Tkinter.TclError:
00483             pass
00484         # queston message box
00485         status = tkMessageBox.askquestion("Close Window", "Do you really want to close this and all child windows ?")
00486         # activate all buttons
00487         try:
00488             for i in range(len(self._all_windows)):
00489                 self._all_windows[i].activate()
00490         except Tkinter.TclError:
00491             pass            
00492         if status == 'yes':
00493             self.shutdown()
00494         
00495     def shutdown(self):
00496         '''
00497         This function closes all open child windows and itself
00498         '''
00499         
00500         if self._file_fd != None:
00501             if self._all_windows[0] == self:
00502                 # only main windows closes file
00503                 self._file_fd.close()
00504         
00505         # destroy all cildren windows
00506         for i in range(len(self._windows)):
00507             try:
00508                 self._windows[i].shutdown()
00509                 
00510             except Tkinter.TclError:
00511                 pass
00512             
00513         # destroy myself            
00514         try:
00515             self.destroy()
00516         except Tkinter.TclError:
00517             pass
00518 
00519     def _select_error(self):
00520         '''
00521         This function get the selected item from the listbox
00522         '''
00523         try:
00524             # get index of chosen listbox item
00525             firstIndex = self.listbox.curselection()[0]
00526         except IndexError:
00527             firstIndex = None
00528             
00529         if firstIndex != None:
00530 
00531             # convert index to int            
00532             firstIndex = int(firstIndex)
00533             
00534             # print data
00535             title = "Diagram Error %s \"Frequency - Date\"" % self.search_label[firstIndex][1]
00536             
00537             field = []
00538             field_label = []
00539             data_new = []
00540             # work up the given data and prepare for display
00541             for i in range(len(self._data)):
00542                 if (int(self._data[i]['error.e_number']) == int(self.search_label[firstIndex][1])):
00543                     data_new.append(self._data[i]) # get new dataset (only interesting data is taken)
00544                     index = find_item(self._data[i]['messages.m_date'], field)
00545                     if (None == index):
00546                         field.append([self._data[i]['messages.m_date'], 1])
00547                         field_label.append([self._data[i]['messages.m_date'], 1])
00548                     else:
00549                         count = field[index][1]
00550                         count += 1
00551                         field[index][1] = count
00552                         field_label[index][1] = count
00553   
00554             field.sort()
00555             field_label.sort()           
00556            
00557             # print result table                 
00558             h_line = "------------------------------------"
00559             v_line = "|"
00560             header = "\nFrequency of Error \"%s\":\n" % self.search_label[firstIndex][1]
00561             
00562             # write in file
00563             if self._file_fd != None:
00564                 content =  "\n"+header
00565                 content += "\n\n Nr.   | Date\t\t| Frequency\n\n"
00566                 self._file_fd.write(content)
00567             
00568             if self._col == 1:
00569                 col_obj = Colour()
00570                 
00571                 header = col_obj.yellow(header)
00572                 h_line = col_obj.yellow(h_line)
00573                 v_line = col_obj.yellow(v_line)
00574                 
00575             print header
00576             print h_line
00577             print " Nr.   "+v_line+" Date\t\t"+v_line+" Frequency"
00578             print h_line
00579             
00580             for i in range(len(field)):
00581                 print " %5d %s %s\t%s %s" % ((i+1), v_line, field[i][0], v_line, field[i][1])
00582                 
00583                 # write in file
00584                 if self._file_fd != None:
00585                     content = " %5d | %s\t| %s\n" % ((i+1),  field[i][0], field[i][1])
00586                     self._file_fd.write(content)                
00587                 
00588             print h_line
00589 
00590             for i in range(len(field_label)):
00591                 temp = field_label[i][0]
00592                 field_label[i][0] = field_label[i][1]
00593                 field_label[i][1] = temp
00594             
00595             for i in range(len(field)):
00596                 field_label[i][0] = (i+1)
00597                 field_label[i][1] = "%s" % field[i][0]
00598                 field[i][0] = (i+1)
00599                     
00600             field_label, field = complete_days(field_label, field)
00601 
00602             pic_obj = Picture(self._col, self._all_windows)
00603 
00604             self._windows.append(pic_obj)
00605             
00606             title = "Diagram \"Frequency - Date\" - Error: %s" % self.search_label[firstIndex][1]
00607             descr = title+" - Range: "+field_label[0][1]+"  -  "+field_label[len(field_label)-1][1]#+" )"
00608             pic_obj.show_line(title, field, field_label, "DATE", "FREQUENCY", data_new, select_type = "date", error = self.search_label[firstIndex][1], labelamount = 10, filus_fd = self._file_fd, descript = descr, typ = "date" )
00609 
00610             pic_obj.mainloop()
00611             
00612         else:
00613             # disable all buttons within the windows
00614             for i in range(len(self._all_windows)):
00615                 self._all_windows[i].deactivate()
00616                 
00617             tkMessageBox.showerror("Error", "No item selected !")
00618             # enable all buttons within the windows
00619             for i in range(len(self._all_windows)):
00620                 self._all_windows[i].activate()
00621             
00622     def _select_date(self):
00623         '''
00624         This functions take a date and generates a new graph 
00625         '''
00626         
00627         try:
00628             firstIndex = self.listbox.curselection()[0]
00629         except IndexError:
00630             firstIndex = None
00631             
00632         if firstIndex != None:
00633             
00634             firstIndex = int(firstIndex)
00635 
00636             # print data
00637             title = "Diagram \"Frequency - Time\" - Date %s" % self.search_label[firstIndex][1]
00638             
00639             field = []
00640             field_label = []
00641             data_new = []
00642             for i in range(len(self._data)):
00643                 if self._data[i]['messages.m_date'] == self.search_label[firstIndex][1] and int(self._the_error) == int(self._data[i]['error.e_number']):
00644                     
00645                     data_new.append(self._data[i])
00646                     hour = self._data[i]['messages.m_time'].split(":")
00647 
00648                     hour[0] = int(hour[0])# hour
00649                    
00650                     index = find_item(hour[0], field)
00651                     if (None == index):
00652                         field.append([hour[0], 1])
00653                         field_label.append([hour[0], 1])
00654                     else:
00655                         count = field[index][1]
00656                         count += 1
00657                         field[index][1] = count
00658                         field_label[index][1] = count
00659         
00660             field.sort()
00661             field_label.sort()
00662             
00663             # rearrange arrays for use within the picture and graph class
00664             for i in range(len(field_label)):
00665                 temp = field_label[i][0]
00666                 field_label[i][0] = field_label[i][1]
00667                 field_label[i][1] = temp
00668             
00669             for i in range(len(field)):
00670                 field_label[i][0] = (i+1)
00671                 field_label[i][1] = "%s" % field[i][0]
00672                 field[i][0] = (i+1)
00673                     
00674             field_label, field = complete_hours(field_label, field)
00675             field_label, field = complete_ticks(field_label, field)
00676            
00677             h_line = "-------------------------------"
00678             v_line = "|"
00679             header = "\nFrequency on Date \"%s\":\n" % self.search_label[firstIndex][1]
00680             
00681             # write in file
00682             if self._file_fd != None:
00683                 content = "\n"+header
00684                 content += "\n\n Time of Day\t| Frequency\n\n"
00685                 self._file_fd.write(content)            
00686             
00687             if self._col == 1:
00688                 col_obj = Colour()
00689                 print col_obj.yellow(header)
00690                 h_line = col_obj.yellow(h_line)
00691                 v_line = col_obj.yellow(v_line)
00692                 
00693             print h_line
00694             print " Time of Day\t"+v_line+" Frequency"
00695             print h_line
00696             
00697             for i in range(len(field)):
00698                 print " %2s h - %2s h\t%s %s" % (i, i+1, v_line, field[i][1])
00699                 
00700                 if self._file_fd != None:
00701                     content = " %2s h - %2s h\t| %s\n" % (i , i+1, field[i][1])
00702                     self._file_fd.write(content)                 
00703                 
00704             print h_line           
00705             
00706             pic_obj = Picture(self._col, self._all_windows)
00707             self._windows.append(pic_obj)
00708 
00709             pic_obj.show_line(title, field, field_label, "TIME OF DAY (hrs)", "FREQUENCY", data_new , select_type = "time", labelamount=24, filus_fd = self._file_fd, descript = title  )
00710             pic_obj.mainloop()
00711         
00712         else:
00713             
00714             for i in range(len(self._all_windows)):
00715                 self._all_windows[i].deactivate()
00716             tkMessageBox.showerror("Error", "No item selected !")
00717             for i in range(len(self._all_windows)):
00718                 self._all_windows[i].activate()
00719             
00720         
00721     def _show_description(self, event):
00722         '''
00723         This function displays the description for the listbox in the status bar.
00724         '''
00725         if self._select_type == 'error':
00726             self.status.config(text = "listbox: error number (frequency) -> select error to zoom", anchor = "w")
00727         if self._select_type == 'date':
00728             self.status.config(text = "listbox: date (frequency) for the choosen error -> select date to zoom", anchor = "w")
00729         self.status.update_idletasks()
00730     
00731     def _show_plot_description(self, event):
00732         '''
00733         This function displays the description of the "plot" button in the status bar.
00734         '''
00735         self.status.config(text = "plot new diagram", anchor = "w")
00736         self.status.update_idletasks()        
00737 
00738     def _hide_description(self, event):
00739         '''
00740         This function deletes the status bar content.
00741         '''
00742         self.status.config(text="")
00743         self.status.update_idletasks()
00744         
00745     def _show_save_as_description(self, event):
00746         '''
00747         This function show the description of the "save as" button in the status bar.
00748         '''
00749         self.status.config(text = "save diagram as postscript file", anchor = "w")
00750         self.status.update_idletasks()
00751         
00752     def _show_dropdown_description(self, event):
00753         '''
00754         This function shows a short description for the dropdown menu in the status bar.
00755         '''
00756         
00757         self.status.config(text = self._dropdown_description, anchor = "w")
00758         self.status.update_idletasks()
00759         

Generated on Sun Mar 5 23:04:01 2006 for Virtualiser by  doxygen 1.4.6-NO