Example #1
0
def createWindow(root):
  global gVisusGuiMaster

  window = gVisusGuiMaster.createWindow(root)

  # If this is the first active window we create 
  if (window == 0):
    try: 
      # If vcdat is running we attch ourself to the tkinter mainloop  
      gui_support.root().after_idle(_fltkIdle,gVisusGuiMaster) 
        
    except: # If vcdat is not running
      pass

  return gVisusGuiMaster.window(window)
Example #2
0
def startFLTKMainLoop():
  """
This function will start the fltk main loop. It allows to use pyvisus
from python in a standalone fashion. Note that this function will only
return once all pyvisus windows are closed. Furthermore, the mainloop
must be run from the main thread of the program as it will not process
events correctly when running in a child process.
"""
  
  gVisusGuiMaster.mainLoop()
  return

  if gui_support.root_exists():      
    gui_support.root().mainloop()
  else: 
    gVisusGuiMaster.mainLoop()
Example #3
0
def _fltkIdle(master_gui):

  active = master_gui.update();
  gui_support.root().update_idletasks()
  gui_support.root().update()

  if active:
    gui_support.root().after_idle(_fltkIdle,master_gui)
Example #4
0
 def infoRequest(self,scene):
    
   root = gui_support.root()
   
   self.dialog = Tkinter.Toplevel()
   Tkinter.Label(self.dialog,text=scene._interface_info).pack(padx=10,pady=10)
   Tkinter.Button(self.dialog,text="Cancel",command=self.dialog.destroy,padx=5,pady=5).pack(side="left",padx=10,pady=10)
   Tkinter.Button(self.dialog,text="OK",command=lambda x = scene: self.createScene(x),
                  padx=5,pady=5).pack(side="right",padx=10,pady=10)
   
   width = root.winfo_width()
   height = root.winfo_height()
   posx = root.winfo_rootx()
   posy = root.winfo_rooty()
   
   self.dialog.wm_geometry('+%d+%d' % (posx+width,posy))
Example #5
0
def guiDefinedData():
    """
    This function attempts to grab all information the user has entered
    into the vcdat gui. If succesful the function will open the file
    and return the approriate array as cdms2 variable.
    """

    try:
        import gui_support
        root = gui_support.root()
        panel = root.panelDM
    except:
        print "Could not find gui root. VCDAT seems not to be running"
        raise

    import browser.gui_formulate

    return browser.gui_formulate.data(root, d_name=panel.var3)
Example #6
0
def guiDefinedData():
    """
    This function attempts to grab all information the user has entered
    into the vcdat gui. If succesful the function will open the file
    and return the approriate array as cdms2 variable.
    """

    try:
        import gui_support
        root = gui_support.root()
        panel = root.panelDM        
    except:
        print "Could not find gui root. VCDAT seems not to be running"
        raise
    
    
    import browser.gui_formulate

    return browser.gui_formulate.data(root,d_name = panel.var3)
Example #7
0
    def infoRequest(self, scene):

        root = gui_support.root()

        self.dialog = Tkinter.Toplevel()
        Tkinter.Label(self.dialog, text=scene._interface_info).pack(padx=10,
                                                                    pady=10)
        Tkinter.Button(self.dialog,
                       text="Cancel",
                       command=self.dialog.destroy,
                       padx=5,
                       pady=5).pack(side="left", padx=10, pady=10)
        Tkinter.Button(self.dialog,
                       text="OK",
                       command=lambda x=scene: self.createScene(x),
                       padx=5,
                       pady=5).pack(side="right", padx=10, pady=10)

        width = root.winfo_width()
        height = root.winfo_height()
        posx = root.winfo_rootx()
        posy = root.winfo_rooty()

        self.dialog.wm_geometry('+%d+%d' % (posx + width, posy))
Example #8
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            self.canvas = vcs.init()
        else:
            self.canvas = canvas

        self.line = self.canvas.getline(name)
        if self.line is None:
            if not name in vcs.listelements('line'):
                raise 'Error ' + t_name + ' is not a valid line name'
            else:
                raise 'Weird unkwnown error but no line object returned....'
        self.parent = Parent
        self.parent_Name = self.parent.parent_Name
        ## Saves original values
        self.orig = []
        self.save_vals()

        L_color = gui_support.gui_color.L_color

        if self.gui_parent is None:
            self.gui_parent = Tkinter.Toplevel()
            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
            self.gui_parent.withdraw()
        title = 'Line Editor - table: ' + self.line.name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=L_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Line Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open line object file',
            label='Open LineObject File',
            command=self.evt_open_file,
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save Line',
            label='Save (i.e Apply changes)',
            command=self.setline,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Line',
            label='Copy Line',
            command=self.evt_save_line_as,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=self.evt_save_to_file,
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close Line Editor',
            label="Exit Line Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Line',
            tag_bg=L_color,
            tagindent=10,
            hull_bg=L_color,
            hull_highlightbackground=L_color,
            hull_highlightcolor=L_color,
            ring_bg=L_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=L_color)
        lines = vcs.listelements('line')
        lines.sort()

        labels = []
        self.Line = Pmw.OptionMenu(
            self.tproperties,
            items=lines,
            labelpos='w',
            label_text='Name:',
            command=self.loadline,
            initialitem=self.line.name,
            label_bg=L_color,
            hull_bg=L_color,
            menu_bg=L_color,
            menu_activebackground=L_color,
            menubutton_bg=L_color,
            menubutton_activebackground=L_color,
        )
        self.Line.pack()
        labels.append(self.Line)
        items = ["solid", "dash", "dot", "dash-dot", "long-dash"]
        self.type = Pmw.OptionMenu(
            self.tproperties,
            items=items,
            labelpos='w',
            label_text='Type:',
            label_bg=L_color,
            hull_bg=L_color,
            menu_bg=L_color,
            menu_activebackground=L_color,
            menubutton_bg=L_color,
            menubutton_activebackground=L_color,
            command=self.setline,
        )
        self.type.pack()
        labels.append(self.type)
        f = Tkinter.Frame(self.tproperties, bg=L_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=L_color,
        )
        l.pack(side='left')
        self.width = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=1,
            to=300,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=L_color,
            activebackground=L_color,
            highlightbackground=L_color,
            command=self.setline,
        )
        self.width.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=L_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=L_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=L_color,
            activebackground=L_color,
            highlightbackground=L_color,
            command=self.setline,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()
        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return
Example #9
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, name='default',Parent=None):
        self.gui_parent=gui_parent
        if canvas is None:
            self.canvas=vcs.init()
        else:
            self.canvas=canvas

        self.line=self.canvas.getline(name)
        if self.line is None:
            if not name in self.canvas.listelements('line'):
                raise 'Error '+t_name+' is not a valid line name'
            else:
                raise 'Weird unkwnown error but no line object returned....'
        self.parent=Parent
        self.parent_Name=self.parent.parent_Name
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        L_color = gui_support.gui_color.L_color
        
        if self.gui_parent is None:
            self.gui_parent=Tkinter.Toplevel()
            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
            self.gui_parent.withdraw()
        title='Line Editor - table: '+self.line.name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()
       
        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=L_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Line Objects', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open line object file',
                         label = 'Open LineObject File',
                         command = self.evt_open_file,
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        self.cmain_menu.addmenuitem('File', 'command', 'Save Line',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setline,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Line',
                                    label = 'Copy Line',
                                    command = self.evt_save_line_as,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save to file',
                                    label = 'Save To File',
                                    command = self.evt_save_to_file,
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close Line Editor',
                                    label = "Exit Line Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        self.tprop=Pmw.Group(parent,
                             tag_text='Line',
                             tag_bg=L_color,
                             tagindent=10,
                             hull_bg=L_color,
                             hull_highlightbackground=L_color,
                             hull_highlightcolor=L_color,
                            ring_bg=L_color,
                             )
        self.tprop.pack(expand='yes',fill='both')
        self.tproperties=self.tprop.interior()
        self.tproperties.configure(bg=L_color)
        lines=self.canvas.listelements('line')
        lines.sort()

        labels=[]
        self.Line=Pmw.OptionMenu(self.tproperties,
                                  items=lines,
                                  labelpos='w',
                                  label_text='Name:',
                                  command=self.loadline,
                                  initialitem=self.line.name,
                                  label_bg=L_color,
                                  hull_bg=L_color,
                                  menu_bg=L_color,
                                  menu_activebackground=L_color,
                                  menubutton_bg=L_color,
                                  menubutton_activebackground=L_color,
                                 )
        self.Line.pack()
        labels.append(self.Line)
        items=["solid", "dash", "dot", "dash-dot", "long-dash"]
        self.type=Pmw.OptionMenu(self.tproperties,
                                 items=items,
                                 labelpos='w',
                                 label_text='Type:',
                                 label_bg=L_color,
                                 hull_bg=L_color,
                                 menu_bg=L_color,
                                 menu_activebackground=L_color,
                                 menubutton_bg=L_color,
                                 menubutton_activebackground=L_color,
                                 command=self.setline,
                                 )
        self.type.pack()
        labels.append(self.type)
        f=Tkinter.Frame(self.tproperties,bg=L_color)
        l=Tkinter.Label(f,
                        text='Width:',
                        bg=L_color,
                        )
        l.pack(side='left')
        self.width=Tkinter.Scale(f,
                                 bigincrement=10,
                                 from_=1,
                                 to=300,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=L_color,
                                 activebackground=L_color,
                                 highlightbackground=L_color,
                                 command=self.setline,
                                 )
        self.width.pack()
        labels.append(l)
        f.pack()

        f=Tkinter.Frame(self.tproperties,bg=L_color)
        
        l=Tkinter.Label(f,
                        text='Color:',
                        bg=L_color,
                        )
        
        l.pack(side='left')
        
        self.Color=Tkinter.Scale(f,
                                 bigincrement=50,
                                 from_=0,
                                 to=255,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=L_color,
                                 activebackground=L_color,
                                 highlightbackground=L_color,
                                 command=self.setline,
                                 )
        
        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        
        self.fbuttons=Tkinter.Frame(parent)
        self.fbuttons.pack()
##         b0=Tkinter.Button(self.fbuttons,
##                           text='Preview',
##                           command=self.setfont)
##         b0.pack(side='left')
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')
        
        self.setgui()
        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
Example #10
0
    for o, a in opts:
        if o == '-h':
            sys.stderr.write(usage_msg)
            sys.exit(2)
        if o == '-n':
            dosplashscreen = 0
            counter_bar = None
        if o == '-u':
            startwalltime = time.time()
            startcputime  = time.clock()
            startusertask = 1    # Store user directory, file, and variable requests
        if o == '-f':
            vcdat_lite = 0

    root = gui_support.root()
    root.Version=Version
    root.startusertask = startusertask
    if startusertask == 1: gui_control.start_tracking_directory_file_variable_log( root )

    if dosplashscreen == 1:
       splash = Tkinter.Toplevel()
       splash.withdraw()
       splash.title('Welcome to VCDAT')
       splash.update_idletasks()

       total_load=23.
       already_loaded=0
       img = Tkinter.PhotoImage( file = os.path.join(vcs.__path__[0],'..','..','..','..', 'bin', 'splash.gif') )
       canvas = Tkinter.Canvas(splash,background='white')
       Font=tkFont.Font(splash,family='Helvetica', size=-25, weight='bold')
Example #11
0
    def __init__(self, canvas=None, gui_parent=None, continents=None):
        if canvas is None:
            import Canvas
            canvas = Canvas.Canvas()
        canvas.clear()
        self.vcs = canvas
        self.continents = continents
        title = "VCS Canvas Page Layout Editor"
        self.dialog= gui_support.VcsDialog( title = title, buttons = ())
        self.dialog.dialog.withdraw()
        self.mainframe = self.dialog.interior()
        max_w = gui_support.root().winfo_screenwidth()
        max_h = gui_support.root().winfo_screenheight()
        pane_pd = Pmw.PanedWidget( self.mainframe, 
                                   hull_width=max_w*0.44, 
                                   hull_height=max_w*0.42, 
                                   orient = 'vertical' 
                                 )
        pane_pd.add('PageForms', min=250, size = 250)
        pane_pd.add('PageBins', min=120, size = 450)
        pane_pd.pack( expand = 1, fill='both' )
        FRAME1 = Tkinter.Frame( pane_pd.pane( 'PageForms' ) )
        FRAME1.pack( side='top', pady=3, fill='both', expand=1 )
        FRAME2 = Tkinter.Frame( pane_pd.pane( 'PageBins' ) )
        FRAME2.pack( side='top', pady=3, fill='both', expand=1 )
        self.FRAME1 = FRAME1
        self.FRAME2 = FRAME2

        # create the page description main toplevel menu
        self.pmain_menu = Pmw.MenuBar(FRAME1,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.pmain_menu.pack(side='top', fill='both')

        #-------------------------------------------
        # menu 1 -- 'File'
        #-------------------------------------------
        self.create_file_menu (self.pmain_menu)

        #-------------------------------------------
        # menu 3 -- 'Options'
        #-------------------------------------------
        create_pd_options_menu( self, self.pmain_menu )

        #-------------------------------------------
        # menu 4 -- 'Help'
        #-------------------------------------------
        self.create_help_menu (self.pmain_menu)

        #-------------------------------------------
        # Page Layout Panel
        #-------------------------------------------
        self.pd = create_page_description_panel(self, FRAME1 )

        #-------------------------------------------
        # Page Layout Panel -- 'Default Page Form'
        #-------------------------------------------
        self.pd.create_form( 'default', 'Boxfill', 'default', None, vcs=self.vcs)

        #------------------------------------------------------------
        # Group the Template, Graphics Method and Data Scroll Lists
        #------------------------------------------------------------
        group_bins = Pmw.Group(FRAME2, tag_text = 'Select Template, Graphics Method, and Data')
        group_bins.pack(side='top', fill = 'both', expand = 1, padx = 5, pady = 5)

        #------------------------------------------------------------
        # Select Controls for the Template, Graphics Method and Data
        #------------------------------------------------------------
        self.bins = show_bin( group_bins, self.dialog )

        #------------------------------------------------------------
        # Show the Template, Graphics Method, and Data lists
        #------------------------------------------------------------
        self.bins.template( self.vcs )
        self.bins.graphics_method( self.vcs, 'Boxfill' )
        self.bins.data( self.vcs )
        # Decide where to put it on the screen
        if gui_parent is None:
            d=[max_w/4,
               max_h/4
              ]
        else:
            g=gui_parent.geometry()
            d = g.split('+')[1:]
        if gui_parent is not None:
           self.dialog.dialog.transient(gui_parent)
        self.dialog.geometry("+%s+%s"% (d[0],d[1]))
        self.dialog.dialog.deiconify()
Example #12
0
    def __init__(self, canvas=None, gui_parent=None, continents=None):
        if canvas is None:
            import Canvas
            canvas = Canvas.Canvas()
        canvas.clear()
        self.vcs_legacy = canvas
        self.continents = continents
        title = "VCS Canvas Page Layout Editor"
        self.dialog = gui_support.VcsDialog(title=title, buttons=())
        self.dialog.dialog.withdraw()
        self.mainframe = self.dialog.interior()
        max_w = gui_support.root().winfo_screenwidth()
        max_h = gui_support.root().winfo_screenheight()
        pane_pd = Pmw.PanedWidget(self.mainframe,
                                  hull_width=max_w * 0.44,
                                  hull_height=max_w * 0.42,
                                  orient='vertical')
        pane_pd.add('PageForms', min=250, size=250)
        pane_pd.add('PageBins', min=120, size=450)
        pane_pd.pack(expand=1, fill='both')
        FRAME1 = Tkinter.Frame(pane_pd.pane('PageForms'))
        FRAME1.pack(side='top', pady=3, fill='both', expand=1)
        FRAME2 = Tkinter.Frame(pane_pd.pane('PageBins'))
        FRAME2.pack(side='top', pady=3, fill='both', expand=1)
        self.FRAME1 = FRAME1
        self.FRAME2 = FRAME2

        # create the page description main toplevel menu
        self.pmain_menu = Pmw.MenuBar(FRAME1,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.pmain_menu.pack(side='top', fill='both')

        #-------------------------------------------
        # menu 1 -- 'File'
        #-------------------------------------------
        self.create_file_menu(self.pmain_menu)

        #-------------------------------------------
        # menu 3 -- 'Options'
        #-------------------------------------------
        create_pd_options_menu(self, self.pmain_menu)

        #-------------------------------------------
        # menu 4 -- 'Help'
        #-------------------------------------------
        self.create_help_menu(self.pmain_menu)

        #-------------------------------------------
        # Page Layout Panel
        #-------------------------------------------
        self.pd = create_page_description_panel(self, FRAME1)

        #-------------------------------------------
        # Page Layout Panel -- 'Default Page Form'
        #-------------------------------------------
        self.pd.create_form('default',
                            'Boxfill',
                            'default',
                            None,
                            vcs_legacy=self.vcs_legacy)

        #------------------------------------------------------------
        # Group the Template, Graphics Method and Data Scroll Lists
        #------------------------------------------------------------
        group_bins = Pmw.Group(
            FRAME2, tag_text='Select Template, Graphics Method, and Data')
        group_bins.pack(side='top', fill='both', expand=1, padx=5, pady=5)

        #------------------------------------------------------------
        # Select Controls for the Template, Graphics Method and Data
        #------------------------------------------------------------
        self.bins = show_bin(group_bins, self.dialog)

        #------------------------------------------------------------
        # Show the Template, Graphics Method, and Data lists
        #------------------------------------------------------------
        self.bins.template(self.vcs_legacy)
        self.bins.graphics_method(self.vcs_legacy, 'Boxfill')
        self.bins.data(self.vcs_legacy)
        # Decide where to put it on the screen
        if gui_parent is None:
            d = [max_w / 4, max_h / 4]
        else:
            g = gui_parent.geometry()
            d = g.split('+')[1:]
        if gui_parent is not None:
            self.dialog.dialog.transient(gui_parent)
        self.dialog.geometry("+%s+%s" % (d[0], d[1]))
        self.dialog.dialog.deiconify()
Example #13
0
def main():
   #------------------------------------------------------------------------------
   # We are using the same gui_support as VCDAT for possible future integration 
   #------------------------------------------------------------------------------
   root = gui_support.root()
   Pmw.initialise( root )

   #----------------------------------------------------------------------------
   # One time only call to setup the database session 
   #----------------------------------------------------------------------------
   root.echoSql = False
   extraction_controls.call_sessionmaker( root )

   #----------------------------------------------------------------------------
   # Initialize the GUI widgets
   #----------------------------------------------------------------------------
   root.main_frame = GUI_frame( root )

   #------------------------------------------------------------------------------
   # Display the ESG-CET world image in the background and the copyright
   #------------------------------------------------------------------------------
   root.canvas = Tkinter.Frame(root.pane2.pane( 'EditPaneTop' ))
   root.canvas.pack(side='top', fill='both', expand=1)

   txtFont = tkFont.Font(root, family = pub_controls.tab_font_type, size=pub_controls.tab_font_size)
   copywrite_text = "\nPublisher software version %s @ copyright LLNL/PCMDI\nEarth System Grid Center for Enabling Technologies, funded by the U.S. Department of Energy" % root.Version
   root.text = Tkinter.Label(root.canvas, text=copywrite_text, font=txtFont, bg = "white")
   root.text.pack(side='top', fill='both', expand=1)

   img = Tkinter.PhotoImage( file = esg_bg )
   root.canvas_img = Tkinter.Label( root.canvas, image = img, background = "white")
   root.canvas_img.image = img
   root.canvas_img.pack(side='top', fill='both', expand=1)

   #------------------------------------------------------------------------------
   # Redirect stderr and stdout to the output windows located in the bottom_right
   # pane (i.e., "Output" and "Error")
   # 
   # INFO messages are sent to the "Output" window -- that is, stdout
   #
   # WARNING, ERROR, DEBUG, CRITICAL, and Exception messages are sent to
   # the "Error" window -- that is, stderr
   #
   # Note: we distinguish between what is standard out and standard error,
   #       then display the appropriate window to view the text       
   #------------------------------------------------------------------------------
   sys.stdout = pub_controls.standard_out( root )
   sys.stderr = pub_controls.standard_err( root )

   #----------------------------------------------------------------------------
   # Log INFO messages to stdout and display the output to the "Output" window
   #----------------------------------------------------------------------------
   inf=logging.StreamHandler(sys.stdout)
   inf.setLevel(logging.INFO)
   logging.getLogger('Info').addHandler(inf)

   #----------------------------------------------------------------------------
   # Log WARNING messages to stderr and display the output to the "Error" window
   #----------------------------------------------------------------------------
   wrn=logging.StreamHandler(sys.stderr)
   wrn.setLevel(logging.WARNING)
   logging.getLogger('Warning').addHandler(wrn)

   #----------------------------------------------------------------------------
   # Log ERROR messages to stderr and display the output to the "Error" window
   #----------------------------------------------------------------------------
   err=logging.StreamHandler(sys.stderr)
   err.setLevel(logging.ERROR)
   logging.getLogger('Error').addHandler(err)

   #----------------------------------------------------------------------------
   # Log DEBUG messages to stderr and display the output to the "Error" window
   #----------------------------------------------------------------------------
   dbg=logging.StreamHandler(sys.stderr)
   dbg.setLevel(logging.DEBUG)
   logging.getLogger('Debug').addHandler(dbg)

   #----------------------------------------------------------------------------
   # Log CRITICAL messages to stderr and display the output to the "Error" window
   #----------------------------------------------------------------------------
   crt=logging.StreamHandler(sys.stderr)
   crt.setLevel(logging.CRITICAL)
   logging.getLogger('Critical').addHandler(crt)

   #----------------------------------------------------------------------------
   # Log Exception messages to stderr and display the output to the "Error" window
   #----------------------------------------------------------------------------
   exc=logging.StreamHandler(sys.stderr)
   exc.setLevel(logging.ERROR)
   logging.getLogger('Exception').addHandler(exc)

   #----------------------------------------------------------------------------
   # Test the message print commands from logging --- the below lines are
   # showing examples of how to use Python logging for message sending
   #----------------------------------------------------------------------------
   #debug("%d: This is the Debug Test" % logging.DEBUG)
   #info("%d: This is the Info Test" % logging.INFO)
   #warning("%d: This is Warning Test" % logging.WARNING)
   #error("%d: This is the Error Test" % logging.ERROR)
   #critical("%d: This is the Critical Test" % logging.CRITICAL)
   #exception("%d: This is the Exception (NotSet) Test" % logging.NOTSET)

   #---------------------------------------------------------------------
   # View the GUI on the screen.
   #---------------------------------------------------------------------
   root.deiconify()
   root.update()
   root.lift()

   #---------------------------------------------------------------------
   # Enter the Tkinter main event loop
   #---------------------------------------------------------------------
   root.mainloop()
Example #14
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, name='default',Parent=None):
        self.gui_parent=gui_parent
        self.dialog_parent=dialog_parent
        self.master=master
        
#        print 'PASSED INSIDE:',gui_parent
        if canvas is None:
##             import Canvas
##             self.canvas = Canvas.Canvas()
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas
            
        self.projection=self.canvas.getprojection(name)
        if self.projection is None:
            raise 'Erro invalid projection name'
        
        self.parent=Parent
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        Proj_color = gui_support.gui_color.Proj_color

#################################################################################################
# At the moment, this will never happen. When we need to pop this editor up on its own, then we
# will revist this case.
##         if self.gui_parent is None:
##             self.gui_parent=Tkinter.Toplevel()
##             #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
##             self.gui_parent.withdraw()
#################################################################################################

        title='Projection Editor - '+self.projection.name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=Proj_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Projections', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open projection file',
                         label = 'Open Projection File',
                         command = self.evt_open_file,
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
##         self.cmain_menu.addmenuitem('File', 'command', 'Select projection',
##                                     label = 'Select',
##                                     command = self.evt_loadproj,
##                                     )
        self.cmain_menu.addmenuitem('File', 'command', 'Save projection',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setprojection,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy projection',
                                    label = 'Copy Projection',
                                    command = self.evt_save_as,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save as file',
                                    label = 'Save To File',
                                    command = self.evt_save_to_file,
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close Projection Editor',
                                    label = "Exit Projection Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        projs=self.canvas.listelements('projection')
        projs.sort()

        self.projections=Pmw.OptionMenu(parent,
                                  items=projs,
                                  labelpos='w',
                                  label_text='Name: ',
                                  command=self.loadproj,
                                  initialitem=self.projection.name,
                                  label_bg=Proj_color,
                                  hull_bg=Proj_color,
                                  menu_bg=Proj_color,
                                  menu_activebackground=Proj_color,
                                  menubutton_bg=Proj_color,
                                  menubutton_activebackground=Proj_color,
                                 )
        self.projections.pack()
        
        self.fprop=Pmw.Group(parent,tag_text='Properties',
                             tagindent=10,
                             tag_bg=Proj_color,
                             ring_bg=Proj_color,
                             hull_bg=Proj_color)
        self.fprop.pack(expand='yes',fill='both')
        inter=self.fprop.interior()
        inter.configure(bg=Proj_color)
        self.fproperties=Tkinter.Frame(inter,bg=Proj_color)
        self.fbuttons=Tkinter.Frame(parent,bg=Proj_color)
        self.fbuttons.pack()

        self.projtypes=["polar (non gctp)",
                        "mollweide (non gctp)",
                        "robinson (non gctp)",
                        "linear",
                        "utm",
                        "state plane",
                        "albers equal area",
                        "lambert",
                        "mercator",
                        "polar stereographic",
                        "polyconic",
                        "equid conic",
                        "transverse mercator",
                        "stereographic",
                        "lambert azimuthal",
                        "azimuthal",
                        "gnomonic",
                        "orthographic",
                        "gen. vert. near per",
                        "sinusoidal",
                        "equirectangular",
                        "miller cylindrical",
                        "van der grinten",
                        "hotin oblique",
                        "robinson",
                        "space oblique",
                        "alaska conformal",
                        "interrupted goode",
                        "mollweide",
                        "interrupted mollweide",
                        "hammer",
                        "wagner iv",
                        "wagner vii",
                        "oblated equal area",
                        ]
        
        self.projtype = Pmw.OptionMenu (inter,
                                        labelpos='w',
                                        label_text='Projection Type',
                                        label_bg=Proj_color,
                                        hull_bg=Proj_color,
                                        menu_bg=Proj_color,
                                        menu_activebackground=Proj_color,
                                        menubutton_bg=Proj_color,
                                        menubutton_activebackground=Proj_color,
                                        items=  self.projtypes,
                                        command=self.settype,
                                        )
        self.projtype.pack()
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
Example #15
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 t_name='default',
                 o_name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            ##             import Canvas
            ##             self.canvas = Canvas.Canvas()
            self.canvas = vcs.init()
        else:
            self.canvas = canvas

        self.text = self.canvas.gettext(t_name, o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error ' + t_name + ' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error ' + o_name + ' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent = Parent
        try:
            self.parent_Name = self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig = []
        self.save_vals()

        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color

        #################################################################################################
        # At the moment, this will never happen. When we need to pop this editor up on its own, then we
        # will revist this case.
        #        if self.gui_parent is None:
        #            self.gui_parent=Tkinter.Toplevel()
        #            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
        #            self.gui_parent.withdraw()
        #################################################################################################

        title = 'Text Editor - table: ' + self.text.Tt_name + ', orientation: ' + self.text.To_name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Text Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open textobject file',
            label='Open TextObject File',
            command=gui_control.Command(self.evt_open_file, master),
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
        ##                                     label = 'Select Table',
        ##                                     command = self.evt_loadtable,
        ##                                     )
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
        ##                                     label = 'Select Orientation',
        ##                                     command = self.evt_loadorientation,
        ##                                     )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save TextObject',
            label='Save (i.e Apply changes)',
            command=self.setfont,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Table',
            label='Copy Table',
            command=gui_control.Command(self.evt_save_table_as, self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Orientation',
            label='Copy Orientation',
            command=gui_control.Command(self.evt_save_orientation_as,
                                        self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=gui_control.Command(self.evt_save_to_file, master),
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close TextObject Editor',
            label="Exit TextObject Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Table',
            tag_bg=Tt_color,
            tagindent=10,
            hull_bg=Tt_color,
            hull_highlightbackground=Tt_color,
            hull_highlightcolor=Tt_color,
            ring_bg=Tt_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables = self.canvas.listelements('texttable')
        tables.sort()

        labels = []
        self.table = Pmw.OptionMenu(
            self.tproperties,
            items=tables,
            labelpos='w',
            label_text='Name:',
            command=self.loadtable,
            initialitem=self.text.Tt_name,
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
        )
        self.table.pack()
        labels.append(self.table)

        fonts = self.canvas.listelements("font")
        self.font = Pmw.OptionMenu(
            self.tproperties,
            items=fonts,
            labelpos='w',
            label_text='Font:',
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
            command=self.setfont,
        )
        self.font.pack()
        labels.append(self.font)

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Spacing:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.spacing = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=-50,
            to=50,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.expansion = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=50,
            to=150,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=Tt_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels = []
        self.oprop = Pmw.Group(parent,
                               tag_text='Orientation',
                               tagindent=10,
                               tag_bg=To_color,
                               ring_bg=To_color,
                               hull_bg=To_color)
        self.oprop.pack(expand='yes', fill='both')
        self.oproperties = self.oprop.interior()
        self.oproperties.configure(bg=To_color)

        orientations = self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation = Pmw.OptionMenu(
            self.oproperties,
            items=orientations,
            labelpos='w',
            label_text='Name:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.loadorientation,
            initialitem=self.text.To_name,
        )
        self.orientation.pack()
        labels.append(self.orientation)

        self.height = Pmw.EntryField(
            self.oproperties,
            label_text='Size:',
            labelpos='w',
            label_justify='left',
            label_bg=To_color,
            hull_bg=To_color,
            validate={
                'min': 0,
                'validator': 'real'
            },
            command=self.setfont,
        )
        self.height.pack()
        labels.append(self.height)

        f = Tkinter.Frame(self.oproperties, bg=To_color)
        l = Tkinter.Label(
            f,
            text='Angle:',
            bg=To_color,
        )
        l.pack(side='left')
        labels.append(l)
        self.angle = Tkinter.Scale(
            f,
            bigincrement=30,
            from_=-180,
            to=180,
            orient='horizontal',
            tickinterval=90,
            length=200,
            bg=To_color,
            activebackground=To_color,
            highlightbackground=To_color,
            command=self.setfont,
        )
        self.angle.pack()
        f.pack()

        paths = ["right", "left", "up", "down"]
        self.path = Pmw.OptionMenu(
            self.oproperties,
            items=paths,
            labelpos='w',
            label_text='Path:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.path.pack()
        labels.append(self.path)

        haligns = ["left", "center", "right"]
        self.halign = Pmw.OptionMenu(
            self.oproperties,
            items=haligns,
            labelpos='w',
            label_text='Halign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.halign.pack()
        labels.append(self.halign)

        valigns = ["top", "cap", "half", "base", "bottom"]
        self.valign = Pmw.OptionMenu(
            self.oproperties,
            items=valigns,
            labelpos='w',
            label_text='Valign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return
Example #16
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, t_name='default',o_name='default',Parent=None):
        self.gui_parent=gui_parent
        if canvas is None:
##             import Canvas
##             self.canvas = Canvas.Canvas()
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas

        self.text=self.canvas.gettext(t_name,o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error '+t_name+' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error '+o_name+' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent=Parent
        try:
            self.parent_Name=self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color
        
#################################################################################################
# At the moment, this will never happen. When we need to pop this editor up on its own, then we
# will revist this case.
#        if self.gui_parent is None:
#            self.gui_parent=Tkinter.Toplevel()
#            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
#            self.gui_parent.withdraw()
#################################################################################################

        title='Text Editor - table: '+self.text.Tt_name+', orientation: '+self.text.To_name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()
       
        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Text Objects', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open textobject file',
                         label = 'Open TextObject File',
                         command = gui_control.Command( self.evt_open_file, master ),
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
##                                     label = 'Select Table',
##                                     command = self.evt_loadtable,
##                                     )
##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
##                                     label = 'Select Orientation',
##                                     command = self.evt_loadorientation,
##                                     )
        self.cmain_menu.addmenuitem('File', 'command', 'Save TextObject',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setfont,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Table',
                                    label = 'Copy Table',
                                    command = gui_control.Command( self.evt_save_table_as, self.dialog ),
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Orientation',
                                    label = 'Copy Orientation',
                                    command = gui_control.Command( self.evt_save_orientation_as, self.dialog ),
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save to file',
                                    label = 'Save To File',
                                    command = gui_control.Command( self.evt_save_to_file, master ),
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close TextObject Editor',
                                    label = "Exit TextObject Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        self.tprop=Pmw.Group(parent,
                             tag_text='Table',
                             tag_bg=Tt_color,
                             tagindent=10,
                             hull_bg=Tt_color,
                             hull_highlightbackground=Tt_color,
                             hull_highlightcolor=Tt_color,
                            ring_bg=Tt_color,
                             )
        self.tprop.pack(expand='yes',fill='both')
        self.tproperties=self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables=self.canvas.listelements('texttable')
        tables.sort()

        labels=[]
        self.table=Pmw.OptionMenu(self.tproperties,
                                  items=tables,
                                  labelpos='w',
                                  label_text='Name:',
                                  command=self.loadtable,
                                  initialitem=self.text.Tt_name,
                                  label_bg=Tt_color,
                                  hull_bg=Tt_color,
                                  menu_bg=Tt_color,
                                  menu_activebackground=Tt_color,
                                  menubutton_bg=Tt_color,
                                  menubutton_activebackground=Tt_color,
                                 )
        self.table.pack()
        labels.append(self.table)
        
        fonts=self.canvas.listelements("font")
        self.font=Pmw.OptionMenu(self.tproperties,
                                 items=fonts,
                                 labelpos='w',
                                 label_text='Font:',
                                 label_bg=Tt_color,
                                 hull_bg=Tt_color,
                                 menu_bg=Tt_color,
                                 menu_activebackground=Tt_color,
                                 menubutton_bg=Tt_color,
                                 menubutton_activebackground=Tt_color,
                                 command=self.setfont,
                                 )
        self.font.pack()
        labels.append(self.font)

        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        l=Tkinter.Label(f,
                        text='Spacing:',
                        bg=Tt_color,
                        )
        l.pack(side='left')
        self.spacing=Tkinter.Scale(f,
                                   bigincrement=10,
                                   from_=-50,
                                   to=50,
                                   orient='horizontal',
                                   tickinterval=25,
                                   length=200,
                                   bg=Tt_color,
                                   activebackground=Tt_color,
                                   highlightbackground=Tt_color,
                                   command=self.setfont,
                                  )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        l=Tkinter.Label(f,
                        text='Width:',
                        bg=Tt_color,
                        )
        l.pack(side='left')
        self.expansion=Tkinter.Scale(f,
                                     bigincrement=10,
                                     from_=50,
                                     to=150,
                                     orient='horizontal',
                                     tickinterval=25,
                                     length=200,
                                     bg=Tt_color,
                                     activebackground=Tt_color,
                                     highlightbackground=Tt_color,
                                     command=self.setfont,
                                     )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        
        l=Tkinter.Label(f,
                        text='Color:',
                        bg=Tt_color,
                        )
        
        l.pack(side='left')
        
        self.Color=Tkinter.Scale(f,
                                 bigincrement=50,
                                 from_=0,
                                 to=255,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=Tt_color,
                                 activebackground=Tt_color,
                                 highlightbackground=Tt_color,
                                 command=self.setfont,
                                 )
        
        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels=[]
        self.oprop=Pmw.Group(parent,tag_text='Orientation',tagindent=10,tag_bg=To_color,ring_bg=To_color,hull_bg=To_color)
        self.oprop.pack(expand='yes',fill='both')
        self.oproperties=self.oprop.interior()
        self.oproperties.configure(bg=To_color)
        
        orientations=self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation=Pmw.OptionMenu(self.oproperties,
                                        items=orientations,
                                        labelpos='w',
                                        label_text='Name:',
                                        label_bg=To_color,
                                        hull_bg=To_color,
                                        menu_bg=To_color,
                                        menu_activebackground=To_color,
                                        menubutton_bg=To_color,
                                        menubutton_activebackground=To_color,
                                        command=self.loadorientation,
                                        initialitem=self.text.To_name,
                                 )
        self.orientation.pack()
        labels.append(self.orientation)
        
        self.height=Pmw.EntryField(self.oproperties,
                                   label_text='Size:',
                                   labelpos='w',
                                   label_justify='left',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   validate={'min':0,'validator':'real'},
                                   command=self.setfont,
                                   )
        self.height.pack()
        labels.append(self.height)
        
        f=Tkinter.Frame(self.oproperties,bg=To_color)
        l=Tkinter.Label(f,
                        text='Angle:',
                        bg=To_color,
                        )
        l.pack(side='left')
        labels.append(l)
        self.angle=Tkinter.Scale(f,
                                 bigincrement=30,
                                 from_=-180,
                                 to=180,
                                 orient='horizontal',
                                 tickinterval=90,
                                 length=200,
                                 bg=To_color,
                                 activebackground=To_color,
                                 highlightbackground=To_color,
                                 command=self.setfont,
                                 )
        self.angle.pack()
        f.pack()

        paths=["right","left","up","down"]
        self.path=Pmw.OptionMenu(self.oproperties,
                                 items=paths,
                                 labelpos='w',
                                 label_text='Path:',
                                 label_bg=To_color,
                                 hull_bg=To_color,
                                 menu_bg=To_color,
                                 menu_activebackground=To_color,
                                 menubutton_bg=To_color,
                                 menubutton_activebackground=To_color,
                                 command=self.setfont,
                                 )
        self.path.pack()
        labels.append(self.path)
        
        haligns=["left","center","right"]
        self.halign=Pmw.OptionMenu(self.oproperties,
                                   items=haligns,
                                   labelpos='w',
                                   label_text='Halign:',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   menu_bg=To_color,
                                   menu_activebackground=To_color,
                                   menubutton_bg=To_color,
                                   menubutton_activebackground=To_color,
                                   command=self.setfont,
                                   )
        self.halign.pack()
        labels.append(self.halign)
        
        valigns=["top","cap","half","base","bottom"]
        self.valign=Pmw.OptionMenu(self.oproperties,
                                   items=valigns,
                                   labelpos='w',
                                   label_text='Valign:',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   menu_bg=To_color,
                                   menu_activebackground=To_color,
                                   menubutton_bg=To_color,
                                   menubutton_activebackground=To_color,
                                   command=self.setfont,
                                   )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)
        
        self.fbuttons=Tkinter.Frame(parent)
        self.fbuttons.pack()
##         b0=Tkinter.Button(self.fbuttons,
##                           text='Preview',
##                           command=self.setfont)
##         b0.pack(side='left')
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')
        
        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
def main():
    #------------------------------------------------------------------------------
    # We are using the same gui_support as VCDAT for possible future integration
    #------------------------------------------------------------------------------
    root = gui_support.root()
    Pmw.initialise(root)

    #----------------------------------------------------------------------------
    # One time only call to setup the database session
    #----------------------------------------------------------------------------
    root.echoSql = False
    extraction_controls.call_sessionmaker(root)

    #----------------------------------------------------------------------------
    # Initialize the GUI widgets
    #----------------------------------------------------------------------------
    root.main_frame = GUI_frame(root)

    #------------------------------------------------------------------------------
    # Display the ESG-CET world image in the background and the copyright
    #------------------------------------------------------------------------------
    root.canvas = Tkinter.Frame(root.pane2.pane('EditPaneTop'))
    root.canvas.pack(side='top', fill='both', expand=1)

    txtFont = tkFont.Font(root,
                          family=pub_controls.tab_font_type,
                          size=pub_controls.tab_font_size)
    copywrite_text = "\nPublisher software version %s @ copyright LLNL/PCMDI\nEarth System Grid Center for Enabling Technologies, funded by the U.S. Department of Energy" % root.Version
    root.text = Tkinter.Label(root.canvas,
                              text=copywrite_text,
                              font=txtFont,
                              bg="white")
    root.text.pack(side='top', fill='both', expand=1)

    img = Tkinter.PhotoImage(file=esg_bg)
    root.canvas_img = Tkinter.Label(root.canvas, image=img, background="white")
    root.canvas_img.image = img
    root.canvas_img.pack(side='top', fill='both', expand=1)

    #------------------------------------------------------------------------------
    # Redirect stderr and stdout to the output windows located in the bottom_right
    # pane (i.e., "Output" and "Error")
    #
    # INFO messages are sent to the "Output" window -- that is, stdout
    #
    # WARNING, ERROR, DEBUG, CRITICAL, and Exception messages are sent to
    # the "Error" window -- that is, stderr
    #
    # Note: we distinguish between what is standard out and standard error,
    #       then display the appropriate window to view the text
    #------------------------------------------------------------------------------
    sys.stdout = pub_controls.standard_out(root)
    sys.stderr = pub_controls.standard_err(root)

    #----------------------------------------------------------------------------
    # Log INFO messages to stdout and display the output to the "Output" window
    #----------------------------------------------------------------------------
    inf = logging.StreamHandler(sys.stdout)
    inf.setLevel(logging.INFO)
    logging.getLogger('Info').addHandler(inf)

    #----------------------------------------------------------------------------
    # Log WARNING messages to stderr and display the output to the "Error" window
    #----------------------------------------------------------------------------
    wrn = logging.StreamHandler(sys.stderr)
    wrn.setLevel(logging.WARNING)
    logging.getLogger('Warning').addHandler(wrn)

    #----------------------------------------------------------------------------
    # Log ERROR messages to stderr and display the output to the "Error" window
    #----------------------------------------------------------------------------
    err = logging.StreamHandler(sys.stderr)
    err.setLevel(logging.ERROR)
    logging.getLogger('Error').addHandler(err)

    #----------------------------------------------------------------------------
    # Log DEBUG messages to stderr and display the output to the "Error" window
    #----------------------------------------------------------------------------
    dbg = logging.StreamHandler(sys.stderr)
    dbg.setLevel(logging.DEBUG)
    logging.getLogger('Debug').addHandler(dbg)

    #----------------------------------------------------------------------------
    # Log CRITICAL messages to stderr and display the output to the "Error" window
    #----------------------------------------------------------------------------
    crt = logging.StreamHandler(sys.stderr)
    crt.setLevel(logging.CRITICAL)
    logging.getLogger('Critical').addHandler(crt)

    #----------------------------------------------------------------------------
    # Log Exception messages to stderr and display the output to the "Error" window
    #----------------------------------------------------------------------------
    exc = logging.StreamHandler(sys.stderr)
    exc.setLevel(logging.ERROR)
    logging.getLogger('Exception').addHandler(exc)

    #----------------------------------------------------------------------------
    # Test the message print commands from logging --- the below lines are
    # showing examples of how to use Python logging for message sending
    #----------------------------------------------------------------------------
    #debug("%d: This is the Debug Test" % logging.DEBUG)
    #info("%d: This is the Info Test" % logging.INFO)
    #warning("%d: This is Warning Test" % logging.WARNING)
    #error("%d: This is the Error Test" % logging.ERROR)
    #critical("%d: This is the Critical Test" % logging.CRITICAL)
    #exception("%d: This is the Exception (NotSet) Test" % logging.NOTSET)

    #---------------------------------------------------------------------
    # View the GUI on the screen.
    #---------------------------------------------------------------------
    root.deiconify()
    root.update()
    root.lift()

    #---------------------------------------------------------------------
    # Enter the Tkinter main event loop
    #---------------------------------------------------------------------
    root.mainloop()