Example #1
0
def restore_directory_setting( self, parent ):
   # restore the directory name
   self.textv_opt9.set('Directory')

   # Restore the icons
   self.canvas_homeicon.pack( side='left', after=self.opt9, fill=Tkinter.BOTH, padx=5 )
   self.canvas_openicon.pack( side='left', after=self.canvas_homeicon, fill=Tkinter.BOTH, padx=5 )
   self.canvas_portalicon.pack( side='left', after=self.canvas_openicon, fill=Tkinter.BOTH, padx=5 )
   self.canvas_bookicon.pack( side='left', fill=Tkinter.BOTH, padx=5 )
   self.canvas_cycleicon.pack( side='left', fill=Tkinter.BOTH, padx=5 )

   gui_control.directory_or_database = 'directory'
   #
   parent.balloon.bind(parent.panelSV.tin2._arrowBtn,'View and Select Directories')        
   parent.balloon.bind(parent.panelSV.tin3._arrowBtn,'View and Select Files in Directory')
   parent.balloon.bind(parent.panelSV.tin4._arrowBtn, 'View and Select Variables in File')
   #
   parent.panelSV.textv_lab3.set("File:        " )
   #
   d,f = gui_functions._scn_a_dir( parent )
   #
   parent.panelSV.tin2.clear( )        # clear "directory" combo box entry and list
   parent.panelSV.tin2.setentry(  os.getcwd() ) # re-write directory information
   for i in range(len(d)): parent.panelSV.tin2.insert( i, d[i] )
   parent.panelSV.tin3.clear( )        # clear "directory" combo box entry and list
   for i in range(len(f)): parent.panelSV.tin3.insert( i, f[i] )
   parent.panelSV.tin4.clear( )        # clear "directory" combo box entry and list
   gui_functions._blank_dim1_to_ndim( parent )
def restore_directory_setting(self, parent):
    # restore the directory name
    self.textv_opt9.set('Directory')

    # Restore the icons
    self.canvas_homeicon.pack(side='left',
                              after=self.opt9,
                              fill=Tkinter.BOTH,
                              padx=5)
    self.canvas_openicon.pack(side='left',
                              after=self.canvas_homeicon,
                              fill=Tkinter.BOTH,
                              padx=5)
    self.canvas_portalicon.pack(side='left',
                                after=self.canvas_openicon,
                                fill=Tkinter.BOTH,
                                padx=5)
    self.canvas_bookicon.pack(side='left', fill=Tkinter.BOTH, padx=5)
    self.canvas_cycleicon.pack(side='left', fill=Tkinter.BOTH, padx=5)

    gui_control.directory_or_database = 'directory'
    #
    parent.balloon.bind(parent.panelSV.tin2._arrowBtn,
                        'View and Select Directories')
    parent.balloon.bind(parent.panelSV.tin3._arrowBtn,
                        'View and Select Files in Directory')
    parent.balloon.bind(parent.panelSV.tin4._arrowBtn,
                        'View and Select Variables in File')
    #
    parent.panelSV.textv_lab3.set("File:        ")
    #
    d, f = gui_functions._scn_a_dir(parent)
    #
    parent.panelSV.tin2.clear()  # clear "directory" combo box entry and list
    parent.panelSV.tin2.setentry(os.getcwd())  # re-write directory information
    for i in range(len(d)):
        parent.panelSV.tin2.insert(i, d[i])
    parent.panelSV.tin3.clear()  # clear "directory" combo box entry and list
    for i in range(len(f)):
        parent.panelSV.tin3.insert(i, f[i])
    parent.panelSV.tin4.clear()  # clear "directory" combo box entry and list
    gui_functions._blank_dim1_to_ndim(parent)
Example #3
0
def evt_popup_database_gui( self, parent, event ):
   if (event == 'Database'):
      self.canvas_homeicon.pack_forget()
      self.canvas_openicon.pack_forget()
      self.canvas_portalicon.pack_forget()
      self.canvas_bookicon.pack_forget()
      self.canvas_cycleicon.pack_forget()
      gui_control.directory_or_database = 'database'
    #  parent.panelSV.textv.set( 'Databases' )
    #  parent.panelSV.textv_opt3.set( 'Datasets' )
    #  parent.panelSV.opt3.configure( menubutton_state = 'disabled' )
      #
      (host, port, path) = gui_database.get_cdms_database_info( )
      if host is not None:
         gui_database.create( parent, host, port, path )
         parent.panelSV.tin2.delete( 0, 'end' )
    #     parent.panelSV.scl1.setlist( '' )
    #     parent.panelSV.scl2.setlist( '' )
    #     parent.panelSV.scl3.setlist( '' )
         gui_functions._blank_dim1_to_ndim( parent )
      else:
         restore_directory_setting( self, parent )
   else:
      restore_directory_setting( self, parent )
def evt_popup_database_gui(self, parent, event):
    if (event == 'Database'):
        self.canvas_homeicon.pack_forget()
        self.canvas_openicon.pack_forget()
        self.canvas_portalicon.pack_forget()
        self.canvas_bookicon.pack_forget()
        self.canvas_cycleicon.pack_forget()
        gui_control.directory_or_database = 'database'
        #  parent.panelSV.textv.set( 'Databases' )
        #  parent.panelSV.textv_opt3.set( 'Datasets' )
        #  parent.panelSV.opt3.configure( menubutton_state = 'disabled' )
        #
        (host, port, path) = gui_database.get_cdms_database_info()
        if host is not None:
            gui_database.create(parent, host, port, path)
            parent.panelSV.tin2.delete(0, 'end')
            #     parent.panelSV.scl1.setlist( '' )
            #     parent.panelSV.scl2.setlist( '' )
            #     parent.panelSV.scl3.setlist( '' )
            gui_functions._blank_dim1_to_ndim(parent)
        else:
            restore_directory_setting(self, parent)
    else:
        restore_directory_setting(self, parent)
Example #5
0
   def execute(self, parent, result):
      if result == 'OK':
         if self.eny1.get( ) == '':
            pass
         else:
            a = self.eny1.get()
            # Add tilde function to entry window
            if a == '~':
              a = os.environ['HOME']
            elif a[0:2] == '~/':
              a = os.environ['HOME'] + '/' + a[2:]
            elif a[0] == '~':
              a = os.environ['HOME'] + '/' + a[1:]

            # Get the page orientation (i.e., either l='landscape', or p=portrait)
            o = 'l'
            if self.parent.panelGC.page_orientation_flg == 0: o = 'p'

            if self.type == 'p':
               self.parent.vcs[ parent.vcs_id ].postscript( a, o )
               gui_control.record_command( parent, "\n# Save VCS Canvas in Postscript File" )
               gui_control.record_command( parent, "vcs.postscript( '%s', 'r' )" % (a,) )
            elif self.type == 'e':
               self.parent.vcs[ parent.vcs_id ].eps( a, 'r', o )
               gui_control.record_command(parent,"\n# Save VCS Canvas in Encapsulated Postscript File")
               gui_control.record_command( parent, "vcs.eps( '%s', 'r')" % (a,) )
            elif self.type == 'g':
               self.parent.vcs[ parent.vcs_id ].gif( a, 'r' )
               gui_control.record_command( parent, "\n# Save VCS Canvas in GIF File" )
               gui_control.record_command( parent, "vcs.gif( '%s', 'r' )" % (a, ) )
            elif self.type == 'c':
               self.parent.vcs[ parent.vcs_id ].cgm( a, 'r' )
               gui_control.record_command( parent, "\n# Save VCS Canvas in CGM File" )
               gui_control.record_command( parent, "vcs.cgm( '%s', 'r' )" % (a,) )
            elif self.type == 'd':
               if ((a == '') or (a == ' ') or
                  (a is None)):
                  self.parent.new_defined_var = None
               else:
                  self.parent.new_defined_var = a
            elif self.type == 'operation':
               try:
                  parent.ret_val = string.atof( self.eny1.get() )
               except:
                  gui_message.error("Not a floating point value.")
                  parent.ret_val = None
            elif self.type == 't':
               self.parent.vcs[ parent.vcs_id ].printer( a, o )
               gui_control.record_command(parent,"\n# Send VCS Canvas to %s Printer" % a )
               gui_control.record_command( parent, "vcs.printer( '%s', '%s' )" % (a, o) )
            elif self.type == 's':
               search_pattern = a
               parent.file_search_pattern =  search_pattern
               #  	re-write the new directory information and save directory list
               d,f = gui_functions._scn_a_dir( parent )
               #parent.panelDM.scl1.setlist( d )
               parent.panelDM.lst1 = d
               #  	display the data files in the directory
#               parent.panelDM.scl2.setlist( f )
               for i in range(len(f)): parent.panelSV.tin3.insert( i, f[i] )
               parent.panelDM.lst2 = f
               #
               parent.panelDM.fid2 = None
               parent.panelDM.var3 = parent.panelDM.remember_var3 = None
               #
#               parent.panelDM.scl3.setlist( () )
               #
               gui_functions._blank_dim1_to_ndim( parent )
            elif self.type == 'ss':
               parent.swap_size = string.atof( a ) * 1000000.
            elif self.type == 'tt':
                 if a not in parent.vcs[ parent.vcs_id ].listelements( 'template' ):
                    gui_message.error( 'Could not find the template name ( %s ) in the template list. Please check the template list to make sure it exist.' % a )
                    return
                 parent.template_name =  a
            elif self.type == 'gm':
                 parent.graphics_method_name = a
            elif self.type in ['template_rename', 'template_copy', 'template_remove', 'template_save_as']:
               new_t_name = a
               if ( (len(new_t_name) < 1) or (self.entry_str == new_t_name) ):
                  self.dialog.destroy()
                  return              			# do nothing
               try:
                  vcs = self.parent.vcs[ parent.vcs_id ]
                  if self.type == 'template_rename':
                     vcs.canvas.renameP(self.entry_str, new_t_name)
                  elif self.type == 'template_copy':
                     vcs.canvas.copyP(self.entry_str, new_t_name)
                  elif self.type == 'template_remove':
                     vcs.canvas.removeP(self.entry_str)
                  elif self.type == 'template_save_as':
                     if new_t_name[-4:] != ".scr": new_t_name += ".scr"
                     vcs.canvas.scriptP( self.entry_str, new_t_name, 'w' )
                  self.update_widget.setlist( vcs.listelements('template') )
               except:
                  gui_message.error( 'Cannot rename template (P_%s). Check to make sure that the old name exist in the template list and that the new name does not.' % self.entry_str )

            elif self.type in ['gm_rename', 'gm_copy', 'gm_remove', 'gm_save_as']:
               new_gm_name = a
               gm_type = string.lower( self.gm_type )
               if ( (len(new_gm_name) < 1) or (self.entry_str == new_gm_name) ):
                  self.dialog.destroy()
                  return              			# do nothing
               try:
                  vcs = self.parent.vcs[ parent.vcs_id ]
                  if self.type == 'gm_rename':
                     if gm_type == 'boxfill': vcs.canvas.renameGfb(self.entry_str, new_gm_name)
                     elif gm_type == 'continents': vcs.canvas.renameGcon(self.entry_str, new_gm_name)
                     elif gm_type == 'isofill': vcs.canvas.renameGfi(self.entry_str, new_gm_name)
                     elif gm_type == 'isoline': vcs.canvas.renameGi(self.entry_str, new_gm_name)
                     elif gm_type == 'outfill': vcs.canvas.renameGfo(self.entry_str, new_gm_name)
                     elif gm_type == 'outline': vcs.canvas.renameGo(self.entry_str, new_gm_name)
                     elif gm_type == 'scatter': vcs.canvas.renameGSp(self.entry_str, new_gm_name)
                     elif gm_type == 'taylordiagrams': vcs.canvas.renameGtd(self.entry_str, new_gm_name)
                     elif gm_type == 'vector': vcs.canvas.renameGv(self.entry_str, new_gm_name)
                     elif gm_type == 'xvsy': vcs.canvas.renameGXY(self.entry_str, new_gm_name)
                     elif gm_type == 'xyvsy': vcs.canvas.renameGXy(self.entry_str, new_gm_name)
                     elif gm_type == 'yxvsx': vcs.canvas.renameGYx(self.entry_str, new_gm_name)
                  elif self.type == 'gm_copy':
                     if gm_type == 'boxfill': vcs.canvas.copyGfb( self.entry_str, new_gm_name)
                     elif gm_type == 'continents': vcs.canvas.copyGcon( self.entry_str, new_gm_name)
                     elif gm_type == 'isofill': vcs.canvas.copyGfi( self.entry_str, new_gm_name)
                     elif gm_type == 'isoline': vcs.canvas.copyGfi( self.entry_str, new_gm_name)
                     elif gm_type == 'outfill': vcs.canvas.copyGfo( self.entry_str, new_gm_name)
                     elif gm_type == 'outline': vcs.canvas.copyGo( self.entry_str, new_gm_name)
                     elif gm_type == 'scatter': vcs.canvas.copyGSp( self.entry_str, new_gm_name)
                     elif gm_type == 'taylordiagrams': vcs.canvas.copyGtd( self.entry_str, new_gm_name)
                     elif gm_type == 'vector': vcs.canvas.copyGv( self.entry_str, new_gm_name)
                     elif gm_type == 'xvsy': vcs.canvas.copyGXY( self.entry_str, new_gm_name)
                     elif gm_type == 'xyvsy': vcs.canvas.copyGXy( self.entry_str, new_gm_name)
                     elif gm_type == 'yxvsx': vcs.canvas.copyGYx( self.entry_str, new_gm_name)
                  elif self.type == 'gm_save_as':
                     if new_gm_name[-4:] != ".scr": new_gm_name += ".scr"
                     if gm_type == 'boxfill': vcs.canvas.scriptGfb( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'continents': vcs.canvas.scriptGcon( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'isofill': vcs.canvas.scriptGfi( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'isoline': vcs.canvas.scriptGi( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'outfill': vcs.canvas.scriptGfo( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'outline': vcs.canvas.scriptGo( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'scatter': vcs.canvas.scriptGSp( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'taylordiagrams': vcs.canvas.scriptGtd( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'vector': vcs.canvas.scriptGv( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'xvsy': vcs.canvas.scriptXY( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'xyvsy': vcs.canvas.scriptXy( self.entry_str, new_gm_name, 'w' )
                     elif gm_type == 'yxvsx': vcs.canvas.scriptYx( self.entry_str, new_gm_name, 'w' )
                  self.update_widget.setlist( vcs.listelements(gm_type) )
               except:
                  gui_message.error( 'Cannot rename %s graphics method (%s). Check to make sure that the old name exist in the %s list and that the new name does not.' % (self.gm_type, self.entry_str, self.gm_type) )
         
      self.dialog.destroy()
Example #6
0
    def execute(self, parent, result):
        if result == 'OK':
            if self.eny1.get() == '':
                pass
            else:
                a = self.eny1.get()
                # Add tilde function to entry window
                if a == '~':
                    a = os.environ['HOME']
                elif a[0:2] == '~/':
                    a = os.environ['HOME'] + '/' + a[2:]
                elif a[0] == '~':
                    a = os.environ['HOME'] + '/' + a[1:]

                # Get the page orientation (i.e., either l='landscape', or p=portrait)
                o = 'l'
                if self.parent.panelGC.page_orientation_flg == 0: o = 'p'

                if self.type == 'p':
                    self.parent.vcs[parent.vcs_id].postscript(a, o)
                    gui_control.record_command(
                        parent, "\n# Save VCS Canvas in Postscript File")
                    gui_control.record_command(
                        parent, "vcs.postscript( '%s', 'r' )" % (a, ))
                elif self.type == 'e':
                    self.parent.vcs[parent.vcs_id].eps(a, 'r', o)
                    gui_control.record_command(
                        parent,
                        "\n# Save VCS Canvas in Encapsulated Postscript File")
                    gui_control.record_command(parent,
                                               "vcs.eps( '%s', 'r')" % (a, ))
                elif self.type == 'g':
                    self.parent.vcs[parent.vcs_id].gif(a, 'r')
                    gui_control.record_command(
                        parent, "\n# Save VCS Canvas in GIF File")
                    gui_control.record_command(parent,
                                               "vcs.gif( '%s', 'r' )" % (a, ))
                elif self.type == 'c':
                    self.parent.vcs[parent.vcs_id].cgm(a, 'r')
                    gui_control.record_command(
                        parent, "\n# Save VCS Canvas in CGM File")
                    gui_control.record_command(parent,
                                               "vcs.cgm( '%s', 'r' )" % (a, ))
                elif self.type == 'd':
                    if ((a == '') or (a == ' ') or (a is None)):
                        self.parent.new_defined_var = None
                    else:
                        self.parent.new_defined_var = a
                elif self.type == 'operation':
                    try:
                        parent.ret_val = string.atof(self.eny1.get())
                    except:
                        gui_message.error("Not a floating point value.")
                        parent.ret_val = None
                elif self.type == 't':
                    self.parent.vcs[parent.vcs_id].printer(a, o)
                    gui_control.record_command(
                        parent, "\n# Send VCS Canvas to %s Printer" % a)
                    gui_control.record_command(
                        parent, "vcs.printer( '%s', '%s' )" % (a, o))
                elif self.type == 's':
                    search_pattern = a
                    parent.file_search_pattern = search_pattern
                    #  	re-write the new directory information and save directory list
                    d, f = gui_functions._scn_a_dir(parent)
                    #parent.panelDM.scl1.setlist( d )
                    parent.panelDM.lst1 = d
                    #  	display the data files in the directory
                    #               parent.panelDM.scl2.setlist( f )
                    for i in range(len(f)):
                        parent.panelSV.tin3.insert(i, f[i])
                    parent.panelDM.lst2 = f
                    #
                    parent.panelDM.fid2 = None
                    parent.panelDM.var3 = parent.panelDM.remember_var3 = None
                    #
                    #               parent.panelDM.scl3.setlist( () )
                    #
                    gui_functions._blank_dim1_to_ndim(parent)
                elif self.type == 'ss':
                    parent.swap_size = string.atof(a) * 1000000.
                elif self.type == 'tt':
                    if a not in parent.vcs[parent.vcs_id].listelements(
                            'template'):
                        gui_message.error(
                            'Could not find the template name ( %s ) in the template list. Please check the template list to make sure it exist.'
                            % a)
                        return
                    parent.template_name = a
                elif self.type == 'gm':
                    parent.graphics_method_name = a
                elif self.type in [
                        'template_rename', 'template_copy', 'template_remove',
                        'template_save_as'
                ]:
                    new_t_name = a
                    if ((len(new_t_name) < 1)
                            or (self.entry_str == new_t_name)):
                        self.dialog.destroy()
                        return  # do nothing
                    try:
                        vcs = self.parent.vcs[parent.vcs_id]
                        if self.type == 'template_rename':
                            vcs.canvas.renameP(self.entry_str, new_t_name)
                        elif self.type == 'template_copy':
                            vcs.canvas.copyP(self.entry_str, new_t_name)
                        elif self.type == 'template_remove':
                            vcs.canvas.removeP(self.entry_str)
                        elif self.type == 'template_save_as':
                            if new_t_name[-4:] != ".scr": new_t_name += ".scr"
                            vcs.canvas.scriptP(self.entry_str, new_t_name, 'w')
                        self.update_widget.setlist(
                            vcs.listelements('template'))
                    except:
                        gui_message.error(
                            'Cannot rename template (P_%s). Check to make sure that the old name exist in the template list and that the new name does not.'
                            % self.entry_str)

                elif self.type in [
                        'gm_rename', 'gm_copy', 'gm_remove', 'gm_save_as'
                ]:
                    new_gm_name = a
                    gm_type = string.lower(self.gm_type)
                    if ((len(new_gm_name) < 1)
                            or (self.entry_str == new_gm_name)):
                        self.dialog.destroy()
                        return  # do nothing
                    try:
                        vcs = self.parent.vcs[parent.vcs_id]
                        if self.type == 'gm_rename':
                            if gm_type == 'boxfill':
                                vcs.canvas.renameGfb(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'continents':
                                vcs.canvas.renameGcon(self.entry_str,
                                                      new_gm_name)
                            elif gm_type == 'isofill':
                                vcs.canvas.renameGfi(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'isoline':
                                vcs.canvas.renameGi(self.entry_str,
                                                    new_gm_name)
                            elif gm_type == 'outfill':
                                vcs.canvas.renameGfo(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'outline':
                                vcs.canvas.renameGo(self.entry_str,
                                                    new_gm_name)
                            elif gm_type == 'scatter':
                                vcs.canvas.renameGSp(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'taylordiagrams':
                                vcs.canvas.renameGtd(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'vector':
                                vcs.canvas.renameGv(self.entry_str,
                                                    new_gm_name)
                            elif gm_type == 'xvsy':
                                vcs.canvas.renameGXY(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'xyvsy':
                                vcs.canvas.renameGXy(self.entry_str,
                                                     new_gm_name)
                            elif gm_type == 'yxvsx':
                                vcs.canvas.renameGYx(self.entry_str,
                                                     new_gm_name)
                        elif self.type == 'gm_copy':
                            if gm_type == 'boxfill':
                                vcs.canvas.copyGfb(self.entry_str, new_gm_name)
                            elif gm_type == 'continents':
                                vcs.canvas.copyGcon(self.entry_str,
                                                    new_gm_name)
                            elif gm_type == 'isofill':
                                vcs.canvas.copyGfi(self.entry_str, new_gm_name)
                            elif gm_type == 'isoline':
                                vcs.canvas.copyGfi(self.entry_str, new_gm_name)
                            elif gm_type == 'outfill':
                                vcs.canvas.copyGfo(self.entry_str, new_gm_name)
                            elif gm_type == 'outline':
                                vcs.canvas.copyGo(self.entry_str, new_gm_name)
                            elif gm_type == 'scatter':
                                vcs.canvas.copyGSp(self.entry_str, new_gm_name)
                            elif gm_type == 'taylordiagrams':
                                vcs.canvas.copyGtd(self.entry_str, new_gm_name)
                            elif gm_type == 'vector':
                                vcs.canvas.copyGv(self.entry_str, new_gm_name)
                            elif gm_type == 'xvsy':
                                vcs.canvas.copyGXY(self.entry_str, new_gm_name)
                            elif gm_type == 'xyvsy':
                                vcs.canvas.copyGXy(self.entry_str, new_gm_name)
                            elif gm_type == 'yxvsx':
                                vcs.canvas.copyGYx(self.entry_str, new_gm_name)
                        elif self.type == 'gm_save_as':
                            if new_gm_name[-4:] != ".scr":
                                new_gm_name += ".scr"
                            if gm_type == 'boxfill':
                                vcs.canvas.scriptGfb(self.entry_str,
                                                     new_gm_name, 'w')
                            elif gm_type == 'continents':
                                vcs.canvas.scriptGcon(self.entry_str,
                                                      new_gm_name, 'w')
                            elif gm_type == 'isofill':
                                vcs.canvas.scriptGfi(self.entry_str,
                                                     new_gm_name, 'w')
                            elif gm_type == 'isoline':
                                vcs.canvas.scriptGi(self.entry_str,
                                                    new_gm_name, 'w')
                            elif gm_type == 'outfill':
                                vcs.canvas.scriptGfo(self.entry_str,
                                                     new_gm_name, 'w')
                            elif gm_type == 'outline':
                                vcs.canvas.scriptGo(self.entry_str,
                                                    new_gm_name, 'w')
                            elif gm_type == 'scatter':
                                vcs.canvas.scriptGSp(self.entry_str,
                                                     new_gm_name, 'w')
                            elif gm_type == 'taylordiagrams':
                                vcs.canvas.scriptGtd(self.entry_str,
                                                     new_gm_name, 'w')
                            elif gm_type == 'vector':
                                vcs.canvas.scriptGv(self.entry_str,
                                                    new_gm_name, 'w')
                            elif gm_type == 'xvsy':
                                vcs.canvas.scriptXY(self.entry_str,
                                                    new_gm_name, 'w')
                            elif gm_type == 'xyvsy':
                                vcs.canvas.scriptXy(self.entry_str,
                                                    new_gm_name, 'w')
                            elif gm_type == 'yxvsx':
                                vcs.canvas.scriptYx(self.entry_str,
                                                    new_gm_name, 'w')
                        self.update_widget.setlist(vcs.listelements(gm_type))
                    except:
                        gui_message.error(
                            'Cannot rename %s graphics method (%s). Check to make sure that the old name exist in the %s list and that the new name does not.'
                            % (self.gm_type, self.entry_str, self.gm_type))

        self.dialog.destroy()
Example #7
0
       __main__.__dict__['vcs_hook3'] = root.vcs[2] # IDLE's connection to VCS
       __main__.__dict__['vcs_hook4'] = root.vcs[3] # IDLE's connection to VCS
 
 #---------------------------------------------------------------------
 # Create the 'Graphics Control' panel (ie. 2nd under the menu bar)
 #---------------------------------------------------------------------
    root.panelGC = gui_graphics_control.create( root )
    if dosplashscreen == 1: counter_bar.update()
 #   print 'root.panelGC = ', dir(root.panelGC)
 
 #---------------------------------------------------------------------
 # Create the 'Dimension 1-to-ndim' panel (ie. 3rd under the menu bar)
 #---------------------------------------------------------------------
    root.panelDM = gui_dimensions.create( root )
    root.panelDM.var3 = None
    gui_functions._blank_dim1_to_ndim( root ) # Don't show the dimension scroll windows
    if dosplashscreen == 1: counter_bar.update()
 #   print 'root.panelDM = ', dir(root.panelDM)
 #   print 'root.panelDM.dim[0] = ', dir(root.panelDM.dim[0])
 
 #---------------------------------------------------------------------
 # Create the 'Defined Variables' panel (ie. 4th under the menu bar)
 #---------------------------------------------------------------------
    root.panelDV = gui_defined_variables.create( root )
    gui_graphics_control.show_and_unshow_graphics_options( root ) # disable menu items
    if dosplashscreen == 1: counter_bar.update()
 #   print 'root.panelDV = ', dir(root.panelDV)
 
 #--------------------------------------------------------------------------------------------
 # Create the 'Variable Information' and 'Page Layout' panel (ie. 4th under the menu bar)
 #--------------------------------------------------------------------------------------------
Example #8
0
def evt_enter_variable( parent, event ):
   a = b = parent.panelSV.tin4.get()
   parent.panelSV.lab1.configure(text = "Select Variable")
   if a.find('- [') != -1:
      a=a[:a.find('- [')]
   if a.find('(') !=-1:
      a = a[:a.rfind('(')-1]
   parent.panelSV.tin4.setentry( a )
   if parent.startusertask == 1: gui_control.track_user( parent, "Variable: %s" % a)
   #
   if ( (a[17:] in ['Variable List *************']) or (a in ['******** Bounds and Weights List ******', '*************** Axes List **************']) ):
     parent.panelSV.tin4.setentry( '' )
     gui_functions._blank_dim1_to_ndim( parent )
     parent.panelDM.var3 = parent.panelDM.remember_var3 = None
     return
   parent.panelDM.var3 = parent.panelDM.remember_var3 = a
   #
   parent.panelSV.tin4.first_time = 0
   #
   var_list = parent.panelSV.tin4._list.get(None)
   found = 0
   for j in range(len(var_list)):
      n = len(a)
      if a+' '==var_list[j][:n+1]:
         found = 1
         break
##          if var_list[j].find('(') == -1:
##             if a == var_list[j]: 
##                found = 1
##                break
##          else:
##             if a == var_list[j][:var_list[j].find('(')-1]: 
##                found = 1
##                break
##          j = j + 1
   if found == 0:
      gui_message.error('Variable [ ++%s++ ] cannot be found in the file.' % a)
      parent.panelSV.tin4.setentry( '' )
      gui_functions._blank_dim1_to_ndim( parent )
      parent.panelDM.var3 = parent.panelDM.remember_var3 = None
      return
   #
   parent.panelVI.lst1 = gui_functions._scn_a_var( parent, a )
   parent.panelVI.scl1.settext( parent.panelVI.lst1 )

   # Blank the dimension's window
   gui_functions._blank_dim1_to_ndim( parent )

   # Reset selection counters back to initial state, (e.g., '00 ')
   if parent.panelDV.lst1 != {}:
      for x in parent.panelDV.lst1.keys():
          parent.panelDV.number_lst1[ x ] = gui_control.dvholder + x
      gui_defined_variables.update_defined_variable_list( parent )

   gui_functions._srl_var_dim1_to_ndim( parent )
   for k in range(parent.panelDM.ndim):
      parent.panelDM.dim[k].comb.component('entry').configure(background = gui_color.dim )
      parent.panelDM.dim[k].first_scl.configure( troughcolor=gui_color.dim )
      parent.panelDM.dim[k].last_scl.configure( troughcolor=gui_color.dim )
   #
   parent.panelDV.scl1.select_clear( 0, 'end' )
   parent.panelDV.selected_list = {}
   #
   parent.panelSV.lab1.configure(text = "Selected Variable -- %s" % b)
Example #9
0
def evt_enter_file( parent, event ):
   a = parent.panelSV.tin3.get()

   # Must close some files (like DRS) before you can open it again
   try: parent.panelDM.fid2.close()
   except: pass
   
   if parent.startusertask == 1: gui_control.track_user( parent, "File: %s" % a)
   if gui_control.directory_or_database == 'directory':
      if a[:7]!="http://":
         d,f = gui_functions._scn_a_dir( parent )     # re-write the new directory information and save directory list
         #
         parent.panelSV.tin3.first_time = 0
         #
         found = 0
         for i in range(len(f)):
            if (f[i] == a):
               try:
                  parent.panelDM.fid2 = cdms2.open( a ) 
                  #
                  # record the event: select a file to be opened
                  gui_control.record_command( parent, '\n# Open CDMS File', 1 )
                  command = "fid2 = cdms2.open( '%s/%s' )" % (os.getcwd(), a)
                  gui_control.record_command( parent, command, 1 )
                  found = 1
               except:
                  found = 0
                  gui_message.error('Cannot open data file [%s].' % a)
                  return
               gui_functions._srl_file_var( parent )
               gui_functions._blank_dim1_to_ndim( parent )
               break
         if found == 0:
             gui_message.error("Invalid file name.")
         else:
            if ( (parent.panelSV.tin4.first_time != 1) and
                 (parent.panelDM.lst3 != []) and
                 (len(parent.panelDM.lst3[0]) > 0) ):
               pass
               #parent.panelSV.tin4.setentry( parent.panelDM.lst3[0] )
               #evt_enter_variable( parent, None )
      else:
         try:
            parent.panelDM.fid2 = cdms2.open( a ) 
            #
            # record the event: select a file to be opened
            gui_control.record_command( parent, '\n# Open CDMS File', 1 )
            command = "fid2 = cdms2.open( '%s' )" % (a)
            gui_control.record_command( parent, command, 1 )
         except:
            import cdat_info
            if cdat_info.CDMS_INCLUDE_DAP=='yes':
               gui_message.error('Cannot open data file [%s].' % a)
               return
            else:
               gui_message.error('Your version of CDAT is not built with DAP support !')
               return
         gui_functions._srl_file_var( parent )
         gui_functions._blank_dim1_to_ndim( parent )
            
   else:
      f = parent.panelSV.tin3.ds_list
      found = 0
      for i in range(len(f)):
         if (f[i] == a):
            try:
               parent.panelDM.fid2 = parent.panelDM.lst2 = gui_control.db.open( a ) 
            except:
               gui_message.error('Cannot open database file [%s].' % a)
            #parent.panelDM.lst2 = parent.panelDM.fid2
            gui_functions._srl_file_var( parent )
            gui_functions._blank_dim1_to_ndim( parent )
            found = 1
            break
      if found == 0:
         gui_message.error("Invalid file name.")
Example #10
0
def evt_enter_directory( parent, event, who_called=0 ):
   # change backgound color to white
   parent.panelSV.tin2.configure( entry_background = 'white' )
   #
   Match_found = None
   if gui_control.directory_or_database == 'directory':
      if type(event) == types.StringType:
            if event[0] == '/':
               a = event
            elif event[0:5] == '=====':
               a = os.getcwd()
            else:
               a = os.getcwd() + '/' + event
      else:
         a = parent.panelSV.tin2.get()
         # Add tilde function to entry window
         if a == '~':
           a = os.environ['HOME']
         elif a[0:2] == '~/':
           a = os.environ['HOME'] + '/' + a[2:]
         elif a[0] == '~':
           a = os.environ['HOME'] + '/' + a[1:]
         a = a + '/'
      try:
         os.chdir( a )
      except:
         gui_message.error(('Cannot access directory [ %s ].' % a))
      a=a[0:-1]

      if parent.startusertask == 1: gui_control.track_user( parent, "Directory: %s" % a)

      parent.panelSV.tin2.clear( )		# clear "directory" combo box entry and list
      if parent.panelSV.tin3.first_time == 1:
         parent.panelSV.tin3.delete(0, 'end')	# clear only the "file" combo box list
      else:
         parent.panelSV.tin3.clear( )	        # clear "file" combo box entry and list
      if parent.panelSV.tin4.first_time == 1:
         parent.panelSV.tin4.delete(0, 'end')	# clear only the "variable" combo box list
      else:
         parent.panelSV.tin4.clear( )	        # clear "variable" combo box entry and list
      #
      if who_called != 1:
         t = os.getcwd()
      else:
         t = os.getcwd() + ' '
      parent.panelSV.tin2._entryfield.setentry( t )
      #
      d,f = gui_functions._scn_a_dir( parent )        # re-write the new directory information and save directory list
      gui_functions._scn_dir_history( parent, t )      # store access directory information to the history directory list
      for j in range(len( parent.dir_history )): parent.panelSV.tin2.insert( j, parent.dir_history[j] )
      for i in range(len(d)): parent.panelSV.tin2.insert( j+i+1, d[i] )
      #
      for i in range(len(f)): parent.panelSV.tin3.insert( i, f[i] )
      #
      parent.panelDM.fid2 = None
      parent.panelDM.var3 = parent.panelDM.remember_var3 = None
      #
      gui_functions._blank_dim1_to_ndim( parent )
      #
      if (parent.panelSV.tin3.first_time != 1) and (len(f) > 0):
         parent.panelSV.tin3.setentry( f[0] )
         evt_enter_file( parent, None )
      #
      # record the event: select a directory
      command = "os.chdir( '%s' )" % os.getcwd()
      gui_control.record_command( parent, command )
   elif gui_control.directory_or_database == 'database':
      if event.keysym == 'Return':
         try:
            parent.parent.update()
            g_wait = gui_message.wait(parent.parent,'Please wait while the connection\n to the database is made.')
            gui_control.db=cdms2.connect( parent.parent.tin2.get() )
            parent.parent.update()
            g_wait.progress()
            for x in gui_control.db_connections:
               Match_found = re.match( parent.parent.tin2.get(), x )
               if Match_found: break
            if not Match_found:
               gui_control.db_connections.append( parent.parent.tin2.get() )
            parent.parent.panelC.scl1.setlist( gui_control.db_connections )
            db_list = gui_control.db.listDatasets()
            db_list.sort()
            parent.parent.panelC.scl2.setlist( db_list )
            parent.parent.panelC.scl3.setlist( '' )
            gui_functions._blank_dim1_to_ndim( parent )
            g_wait.execute()
         except:
            g_wait.execute()
            gui_message.error("Invalid database string.\nCould not connect to specified database.")
def evt_enter_variable(parent, event):
    a = b = parent.panelSV.tin4.get()
    parent.panelSV.lab1.configure(text="Select Variable")
    if a.find('- [') != -1:
        a = a[:a.find('- [')]
    if a.find('(') != -1:
        a = a[:a.rfind('(') - 1]
    parent.panelSV.tin4.setentry(a)
    if parent.startusertask == 1:
        gui_control.track_user(parent, "Variable: %s" % a)
    #
    if ((a[17:] in ['Variable List *************']) or (a in [
            '******** Bounds and Weights List ******',
            '*************** Axes List **************'
    ])):
        parent.panelSV.tin4.setentry('')
        gui_functions._blank_dim1_to_ndim(parent)
        parent.panelDM.var3 = parent.panelDM.remember_var3 = None
        return
    parent.panelDM.var3 = parent.panelDM.remember_var3 = a
    #
    parent.panelSV.tin4.first_time = 0
    #
    var_list = parent.panelSV.tin4._list.get(None)
    found = 0
    for j in range(len(var_list)):
        n = len(a)
        if a + ' ' == var_list[j][:n + 1]:
            found = 1
            break
##          if var_list[j].find('(') == -1:
##             if a == var_list[j]:
##                found = 1
##                break
##          else:
##             if a == var_list[j][:var_list[j].find('(')-1]:
##                found = 1
##                break
##          j = j + 1
    if found == 0:
        gui_message.error('Variable [ ++%s++ ] cannot be found in the file.' %
                          a)
        parent.panelSV.tin4.setentry('')
        gui_functions._blank_dim1_to_ndim(parent)
        parent.panelDM.var3 = parent.panelDM.remember_var3 = None
        return
    #
    parent.panelVI.lst1 = gui_functions._scn_a_var(parent, a)
    parent.panelVI.scl1.settext(parent.panelVI.lst1)

    # Blank the dimension's window
    gui_functions._blank_dim1_to_ndim(parent)

    # Reset selection counters back to initial state, (e.g., '00 ')
    if parent.panelDV.lst1 != {}:
        for x in parent.panelDV.lst1.keys():
            parent.panelDV.number_lst1[x] = gui_control.dvholder + x
        gui_defined_variables.update_defined_variable_list(parent)

    gui_functions._srl_var_dim1_to_ndim(parent)
    for k in range(parent.panelDM.ndim):
        parent.panelDM.dim[k].comb.component('entry').configure(
            background=gui_color.dim)
        parent.panelDM.dim[k].first_scl.configure(troughcolor=gui_color.dim)
        parent.panelDM.dim[k].last_scl.configure(troughcolor=gui_color.dim)
    #
    parent.panelDV.scl1.select_clear(0, 'end')
    parent.panelDV.selected_list = {}
    #
    parent.panelSV.lab1.configure(text="Selected Variable -- %s" % b)
def evt_enter_file(parent, event):
    a = parent.panelSV.tin3.get()

    # Must close some files (like DRS) before you can open it again
    try:
        parent.panelDM.fid2.close()
    except:
        pass

    if parent.startusertask == 1:
        gui_control.track_user(parent, "File: %s" % a)
    if gui_control.directory_or_database == 'directory':
        if a[:7] != "http://":
            d, f = gui_functions._scn_a_dir(
                parent
            )  # re-write the new directory information and save directory list
            #
            parent.panelSV.tin3.first_time = 0
            #
            found = 0
            for i in range(len(f)):
                if (f[i] == a):
                    try:
                        parent.panelDM.fid2 = cdms2.open(a)
                        #
                        # record the event: select a file to be opened
                        gui_control.record_command(parent,
                                                   '\n# Open CDMS File', 1)
                        command = "fid2 = cdms2.open( '%s/%s' )" % (
                            os.getcwd(), a)
                        gui_control.record_command(parent, command, 1)
                        found = 1
                    except:
                        found = 0
                        gui_message.error('Cannot open data file [%s].' % a)
                        return
                    gui_functions._srl_file_var(parent)
                    gui_functions._blank_dim1_to_ndim(parent)
                    break
            if found == 0:
                gui_message.error("Invalid file name.")
            else:
                if ((parent.panelSV.tin4.first_time != 1)
                        and (parent.panelDM.lst3 != [])
                        and (len(parent.panelDM.lst3[0]) > 0)):
                    pass
                    #parent.panelSV.tin4.setentry( parent.panelDM.lst3[0] )
                    #evt_enter_variable( parent, None )
        else:
            try:
                parent.panelDM.fid2 = cdms2.open(a)
                #
                # record the event: select a file to be opened
                gui_control.record_command(parent, '\n# Open CDMS File', 1)
                command = "fid2 = cdms2.open( '%s' )" % (a)
                gui_control.record_command(parent, command, 1)
            except:
                import cdat_info
                if cdat_info.CDMS_INCLUDE_DAP == 'yes':
                    gui_message.error('Cannot open data file [%s].' % a)
                    return
                else:
                    gui_message.error(
                        'Your version of CDAT is not built with DAP support !')
                    return
            gui_functions._srl_file_var(parent)
            gui_functions._blank_dim1_to_ndim(parent)

    else:
        f = parent.panelSV.tin3.ds_list
        found = 0
        for i in range(len(f)):
            if (f[i] == a):
                try:
                    parent.panelDM.fid2 = parent.panelDM.lst2 = gui_control.db.open(
                        a)
                except:
                    gui_message.error('Cannot open database file [%s].' % a)
                #parent.panelDM.lst2 = parent.panelDM.fid2
                gui_functions._srl_file_var(parent)
                gui_functions._blank_dim1_to_ndim(parent)
                found = 1
                break
        if found == 0:
            gui_message.error("Invalid file name.")
def evt_enter_directory(parent, event, who_called=0):
    # change backgound color to white
    parent.panelSV.tin2.configure(entry_background='white')
    #
    Match_found = None
    if gui_control.directory_or_database == 'directory':
        if type(event) == types.StringType:
            if event[0] == '/':
                a = event
            elif event[0:5] == '=====':
                a = os.getcwd()
            else:
                a = os.getcwd() + '/' + event
        else:
            a = parent.panelSV.tin2.get()
            # Add tilde function to entry window
            if a == '~':
                a = os.environ['HOME']
            elif a[0:2] == '~/':
                a = os.environ['HOME'] + '/' + a[2:]
            elif a[0] == '~':
                a = os.environ['HOME'] + '/' + a[1:]
            a = a + '/'
        try:
            os.chdir(a)
        except:
            gui_message.error(('Cannot access directory [ %s ].' % a))
        a = a[0:-1]

        if parent.startusertask == 1:
            gui_control.track_user(parent, "Directory: %s" % a)

        parent.panelSV.tin2.clear(
        )  # clear "directory" combo box entry and list
        if parent.panelSV.tin3.first_time == 1:
            parent.panelSV.tin3.delete(
                0, 'end')  # clear only the "file" combo box list
        else:
            parent.panelSV.tin3.clear(
            )  # clear "file" combo box entry and list
        if parent.panelSV.tin4.first_time == 1:
            parent.panelSV.tin4.delete(
                0, 'end')  # clear only the "variable" combo box list
        else:
            parent.panelSV.tin4.clear(
            )  # clear "variable" combo box entry and list
        #
        if who_called != 1:
            t = os.getcwd()
        else:
            t = os.getcwd() + ' '
        parent.panelSV.tin2._entryfield.setentry(t)
        #
        d, f = gui_functions._scn_a_dir(
            parent
        )  # re-write the new directory information and save directory list
        gui_functions._scn_dir_history(
            parent, t
        )  # store access directory information to the history directory list
        for j in range(len(parent.dir_history)):
            parent.panelSV.tin2.insert(j, parent.dir_history[j])
        for i in range(len(d)):
            parent.panelSV.tin2.insert(j + i + 1, d[i])
        #
        for i in range(len(f)):
            parent.panelSV.tin3.insert(i, f[i])
        #
        parent.panelDM.fid2 = None
        parent.panelDM.var3 = parent.panelDM.remember_var3 = None
        #
        gui_functions._blank_dim1_to_ndim(parent)
        #
        if (parent.panelSV.tin3.first_time != 1) and (len(f) > 0):
            parent.panelSV.tin3.setentry(f[0])
            evt_enter_file(parent, None)
        #
        # record the event: select a directory
        command = "os.chdir( '%s' )" % os.getcwd()
        gui_control.record_command(parent, command)
    elif gui_control.directory_or_database == 'database':
        if event.keysym == 'Return':
            try:
                parent.parent.update()
                g_wait = gui_message.wait(
                    parent.parent,
                    'Please wait while the connection\n to the database is made.'
                )
                gui_control.db = cdms2.connect(parent.parent.tin2.get())
                parent.parent.update()
                g_wait.progress()
                for x in gui_control.db_connections:
                    Match_found = re.match(parent.parent.tin2.get(), x)
                    if Match_found: break
                if not Match_found:
                    gui_control.db_connections.append(parent.parent.tin2.get())
                parent.parent.panelC.scl1.setlist(gui_control.db_connections)
                db_list = gui_control.db.listDatasets()
                db_list.sort()
                parent.parent.panelC.scl2.setlist(db_list)
                parent.parent.panelC.scl3.setlist('')
                gui_functions._blank_dim1_to_ndim(parent)
                g_wait.execute()
            except:
                g_wait.execute()
                gui_message.error(
                    "Invalid database string.\nCould not connect to specified database."
                )