コード例 #1
0
    def __init__(self, parent, fself, fn_name, expression):
        self.parent = parent
        self.fself = fself
        self.dialog = Pmw.Dialog(parent,
                                 title="Enter Variable Name and Expression",
                                 buttons=('Apply', 'Clear', 'Dismiss'),
                                 command=gui_control.Command(
                                     self.execute, parent))

        self.dialog.transient(parent)  # draw widget on top of its parent

        framea = Tkinter.Frame(self.dialog.interior())
        framea.pack(side='top', fill='both', expand=1)

        self.name = Pmw.EntryField(self.dialog.interior(),
                                   labelpos='n',
                                   label_text='Name',
                                   value=fn_name,
                                   entry_background='white',
                                   entry_foreground='black',
                                   entry_width=15)
        self.name.pack(side='left', expand=1, fill='both', padx=3, pady=10)
        self.parent.balloon.bind(self.name, "Enter variable name.")

        equal_sign = Tkinter.Label(
            self.dialog.interior(),
            text=" = ",
            justify='left',
            anchor='w',
        )
        equal_sign.pack(side='left', expand=1, fill='both', padx=3, pady=10)

        self.expression = Pmw.EntryField(self.dialog.interior(),
                                         labelpos='n',
                                         label_text='Expression',
                                         value=expression,
                                         entry_background='white',
                                         entry_foreground='black',
                                         entry_width=45)
        self.expression.pack(side='left',
                             expand=1,
                             fill='both',
                             padx=3,
                             pady=10)
        self.expression.component('entry').bind(
            "<Key>", gui_control.Command(self.evt_change_color, parent))
        self.expression.component('entry').bind(
            "<Return>", gui_control.Command(self.evt_get_entry, parent))
        self.parent.balloon.bind(
            self.expression,
            "Enter or modify expression, followed by the <Return> key.")

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #2
0
   def __init__(self, parent, statistics_type):
        self.parent = parent
        lst = parent.panelDV.selected_list.keys()
        if len(lst)==0:
           return
        var1=parent.panelDV.lst1[ parent.panelDV.selected_list[ lst[0] ]]
        
        self.dialog = Pmw.Dialog( parent,
            title = "%s Question to User"%statistics_type,
            buttons = ('OK', 'Dismiss'),
            defaultbutton = 'OK',
            command = gui_control.Command(self.execute, parent, statistics_type, var1) )

        if parent.menu.popup_window_settings_flg == 1:
           self.dialog.transient( self.parent ) # Keep widget on top of its parent

        lbl=Tkinter.Label(self.dialog.interior(),
            text = "Operate the '%s' function on the following\ndimension(s):"%statistics_type,
            justify = 'left',
            anchor = 'w', 
            )
        lbl.pack( expand = 1, fill = 'both', padx=10, pady=5 )

        self.dimension_name = {}
        self.dimension_toggles1 ={}
        self.dimension_toggles2 ={}
        self.dimension_state ={}
        for text in var1.listdimnames():
           frame = Tkinter.Frame( self.dialog.interior() )
           frame.pack( side='top', expand = 1, fill = 'both', padx=10, pady=5 )
           self.dimension_name[text] = Tkinter.Label(frame,
            text = '%s: ' % text,
            justify = 'left',
            anchor = 'w',
            )
           self.dimension_name[text].pack( side='left', expand = 1, fill = 'both', padx=10, pady=5 )
	   # Create and pack a check buttons for the variable axis.
           self.dimension_toggles1[text] = Tkinter.Checkbutton( frame,
             selectcolor=gui_color.one,
             text = 'Yes                                            ',
             command = gui_control.Command(self.weighted_cb, text, 1)
           )
           self.dimension_toggles1[text].pack(side = 'left', fill = 'both', padx=5, pady=5)
           self.dimension_state[text] = 0
           if text == var1.listdimnames()[0] :
              self.dimension_toggles1[text].select()
              self.dimension_state[text] = 1


        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi( geom[1] )
        d2 = string.atoi( geom[2] )
	self.dialog.geometry( "+%d+%d" % (d1, d2) )
コード例 #3
0
   def __init__( self, parent ):
        self.eself = parent

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

        self.pmain_menu.addmenu('Page Layout Option', 'Set VCS Page Layout Preferences', tearoff = 1)

        self.pmain_menu.addmenuitem('Page Layout Option', 'command', 'create new page description form',
                       label = 'Create Page Layout Form',
                       command = gui_control.Command(self.evt_create_new_pl_form, parent)
                      )

        self.scl_frame = Pmw.ScrolledFrame( parent.pane.pane( 'panelVI' ),
#                labelpos = 'nw',
#                label_text = 'Page Layout Forms:',
                horizscrollbar_width=gui_control.scl_width,
                vertscrollbar_width=gui_control.scl_width
                )
        self.scl_frame.pack( side='top', fill='both' )
        self.eself.balloon.bind(self.scl_frame, " The Page Layout Editor is used to specify picture descriptor\n forms that define how plots are displayed on the\n VCS Canvas (drawing area). There are three primary\n objects in each picture descriptor form that correspond\n to text windows of the template (in green), the\n graphics method (in blue), and the data (in red).\n Names are assigned to these text windows from the\n scroll windows below the 'Page Layout Forms'.\n These scroll windows include a green `Template'\n window, a blue `Graphics Method' window, and a red\n `Data' window.")

        # Keep track of created forms
        self.form={}
コード例 #4
0
    def __init__(self, parent,bounds_type):
        self.parent = parent
        self.dialog = Pmw.Dialog( parent,
                                  title = "%s Question to User"%bounds_type,
                                  buttons = ('OK', 'Dismiss'),
                                  defaultbutton = 'OK',
                                  command = gui_control.Command(self.execute, parent, bounds_type) )
        
        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient( self.parent ) # Keep widget on top of its parent

        if bounds_type=='Xhourly':
            label="Frequency"
        if label!="":
            self.entry=Pmw.EntryField(self.dialog.interior(),
                                      validate = { 'validator':'integer','min':1,'max':24},
                                      labelpos='w',
                                      label_text=label)
            self.entry.pack()

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi( geom[1] )
        d2 = string.atoi( geom[2] )
	self.dialog.geometry( "+%d+%d" % (d1, d2) )
コード例 #5
0
    def __init__(self,
                 parent,
                 type,
                 title,
                 text,
                 entry_str='',
                 update_widget=None,
                 gm_type=None):
        self.parent = parent
        self.type = type
        self.entry_str = entry_str
        self.update_widget = update_widget
        self.gm_type = gm_type
        self.dialog = Pmw.Dialog(parent,
                                 title=title,
                                 buttons=('OK', 'Dismiss'),
                                 defaultbutton='OK',
                                 command=gui_control.Command(
                                     self.execute, parent))

        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient(
                self.parent)  # Keep widget on top of its parent

        lbl = Tkinter.Label(
            self.dialog.interior(),
            text=text,
            justify='left',
            anchor='w',
        )
        lbl.pack(expand=1, fill='both', padx=10, pady=5)

        self.eny1 = Pmw.EntryField(
            self.dialog.interior(),
            labelpos='w',
            entry_background='white',
            entry_foreground='black',
            value=entry_str,
            entry_width=50,
        )
        self.eny1.pack(expand=1, fill='both', padx=10, pady=5)
        if self.type in ['template_save_as', 'gm_save_as']:
            self.eny1.setentry("")

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        if type != 'd' and type != 'operation':
            self.dialog.geometry("+%d+%d" % (d1, d2))
        else:
            geom = "+%d+%d" % (d1, d2)
            self.dialog.activate(geometry=geom)
コード例 #6
0
    def execute(self, parent, template_name, template_member, result):
        if result in ['Apply', 'OK']:
            self.get_template_attribute_settings(parent, template_name,
                                                 template_member)
        else:
            template = parent.vcs[parent.vcs_id].gettemplate(template_name)
            template_member = template.__dict__[template_member]

            template_member.priority = self.template_member_priority
            template_member.x = self.template_member_x
            template_member.y = self.template_member_y
            template_member.texttable = self.template_member_texttable
            template_member.textorientation = self.template_member_textorientation

        parent.panelGC.evt_plot(parent)
        if result == 'Apply':
            template = parent.vcs[parent.vcs_id].gettemplate(template_name)
            template_member = template.__dict__[template_member]

            if self.parent.vcg[parent.vcs_id][3] is not None:
                tentry = self.parent.vcg[parent.vcs_id][3]
            else:
                tentry = template_member.texttable
            if self.parent.vcg[parent.vcs_id][2] is not None:
                oentry = self.parent.vcg[parent.vcs_id][2]
            else:
                oentry = template_member.textorientation

            self.bpo.configure(command=gui_control.Command(
                fonteditorgui.FontGUI, self.parent.vcs[parent.vcs_id],
                self.parent, self.dialog, self.fo, tentry, oentry, self))
            self.bpf.configure(command=gui_control.Command(
                fonteditorgui.FontGUI, self.parent.vcs[parent.vcs_id],
                self.parent, self.dialog, self.ft, tentry, oentry, self))

        else:
            self.dialog.destroy()
コード例 #7
0
    def __init__(self, parent, filter_type):
        lst = parent.panelDV.selected_list.keys()
        if len(lst)!=1:
            gui_message.error( "The '"+filter_type+" Filter  Tool' could not complete its function, only one variable at a time please" )
            return
        var=parent.panelDV.lst1[ parent.panelDV.selected_list[ lst[0] ] ]
        self.parent = parent
        self.dialog = Pmw.Dialog( parent,
                                  title = "%s Question to User"%filter_type,
                                  buttons = ('OK', 'Dismiss'),
                                  defaultbutton = 'OK',
                                  command = gui_control.Command(self.execute, parent, filter_type, var) )
        
        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient( self.parent ) # Keep widget on top of its parent

        if filter_type=='RunningAverage':
            label="Length"
        elif filter_type=="121":
            label=""
        elif filter_type=='Custom':
            label="Filter (Enter as a list)"
        if label!="":
            self.entry=Pmw.EntryField(self.dialog.interior(),
                                      labelpos='w',
                                      label_text=label)
            self.entry.pack()

        self.radio=Pmw.RadioSelect(self.dialog.interior(),
                                   labelpos='nw',
                                   label_text='Choose which dimension to apply the filter on',
                                   buttontype = 'radiobutton',
                                   orient='vertical',
                                   )
        self.radio.pack()
        for text in var.listdimnames():
            self.radio.add(text)
        self.radio.invoke(0)
        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi( geom[1] )
        d2 = string.atoi( geom[2] )
	self.dialog.geometry( "+%d+%d" % (d1, d2) )
コード例 #8
0
    def __init__(self, parent):
        self.parent = parent
        dialog = Pmw.Dialog(parent,
                            title='User menus',
                            buttons=('Close', ),
                            defaultbutton='Close')

        current_directory = os.getcwd()
        # Hide 'Manage user menus' window until all drawing is complete
        dialog.withdraw()

        dialog.unbind("<Return>")
        if parent.menu.popup_window_settings_flg == 1:
            dialog.transient(self.parent)  # Keep widget on top of its parent

        self.directory = os.environ['HOME']

        # Generate a list of user defined menu names
        self.menus = []
        for i in range(len(l_menu)):
            self.menus.append(l_menu[i]['m_nam'])

        # Initialize the list of functions for selected menu
        self.functions = []

        # Set mode of getting functions to file
        self.mode = 'File'

        # Setup groups for dialog window
        group1 = Pmw.Group(dialog.interior(),
                           tag_text='Create user menu:',
                           tag_font=('Times', 14, 'bold'),
                           tagindent=15)
        group2 = Pmw.Group(dialog.interior(),
                           tag_text='Modify user menu:',
                           tag_font=('Times', 14, 'bold'),
                           tagindent=15)
        group3 = Pmw.Group(dialog.interior(),
                           tag_text='Delete user menu:',
                           tag_font=('Times', 14, 'bold'),
                           tagindent=15)

        # Populate group1
        self.eny1 = Pmw.EntryField(group1.interior(),
                                   labelpos='w',
                                   label_text='Menu name:',
                                   entry_background='white',
                                   entry_foreground='black',
                                   validate='alphanumeric')
        self.eny1.component('entry').bind(
            '<Return>', gui_control.Command(self.add_top_menu, parent))
        help_message = wrap_balloon_help(
            "Enter a new menu name. Use only alphanumeric characters. Press <Enter> or click on the 'Add' button to add the new menu to the main menu panel."
        )
        parent.balloon.bind(self.eny1, help_message)
        self.eny1.pack(expand=1, fill='x', padx=10, pady=1)
        self.eny2 = Pmw.EntryField(group1.interior(),
                                   labelpos='w',
                                   label_text='Description:',
                                   entry_background='white',
                                   entry_foreground='black')
        self.eny2.pack(expand=1, fill='x', padx=10, pady=1)
        self.eny2.component('entry').bind(
            '<Return>', gui_control.Command(self.add_top_menu, parent))
        help_message = wrap_balloon_help(
            "(Optional) Enter a description to be displayed as part of the ballon help for the new menu. This message will be displayed when the user rests the mouse pointer over the menu name."
        )
        parent.balloon.bind(self.eny2, help_message)
        labels = (self.eny1, self.eny2)
        Pmw.alignlabels(labels)

        tempframe = Tkinter.Frame(group1.interior())
        btn1 = Tkinter.Button(tempframe,
                              text='Clear',
                              command=gui_control.Command(
                                  self.clear_top, parent))
        btn1.pack(side='left', expand=0, fill='x', padx=10, pady=5)
        help_message = wrap_balloon_help(
            "Clear menu name and description fields.")
        parent.balloon.bind(btn1, help_message)

        btn2 = Tkinter.Button(tempframe,
                              text='Add',
                              default='active',
                              command=gui_control.Command(
                                  self.add_top_menu, parent))
        btn2.pack(side='left', expand=0, fill='x', padx=10)
        help_message = wrap_balloon_help("Add menu to main menu panel.")
        parent.balloon.bind(btn2, help_message)
        tempframe.pack()
        group1.pack(fill='x', anchor='nw', expand=1, padx=10, pady=10)

        # Populate group2
        self.eny3 = Pmw.ComboBox(group2.interior(),
                                 labelpos='w',
                                 label_text='Menu name:',
                                 entry_background='white',
                                 entry_foreground='black',
                                 dropdown=1,
                                 selectioncommand=gui_control.Command(
                                     self.populate_group2),
                                 scrolledlist_items=self.menus)
        self.eny3.pack(side='top', expand=1, fill='x', padx=10, pady=1)
        help_message = wrap_balloon_help(
            "Select a menu to modify by clicking on the pull down menu or typing in the menu name by hand and pressing <Enter>."
        )
        parent.balloon.bind(self.eny3, help_message)
        tempframe = Tkinter.Frame(group2.interior())
        self.eny4 = Pmw.EntryField(tempframe,
                                   labelpos='w',
                                   label_text='Description:',
                                   entry_background='white',
                                   entry_foreground='black')
        self.eny4.component('entry').bind(
            '<Return>', gui_control.Command(self.change_description, parent))
        help_message = wrap_balloon_help(
            'Enter a new description and press <Enter> or click on the \"Change\" button to change the help balloon associated with the selected menu.'
        )
        parent.balloon.bind(self.eny4, help_message)
        self.eny4.pack(side='left', expand=1, fill='x', padx=10)
        btn3 = Tkinter.Button(tempframe,
                              text='Change',
                              command=gui_control.Command(
                                  self.change_description, parent))
        btn3.pack(side='left', padx=10)
        help_message = wrap_balloon_help(
            'Change help balloon associated with the selected menu.')
        parent.balloon.bind(btn3, help_message)
        tempframe.pack(expand=1, fill='x', pady=1)

        labels2 = (self.eny3, self.eny4)
        Pmw.alignlabels(labels2)

        # Setup group2a
        self.group2a = Pmw.Group(group2.interior(),
                                 tag_text='Add function to menu from file:',
                                 tag_font=('Times', 14),
                                 tagindent=10)
        tempframe = Tkinter.Frame(self.group2a.interior())
        self.eny5_file = Pmw.EntryField(tempframe,
                                        labelpos='w',
                                        label_pyclass=Pmw.OptionMenu,
                                        label_items=gui_control.dirimpchlst,
                                        label_command=gui_control.Command(
                                            self.file_or_import, parent),
                                        label_initialitem='File',
                                        entry_background='white',
                                        entry_foreground='black')
        self.eny5_file.component('entry').bind(
            '<Return>', gui_control.Command(self.get_functions))
        self.eny5_file.pack(side='left', fill='x', expand=1, padx=10)
        help_message = wrap_balloon_help(
            'Select a python file to add functions from by typing in the name of the file and pressing <Enter>, or click on the \'Browse\' button and search for your file. If you enter the file name by hand and don\'t specify the full path, the file location is relative to your home directory.'
        )
        parent.balloon.bind(self.eny5_file, help_message)
        self.eny5_import = Pmw.ComboBox(
            tempframe,
            labelpos='w',
            label_pyclass=Pmw.OptionMenu,
            label_items=gui_control.dirimpchlst,
            label_command=gui_control.Command(self.file_or_import, parent),
            selectioncommand=gui_control.Command(self.get_functions),
            entry_background='white',
            entry_foreground='black')
        help_message = wrap_balloon_help(
            'Select a module to import functions from by clicking on the pull down menu or entering the module name by hand and pressing <Enter>.'
        )
        parent.balloon.bind(self.eny5_import, help_message)
        self.btn4 = Tkinter.Button(tempframe,
                                   text='Browse',
                                   command=gui_control.Command(
                                       self.browse_files, parent))
        self.btn4.pack(side='left', padx=10)
        help_message = wrap_balloon_help(
            'Select a python file to import functions from.')
        parent.balloon.bind(self.btn4, help_message)
        tempframe.pack(side='top', anchor='w', expand=1, fill='x', pady=1)

        self.eny6 = Pmw.ComboBox(self.group2a.interior(),
                                 labelpos='w',
                                 label_text='Function:',
                                 entry_background='white',
                                 entry_foreground='black',
                                 entry_width=40,
                                 selectioncommand=gui_control.Command(
                                     self.select_function),
                                 dropdown=1)
        self.eny6.pack(side='top', expand=1, fill='x', padx=10, pady=1)

        help_message = wrap_balloon_help(
            'Select a function name to add by clicking on the pull down menu.')
        parent.balloon.bind(self.eny6, help_message)
        tempframe = Tkinter.Frame(self.group2a.interior())
        ## checkbox to have the function wrapped as a plotting extension
        self.eny7b = Pmw.RadioSelect(
            tempframe,
            buttontype='checkbutton',
            labelpos='w',
            label_text='This function plots onto the VCS canvas',
        )
        self.eny7b.pack(side='left', expand=1, fill='x', padx=10)
        self.eny7b.add("")
        help_message = wrap_balloon_help(
            'If this is checked you can then drop defined variable in the display lines to redraw with new variable, and use different templates'
        )
        parent.balloon.bind(self.eny7b, help_message)
        tempframe.pack(side='top', anchor='w', fill='x', expand=1, pady=1)
        tempframe = Tkinter.Frame(self.group2a.interior())
        self.eny7 = Pmw.EntryField(tempframe,
                                   labelpos='w',
                                   label_text='Function name:',
                                   entry_background='white',
                                   entry_foreground='black')
        self.eny7.component('entry').bind(
            '<Return>', gui_control.Command(self.add_function, parent))
        self.eny7.pack(side='left', expand=1, fill='x', padx=10)
        help_message = wrap_balloon_help(
            'Enter the name of the function to be added to the selected menu.')
        parent.balloon.bind(self.eny7, help_message)

        btn5 = Tkinter.Button(tempframe,
                              text='Add',
                              command=gui_control.Command(
                                  self.add_function, parent))
        btn5.pack(side='left', padx=10)
        help_message = wrap_balloon_help('Add function to selected menu.')
        parent.balloon.bind(btn5, help_message)
        tempframe.pack(side='top', anchor='w', fill='x', expand=1, pady=1)
        labels = (self.eny5_file, self.eny6, self.eny7)
        Pmw.alignlabels(labels)

        self.group2a.pack(side='top', expand=1, fill='x', padx=10, pady=5)

        # Setup group2b
        group2b = Pmw.Group(group2.interior(),
                            tag_text='Delete or Rename function:',
                            tag_font=('Times', 14),
                            tagindent=10)
        tempframe = Tkinter.Frame(group2b.interior())
        self.eny8 = Pmw.ComboBox(tempframe,
                                 labelpos='w',
                                 label_text='Function name:',
                                 entry_background='white',
                                 entry_foreground='black',
                                 entry_state='disabled',
                                 dropdown=1)
        self.eny8.component('entry').bind('<KeyPress>',
                                          gui_control.Command(self.do_nothing))
        self.eny8.pack(side='left', expand=1, fill='x', padx=10)
        help_message = wrap_balloon_help(
            'Select function name by clicking on the pull down menu.')
        parent.balloon.bind(self.eny8, help_message)
        btn7 = Tkinter.Button(tempframe,
                              text='Delete',
                              command=gui_control.Command(
                                  self.delete_function, parent))
        btn7.pack(side='left', padx=10)
        help_message = wrap_balloon_help('Delete function from menu.')
        parent.balloon.bind(btn7, help_message)
        tempframe.pack(side='top', fill='x', expand=1, pady=1)

        tempframe = Tkinter.Frame(group2b.interior())
        self.eny8a = Pmw.EntryField(tempframe,
                                    labelpos='w',
                                    label_text='New name:',
                                    entry_background='white',
                                    entry_foreground='black')
        self.eny8a.component('entry').bind('<Return>',
                                           gui_control.Command(self.rename))
        self.eny8a.pack(side='left', expand=1, fill='x', padx=10)
        help_message = wrap_balloon_help(
            'Change function name by typing in new function name and pressing <Enter> or clicking on the \'Delete\' button.'
        )
        parent.balloon.bind(self.eny8a, help_message)
        btn6 = Tkinter.Button(tempframe,
                              text='Rename',
                              command=gui_control.Command(self.rename))
        btn6.pack(side='left', padx=10)
        help_message = wrap_balloon_help('Rename function.')
        parent.balloon.bind(btn6, help_message)
        labels = (self.eny8, self.eny8a)
        Pmw.alignlabels(labels)
        tempframe.pack(side='top', fill='x', expand=1, pady=1)

        group2b.pack(side='top', expand=1, fill='x', padx=10, pady=10)

        group2.pack(fill='x', anchor='nw', expand=1, padx=10, pady=5)

        # Populate group3
        self.eny9 = Pmw.ComboBox(group3.interior(),
                                 labelpos='w',
                                 label_text="Menu name:",
                                 entry_background='white',
                                 entry_foreground='black',
                                 scrolledlist_items=self.menus,
                                 dropdown=1)
        self.eny9.pack(side='left', expand=1, fill='x', padx=10)
        help_message = wrap_balloon_help(
            'Select a menu to delete by clicking on the pull down menu.')
        parent.balloon.bind(self.eny9, help_message)
        btn8 = Tkinter.Button(group3.interior(),
                              text='Delete',
                              command=gui_control.Command(
                                  self.del_top_menu, parent))
        btn8.pack(side='left', padx=10)
        help_message = wrap_balloon_help('Delete menu from main menu bar.')
        parent.balloon.bind(btn8, help_message)
        group3.pack(side='top',
                    anchor='nw',
                    expand=1,
                    fill='x',
                    padx=10,
                    pady=15,
                    ipady=2)

        # Position dialog popup on top of the main GUI
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2]) + 40

        #      dialog.activate(globalMode = 'nograb' ,geometry = 'centerscreenalways')
        dialog.geometry("+%d+%d" % (d1, d2))
        dialog.show()
コード例 #9
0
   def __init__(self, parent):
        if parent.annotate_start_over == 1: parent.panelGC.evt_plot( parent )

        if (parent.panelDM.var3 is None) and (len(parent.panelDV.selected) == 0): return

        self.parent = parent
        self.preview_flg = 0
        self.dialog = Pmw.Dialog( parent,
            title = 'Annotate VCS Plot',
            buttons = ('Preview', 'Reset to\nInitial\nState', 'Use\nVariable\nDefaults', 'Apply\nCurrent\nSettings', 'Cancel'),
            defaultbutton = 'Apply\nCurrent\nSettings',
            command = gui_control.Command(self.execute, parent) )

        if parent.menu.popup_window_settings_flg == 1:
           self.dialog.transient( self.parent ) # Keep widget on top of its parent
        self.dialog.withdraw()                  # this is too slow

        # Save the incoming settings, just in case the user cancels.
        self.hold_annotate_cancel_settings( parent )

        # Get information from the data and the graphics methods
#        if self.parent.annotate_get_info == 1:
#           get_annotation_info( parent, self.parent.annotate_var_name )
        self.parent.annotate_view = 1

        # Setup group1 (Master annotations control)
        group1 = Pmw.Group(self.dialog.interior(),
                            tag_text = 'Master control',
                            tagindent = 10,
                            tag_font = ('times',14,'bold'))

        self.retain = Pmw.RadioSelect(group1.interior(),
                            labelpos = 'w',
                            label_text = 'Retain Annotation Settings:',
                            labelmargin = 20,
                            buttontype = 'radiobutton',
                            command = gui_control.Command(self.retain_switch, parent)
                            )
        self.parent.balloon.bind(self.retain, "Select whether or not to retain annotation settings for all variables selected.")

        self.retain.add('no')
        self.retain.add('yes')
        self.retain.invoke( self.parent.annotate_retain )
        self.retain.pack(side = 'top', expand = 1, fill = 'x',padx = 10,pady = 0)
        group1.pack(side = 'top', expand = 1, fill = 'x',padx = 10,pady = 10)

        self.master = Pmw.RadioSelect(group1.interior(),
                            labelpos = 'w',
                            label_text = 'Annotation Status:',
                            labelmargin = 75,
                            buttontype = 'radiobutton',
                            command = gui_control.Command(self.master_switch, parent) )
        self.parent.balloon.bind(self.master, "Toggle 'All Annotation' on or off.")

        self.master.add('on')
        self.master.add('off')
        self.master.invoke( self.parent.annotate_status )
        self.master.pack(side = 'left', expand = 1, fill = 'x',padx = 10,pady = 0)
        group1.pack(side = 'top', expand = 1, fill = 'x',padx = 10,pady = 10)

        # Setup group2 (Change plot labels)
        group2 = Pmw.Group(self.dialog.interior(),
                            tag_text = 'Change labels',
                            tagindent = 10,
                            tag_font = ('times',14,'bold'))
        tempframe = Tkinter.Frame(group2.interior())
        self.eny1 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'Source:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black')
        self.eny1.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        parent.balloon.bind(self.eny1,"Enter the 'Source' text to be displayed on the VCS Canvas")
        if self.parent.annotate_source is not None:
           self.eny1.setentry( self.parent.annotate_source )
        btn1 = Tkinter.Button(tempframe,
                                text = 'Properties',
                                command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'source', None))
        btn1.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x', pady = 1)

        tempframe = Tkinter.Frame(group2.interior())
        self.eny2 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'Name:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black',
                                    command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'dataname'))
        self.eny2.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        self.parent.balloon.bind(self.eny2, "Enter the 'Name' text to be displayed on the VCS Canvas")
        if self.parent.annotate_name is not None:
           self.eny2.setentry( self.parent.annotate_name )
        elif ((parent.annotate_name is None) or (parent.annotate_name == "QuickPlot")):
           try: self.eny2.setentry( parent.QuickPlot_name[ 'QuickPlot' ] )
           except: pass
        btn2 = Tkinter.Button(tempframe,
                                text = 'Properties',
                                command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'dataname', None))
        btn2.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x', pady = 1)

        tempframe = Tkinter.Frame(group2.interior())
        self.eny3 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'Title:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black')
        self.eny3.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        parent.balloon.bind(self.eny3,"Enter the 'Title' text to be displayed on the VCS Canvas")
        if self.parent.annotate_title is not None:
           self.eny3.setentry( self.parent.annotate_title )
        btn3 = Tkinter.Button(tempframe,
                                text = 'Properties',
                                command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'title', None))
        btn3.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x', pady = 1)

        tempframe = Tkinter.Frame(group2.interior())
        self.eny4 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'Units:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black')
        self.eny4.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        parent.balloon.bind(self.eny4,"Enter the 'Units' text to be displayed on the VCS Canvas")
        if self.parent.annotate_units is not None:
           self.eny4.setentry( self.parent.annotate_units )
        btn4 = Tkinter.Button(tempframe,
                                text = 'Properties',
                                command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'units', None))
        btn4.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x', pady = 1)

        tempframe = Tkinter.Frame(group2.interior())
        self.eny5 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'X-label:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black')
        self.eny5.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        gm_type = parent.panelGC.text_opt2.get()
        if gm_type in ['Xyvsy']:
            self.eny5.configure( label_state = 'disabled', entry_state = 'disabled')
            parent.balloon.bind(self.eny5,"'X-label' disabled for this graphic method, use Name instead")
        else:       
            parent.balloon.bind(self.eny5,"Enter the 'X-label' name to be displayed on the VCS Canvas")
        if self.parent.annotate_xlabel is not None:
           self.eny5.setentry( self.parent.annotate_xlabel )
        else:
           try: self.eny5.setentry( self.parent.hannotate_xlabel )
           except: pass
        self.store_annotate_xlabel = parent.annotate_xlabel
        btn5 = Tkinter.Button(tempframe,
                                text = 'Properties',
                                command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'xname', None))
        btn5.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x', pady = 1)

        tempframe = Tkinter.Frame(group2.interior())
        self.eny6 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'Y-label:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black')
        self.eny6.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        
        if gm_type in ['Yxvsx']:
            self.eny6.configure( label_state = 'disabled', entry_state = 'disabled')
            parent.balloon.bind(self.eny6,"'Y-label' disabled for this graphic method, use Name instead")
        else:
            parent.balloon.bind(self.eny6,"Enter the 'Y-label' name to be displayed on the VCS Canvas")
            
        if self.parent.annotate_ylabel is not None:
           self.eny6.setentry( self.parent.annotate_ylabel )
        else:
           try: self.eny6.setentry( self.parent.hannotate_ylabel )
           except: pass
        self.store_annotate_ylabel = parent.annotate_ylabel
        btn6 = Tkinter.Button(tempframe,
                                text = 'Properties',
                                command = gui_control.Command(gui_set_text_object.create, self.dialog, parent, parent.template_name, 'yname', None))
        btn6.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x',pady = 1)

        tempframe = Tkinter.Frame(group2.interior())
        self.eny7 = Pmw.EntryField(tempframe,
                                    labelpos = 'w',
                                    label_text = 'Legend:',
                                    entry_width = 40,
                                    entry_background = 'white',
                                    entry_foreground = 'black')
        self.eny7.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        parent.balloon.bind(self.eny7,"Enter the 'Legend' text to be displayed on the VCS Canvas")
        if self.parent.annotate_legendlabel is not None:
           self.eny7.setentry( self.parent.annotate_legendlabel )
        #btn7 = Tkinter.Button(tempframe,
        #                        text = 'Properties')
        #btn7.pack(side = 'left', expand = 1, fill = 'x', padx = 10)
        tempframe.pack(side = 'top', expand = 1, fill = 'x', pady = 1)

        labels = (self.eny1, self.eny2, self.eny3, self.eny4, self.eny5, self.eny6, self.eny7)
        Pmw.alignlabels(labels)
        group2.pack(side = 'top',expand = 1, fill = 'x',padx = 10, pady = 10)

        # Setup group3 (Turn labels on/off)
        group3 = Pmw.Group(self.dialog.interior(),
                            tag_text = 'Turn labels on/off',
                            tagindent = 10,
                            tag_font = ('times',14,'bold'))
        tempframe = Tkinter.Frame(group3.interior())
        self.chkbtn1 = Tkinter.Checkbutton(tempframe,
                            text = 'Date',
                            selectcolor=gui_color.one,
                            command = gui_control.Command(self.evt_set_toggle_state, parent,0) 
                           )
        self.chkbtn1.pack(side = 'top',anchor = 'nw', expand = 1, padx = 10,pady=1)
        self.chkbtn2 = Tkinter.Checkbutton(tempframe,
                            text = 'Time',
                            selectcolor=gui_color.one,
                            command = gui_control.Command(self.evt_set_toggle_state, parent,1) 
                           )
        self.chkbtn2.pack(side = 'top',anchor = 'nw', expand = 1, padx = 10,pady=1)
        self.chkbtn3 = Tkinter.Checkbutton(tempframe,
                            text = 'Mean',
                            selectcolor=gui_color.one,
                            command = gui_control.Command(self.evt_set_toggle_state, parent,2) 
                           )
        self.chkbtn3.pack(side = 'top',anchor = 'nw', expand = 1, padx = 10,pady=1)
        tempframe.pack(side = 'left', expand = 1, fill = 'x')

        tempframe = Tkinter.Frame(group3.interior())
        self.chkbtn4 = Tkinter.Checkbutton(tempframe,
                            text = 'Max',
                            selectcolor=gui_color.one,
                            command = gui_control.Command(self.evt_set_toggle_state, parent,3) 
                           )
        self.chkbtn4.pack(side = 'top',anchor = 'nw', expand = 1, padx = 10,pady=1)
        self.chkbtn5 = Tkinter.Checkbutton(tempframe,
                            text = 'Min',
                            selectcolor=gui_color.one,
                            command = gui_control.Command(self.evt_set_toggle_state, parent,4) 
                           )
        self.chkbtn5.pack(side = 'top',anchor = 'nw', expand = 1, padx = 10,pady=1)
        self.chkbtn6 = Tkinter.Checkbutton(tempframe,
                            text = 'Multiplier',
                            selectcolor=gui_color.one,
                            command = gui_control.Command(self.evt_set_toggle_state, parent,5) 
                           )
        self.chkbtn6.pack(side = 'top',anchor = 'nw', expand = 1, padx = 10,pady=1)
        tempframe.pack(side = 'left', expand = 1, fill = 'x')
        group3.pack(side = 'top', expand = 1, fill = 'x', padx = 10, pady = 10)

        if (self.parent.toggle_state[0]): self.chkbtn1.select()
        if (self.parent.toggle_state[1]): self.chkbtn2.select()
        if (self.parent.toggle_state[2]): self.chkbtn3.select()
        if (self.parent.toggle_state[3]): self.chkbtn4.select()
        if (self.parent.toggle_state[4]): self.chkbtn5.select()
        if (self.parent.toggle_state[5]): self.chkbtn6.select()

        # Hold the values of the original settings. This is needed for Reset and Cancel
        self.hold_annotate_original_settings( parent )

        # Position dialog popup on top of the main GUI
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi( geom[1] )
        d2 = string.atoi( geom[2] )

#        self.dialog.activate(globalMode = 1, geometry= "+%d+%d" % (d1, d2) )
        self.dialog.geometry( "+%d+%d" % (d1, d2) )
        self.dialog.show()
コード例 #10
0
    def __init__(self, gui_parent=None, transient=0):
        title = "THREDDS/OPeNDAP Catalog Browser"
        self.dialog = gui_support.VcsDialog(
            title=title,
            buttons=(),
        )
        self.dialog.dialog.withdraw()
        parent = self.dialog.interior()
        self.parent = parent

        self.gui_parent = gui_parent

        #-------------------------------------------------------------------------
        # Create browsing widgets (catalog combo box, browse/search, search field
        #-------------------------------------------------------------------------
        self.topFrame = Tkinter.Frame(parent)

        self.servers = {
            #            'CCSM' : {
            #                'thredds_url' : 'http://dataportal.ucar.edu/metadata/cgd/ccsm/thredds/ccsm.thredds'
            #                },
            #            'CCSM POP' : {
            #                'thredds_url' : 'http://dataportal.ucar.edu/metadata/cgd/pop/thredds/ucar.cgd.pop.thredds'
            #                },
            #            'PCM' : {
            #                'thredds_url' : 'http://dataportal.ucar.edu/metadata/cgd/pcm/thredds/ucar.cgd.pcm.thredds'
            #                },
            #            'POP' : {
            #                'thredds_url' : 'http://dataportal.ucar.edu/metadata/lanl/pop/thredds/lanl.pop.thredds'
            #                },
            #            'ESG2-TEST' : {
            #                'thredds_url' : 'http://esg2.llnl.gov:8000/opendap/data/?thredds'
            #                },
            #            'ANANKE-TEST' : {
            #                'thredds_url' : 'http://ananke.llnl.gov:8000/tmp/index.thredds'
            #                },
            'IPCC AR4': {
                'thredds_url': 'http://esgcet.llnl.gov/dap/ipcc4/?thredds'
            }
        }

        self.passwordMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
        authHandler = urllib2.HTTPBasicAuthHandler(self.passwordMgr)
        opener = urllib2.build_opener(authHandler)
        urllib2.install_opener(opener)

        self.ptls = Pmw.ComboBox(
            self.topFrame,
            labelpos='n',
            label_text='THREDDS Catalogs:',
            entryfield_value=self.servers.keys()[0],
            entry_background='white',
            entry_foreground='black',
            selectioncommand=self.evt_select_opendap_server,
            scrolledlist_items=self.servers.keys())
        self.ptls.pack(side=Tkinter.LEFT, padx=5)
        gui_parent.balloon.bind(
            self.ptls,
            'Select the THREDDS Catalog to display the Directory Tree')

        #-------------------------------------------------------------------------
        # Create and pack a RadioSelect widget, with radiobuttons.
        #-------------------------------------------------------------------------
        #self.selmode = Pmw.RadioSelect(
        #                    self.topFrame,
        #                    buttontype = 'radiobutton',
        #                    orient = 'vertical',
        #                    #command = self.callback,
        #                    hull_borderwidth = 2,
        #                    hull_relief = 'ridge',
        #                    )
        #self.selmode.pack(side=Tkinter.LEFT, padx=5)
        #gui_parent.balloon.bind( self.selmode, 'Choose which method to search for data.' )

        # Add some buttons to the radiobutton RadioSelect.
        #for text in ('Browse', 'Search'): self.selmode.add(text)
        #self.selmode.invoke('Browse')

        #-------------------------------------------------------------------------
        # Add search entry window
        #-------------------------------------------------------------------------
        #self.searchtxt = Pmw.EntryField(
        #                    self.topFrame,
        #                    labelpos = 'n',
        #                    label_text = 'Search',
        #                    entry_background = 'white',
        #                    entry_foreground = 'black'
        #                    )
        #self.searchtxt.pack(side=Tkinter.LEFT, fill=Tkinter.X, expand=Tkinter.YES, padx=5)
        #gui_parent.balloon.bind( self.searchtxt, 'Enter the search text.' )

        self.topFrame.place(relx=0.0, rely=0.0, relwidth=1.0, relheight=0.2)

        #-------------------------------------------------------------------------
        # Create the labels
        #-------------------------------------------------------------------------
        self.middleFrame = Tkinter.Frame(parent)

        self.lbl_tree = Tkinter.Label(
            self.middleFrame,
            text="THREDDS Catalog Directory Tree",
        )
        self.lbl_tree.place(relx=0.0, rely=0.0, relwidth=0.5, relheight=1.0)

        self.lbl_metadata = Tkinter.Label(
            self.middleFrame,
            text="File Metadata",
        )
        self.lbl_metadata.place(relx=0.5,
                                rely=0.0,
                                relwidth=0.5,
                                relheight=1.0)

        self.middleFrame.place(relx=0.0,
                               rely=0.2,
                               relwidth=1.0,
                               relheight=0.05)

        #-------------------------------------------------------------------------
        # Create the Tree control and metadata windows
        #-------------------------------------------------------------------------
        self.bottomFrame = Tkinter.Frame(parent)
        self.bottomFrame.grid_rowconfigure(0, weight=1)
        self.bottomFrame.grid_columnconfigure(0, weight=1)

        # The tree control
        self.trb1 = gui_tree.Tree(master=self.bottomFrame,
                                  background='orange',
                                  relief='sunken',
                                  borderwidth=2,
                                  root_id=0,
                                  root_label='',
                                  get_contents_callback=self.evt_expand_node,
                                  node_class=CustomNode)

        self.trb1.root.set_label('Select a THREDDS Catalog.')
        self.trb1.first()

        self.trb1.grid(row=0, column=0, sticky='nsew')

        sb = Tkinter.Scrollbar(parent)
        self.trb1.configure(yscrollcommand=sb.set)
        sb.configure(command=self.trb1.yview)
        sb.place(relx=0.468, rely=0.25, relwidth=0.032, relheight=0.62)

        sb2 = Tkinter.Scrollbar(parent, orient=Tkinter.HORIZONTAL)
        self.trb1.configure(xscrollcommand=sb2.set)
        sb2.configure(command=self.trb1.xview)
        sb2.place(relx=0.0, rely=0.866, relwidth=0.47, relheight=0.054)

        gui_parent.balloon.bind(self.trb1,
                                'Browse the THREDDS catalog for data.')

        self.bottomFrame.place(relx=0.0,
                               rely=0.25,
                               relwidth=0.468,
                               relheight=0.616)

        #-------------------------------------------------------------------------
        # Capture left mouse clicks on the tree
        #-------------------------------------------------------------------------
        self.trb1.bind('<1>', self.evt_click_tree)

        #-------------------------------------------------------------------------
        # Create the metadata information scroll window
        #-------------------------------------------------------------------------
        self.txt = Pmw.ScrolledText(
            parent,
            text_background='white',
            text_foreground='black',
        )
        self.txt.place(relx=0.5, rely=0.25, relwidth=0.5, relheight=0.67)
        gui_parent.balloon.bind(self.txt, 'File metadata.')

        # ------------------------------------------------------------------------
        # Button bar
        # ------------------------------------------------------------------------
        self.buttonFrame = Tkinter.Frame(parent)

        self.btn_cancel = Tkinter.Button(self.buttonFrame,
                                         text='Cancel',
                                         command=self.evt_btn_cancel)
        self.btn_cancel.pack(side=Tkinter.RIGHT, padx=5, pady=4)
        gui_parent.balloon.bind(self.btn_cancel, 'Cancel.')

        self.btn_select = Tkinter.Button(self.buttonFrame,
                                         text='Open File & Exit',
                                         command=gui_control.Command(
                                             self.evt_btn_select_file, "exit"))
        self.btn_select.pack(side=Tkinter.RIGHT, padx=5, pady=4)
        gui_parent.balloon.bind(self.btn_select,
                                'Open the selected file in VCDAT and exit.')

        self.btn2_select = Tkinter.Button(self.buttonFrame,
                                          text='Open File',
                                          command=gui_control.Command(
                                              self.evt_btn_select_file, None))
        self.btn2_select.pack(side=Tkinter.RIGHT, padx=5, pady=4)
        gui_parent.balloon.bind(self.btn2_select,
                                'Open the selected file in VCDAT.')

        self.buttonFrame.place(relx=0.0,
                               rely=0.92,
                               relwidth=1.0,
                               relheight=0.08)

        self.evt_select_opendap_server(self.servers.keys()[0])

        self.add_password_flg = 0  # Flag to determine if user needs to authenticate.

        #-------------------------------------------------------------------------
        # Decide where to put the window
        #-------------------------------------------------------------------------
        g = gui_parent.geometry()
        d = g.split('+')[1:]
        c = g.split('+')[0].split('x')
        e = int(d[0]) - int(c[0])
        if e < 0: e = 0
        self.dialog.geometry("%sx%s+%s+%s" %
                             (c[0], str(int(int(c[1]) * 0.5)), str(e), d[1]))

        self.dialog.deiconify()

        if (transient == 1): self.dialog.dialog.transient(gui_parent)
コード例 #11
0
   def __init__(self, parent):
        self.parent = parent
        self.preview_flg = 0
        self.apply_flg = 1
        self.dialog = Pmw.Dialog( parent,
            title = "Set VCS Canvas %i Geometry" % (parent.vcs_id+1),
            buttons = ('Preview', 'Unset', 'Apply', 'Cancel'),
            defaultbutton = 'Apply',
            command = gui_control.Command(self.execute, parent) )

        if parent.menu.popup_window_settings_flg == 1:
           self.dialog.transient( self.parent ) # Keep widget on top of its parent
        self.dialog.withdraw()		     # this is really slow

        lbl=Tkinter.Label(self.dialog.interior(),
            text = ("Set Geometry for VCS Canvas %i:" % (parent.vcs_id+1)),
            justify = 'left',
            anchor = 'w',
            )
        lbl.pack( expand = 1, fill = 'both', padx=10, pady=5 )

        try:
           w_attr= parent.vcs[ parent.vcs_id ].canvasinfo( )
           width  = w_attr['width']
           height = w_attr['height']
        except:
           width = None
           height = None

        self.eny1=Pmw.EntryField(self.dialog.interior(),
            labelpos = 'w',
            label_text = 'Width:',
            entry_background = 'white',
            entry_foreground = 'black',
            entry_width =  48,
            )
        if width is not None: self.eny1.setentry( "%d" % width )
        self.eny1.pack( expand = 1, fill = 'both', padx=10, pady=5 )
        self.parent.balloon.bind(self.eny1, "Enter the 'Width' for VCS Canvas %i."%(parent.vcs_id+1))
        if self.parent.vcg[ parent.vcs_id ][0] is not None:
           self.eny1.setentry( self.parent.vcg[ parent.vcs_id ][0] )
        self.eny1.component('entry').bind( "<Key>", gui_control.Command(self.evt_set_apply, parent, 1) )

        self.eny2=Pmw.EntryField(self.dialog.interior(),
            labelpos = 'w',
            label_text = 'Height:',
            entry_background = 'white',
            entry_foreground = 'black',
            entry_width =  48,
            )
        if height is not None: self.eny2.setentry( "%d" % height )
        self.eny2.pack( expand = 1, fill = 'both', padx=10, pady=5 )
        self.parent.balloon.bind(self.eny2, "Enter the 'Height' for VCS Canvas %i."%(parent.vcs_id+1))
        if self.parent.vcg[ parent.vcs_id ][1] is not None:
           self.eny2.setentry( self.parent.vcg[ parent.vcs_id ][1] )
        self.eny2.component('entry').bind( "<Key>", gui_control.Command(self.evt_set_apply, parent, 2) )

        self.eny3=Pmw.EntryField(self.dialog.interior(),
            labelpos = 'w',
            label_text = 'X-Position:',
            entry_background = 'white',
            entry_foreground = 'black',
            entry_width =  48,
            )
        self.eny3.pack( expand = 1, fill = 'both', padx=10, pady=5 )
        self.parent.balloon.bind(self.eny3, "Enter the 'X-Position' for VCS Canvas %i.\n\nNote, setting only the X-Position has no effect on the VCS Canvas\nwithout a change to the width or height."%(parent.vcs_id+1))
        if self.parent.vcg[ parent.vcs_id ][2] is not None:
           self.eny3.setentry( self.parent.vcg[ parent.vcs_id ][2] )
        self.eny3.component('entry').bind( "<Key>", gui_control.Command(self.evt_set_apply, parent, 3) )

        self.eny4=Pmw.EntryField(self.dialog.interior(),
            labelpos = 'w',
            label_text = 'Y-Position: ',
            entry_background = 'white',
            entry_foreground = 'black',
            entry_width =  48,
            )
        self.eny4.pack( expand = 1, fill = 'both', padx=10, pady=5 )
        self.parent.balloon.bind(self.eny4, "Enter the 'Y-Position' for VCS Canvas %i.\n\nNote, setting only the Y-Position has no effect on the VCS Canvas\nwithout a change to the width or height."%(parent.vcs_id+1))
        if self.parent.vcg[ parent.vcs_id ][3] is not None:
           self.eny4.setentry( self.parent.vcg[ parent.vcs_id ][3] )
        self.eny4.component('entry').bind( "<Key>", gui_control.Command(self.evt_set_apply, parent, 4) )

#        btn1=Tkinter.Button(self.dialog.interior(),
#            text = 'Re-Plot',
#            background = gui_color.replot,
#            command = gui_control.Command(self.geometry_replot, parent)
#            )
#        btn1.pack( expand = 1, fill = 'both', padx=190, pady=5 )

#        btn2=Tkinter.Button(self.dialog.interior(),
#            text = 'Clear All',
#            background = gui_color.one,
#            command = self.geometry_clear,
#            )
#        btn2.pack( expand = 1, fill = 'both', padx=190, pady=5 )

        entries = ( self.eny1, self.eny2, self.eny3, self.eny4 )
        Pmw.alignlabels(entries)

        # This is needed to Reset and Cancel the GUI
        self.hold_geom_original_settings( )

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi( geom[1] )
        d2 = string.atoi( geom[2] )
	self.dialog.geometry( "+%d+%d" % (d1, d2) )

        self.dialog.show()
コード例 #12
0
    def __init__(self, Self, parent):
        self.parent = parent
        self.Self = Self
        self.dialog = Pmw.Dialog(parent,
                                 title="Reading an ASCII File",
                                 buttons=('OK', 'Dismiss'),
                                 defaultbutton='OK',
                                 command=gui_control.Command(
                                     self.execute, parent))

        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient(
                self.parent)  # Keep widget on top of its parent

        d = self.dialog.interior()
        frame = Tkinter.Frame(d)
        frame.pack(expand=1, fill='x', padx=5, pady=20)
        file = Tkinter.Label(frame, text='File:')
        file.pack(side='left')
        self.canvas_openicon = Tkinter.Canvas(frame,
                                              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(
            vcs.__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(self.evt_icon_open_file, parent, None))
        self.file = Pmw.EntryField(
            frame,
            labelpos='w',
            label_text='',
            entry_background='white',
            entry_foreground='black',
            entry_width=20,
        )
        self.file.pack(side='left', expand=1, fill='x', padx=20, pady=5)
        self.parent.balloon.bind(self.file, "Browse to get the file to read")
        self.header = Pmw.EntryField(
            d,
            labelpos='w',
            label_text='Header:',
            entry_background='white',
            entry_foreground='black',
            entry_width=20,
        )
        self.header.pack(expand=1, fill='x', padx=20, pady=5)
        self.parent.balloon.bind(
            self.header,
            "The number of lignes to skip at the begining of the files")
        frame2 = Tkinter.Frame(d)
        ##         frame.pack(expand=1,fill='x',padx=5,pady=20)
        frame2.pack()
        self.cskip = Pmw.Counter(
            frame2,
            labelpos='w',
            label_text='On each line skip:',
            datatype='integer',
            orient='horizontal',
            entry_background='white',
            entry_foreground='black',
        )
        self.cskip.pack(side='left')

        self.parent.balloon.bind(
            self.cskip,
            "The number of lignes to skip at the begining of the files")

        self.cskip_type = Pmw.RadioSelect(
            frame2,
            buttontype='radiobutton',
            orient='horizontal',
        )
        self.cskip_type.pack(side='left')
        self.cskip_type.add('columns')
        self.cskip_type.add('characters')
        self.cskip_type.invoke('columns')

        self.axis = Pmw.RadioSelect(
            d,
            labelpos='w',
            label_text='First Column is X-Axis',
            buttontype='radiobutton',
        )
        self.axis.pack(side='left', expand=1, fill='x', padx=20, pady=5)
        self.axis.add('Yes')
        self.axis.add('No')
        self.axis.invoke('No')
        self.parent.balloon.bind(
            self.axis,
            "Check if the first column represent axis values\nNot necessarily ordered, but will be reordered automatically\nIf ids filled, then first id is axis name"
        )
        frame3 = Tkinter.Frame(d)
        ##         frame.pack(expand=1,fill='x',padx=5,pady=20)
        frame3.pack(fill='x', expand=1)
        self.id = Pmw.EntryField(
            frame3,
            labelpos='w',
            label_text='Id:',
            entry_background='white',
            entry_foreground='black',
            entry_width=20,
        )
        self.id.pack(side='left', fill='x', padx=20, pady=5)
        self.parent.balloon.bind(
            self.id, "The variables id(s) (space or comma separated)")
        self.idrow = Pmw.RadioSelect(
            frame3,
            labelpos='w',
            label_text='Ids in file: ',
            buttontype='checkbutton',
        )
        self.idrow.pack(side='left')
        self.idrow.add('')
        self.parent.balloon.bind(
            self.idrow,
            "Check if the variables ids are stored in first row of data")
        self.separators = Pmw.EntryField(
            d,
            labelpos='w',
            label_text='Separators:',
            entry_background='white',
            entry_foreground='black',
            entry_width=20,
        )
        self.separators.pack(expand=1, fill='x', padx=20, pady=5)
        self.separators.setentry("; , :")
        self.parent.balloon.bind(
            self.separators,
            "The numbers separators\nOther than (space), \n (return) and \t (tab)\nSpace separated"
        )
        entries = (frame3, self.axis, self.separators, self.separators,
                   self.header, self.axis)
        Pmw.alignlabels(entries)
コード例 #13
0
    def __init__(self, dialog, parent, o_name):
        self.parent = parent
        self.dialog = Pmw.Dialog(parent,
                                 title="Set %s's text orientation" % o_name,
                                 buttons=('Re-Plot', 'Apply', 'Dismiss'),
                                 defaultbutton='Dismiss',
                                 command=gui_control.Command(
                                     self.execute, parent, o_name))

        self.dialog.transient(dialog)  # draw widget on top of its parent

        text_o = parent.vcs[parent.vcs_id].gettextorientation(o_name)

        frameb = Tkinter.Frame(self.dialog.interior())
        frameb.pack(side='top', fill='both', expand=1)

        path_lst = ["right", "left", "up", "down"]
        self.text_path = Tkinter.StringVar()
        self.text_path.set(text_o.path)
        self.path = Pmw.OptionMenu(frameb,
                                   labelpos='w',
                                   label_text='Path:',
                                   menubutton_width=10,
                                   menubutton_textvariable=self.text_path,
                                   items=path_lst)
        self.path.pack(side='left', fill='both', expand=1)

        halign_lst = ["left", "center", "right"]
        self.text_halign = Tkinter.StringVar()
        self.text_halign.set(text_o.halign)
        self.halign = Pmw.OptionMenu(frameb,
                                     labelpos='w',
                                     label_text='HAlign:',
                                     menubutton_width=10,
                                     menubutton_textvariable=self.text_halign,
                                     items=halign_lst)
        self.halign.pack(side='left', fill='both', expand=1)

        valign_lst = ["top", "cap", "half", "base", "bottom"]
        self.text_valign = Tkinter.StringVar()
        self.text_valign.set(text_o.valign)
        self.valign = Pmw.OptionMenu(frameb,
                                     labelpos='w',
                                     label_text='Valign:',
                                     menubutton_width=10,
                                     menubutton_textvariable=self.text_valign,
                                     items=valign_lst)
        self.valign.pack(side='left', fill='both', expand=1)

        framea = Tkinter.Frame(self.dialog.interior())
        framea.pack(side='top', fill='both', expand=1)

        self.height = Pmw.Counter(framea,
                                  labelpos='w',
                                  label_text='Height:',
                                  entry_background='white',
                                  entry_foreground='black',
                                  entry_width=5,
                                  entryfield_value=text_o.height,
                                  entryfield_validate={
                                      'validator': 'integer',
                                      'minstrict': 1
                                  })
        self.height.pack(side='left', fill='y', expand=1)
        self.height.component('entry').unbind("<Return>")

        self.angle = Pmw.Counter(
            framea,
            labelpos='w',
            label_text='Angle:',
            entry_background='white',
            entry_foreground='black',
            entry_width=5,
            entryfield_value=text_o.angle,
            #entryfield_modifiedcommand,
            entryfield_validate={
                'validator': 'integer',
                'min': 0,
                'max': 360,
                'minstrict': 1
            })
        self.angle.pack(side='left', fill='y', expand=1)
        self.angle.component('entry').unbind("<Return>")

        entries = (self.height.component('label'),
                   self.angle.component('label'), self.path.component('label'),
                   self.halign.component('label'),
                   self.halign.component('label'))
        Pmw.alignlabels(entries)

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #14
0
    def __init__(self, parent, statistics_type):
        var1, var2 = parent.menu.pcmdi_tools_menu.get_var(parent)
        if var1 is None: return

        self.parent = parent
        self.dialog = Pmw.Dialog(parent,
                                 title="%s Question to User" % statistics_type,
                                 buttons=('OK', 'Dismiss'),
                                 defaultbutton='OK',
                                 command=gui_control.Command(
                                     self.execute, parent, statistics_type,
                                     var1, var2))

        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient(
                self.parent)  # Keep widget on top of its parent

        lbl = Tkinter.Label(
            self.dialog.interior(),
            text="Operate the '%s' function on the following\ndimension(s):" %
            statistics_type,
            justify='left',
            anchor='w',
        )
        lbl.pack(expand=1, fill='both', padx=10, pady=5)

        self.dimension_name = {}
        self.dimension_toggles1 = {}
        self.dimension_toggles2 = {}
        self.dimension_state = {}
        for text in var1.listdimnames():
            frame = Tkinter.Frame(self.dialog.interior())
            frame.pack(side='top', expand=1, fill='both', padx=10, pady=5)
            self.dimension_name[text] = Tkinter.Label(
                frame,
                text='%s: ' % text,
                justify='left',
                anchor='w',
            )
            self.dimension_name[text].pack(side='left',
                                           expand=1,
                                           fill='both',
                                           padx=10,
                                           pady=5)
            # Create and pack a check buttons for the variable axis.
            if string.lower(statistics_type) not in [
                    'laggedcovariance', 'laggedcorrelation', 'autocovariance',
                    'autocorrelation', 'linearregression', 'geometricmean',
                    'rank', 'median'
            ]:
                self.dimension_toggles1[text] = Tkinter.Checkbutton(
                    frame,
                    selectcolor=gui_color.one,
                    text='Weighted',
                    command=gui_control.Command(self.weighted_cb, text, 1))
                self.dimension_toggles1[text].pack(side='left',
                                                   fill='both',
                                                   padx=5,
                                                   pady=5)
                self.dimension_toggles2[text] = Tkinter.Checkbutton(
                    frame,
                    selectcolor=gui_color.one,
                    text='Unweighted',
                    command=gui_control.Command(self.weighted_cb, text, 2))
                self.dimension_toggles2[text].pack(side='left',
                                                   fill='both',
                                                   padx=5,
                                                   pady=5)
                self.dimension_state[text] = 0
                if string.lower(text) in gui_control.latitude_alias:
                    if text == var1.listdimnames()[0]:
                        self.dimension_toggles1[text].select()
                        self.dimension_state[text] = 1
                else:
                    if text == var1.listdimnames()[0]:
                        self.dimension_toggles2[text].select()
                        self.dimension_state[text] = 2
            else:
                self.dimension_toggles1[text] = Tkinter.Checkbutton(
                    frame,
                    selectcolor=gui_color.one,
                    text='Yes                                            ',
                    command=gui_control.Command(self.weighted_cb, text, 1))
                self.dimension_toggles1[text].pack(side='left',
                                                   fill='both',
                                                   padx=5,
                                                   pady=5)
                self.dimension_state[text] = 0
                if text == var1.listdimnames()[0]:
                    self.dimension_toggles1[text].select()
                    self.dimension_state[text] = 1

        if string.lower(statistics_type) in [
                'laggedcovariance', 'laggedcorrelation', 'autocovariance',
                'autocorrelation'
        ]:
            frame = Tkinter.Frame(self.dialog.interior())
            frame.pack(side='top', expand=1, fill='both', padx=10, pady=5)
            self.lags = Pmw.EntryField(
                frame,
                labelpos='w',
                label_text='Lags:',
                entry_width=8,
                value='',
                entry_state='normal',
                label_state='normal',
            )
            self.lags.pack(side='left', fill='both', padx=5, pady=5)
            frame = Tkinter.Frame(self.dialog.interior())
            frame.pack(side='top', expand=1, fill='both', padx=10, pady=5)
            self.loopvar = Tkinter.Variable()
            loop = Tkinter.Checkbutton(
                frame,
                selectcolor=gui_color.one,
                text='Loop ?',
                variable=self.loopvar,
            )
            loop.pack(side='left', fill='both', padx=5, pady=5)
            loop.select()

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #15
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))
コード例 #16
0
   def create_form( self, parent, data1=None, data2=None, data3=5, id = 1, vcs=None ):
        # Get the appropriate template and graphics method
        graphics_method = parent.panelGC.text_opt2.get()
        if string.lower(graphics_method) not in parent.vcs[ parent.vcs_id ].listelements():
           graphics_method = 'Boxfill'
        if parent.template_name not in parent.vcs[ parent.vcs_id ].listelements('template'):
           template = 'default'
        else:
           template = parent.template_name
        if parent.graphics_method_name not in parent.vcs[ parent.vcs_id ].listelements( graphics_method ):
##            print parent.graphics_method_name,graphics_method,parent.vcs[ parent.vcs_id ].listelements( graphics_method )
           graphics_name = 'default'
           graphics_name = 'ASD'
        else:
           graphics_name = parent.graphics_method_name
        form = Form()
        self.form[id] = form
        self.form[id].display = None

        form.line=Tkinter.Frame(self.scl_frame.interior())
        form.line.pack(side='top', fill='both')

        # Scroll to the bottom of the window to show new form
        self.scl_frame.yview( 'moveto', 1 )

        # Set the unique id number
        form.id = id

        # Store the Canvas ID
        form.canvasid = vcs.canvasid()

        form.remove = Pmw.LabeledWidget(form.line,
                    labelpos = 'n',
                    label_text = 'Remove')
        form.remove.pack( side='left', padx = 5 )
        form.remove_btn = Tkinter.Canvas(form.remove.interior(), bd=0, highlightthickness=0,
                                        width = 32, height = 32)
        form.remove_btn.pack( padx=1, pady=1 )
        self.eself.balloon.bind( form.remove_btn, "Remove the page layout form and displayed  graphics on the VCS Canvas." )
        form.remove_btnimage = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'remove.gif') )
        form.on_btnimage = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'on.gif') )
        form.remove_btn.create_image(0,0, anchor=Tkinter.NW, image=form.remove_btnimage )
        form.remove_btn.bind( '<1>', gui_control.Command( self.evt_remove_form, id, parent ))

        form.lbl = Pmw.LabeledWidget(form.line,
                    labelpos = 'n',
                    label_text = 'Off'
                    )
        form.lbl.pack( side='left', padx = 5 )
        self.eself.balloon.bind(form.lbl, "Toggle the plot diplayed on the VCS Canvas 'On' or 'Off'.")

        form.off_btn = Tkinter.Canvas(form.lbl.interior(), bd=0, highlightthickness=0,
                                      width = 32, height = 32)
        form.off_btn.pack( side='left', fill=Tkinter.BOTH, expand='no', padx=1, pady=1 )
        self.eself.balloon.bind( form.off_btn, "Select button to remove or redraw plot." )
        form.off_btnimage = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'off.gif') )
        form.on_btnimage = Tkinter.PhotoImage( file = os.path.join(cdms2.__path__[0],'..','..','..','..', 'bin', 'on.gif') )
        form.off_btn.create_image(0,0, anchor=Tkinter.NW, image=form.off_btnimage )
        form.off_btn.bind( '<1>', gui_control.Command( self.evt_status_button, id, parent ))

#        form.btn = Tkinter.Button(form.lbl.interior(),
#            background = 'red',
#            height = 1,
#            command = gui_control.Command(self.evt_status_button, id, parent)
#            )
#        form.btn.pack(fill='both')

        form.template = Pmw.EntryField(form.line,
                labelpos = 'n',
                label_text = 'Template',
                entry_width = 15,
                entry_background = gui_color.template_bg,
                entry_foreground = gui_color.template_fg,
                value = template,
                validate = None)
        form.template.pack( side='left', padx = 5)
        form.template.component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_template, 1, id, parent ))
        form.template.component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_template, 0, id, parent ))
        form.template.component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_template, 0, id, parent ))
        self.eself.balloon.bind(form.template, "Select an entry from the %s 'Template' list above." % gui_color.template_bg)

        form.gm = Pmw.EntryField(form.line,
                labelpos = 'n',
                label_text = graphics_method,
                entry_width = 15,
                entry_background = gui_color.graphics_method_bg,
                entry_foreground = gui_color.graphics_method_fg,
                value = graphics_name,
                validate = None)
        form.gm.pack( side='left', padx = 5)
        form.gm.component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_gm,1,id, parent))
        form.gm.component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_gm,0,id, parent))
        form.gm.component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_gm,0,id, parent))
        form.gm.type = graphics_method
        self.eself.balloon.bind(form.gm, "Select an entry from the %s 'Graphics Method' list above." % gui_color.graphics_method_bg)

        label_txt = 'A(X,Y)'
        if graphics_method in ['Boxfill']:
           label_txt = 'A(X,Y)'
        data1_txt = ''
        if data1 is not None:
           data1_txt = data1
        form.needed_data = 1
        form.data1 = Pmw.EntryField(form.line,
                labelpos = 'n',
                label_text = label_txt,
                entry_width = 15,
                entry_background = gui_color.six,
                entry_foreground = 'black',
                value = data1_txt,
                validate = None)
        form.data1.pack( side='left', padx = 5)
        form.data1.component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_data, 1, id, 1, parent))
        form.data1.component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_data, 0, id, 1, parent))
        form.data1.component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_data, 0, id, 1, parent))
        self.eself.balloon.bind(form.data1, "Select an entry from the white 'Data' list above.")

        label_txt = 'B(X,Y)'
        if graphics_method in ['Boxfill']:
           label_txt = 'B(X,Y)'
        data2_txt = ''
        if data2 is not None:
           data2_txt = data2
        form.data2 = Pmw.EntryField(form.line,
                labelpos = 'n',
                label_text = label_txt,
                entry_width = 15,
                entry_background = gui_color.six,
                entry_foreground = 'black',
                value = data2_txt,
                validate = None)
#        form.data2.pack( side='left', padx = 5)
        form.data2.component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_data, 1, id, 2, parent))
        form.data2.component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_data, 0, id, 2, parent))     
        form.data2.component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_data, 0, id, 2, parent))        
        self.eself.balloon.bind(form.data2, "Select an entry from the white 'Data' list above.")

        ## Charles Doutriaux code for additional vars
        ## resuisng data3 which was not used, if we ever want to allow creation of forms for more than 5 extra vars
        form.datas = []
        for j in range(data3):
           form.datas.append(
              Pmw.EntryField(form.line,
                             labelpos = 'n',
                             label_text = label_txt,
                             entry_width = 15,
                             entry_background = gui_color.six,
                             entry_foreground = 'black',
                             value = "",
                             validate = None)
              )
           #        form.data2.pack( side='left', padx = 5)
           form.datas[-1].component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_data, 1, id, j+3, parent))
           form.datas[-1].component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_data, 0, id, j+3, parent))     
           form.datas[-1].component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_data, 0, id, j+3, parent))        
           self.eself.balloon.bind(form.datas[-1], "Select an entry from the white 'Data' list above.")
           
        form.priority = Pmw.EntryField(form.line,
                labelpos = 'n',
                label_text = 'P',
                entry_width = 3,
                value = '0',
                validate = None,
                command = gui_control.Command(self.evt_change_priority, id, parent)
                )
        
        form.priority.pack( side='left', padx = 5)
        self.eself.balloon.bind(form.priority, "Enter priority level for plot.")
        form.priority.component('entry').bind( "<Key>", gui_control.Command(self.evt_form_priority_change_color, id, parent) )

        form.lblc = Pmw.LabeledWidget(form.line,
                    labelpos = 'n',
                    label_text = 'Canvas')
        form.lblc.pack( side='left', padx = 5 )
        form.lbln = Tkinter.Label(form.lblc.interior(),
                text = '%d.' % vcs.canvasid())
        form.lbln.pack(fill='x', expand=1, padx=10, pady=5)
        self.eself.balloon.bind(form.lblc, "Set VCS Canvas ID from main VCDAT 'Plot Output\nDestination' choice button.")

#        form.btn2 = Tkinter.Button(form.remove.interior(),
#            background = gui_color.one,
#            height = 1,
#            command = gui_control.Command(self.evt_remove_form, id, parent)
#            )
#        form.btn2.pack(fill='both')


#        form.data2 = Pmw.EntryField(form.line,
#                labelpos = 'n',
#                label_text = 'A(X,Y)',
#                entry_width = 15,
#                entry_background = 'red',
#                entry_foreground = 'white',
#                validate = None)
#        form.data2.pack( side='left', padx = 5)
#        form.data2.component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_data,1,id,parent))
#        form.data2.component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_data,0,id,parent))
#        form.data2.component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_data,0,id,parent))
#
#        form.data3 = Pmw.EntryField(form.line,
#                labelpos = 'n',
#                label_text = 'A(X,Y)',
#                entry_width = 15,
#                entry_background = 'red',
#                entry_foreground = 'white',
#                validate = None)
#        form.data3.pack( side='left', padx = 5)
#        form.data3.component('entry').bind('<ButtonPress>', gui_control.Command(self.evt_replace_data,1,id,parent))
#        form.data3.component('entry').bind('<ButtonRelease>', gui_control.Command(self.evt_replace_data,0,id,parent))
#        form.data3.component('entry').bind('<KeyPress>', gui_control.Command(self.evt_replace_data,0,id,parent))

        form.separator = Tkinter.Frame ( self.scl_frame.interior(), relief = 'raised',
                    height = 4, width = 820, borderwidth = 2, background="MEDIUM ORCHID")
        form.separator.pack(side = 'top' )
コード例 #17
0
    def __init__(self, Self,parent):
        self.parent = parent
        self.Self=Self
        self.dialog = Pmw.Dialog( parent,
                                  title = "Reading a Binary File",
                                  buttons = ('OK', 'Dismiss'),
                                  defaultbutton = 'OK',
                                  command = gui_control.Command(self.execute, parent) )
        
        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient( self.parent ) # Keep widget on top of its parent
            
        d=self.dialog.interior()
        frame=Tkinter.Frame(d)
        frame.pack(fill='x',pady=5)
        file=Tkinter.Label(frame,text='File:')
        file.pack(fill='x',pady=5,side='left')
        self.canvas_openicon = Tkinter.Canvas(frame, bd=0, highlightthickness=0,
                                              width = 27, height = 27)
        self.canvas_openicon.pack( side='left', fill='x', pady=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( self.evt_icon_open_file, parent, None ))
        self.file=Pmw.EntryField(frame,labelpos='w',
                                 label_text='',
                                 entry_background = 'white',
                                 entry_foreground = 'black',
                                 entry_width =  20,
                                 )
        self.file.pack( side='left',fill = 'x', pady=5 )
        self.parent.balloon.bind( self.file, "Browse to get the file to read" )

        ## Big or Little Endian Button
        endian=['Native (@)','Native (=)','Little-Endian (<)', 'Big-Endian (>)',]
        self.endian=Pmw.OptionMenu(d,
                                   labelpos='w',
                                   label_text='Endian:',
                                   items=endian,
                                   initialitem='Native (@)',
                                   )
        self.endian.pack( pady=5,fill='x')
        self.parent.balloon.bind( self.endian, "The Endian in which the File as been written, Big or Little" )

        ## Variables format
        self.format=Pmw.EntryField(d,labelpos='w',
                               label_text='Format:',
                               entry_background = 'white',
                               entry_foreground = 'black',
                               entry_width =  20,
                               )
        self.format.pack( fill ='x', pady=5 )
        self.parent.balloon.bind( self.format, "The format of each variables" )
        self.format.setentry('')
        
        ## datatype
        datatypes=['char','signed char','unsigned char','short','unsigned short','int','unsigned int','long','unsigned long','float','double']
        self.datatype=Pmw.OptionMenu(d,
                                     labelpos='w',
                                     label_text='Datatype:',
                                     items=datatypes,
                                     initialitem='float',
                                     )

        self.datatype.pack(fill='x',pady=5)
        self.parent.balloon.bind( self.datatype, "Datatype in the file (only if all data are from same type)\nEntering anything in Format will override this" )

        ## Number of elements or shape
        self.shape=Pmw.EntryField(d,labelpos='w',
                                  label_text='Shape:',
                                  entry_background = 'white',
                                  entry_foreground = 'black',
                                  entry_width =  20,
                                  )
        self.shape.pack( fill = 'x', pady=5 )
        self.parent.balloon.bind( self.shape,
                                  "The variables shape or number of elements in the file\nDimensions are spaces or comma separated)\nMultiple shapes can be entered must be in format (n1,n2,n3..), (m1,m2,m3,...)\nIf only one shape and multiple ids, then it is assumed shape is identical for all variables\nIf Format is filled then shape(s) and Format must match, otherwise format will prevail and a 1D array will be returned",
                                  )
                
        ## Variable id once into the Defined variable
        self.id=Pmw.EntryField(d,labelpos='w',
                               label_text='Id:',
                               entry_background = 'white',
                               entry_foreground = 'black',
                               entry_width =  20,
                               )
        self.id.pack( fill = 'x', pady=5 )
        self.parent.balloon.bind( self.id, "The variables id(s) (space or comma separated)" )

        ## Variables separator
        self.vs=Pmw.EntryField(d,labelpos='w',
                               label_text='Variables separators:',
                               entry_background = 'white',
                               entry_foreground = 'black',
                               entry_width =  20,
                               )
        self.vs.pack( fill = 'x', pady=5 )
        self.parent.balloon.bind( self.vs, "The string sequence that separates variables\nWill be inserted between each variable format" )
        self.vs.setentry('')

        
        entries = ( self.endian, self.format, self.datatype, self.shape, self.id, self.vs)
        Pmw.alignlabels(entries)
コード例 #18
0
    def __init__(self, dialog, parent, t_name):
        self.parent = parent
        self.dialog = Pmw.Dialog(
            parent,
            title="Set %s's text properties (i.e., table)" % t_name,
            buttons=('Re-Plot', 'Apply', 'Dismiss'),
            defaultbutton='Dismiss',
            command=gui_control.Command(self.execute, parent, t_name))

        self.dialog.transient(dialog)  # draw widget on top of its parent

        text_t = parent.vcs[parent.vcs_id].gettexttable(t_name)

        framea = Tkinter.Frame(self.dialog.interior())
        framea.pack(side='top', fill='both', expand=1)

        self.font = Pmw.Counter(framea,
                                labelpos='w',
                                label_text='Font:',
                                entry_background='white',
                                entry_foreground='black',
                                entry_width=5,
                                entryfield_value=text_t.font,
                                entryfield_validate={
                                    'validator': 'integer',
                                    'min': 1,
                                    'max': 9,
                                    'minstrict': 1
                                })
        self.font.pack(side='left', fill='y', expand=1)
        #        self.font.component('entry').unbind("<Return>")

        self.color = Pmw.Counter(framea,
                                 labelpos='w',
                                 label_text='Color:',
                                 entry_background='white',
                                 entry_foreground='black',
                                 entry_width=5,
                                 entryfield_value=text_t.color,
                                 entryfield_validate={
                                     'validator': 'integer',
                                     'min': 0,
                                     'max': 255,
                                     'minstrict': 1
                                 })
        self.color.pack(side='left', fill='y', expand=1)
        #        self.color.component('entry').unbind("<Return>")

        frameb = Tkinter.Frame(self.dialog.interior())
        frameb.pack(side='top', fill='both', expand=1)

        self.spacing = Pmw.Counter(frameb,
                                   labelpos='w',
                                   label_text='Spacing:',
                                   entry_background='white',
                                   entry_foreground='black',
                                   entry_width=5,
                                   entryfield_value=text_t.spacing,
                                   entryfield_validate={
                                       'validator': 'integer',
                                       'min': -50,
                                       'max': 50,
                                       'minstrict': 1
                                   })
        self.spacing.pack(side='left', fill='y', expand=1)
        #        self.spacing.component('entry').unbind("<Return>")

        self.expansion = Pmw.Counter(
            frameb,
            labelpos='w',
            label_text='Expansion:',
            entry_background='white',
            entry_foreground='black',
            entry_width=5,
            entryfield_value=text_t.expansion,
            #entryfield_modifiedcommand,
            entryfield_validate={
                'validator': 'integer',
                'min': 50,
                'max': 150,
                'minstrict': 1
            })
        self.expansion.pack(side='left', fill='y', expand=1)
        #        self.expansion.component('entry').unbind("<Return>")

        entries = (self.font.component('label'), self.color.component('label'),
                   self.spacing.component('label'),
                   self.expansion.component('label'))
        Pmw.alignlabels(entries)

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #19
0
    def __init__(self, dialog, parent, template_name, template_member, event):
        self.parent = parent
        self.dialog = Pmw.Dialog(
            parent,
            title="Set template %s's -- %s attributes" %
            (template_name, string.capwords(template_member)),
            buttons=('OK', 'Apply', 'Dismiss'),
            defaultbutton='Dismiss',
            command=gui_control.Command(self.execute, parent, template_name,
                                        template_member))

        self.dialog.transient(dialog)  # draw widget on top of its parent

        self.template_name = template_name
        self.template_member = template_member

        template = parent.vcs[parent.vcs_id].gettemplate(template_name)
        template_member = template.__dict__[template_member]

        self.template_member_priority = template_member.priority
        self.template_member_x = template_member.x
        self.template_member_y = template_member.y
        self.template_member_texttable = template_member.texttable
        self.template_member_textorientation = template_member.textorientation

        self.priority = Pmw.Counter(self.dialog.interior(),
                                    labelpos='w',
                                    label_text='Priority',
                                    entry_background='white',
                                    entry_foreground='black',
                                    entry_width=5,
                                    entryfield_value=str(
                                        template_member.priority),
                                    entryfield_validate={
                                        'validator': 'integer',
                                        'min': 0,
                                        'minstrict': 1
                                    },
                                    downarrow_state='disabled',
                                    uparrow_state='disabled')
        self.priority.pack(fill='both', expand=1)
        if template_name == 'ASD':
            self.priority.configure(label_state='disabled',
                                    entry_state='disabled')
            self.priority.component('downarrow').bind('<1>', "break")
            self.priority.component('uparrow').bind('<1>', "break")
        else:
            self.priority.component('entry').unbind("<Return>")

        self.x = Pmw.EntryField(self.dialog.interior(),
                                labelpos='w',
                                label_text='X',
                                entry_background='white',
                                entry_foreground='black',
                                entry_width=28,
                                value=str(template_member.x))
        self.x.pack(expand=1, fill='both', padx=10, pady=5)
        if self.parent.vcg[parent.vcs_id][0] is not None:
            self.x.setentry(self.parent.vcg[parent.vcs_id][0])

        self.y = Pmw.EntryField(self.dialog.interior(),
                                labelpos='w',
                                label_text='Y',
                                entry_background='white',
                                entry_foreground='black',
                                entry_width=28,
                                value=str(template_member.y))
        self.y.pack(expand=1, fill='both', padx=10, pady=5)
        if self.parent.vcg[parent.vcs_id][1] is not None:
            self.y.setentry(self.parent.vcg[parent.vcs_id][1])
        if template_name == 'ASD':
            self.y.configure(label_state='disabled', entry_state='disabled')

        if self.parent.vcg[parent.vcs_id][3] is not None:
            tentry = self.parent.vcg[parent.vcs_id][3]
        else:
            tentry = template_member.texttable
        if self.parent.vcg[parent.vcs_id][2] is not None:
            oentry = self.parent.vcg[parent.vcs_id][2]
        else:
            oentry = template_member.textorientation

        self.ft = Tkinter.Frame(self.dialog.interior())

        self.bpf = Tkinter.Button(
            self.ft,
            font=('helvetica', 10),
            bg=gui_support.gui_color.Tt_color,
            text='Table',
        )
        self.bpf.configure(command=gui_control.Command(
            fonteditorgui.FontGUI, self.parent.vcs[parent.vcs_id], self.parent,
            self.dialog, self.ft, tentry, oentry, self))
        self.bpf.pack(side='left')
        self.parent.balloon.bind(self.bpf, "Modify 'text table' attributes")

        self.properties_font = Pmw.ComboBox(
            self.ft,
            scrolledlist_items=self.parent.vcs[parent.vcs_id].listelements(
                'texttable'),
            ##             labelpos = 'w',
            ##             label_pyclass = gui_annotate.EntryButton,
            ##             label_text = 'Properties',
            entry_background='white',
            entry_foreground='black',
            entry_width=28,
            entryfield_value=tentry,
            selectioncommand=self.update,
        )
        self.properties_font.pack(expand=1, fill='both', padx=10, pady=5)
        self.ft.pack()

        self.fo = Tkinter.Frame(self.dialog.interior())
        self.bpo = Tkinter.Button(
            self.fo,
            font=('helvetica', 10),
            bg=gui_support.gui_color.To_color,
            text='Orientation',
        )
        self.bpo.configure(command=gui_control.Command(
            fonteditorgui.FontGUI, self.parent.vcs[parent.vcs_id], self.parent,
            self.dialog, self.fo, tentry, oentry, self))

        self.properties_orientation = Pmw.ComboBox(
            self.fo,
            scrolledlist_items=self.parent.vcs[parent.vcs_id].listelements(
                'textorientation'),
            ##             labelpos = 'w',
            ##             label_pyclass = gui_annotate.EntryButton,
            ##             label_text = 'Orientation',
            entry_background='white',
            entry_foreground='black',
            entry_width=28,
            entryfield_value=oentry,
            selectioncommand=self.update,
        )
        self.bpo.pack(side='left')
        self.properties_orientation.pack(expand=1,
                                         fill='both',
                                         padx=10,
                                         pady=5)
        self.fo.pack()
        self.parent.balloon.bind(self.bpo,
                                 "Modify 'text orientation' attributes")
        ##         self.properties_orientation.component('label').bind('<1>', gui_control.Command(self.evt_orientation_widget, self.parent))
        entries = (self.priority, self.x, self.y, self.properties_orientation,
                   self.properties_font)
        Pmw.alignlabels(entries)

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #20
0
def restore_menus(parent):
    try:
        for i in range(len(user_menus.set.menu_dict)):
            success = 1
            if user_menus.set.menu_dict[i].keys()[0] == 'Menu_name':
                nam = user_menus.set.menu_dict[i].values()[0]
                inf = user_menus.set.menu_dict[i + 1].values()[0]
                menu_name = parent.menu.main_menu.addmenu(nam, inf, tearoff=1)
                m_dict = {'m_nam': nam, 'm_info': inf, 'm_items': []}
                l_menu.append(m_dict)

            if user_menus.set.menu_dict[i].keys()[0] == 'item_Name':
                i_nam = user_menus.set.menu_dict[i].values()[0]
                i_dir = user_menus.set.menu_dict[i + 1].values()[0]
                i_fun = user_menus.set.menu_dict[i + 2].values()[0]
                i_file = user_menus.set.menu_dict[i + 3].values()[0]

                i_dict = {
                    'i_nam': i_nam,
                    'i_dir': i_dir,
                    'i_file': i_file,
                    'i_fun': i_fun
                }
                l_item = m_dict['m_items']

                pfile_name = nam + '_' + i_dict['i_nam']
                if i_dir != '-999':
                    current_directory = os.getcwd()
                    try:
                        eval('os.chdir(i_dir)')
                    except:
                        success = 0
                        gui_message.error('Could not access module directory')
                        pass
                    eval('os.chdir(current_directory)')

                try:
                    exec "from %s import %s" % (pfile_name, i_dict['i_nam'])
                except:
                    success = 0
                    m1 = ('Cannot access def [ %s ] in .py file [ %s ]' %
                          (i_dict['i_nam'], pfile_name))
                    gui_message.error(m1)
                    pass

                try:
                    f = eval(i_dict['i_nam'])
                    parent.menu.main_menu.addmenuitem(
                        nam,
                        'command',
                        ' ',
                        label=i_nam,
                        command=gui_control.Command(f, i_dict['i_nam'],
                                                    i_dict['i_dir']))
                except:
                    success = 0
                    pass

                if success:
                    l_item.append(i_dict)

        gui_saved_settings.save_menus()
    except:
        pass
コード例 #21
0
 def __init__(self, Self,parent):
     self.parent = parent
     self.Self=Self
     self.dialog = Pmw.Dialog( parent,
                               title = "Reading an ASCII File",
                               buttons = ('OK', 'Dismiss'),
                               defaultbutton = 'OK',
                               command = gui_control.Command(self.execute, parent) )
     
     if parent.menu.popup_window_settings_flg == 1:
         self.dialog.transient( self.parent ) # Keep widget on top of its parent
         
     d=self.dialog.interior()
     frame=Tkinter.Frame(d)
     frame.pack()
     file=Tkinter.Label(frame,text='File:')
     file.pack(side='left')
     self.canvas_openicon = Tkinter.Canvas(frame, 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(vcs.__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( self.evt_icon_open_file, parent, None ))
     self.file=Pmw.EntryField(frame,labelpos='w',
                              label_text='',
                              entry_background = 'white',
                              entry_foreground = 'black',
                              entry_width =  20,
                              )
     self.file.pack( side='left',expand = 1, fill = 'x', padx=20, pady=5 )
     self.parent.balloon.bind( self.file, "Browse to get the file to read" )
     self.header=Pmw.EntryField(d,labelpos='w',
                                label_text='Header:',
                                entry_background = 'white',
                                entry_foreground = 'black',
                                entry_width =  20,
                                )
     self.header.pack( expand = 1, fill = 'x', padx=20, pady=5 )
     self.parent.balloon.bind( self.header, "The number of lignes to skip at the begining of the files" )
     self.separators=Pmw.EntryField(d,labelpos='w',
                                    label_text='Separators:',
                                    entry_background = 'white',
                                    entry_foreground = 'black',
                                    entry_width =  20,
                                    )
     self.separators.pack( expand = 1, fill = 'x', padx=20, pady=5 )
     self.separators.setentry("; , :")
     self.parent.balloon.bind( self.separators, "The numbers separators\nOther than (space), \n (return) and \t (tab)\nSpace separated" )
     self.id=Pmw.EntryField(d,labelpos='w',
                            label_text='Id:',
                            entry_background = 'white',
                            entry_foreground = 'black',
                            entry_width =  20,
                            )
     self.id.pack( expand = 1, fill = 'x', padx=20, pady=5 )
     self.parent.balloon.bind( self.id, "The variables id(s) (space or comma separated)" )
     self.shape=Pmw.EntryField(d,labelpos='w',
                               label_text='Shape:',
                               entry_background = 'white',
                               entry_foreground = 'black',
                               entry_width =  20,
                               )
     self.shape.pack( expand = 1, fill = 'x', padx=20, pady=5 )
     self.parent.balloon.bind( self.shape, "The variables shape\nDimensions are spaces or comma separated)" )
     self.vs=Pmw.EntryField(d,labelpos='w',
                            label_text='Variables separators:',
                            entry_background = 'white',
                            entry_foreground = 'black',
                            entry_width =  20,
                            )
     self.vs.pack( expand = 1, fill = 'x', padx=20, pady=5 )
     self.parent.balloon.bind( self.vs, "The string sequence that separates variables" )
     self.vs.setentry('------')
     entries = ( self.id, self.separators, self.shape, self.vs, self.header)
     Pmw.alignlabels(entries)
コード例 #22
0
    def __init__(self, parent):
        if len(parent.panelDV.selected) == 0:
            gui_message.error(
                'No variable selected in the "Defined Variable" list window.')
            return
        parent.slab = parent.panelDV.lst1[parent.panelDV.selected]
        var_name = ''
        for x in parent.panelDV.selected_list.values():
            var_name += "%s, " % (string.split(x, ' ')[0])
        var_name = var_name[:-2]
        str_title = ('Write variable(s) [ %s ] to NetCDF File' % var_name)
        self.dialog = Pmw.Dialog(parent,
                                 title=str_title,
                                 buttons=('OK', 'Dismiss'),
                                 defaultbutton='OK',
                                 command=gui_control.Command(
                                     self.execute, parent))

        self.dialog.transient(parent)  # draw widget on top of its parent

        str_lbl1 = ('Save variable(s) [ %s ] to a netCDF file: ' % var_name)
        lbl1 = Tkinter.Label(
            self.dialog.interior(),
            text=str_lbl1,
            justify='left',
            anchor='w',
        )
        lbl1.pack(expand=1, fill='both', padx=10, pady=5)

        frame = Tkinter.Frame(self.dialog.interior())
        frame.pack(expand=1, fill='both', padx=10, pady=5)
        file = Tkinter.Label(frame, text='NetCDF File Name:')
        file.pack(side='left')
        self.canvas_openicon = Tkinter.Canvas(frame,
                                              bd=0,
                                              highlightthickness=0,
                                              width=27,
                                              height=27)
        self.canvas_openicon.pack(side='left')
        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(self.evt_icon_open_file, parent, None))
        self.eny1 = Pmw.EntryField(
            frame,
            labelpos='w',
            label_text='',
            entry_background='white',
            entry_foreground='black',
            entry_width=39,
        )
        self.eny1.pack(side='left', expand=1, fill='both', padx=20, pady=5)

        self.rdo = Pmw.RadioSelect(
            self.dialog.interior(),
            buttontype='radiobutton',
            orient='vertical',
            labelpos='wn',
            label_text='File save mode:',
            hull_borderwidth=0,
            hull_relief='ridge',
        )
        self.rdo.pack(side='left', padx=20, pady=5)

        # Add some buttons to the radiobutton RadioSelect.
        self.rdo.add('[Replace] by overwriting netCDF file')
        self.rdo.add('[Append] to existing netCDF file')
        self.rdo.invoke('[Replace] by overwriting netCDF file')

        entries = (self.eny1, self.rdo)
        Pmw.alignlabels(entries)

        # Position dialog popup
        parent_geom = parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #23
0
   def __init__(self, parent, dim_name, event=None):
      if dim_name == 'directory':
        title = 'List of Favorite Directories'
      elif dim_name == 'mybinfiles':
        title = 'List of Favorite Files'
      else:
         title = 'Dimension Aliases for %s' % dim_name
      self.parent = parent
      self.dialog = Pmw.Dialog( parent,
         title = title,
         buttons = ( 'Dismiss', ),
         defaultbutton = 'Dismiss' )
      self.dialog.unbind( "<Return>" )

      if parent.menu.popup_window_settings_flg == 1:
         self.dialog.transient( self.parent ) # Keep widget on top of its parent

      # Create the ScrolledListBox.
      if dim_name == 'directory':
        label_text = 'Directories:'
        items=gui_control.favorite_directories
        dbclkcmd=gui_control.Command(self.goto_directory, parent)
      elif dim_name == 'mybinfiles':
        label_text = 'Files:'
        items=gui_control.favorite_files
        dbclkcmd=gui_control.Command(self.open_file, parent)
      else:
         label_text = '%s Aliases:' % dim_name
	 items=return_alias_list( dim_name )
         dbclkcmd=gui_control.Command(self.goto_directory, parent)
         
      self.alias_list = Pmw.ScrolledListBox(self.dialog.interior(),
		items=items,
		labelpos='nw',
		label_text = label_text,
		listbox_height = 6,
                listbox_background = 'white',
                listbox_foreground = 'black',
                dblclickcommand = dbclkcmd,
		usehullsize = 1,
		hull_width = 250,
		hull_height = 200
      )
      self.alias_list.pack(side = 'top', expand = 1, fill = 'both', padx = 5, pady = 5)
      if dim_name == 'directory':
         parent.balloon.bind(self.alias_list, ("This window contains the list of favorite directories.\n\nTo add a new directory, enter the directory in the entry\nwindow below followed by the <Enter> key.\n\nTo remove a directory from the list, select the\ndesired directory in this list, then select the 'Remove'\nbutton below.\n\nDouble click on any directory in the list and go directly\nthere.") )
      elif dim_name == 'mybinfiles':
         parent.balloon.bind(self.alias_list, ("This window contains the list of favorite files.\n\nTo add a new file, enter the file in the entry\nwindow below followed by the <Enter> key.\n\nTo remove a file from the list, select the\ndesired file in this list, then select the 'Remove'\nbutton below.\n\nDouble click on any file in the list and open it directly.") )
      else:
         parent.balloon.bind(self.alias_list, ("This window contains the list of alias names for\n%s.\n\nTo add new alias names, enter the name in the entry\nwindow below followed by the <Enter> key.\n\nTo remove an alias name from the list, select the\ndesired alias name in this list, then select the 'Remove'\nbutton below." % dim_name) )

      #
      # Create a group widget to contain the add new alias.
      #
      if dim_name == 'directory':
         tag_text='Add New Directory'
      elif dim_name == 'mybinfiles':
         tag_text='Add New File'
      else:
         tag_text='Add New %s Alias Name' % dim_name
      group1 = Pmw.Group(self.dialog.interior(), tag_text=tag_text)
      group1.pack(side = 'top', expand = 1, fill = 'both', padx = 5, pady = 5)
      self.new_alias = Tkinter.Entry(group1.interior(),
                background='white', 
                foreground='black',
                width = 40
      )
      self.new_alias.pack(padx = 10, pady = 10)
      if dim_name == 'directory':
         self.new_alias.insert(0, os.getcwd() )
#         self.new_alias.configure( state = 'disabled' )
         parent.balloon.bind(self.new_alias, "Enter new directory, followed by the <Enter> key.")
      elif dim_name == 'mybinfiles':
         a=parent.panelSV.tin3.get() # get the file name
         if a != 'Type in a file name or select file using pull down arrow -->.':
         
            if a[:7]!='http://': # add the path if not dods stuff
               a=os.path.join(os.getcwd(),a)
            self.new_alias.insert(0, a )
#         self.new_alias.configure( state = 'disabled' )
         parent.balloon.bind(self.new_alias, "Enter new file, followed by the <Enter> key.")
      else:
         parent.balloon.bind(self.new_alias, "Enter new alias name, followed by the <Enter> key.")
      self.new_alias.bind( "<Key>", gui_control.Command(self.evt_change_alias_entry_color, parent) )
      self.new_alias.bind( "<Return>", gui_control.Command(self.enter_new_alias, dim_name) )

      if dim_name == 'directory':
         btn_text = 'Add Directory'
      if dim_name == 'mybinfiles':
         btn_text = 'Add File'
      else:
         btn_text = 'Add ' + string.capitalize(dim_name)
      btn1 = Tkinter.Button( group1.interior(),
                text = btn_text,
                background = gui_color.three,
                command = gui_control.Command(self.enter_new_alias, dim_name)
                            )
      btn1.pack( expand = 1, fill = 'both', padx = 190, pady = 5 )
      if dim_name == 'directory':
         parent.balloon.bind(btn1, "Add directory to directory list.")
      elif dim_name == 'mybinfiles':
         parent.balloon.bind(btn1, "Add file to file list.")
      else:
         parent.balloon.bind(btn1, "Add %s alias to list." % dim_name)

      if dim_name == 'directory':
         btn2 = Tkinter.Button( group1.interior(),
                text = "Goto Selected Directory",
                background = gui_color.two,
                command = gui_control.Command(self.goto_directory, parent )
                            )
         btn2.pack( expand = 1, fill = 'both', padx = 190, pady = 5 )
         parent.balloon.bind(btn1, "Goto the selected directory.")
         
      if dim_name == 'mybinfiles':
         btn2 = Tkinter.Button( group1.interior(),
                text = "Open Selected File",
                background = gui_color.two,
                command = gui_control.Command(self.open_file, parent )
                            )
         btn2.pack( expand = 1, fill = 'both', padx = 190, pady = 5 )
         parent.balloon.bind(btn1, "Open the selected file.")

      #
      # Create a group widget to contain the removal of dimension alias.
      #
      if dim_name == 'directory':
         tag_text='Remove Directory from List'
      elif dim_name == 'mybinfiles':
         tag_text='Remove File from List'
      else:
         tag_text='Remove Alias Name from %s List' % dim_name
      group2 = Pmw.Group(self.dialog.interior(), tag_text=tag_text)
      group2.pack(side = 'top', expand = 1, fill = 'both', padx = 5, pady = 5)
      self.remove_btn = Tkinter.Button(group2.interior(),
                text = tag_text,
                background = 'red',
                command = gui_control.Command(self.remove_alias, dim_name)
      )
      self.remove_btn.pack(padx = 10, pady = 10)
      if dim_name == 'directory':
         parent.balloon.bind(self.remove_btn, "Remove the directory from the directory list by first\nselecting the directory in the list above, then\nselect this removal button.")
      if dim_name == 'mybinfiles':
         parent.balloon.bind(self.remove_btn, "Remove the file from the files list by first\nselecting the file in the list above, then\nselect this removal button.")
      else:
         parent.balloon.bind(self.remove_btn, "Remove the alias name from the alias list by first\nselecting the alias name in the list above, then\nselect this removal button.")

      # Position dialog popup
      parent_geom = parent.geometry()
      geom = string.split(parent_geom, '+')
      d1 = string.atoi( geom[1] )
      d2 = string.atoi( geom[2] )
      self.dialog.geometry( "+%d+%d" % (d1, d2) )
コード例 #24
0
    def __init__(self, parent):
        self.parent = parent
        self.dialog = Pmw.Dialog(parent,
                                 title="Set the Edit and Command Line Font",
                                 buttons=('OK', 'Dismiss'),
                                 defaultbutton='OK',
                                 command=gui_control.Command(
                                     self.execute, parent))

        if parent.menu.popup_window_settings_flg == 1:
            self.dialog.transient(
                self.parent)  # Keep widget on top of its parent

        lbl = Tkinter.Label(
            self.dialog.interior(),
            text="Set Font Specifications:",
            justify='left',
            anchor='w',
        )
        lbl.pack(expand=1, fill='both', padx=10, pady=5)

        self.eny1 = Pmw.EntryField(
            self.dialog.interior(),
            labelpos='w',
            label_text="Font-Name: ",
            entry_background='white',
            entry_foreground='black',
            entry_width=47,
        )
        self.eny1.pack(expand=1, fill='both', padx=10, pady=5)
        if gui_control.idle_font_name is not None:
            self.eny1.setentry(gui_control.idle_font_name)

        self.eny2 = Pmw.EntryField(
            self.dialog.interior(),
            labelpos='w',
            label_text="Font-Size:",
            entry_background='white',
            entry_foreground='black',
            entry_width=47,
        )
        self.eny2.pack(expand=1, fill='both', padx=10, pady=5)
        if gui_control.idle_font_size is not None:
            self.eny2.setentry(gui_control.idle_font_size)

        self.eny3 = Pmw.EntryField(
            self.dialog.interior(),
            labelpos='w',
            label_text="Font-Width:",
            entry_background='white',
            entry_foreground='black',
            entry_width=47,
        )
        self.eny3.pack(expand=1, fill='both', padx=10, pady=5)
        if gui_control.idle_font_width is not None:
            self.eny3.setentry(gui_control.idle_font_width)

        self.eny4 = Pmw.EntryField(
            self.dialog.interior(),
            labelpos='w',
            label_text="Font-Height:",
            entry_background='white',
            entry_foreground='black',
            entry_width=47,
        )
        self.eny4.pack(expand=1, fill='both', padx=10, pady=5)
        if gui_control.idle_font_height is not None:
            self.eny4.setentry(gui_control.idle_font_height)

        entries = (self.eny1, self.eny2, self.eny3, self.eny4)
        Pmw.alignlabels(entries)

        # Position dialog popup
        parent_geom = self.parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #25
0
    def __init__(self, parent):
        if len(parent.panelDV.selected) == 0:
            gui_message.error(
                'No variable selected in the "Defined Variable" list window.')
            return
        parent.slab = parent.panelDV.lst1[parent.panelDV.selected]
        var_name = string.split(parent.panelDV.selected)[0]
        str_title = ('Alter Variable [ %s ] Attributes ' % var_name)
        self.dialog = Pmw.Dialog(
            parent,
            title=str_title,
            buttons=('Dismiss', ),
            #            defaultbutton = 'Dismiss',
            command=self.execute)

        self.dialog.transient(parent)  # draw widget on top of its parent

        fm0 = Tkinter.Frame(self.dialog.interior())
        self.lbl0_text = Tkinter.StringVar()
        self.lbl0_text.set(
            ("Change the variable's name from [ %s ] to [ ? ]:" % var_name))
        self.lbl0 = Tkinter.Label(
            fm0,
            textvariable=self.lbl0_text,
            justify='left',
            anchor='w',
        )
        self.lbl0.pack(expand=1, fill='both', padx=10, pady=5)

        self.eny0 = Pmw.EntryField(
            fm0,
            labelpos='w',
            label_text='Rename Variable:',
            entry_background='white',
            entry_foreground='black',
            entry_width=30,
        )
        self.eny0.pack(expand=1, fill='both', padx=20, pady=5)
        self.eny0.component('entry').bind(
            "<Return>", gui_control.Command(self.evt_getfocus1, parent))
        #self.eny0.pack( side='left', fill = 'both', padx=20, pady=5 )

        self.btn0 = Tkinter.Button(fm0,
                                   text="Apply",
                                   background=gui_color.one,
                                   command=gui_control.Command(
                                       self.rename_variable_apply, parent))
        self.btn0.pack(expand=1, fill='both', padx=200, pady=5)
        fm0.pack(side='top', fill='both', expand=1)

        fm = Tkinter.Frame(self.dialog.interior())
        self.lbl1_text = Tkinter.StringVar()
        self.lbl1_text.set(
            ('Change or add variable attribute to [ %s ]:' % var_name))
        self.lbl1 = Tkinter.Label(
            fm,
            textvariable=self.lbl1_text,
            justify='left',
            anchor='w',
        )
        self.lbl1.pack(expand=1, fill='both', padx=10, pady=5)

        self.eny1 = Pmw.EntryField(
            fm,
            labelpos='w',
            label_text='Attribute Name:',
            entry_background='white',
            entry_foreground='black',
            entry_width=30,
        )
        self.eny1.pack(side='top', fill='both', padx=20, pady=5)

        fm.pack(side='top', fill='both', expand=1)

        self.fm2 = Tkinter.Frame(self.dialog.interior())
        fm2 = Tkinter.Frame(self.fm2)
        fm2.pack(side='top', fill='both', expand=1)
        self.eny2 = Pmw.EntryField(
            fm2,
            labelpos='w',
            label_text="Attribute's Values:",
            entry_background='white',
            entry_foreground='black',
            entry_width=30,
        )
        self.eny2.pack(side='left', expand=1, fill='both', padx=20, pady=5)
        self.eny2.component('entry').bind(
            "<Return>", gui_control.Command(self.evt_getfocus2, parent))

        chlst = ["str  String value", "int  Integer value", "flt  Float value"]
        self.omu = Pmw.OptionMenu(fm2,
                                  items=chlst,
                                  menubutton_width=3,
                                  menubutton_anchor='w',
                                  command=self.set_right)
        self.omu.configure(menubutton_text=chlst[0][0:3])
        self.omu.pack(side='left', fill='both', after=self.eny2)

        self.btn1 = Tkinter.Button(self.fm2,
                                   text="Apply",
                                   background=gui_color.one,
                                   command=gui_control.Command(
                                       self.attribute_apply, parent))
        self.btn1.pack(expand=1, fill='both', padx=200, pady=5)
        self.fm2.pack(side='top', fill='both', expand=1)

        self.fm3 = Tkinter.Frame(self.dialog.interior())
        self.lbl2_text = Tkinter.StringVar()
        self.lbl2_text.set(
            ('Remove variable attributes from [ %s ]:' % var_name))
        self.lbl2 = Tkinter.Label(
            self.fm3,
            textvariable=self.lbl2_text,
            justify='left',
            anchor='w',
        )
        self.lbl2.pack(expand=1, fill='both', padx=10, pady=5)

        self.eny3 = Pmw.EntryField(
            self.fm3,
            labelpos='w',
            label_text='Attribute Name:',
            entry_background='red',
            entry_foreground='black',
            entry_width=30,
        )
        self.eny3.pack(expand=1, fill='both', padx=20, pady=5)
        self.eny3.component('entry').bind(
            "<Return>", gui_control.Command(self.evt_getfocus3, parent))

        self.btn2 = Tkinter.Button(self.fm3,
                                   text="Apply",
                                   background=gui_color.one,
                                   command=gui_control.Command(
                                       self.remove_apply, parent))
        self.btn2.pack(expand=1, fill='both', padx=200, pady=5)
        self.fm3.pack(side='top', fill='both', expand=1)

        self.lbl3_text = Tkinter.StringVar()
        if len(parent.slab.shape) > 0:
            self.fm4 = Tkinter.Frame(self.dialog.interior())
            self.ctr = Pmw.Counter(
                self.fm4,
                labelpos='w',
                label_text='Set Dimension ',
                entryfield_value='1',
                #datatype = {'counter' : 'integer'},
                entry_background='white',
                entry_foreground='black',
                entryfield_entry_width=4,
                entryfield_entry_justify='center',
                entryfield_validate={
                    'validator': 'integer',
                    'min': '1',
                    'max': str(len(parent.slab.shape))
                },
                increment=1)
            self.ctr.pack(side='left', padx=10, pady=5)

            self.lbl3_text.set(('attribute for [ %s ]:' % var_name))
            lbl3 = Tkinter.Label(
                self.fm4,
                textvariable=self.lbl3_text,
                justify='left',
                anchor='w',
            )
            lbl3.pack(expand=1, fill='both', padx=0, pady=5)
            self.fm4.pack(side='top', fill='both', expand=1)

            fm5 = Tkinter.Frame(self.dialog.interior())
            self.eny4 = Pmw.EntryField(
                fm5,
                labelpos='w',
                label_text='Set Dimension Units:',
                entry_background='white',
                entry_foreground='black',
                entry_width=30,
            )
            self.eny4.pack(expand=1, fill='both', padx=20, pady=5)
            self.eny4.component('entry').bind(
                "<Return>", gui_control.Command(self.evt_getfocus4, parent))

            btn3 = Tkinter.Button(fm5,
                                  text="Apply",
                                  background=gui_color.one,
                                  command=gui_control.Command(
                                      self.dimension_apply, parent))
            btn3.pack(expand=1, fill='both', padx=200, pady=5)
            fm5.pack(side='top', fill='both', expand=1)
            entries = (self.eny1, self.eny2, self.eny3, self.eny4)
        else:
            entries = (self.eny1, self.eny2, self.eny3)
        Pmw.alignlabels(entries)

        # Position dialog popup
        parent_geom = parent.geometry()
        geom = string.split(parent_geom, '+')
        d1 = string.atoi(geom[1])
        d2 = string.atoi(geom[2])
        self.dialog.geometry("+%d+%d" % (d1, d2))
コード例 #26
0
        try:
            exec "from %s import %s" % (pfile_name, i_dict['i_nam'])
        except Exception, err:
            m1 = ('Cannot access def [ %s ] in .py file [ %s ]\nError was %s' %
                  (pfile_name, i_dict['i_nam'], err))
            gui_message.error(m1)
            return

        f = eval(i_dict['i_nam'])

        men7 = parent.menu.main_menu.addmenuitem(menu_name,
                                                 'command',
                                                 ' ',
                                                 label=menu_item,
                                                 command=gui_control.Command(
                                                     f, i_dict['i_nam'],
                                                     i_dict['i_dir']))
        self.eny6.setentry('')
        self.eny7.clear()
        gui_saved_settings.save_menus()
        self.functions.append(menu_item)
        self.eny8.setlist(self.functions)

    #---------------------------------------------
    # Delete a function from the main menu bar
    #---------------------------------------------
    def delete_function(self, parent):
        global l_menu
        menu_name = self.eny3.get()
        func_name = self.eny8.get()