예제 #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 )
예제 #2
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)
예제 #3
0
파일: gui_output.py 프로젝트: AZed/uvcdat
   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()
예제 #4
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()
예제 #5
0
   def __init__( self, parent ):

      #-------------------------------------------
      # create 1st sub-panel
      #-------------------------------------------
      FRAME = Tkinter.Frame( parent.pane.pane( 'panelSV' ) )
      FRAME.pack( side='top', pady=3, fill='x', expand=1 )

      #-------------------------------------------
      # line 1
      #-------------------------------------------
      framea = Tkinter.Frame( FRAME )
      self.lab1 = Tkinter.Label( framea, text="Select Variable" )
      self.lab1.pack( )
      framea.pack( side='top', fill='x', expand=1 )

      d,f = gui_functions._scn_a_dir( parent )

      #-------------------------------------------
      # line 2
      #-------------------------------------------
      frameb = Tkinter.Frame( FRAME )

      # Set up database or directory combo box
      if gui_control.have_cdms_database:
         self.textv_opt9 = Tkinter.StringVar()
         self.textv_opt9.set('Directory')
         self.opt9 = Pmw.OptionMenu( frameb,
                             menubutton_width=7,
                             menubutton_textvariable = self.textv_opt9,
                             items=gui_control.dbdchlst,
                             command=gui_control.Command(evt_popup_database_gui, self, parent) )
         self.opt9.configure( menubutton_text=gui_control.dbdchlst[0] )
      else:
         self.opt9 = Tkinter.Label( frameb, text="Directory:" )
      self.opt9.pack( side='top' )
      parent.balloon.bind( self.opt9, 'Select Variables from a Directory or a Database' )

      # Set up go home icon
      self.canvas_homeicon = Tkinter.Canvas(frameb, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.canvas_homeicon.pack( side='left', fill=Tkinter.BOTH, expand='no', padx=5 )
      parent.balloon.bind( self.canvas_homeicon,
                 "Go to user's home directory." )
      self.img4 = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'gohome.gif') )
      self.canvas_homeicon.create_image(0,0, anchor=Tkinter.NW, image=self.img4 )
      self.canvas_homeicon.bind( '<1>', gui_control.Command( evt_icon_open_file, parent, os.environ['HOME'] ))

      # Set up file open icon
      self.canvas_openicon = Tkinter.Canvas(frameb, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.canvas_openicon.pack( side='left', fill=Tkinter.BOTH, expand='no', padx=5 )
      parent.balloon.bind( self.canvas_openicon, 
                 "Display 'File Select' browser for 'Directory' and 'File' selection." )
      self.img = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'open.gif') )
      self.canvas_openicon.create_image(0,0, anchor=Tkinter.NW, image=self.img )
      self.canvas_openicon.bind( '<1>', gui_control.Command( evt_icon_open_file, parent, None ))

      # Set up opendap icon, but only if built with opendap
      import cdat_info
      if cdat_info.CDMS_INCLUDE_DAP == 'yes':
         self.canvas_opendapicon = Tkinter.Canvas(frameb, bd=0, highlightthickness=0,
                                                  width = 27, height = 27)
         self.canvas_opendapicon.pack( side='left', fill=Tkinter.BOTH, expand='no', padx=5 )
         parent.balloon.bind( self.canvas_opendapicon,
                              "Display 'Portal Internet Manager' for data browsing and searching." )
         self.img5 = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'opendap.gif') )
         self.canvas_opendapicon.create_image(0,0, anchor=Tkinter.NW, image=self.img5 )
         self.canvas_opendapicon.bind( '<1>', gui_control.Command( evt_icon_opendap_file, parent, None ))

         
      self.tin2 = Pmw.ComboBox( frameb,
                                       scrolledlist_items = d,
		                       entryfield_value = os.getcwd(),
                                       entry_width=10,
                                       entry_background='white', entry_foreground='black',
                                       selectioncommand=gui_control.Command(evt_enter_directory, parent)
                                     )
      parent.balloon.bind( self.tin2._entryfield, "Enter the directory of the variable file(s). Can\nuse the arrow button to the right or the 'Open File'\nmenu item located under the 'File' menu option to\nalso set the directory.\n\nNote: The tab key can be used to complete subdirectory\nnames.")
      parent.balloon.bind( self.tin2._arrowBtn, 'View and Select Directories' )
      self.opt9.pack( side='left', padx=0 )
      self.tin2.pack( side='left', fill='x', expand=1,
                        padx=5, ipady=2 )

      # Set up bookmarks (i.e., favorite directories icon)
      self.canvas_bookicon = Tkinter.Canvas(frameb, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.canvas_bookicon.pack( side='left', fill='x', padx=5 )
      parent.balloon.bind( self.canvas_bookicon,
                 "Bookmark your favorite working directories." )
      self.img2 = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'bookmark_folder.gif') )
      self.canvas_bookicon.create_image(0,0, anchor=Tkinter.NW, image=self.img2 )
      self.canvas_bookicon.bind( '<1>', gui_control.Command( gui_edit_list.create, parent, 'directory' ))

      # Set up cycle throught favorite directories icon
      self.canvas_cycleicon = Tkinter.Canvas(frameb, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.canvas_cycleicon.pack( side='left', fill='x', padx=5 )
      parent.balloon.bind( self.canvas_cycleicon,
                 "Cycle through your favorite working directories." )
      self.img3 = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'cycle.gif') )
      self.canvas_cycleicon.create_image(0,0, anchor=Tkinter.NW, image=self.img3 )
      self.canvas_cycleicon.bind( '<1>', gui_control.Command( evt_cycle_through_directories, parent ))
      
      frameb.pack( side='top', fill='x', expand=0 )

      #-------------------------------------------
      # line 3
      #-------------------------------------------
      framec = Tkinter.Frame( FRAME )
      self.textv_lab3 = Tkinter.StringVar()
      self.lab3 = Tkinter.Label( framec, textvariable=self.textv_lab3 )
      if cdat_info.CDMS_INCLUDE_DAP != 'yes':
         self.textv_lab3.set("File:        " )
      else:
         self.textv_lab3.set("File or URL: " )
      self.tin3 = Pmw.ComboBox( framec, 
                                    scrolledlist_items = f,
		                    entryfield_value = "Type in a file name or select file using pull down arrow -->.",
                                    entry_width=1,
                                    entry_background='white', entry_foreground='black',
                                    selectioncommand=gui_control.Command(evt_enter_file, parent)
                                   )
      parent.balloon.bind( self.tin3._entryfield, "Enter the file name. Can use the arrow button to\nthe right or the 'Open File' menu item located\nunder the 'File' menu option to also set the file\nname." )
      parent.balloon.bind( self.tin3._arrowBtn, 'View and Select Files in Directory' )
      self.tin3.first_time = 1
      self.lab3.pack( side='left', padx=2 )
      self.tin3.pack( side='left', fill='x', expand=1,
                        pady=5, padx=5, ipady=2 )
      # Set up files bookmarks (i.e., favorite directories icon)
      self.canvas_bookicon_file = Tkinter.Canvas(framec, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.canvas_bookicon_file.pack( side='left', fill='x', padx=5 )
      parent.balloon.bind( self.canvas_bookicon_file,
                 "Bookmark your favorite working files." )
      self.img2_file = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'save_file.gif') )
      self.canvas_bookicon_file.create_image(0,0, anchor=Tkinter.NW, image=self.img2_file )
      self.canvas_bookicon_file.bind( '<1>', gui_control.Command( gui_edit_list.create, parent, 'mybinfiles' ))

      # Set up cycle throught favorite files icon
      self.canvas_cycleicon_files = Tkinter.Canvas(framec, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.canvas_cycleicon_files.pack( side='left', fill='x', padx=5 )
      parent.balloon.bind( self.canvas_cycleicon_files,
                 "Cycle through your favorite working files." )
      self.img3_files = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'recycle_file.gif') )
      self.canvas_cycleicon_files.create_image(0,0, anchor=Tkinter.NW, image=self.img3_files )
      self.canvas_cycleicon_files.bind( '<1>', gui_control.Command( evt_cycle_through_files, parent ))

      framec.pack( side='top', fill='both', expand=0 )

      #-------------------------------------------
      # line 4
      #-------------------------------------------
      framed = Tkinter.Frame( FRAME )
      self.textv_lab4 = Tkinter.StringVar()
      self.lab4 = Tkinter.Label( framed, textvariable=self.textv_lab4 )
      if cdat_info.CDMS_INCLUDE_DAP != 'yes':
         self.textv_lab4.set("Variable: " )
      else:
         self.textv_lab4.set("Variable:      " )
      self.tin4 = Pmw.ComboBox( framed,
	                    entryfield_value = "Type in variable name or select variable using pull down arrow -->.",
                            entry_width=1,
                            entry_background='white', entry_foreground='black',
                            selectioncommand=gui_control.Command(evt_enter_variable, parent)
                            )
      parent.balloon.bind( self.tin4._entryfield, "Enter the variable name. Can use the arrow button\nto the right to view and select variables." )
      parent.balloon.bind( self.tin4._arrowBtn, 'View and Select Variables in File' )
      self.tin4.first_time = 1
      self.lab4.pack( side='left', padx=2, pady=2 )
      self.tin4.pack( side='left', fill='x', expand=1,
                        padx=5, ipady=2 )

      # Set up cycle throught favorite directories icon
      self.file_infoicon = Tkinter.Canvas(framed, bd=0, highlightthickness=0,
                                        width = 27, height = 27)
      self.file_infoicon.pack( side='left', fill='x', padx=5 )
      parent.balloon.bind( self.file_infoicon,
                 "Display file variable information." )
      self.img_info = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'info.gif') )
      self.file_infoicon.create_image(0,0, anchor=Tkinter.NW, image=self.img_info )
      self.file_infoicon.bind( '<1>', gui_control.Command( evt_display_file_info, parent ))
      framed.pack( side='top', fill='both', expand=0 )

      self.tin2.component('entry').bind( "<Key>", gui_control.Command(evt_change_color, parent) )
      self.tin2.component('entry').bind( "<Return>", gui_control.Command(evt_enter_directory, parent) )
      #self.tin2.component('entry').bind( "/", gui_control.Command(evt_enter_directory, parent) )
      self.tin2.component('entry').bind('<Tab>', gui_control.Command(evt_tab,parent) )
      self.tin2.component('entry').bind( "<BackSpace>", gui_control.Command(evt_backspace, parent) )
      self.tin3.component('entry').bind( "<Return>", gui_control.Command(evt_enter_file, parent) )
      self.tin4.component('entry').bind( "<Return>", gui_control.Command(evt_enter_variable, parent)  )
예제 #6
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.")
예제 #7
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.")
예제 #8
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.")
예제 #9
0
    def __init__(self, parent):

        #-------------------------------------------
        # create 1st sub-panel
        #-------------------------------------------
        FRAME = Tkinter.Frame(parent.pane.pane('panelSV'))
        FRAME.pack(side='top', pady=3, fill='x', expand=1)

        #-------------------------------------------
        # line 1
        #-------------------------------------------
        framea = Tkinter.Frame(FRAME)
        self.lab1 = Tkinter.Label(framea, text="Select Variable")
        self.lab1.pack()
        framea.pack(side='top', fill='x', expand=1)

        d, f = gui_functions._scn_a_dir(parent)

        #-------------------------------------------
        # line 2
        #-------------------------------------------
        frameb = Tkinter.Frame(FRAME)

        # Set up database or directory combo box
        if gui_control.have_cdms_database:
            self.textv_opt9 = Tkinter.StringVar()
            self.textv_opt9.set('Directory')
            self.opt9 = Pmw.OptionMenu(frameb,
                                       menubutton_width=7,
                                       menubutton_textvariable=self.textv_opt9,
                                       items=gui_control.dbdchlst,
                                       command=gui_control.Command(
                                           evt_popup_database_gui, self,
                                           parent))
            self.opt9.configure(menubutton_text=gui_control.dbdchlst[0])
        else:
            self.opt9 = Tkinter.Label(frameb, text="Directory:")
        self.opt9.pack(side='top')
        parent.balloon.bind(self.opt9,
                            'Select Variables from a Directory or a Database')

        # Set up go home icon
        self.canvas_homeicon = Tkinter.Canvas(frameb,
                                              bd=0,
                                              highlightthickness=0,
                                              width=27,
                                              height=27)
        self.canvas_homeicon.pack(side='left',
                                  fill=Tkinter.BOTH,
                                  expand='no',
                                  padx=5)
        parent.balloon.bind(self.canvas_homeicon,
                            "Go to user's home directory.")
        self.img4 = Tkinter.PhotoImage(file=os.path.join(
            cdms2.__path__[0], '..', '..', '..', '..', 'bin', 'gohome.gif'))
        self.canvas_homeicon.create_image(0,
                                          0,
                                          anchor=Tkinter.NW,
                                          image=self.img4)
        self.canvas_homeicon.bind(
            '<1>',
            gui_control.Command(evt_icon_open_file, parent,
                                os.environ['HOME']))

        # Set up file open icon
        self.canvas_openicon = Tkinter.Canvas(frameb,
                                              bd=0,
                                              highlightthickness=0,
                                              width=27,
                                              height=27)
        self.canvas_openicon.pack(side='left',
                                  fill=Tkinter.BOTH,
                                  expand='no',
                                  padx=5)
        parent.balloon.bind(
            self.canvas_openicon,
            "Display 'File Select' browser for 'Directory' and 'File' selection."
        )
        self.img = Tkinter.PhotoImage(file=os.path.join(
            cdms2.__path__[0], '..', '..', '..', '..', 'bin', 'open.gif'))
        self.canvas_openicon.create_image(0,
                                          0,
                                          anchor=Tkinter.NW,
                                          image=self.img)
        self.canvas_openicon.bind(
            '<1>', gui_control.Command(evt_icon_open_file, parent, None))

        # Set up opendap icon, but only if built with opendap
        import cdat_info
        if cdat_info.CDMS_INCLUDE_DAP == 'yes':
            self.canvas_opendapicon = Tkinter.Canvas(frameb,
                                                     bd=0,
                                                     highlightthickness=0,
                                                     width=27,
                                                     height=27)
            self.canvas_opendapicon.pack(side='left',
                                         fill=Tkinter.BOTH,
                                         expand='no',
                                         padx=5)
            parent.balloon.bind(
                self.canvas_opendapicon,
                "Display 'Portal Internet Manager' for data browsing and searching."
            )
            self.img5 = Tkinter.PhotoImage(
                file=os.path.join(cdms2.__path__[0], '..', '..', '..', '..',
                                  'bin', 'opendap.gif'))
            self.canvas_opendapicon.create_image(0,
                                                 0,
                                                 anchor=Tkinter.NW,
                                                 image=self.img5)
            self.canvas_opendapicon.bind(
                '<1>', gui_control.Command(evt_icon_opendap_file, parent,
                                           None))

        self.tin2 = Pmw.ComboBox(frameb,
                                 scrolledlist_items=d,
                                 entryfield_value=os.getcwd(),
                                 entry_width=10,
                                 entry_background='white',
                                 entry_foreground='black',
                                 selectioncommand=gui_control.Command(
                                     evt_enter_directory, parent))
        parent.balloon.bind(
            self.tin2._entryfield,
            "Enter the directory of the variable file(s). Can\nuse the arrow button to the right or the 'Open File'\nmenu item located under the 'File' menu option to\nalso set the directory.\n\nNote: The tab key can be used to complete subdirectory\nnames."
        )
        parent.balloon.bind(self.tin2._arrowBtn, 'View and Select Directories')
        self.opt9.pack(side='left', padx=0)
        self.tin2.pack(side='left', fill='x', expand=1, padx=5, ipady=2)

        # Set up bookmarks (i.e., favorite directories icon)
        self.canvas_bookicon = Tkinter.Canvas(frameb,
                                              bd=0,
                                              highlightthickness=0,
                                              width=27,
                                              height=27)
        self.canvas_bookicon.pack(side='left', fill='x', padx=5)
        parent.balloon.bind(self.canvas_bookicon,
                            "Bookmark your favorite working directories.")
        self.img2 = Tkinter.PhotoImage(
            file=os.path.join(cdms2.__path__[0], '..', '..', '..', '..', 'bin',
                              'bookmark_folder.gif'))
        self.canvas_bookicon.create_image(0,
                                          0,
                                          anchor=Tkinter.NW,
                                          image=self.img2)
        self.canvas_bookicon.bind(
            '<1>',
            gui_control.Command(gui_edit_list.create, parent, 'directory'))

        # Set up cycle throught favorite directories icon
        self.canvas_cycleicon = Tkinter.Canvas(frameb,
                                               bd=0,
                                               highlightthickness=0,
                                               width=27,
                                               height=27)
        self.canvas_cycleicon.pack(side='left', fill='x', padx=5)
        parent.balloon.bind(
            self.canvas_cycleicon,
            "Cycle through your favorite working directories.")
        self.img3 = Tkinter.PhotoImage(file=os.path.join(
            cdms2.__path__[0], '..', '..', '..', '..', 'bin', 'cycle.gif'))
        self.canvas_cycleicon.create_image(0,
                                           0,
                                           anchor=Tkinter.NW,
                                           image=self.img3)
        self.canvas_cycleicon.bind(
            '<1>', gui_control.Command(evt_cycle_through_directories, parent))

        frameb.pack(side='top', fill='x', expand=0)

        #-------------------------------------------
        # line 3
        #-------------------------------------------
        framec = Tkinter.Frame(FRAME)
        self.textv_lab3 = Tkinter.StringVar()
        self.lab3 = Tkinter.Label(framec, textvariable=self.textv_lab3)
        if cdat_info.CDMS_INCLUDE_DAP != 'yes':
            self.textv_lab3.set("File:        ")
        else:
            self.textv_lab3.set("File or URL: ")
        self.tin3 = Pmw.ComboBox(
            framec,
            scrolledlist_items=f,
            entryfield_value=
            "Type in a file name or select file using pull down arrow -->.",
            entry_width=1,
            entry_background='white',
            entry_foreground='black',
            selectioncommand=gui_control.Command(evt_enter_file, parent))
        parent.balloon.bind(
            self.tin3._entryfield,
            "Enter the file name. Can use the arrow button to\nthe right or the 'Open File' menu item located\nunder the 'File' menu option to also set the file\nname."
        )
        parent.balloon.bind(self.tin3._arrowBtn,
                            'View and Select Files in Directory')
        self.tin3.first_time = 1
        self.lab3.pack(side='left', padx=2)
        self.tin3.pack(side='left',
                       fill='x',
                       expand=1,
                       pady=5,
                       padx=5,
                       ipady=2)
        # Set up files bookmarks (i.e., favorite directories icon)
        self.canvas_bookicon_file = Tkinter.Canvas(framec,
                                                   bd=0,
                                                   highlightthickness=0,
                                                   width=27,
                                                   height=27)
        self.canvas_bookicon_file.pack(side='left', fill='x', padx=5)
        parent.balloon.bind(self.canvas_bookicon_file,
                            "Bookmark your favorite working files.")
        self.img2_file = Tkinter.PhotoImage(file=os.path.join(
            cdms2.__path__[0], '..', '..', '..', '..', 'bin', 'save_file.gif'))
        self.canvas_bookicon_file.create_image(0,
                                               0,
                                               anchor=Tkinter.NW,
                                               image=self.img2_file)
        self.canvas_bookicon_file.bind(
            '<1>',
            gui_control.Command(gui_edit_list.create, parent, 'mybinfiles'))

        # Set up cycle throught favorite files icon
        self.canvas_cycleicon_files = Tkinter.Canvas(framec,
                                                     bd=0,
                                                     highlightthickness=0,
                                                     width=27,
                                                     height=27)
        self.canvas_cycleicon_files.pack(side='left', fill='x', padx=5)
        parent.balloon.bind(self.canvas_cycleicon_files,
                            "Cycle through your favorite working files.")
        self.img3_files = Tkinter.PhotoImage(
            file=os.path.join(cdms2.__path__[0], '..', '..', '..', '..', 'bin',
                              'recycle_file.gif'))
        self.canvas_cycleicon_files.create_image(0,
                                                 0,
                                                 anchor=Tkinter.NW,
                                                 image=self.img3_files)
        self.canvas_cycleicon_files.bind(
            '<1>', gui_control.Command(evt_cycle_through_files, parent))

        framec.pack(side='top', fill='both', expand=0)

        #-------------------------------------------
        # line 4
        #-------------------------------------------
        framed = Tkinter.Frame(FRAME)
        self.textv_lab4 = Tkinter.StringVar()
        self.lab4 = Tkinter.Label(framed, textvariable=self.textv_lab4)
        if cdat_info.CDMS_INCLUDE_DAP != 'yes':
            self.textv_lab4.set("Variable: ")
        else:
            self.textv_lab4.set("Variable:      ")
        self.tin4 = Pmw.ComboBox(
            framed,
            entryfield_value=
            "Type in variable name or select variable using pull down arrow -->.",
            entry_width=1,
            entry_background='white',
            entry_foreground='black',
            selectioncommand=gui_control.Command(evt_enter_variable, parent))
        parent.balloon.bind(
            self.tin4._entryfield,
            "Enter the variable name. Can use the arrow button\nto the right to view and select variables."
        )
        parent.balloon.bind(self.tin4._arrowBtn,
                            'View and Select Variables in File')
        self.tin4.first_time = 1
        self.lab4.pack(side='left', padx=2, pady=2)
        self.tin4.pack(side='left', fill='x', expand=1, padx=5, ipady=2)

        # Set up cycle throught favorite directories icon
        self.file_infoicon = Tkinter.Canvas(framed,
                                            bd=0,
                                            highlightthickness=0,
                                            width=27,
                                            height=27)
        self.file_infoicon.pack(side='left', fill='x', padx=5)
        parent.balloon.bind(self.file_infoicon,
                            "Display file variable information.")
        self.img_info = Tkinter.PhotoImage(file=os.path.join(
            cdms2.__path__[0], '..', '..', '..', '..', 'bin', 'info.gif'))
        self.file_infoicon.create_image(0,
                                        0,
                                        anchor=Tkinter.NW,
                                        image=self.img_info)
        self.file_infoicon.bind(
            '<1>', gui_control.Command(evt_display_file_info, parent))
        framed.pack(side='top', fill='both', expand=0)

        self.tin2.component('entry').bind(
            "<Key>", gui_control.Command(evt_change_color, parent))
        self.tin2.component('entry').bind(
            "<Return>", gui_control.Command(evt_enter_directory, parent))
        #self.tin2.component('entry').bind( "/", gui_control.Command(evt_enter_directory, parent) )
        self.tin2.component('entry').bind('<Tab>',
                                          gui_control.Command(evt_tab, parent))
        self.tin2.component('entry').bind(
            "<BackSpace>", gui_control.Command(evt_backspace, parent))
        self.tin3.component('entry').bind(
            "<Return>", gui_control.Command(evt_enter_file, parent))
        self.tin4.component('entry').bind(
            "<Return>", gui_control.Command(evt_enter_variable, parent))
예제 #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."
                )