def evt_popup_fields_window(self, parent, projectName): if self.evt_fields_flg: return self.evt_fields_flg = True #--------------------------------------------------------------------------------- # Create the Fields dialog window #--------------------------------------------------------------------------------- self.fields = Pmw.Dialog(parent, buttons=('OK', 'Cancel'), defaultbutton='OK', title='Set Additional Mandatory Fields', command=pub_controls.Command( self.close_fields_dialog, parent)) self.fields.withdraw() self.fields.transient(parent) frame = Pmw.ScrolledFrame( self.fields.interior(), usehullsize=1, horizflex='expand', ) # Add additional mandatory fields to allow the user to set default settings handler = getHandlerByName(projectName, None, self.Session) list_fields = getQueryFields(handler) for x in list_fields: if handler.isMandatory(x): if x.lower() != "project": field_options = handler.getFieldOptions(x) if field_options is not None: if x in self.defaultGlobalValues.keys(): set_to = self.defaultGlobalValues[x] else: set_to = x + " (Default Global Setting)" field_options.insert(0, x + " (Default Global Setting)") self.dataset_fields[x] = show_field( parent, frame.interior(), x.capitalize(), field_options, set_to, 1, 1) Pmw.alignlabels(self.dataset_fields.values()) frame.pack(side='top', expand=1, fill='both') #--------------------------------------------------------------------------------- # Position dialog popup #--------------------------------------------------------------------------------- import string parent_geom = parent.geometry() geom = string.split(parent_geom, '+') d1 = string.atoi(geom[1]) d2 = string.atoi(geom[2]) self.fields.geometry("500x200+%d+%d" % (d1, d2)) self.fields.show()
def evt_popup_fields_window(self, parent, projectName): if self.evt_fields_flg: return self.evt_fields_flg = True # --------------------------------------------------------------------------------- # Create the Fields dialog window # --------------------------------------------------------------------------------- self.fields = Pmw.Dialog( parent, buttons=("OK", "Cancel"), defaultbutton="OK", title="Set Additional Mandatory Fields", command=pub_controls.Command(self.close_fields_dialog, parent), ) self.fields.withdraw() self.fields.transient(parent) frame = Pmw.ScrolledFrame(self.fields.interior(), usehullsize=1, horizflex="expand") # Add additional mandatory fields to allow the user to set default settings handler = getHandlerByName(projectName, None, self.Session) list_fields = getQueryFields(handler) for x in list_fields: if handler.isMandatory(x): if x.lower() != "project": field_options = handler.getFieldOptions(x) if field_options is not None: if x in self.defaultGlobalValues.keys(): set_to = self.defaultGlobalValues[x] else: set_to = x + " (Default Global Setting)" field_options.insert(0, x + " (Default Global Setting)") self.dataset_fields[x] = show_field( parent, frame.interior(), x.capitalize(), field_options, set_to, 1, 1 ) Pmw.alignlabels(self.dataset_fields.values()) frame.pack(side="top", expand=1, fill="both") # --------------------------------------------------------------------------------- # Position dialog popup # --------------------------------------------------------------------------------- import string parent_geom = parent.geometry() geom = string.split(parent_geom, "+") d1 = string.atoi(geom[1]) d2 = string.atoi(geom[2]) self.fields.geometry("500x200+%d+%d" % (d1, d2)) self.fields.show()
def __init__(self, parent): self.parent = parent self.Session = parent.parent.Session # ---------------------------------------------------------------------------------------- # Display the Project selection # ---------------------------------------------------------------------------------------- self.dataset_fields = {} projectOption = self.parent.parent.config.get("initialize", "project_options") projectSpecs = splitRecord(projectOption) projectName = projectSpecs[0][0] projectList = [] for x in projectSpecs: projectList.append(x[0]) projectList.sort() self.dataset_fields["Project"] = self.project_dataset = show_field( self.parent, self.parent.control_frame1, "Project", projectList, projectName, 1, 1 ) # Create and pack the LabeledWidgets for setting additional mandatory fields bnFont = tkFont.Font( self.parent.parent, family=pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight, ) self.evt_fields_flg = False self.defaultGlobalValues = {} lw_dir = Pmw.LabeledWidget( self.parent.control_frame1, labelpos="w", label_font=bnFont, label_text="Set additional mandatory: " ) lw_dir.component("hull").configure(relief="sunken", borderwidth=2) lw_dir.pack(side="top", expand=1, fill="both", padx=10, pady=10) cw_dir = Tkinter.Button( lw_dir.interior(), text="Fields", font=bnFont, background="lightblue", foreground="black", command=pub_controls.Command(self.evt_popup_fields_window, self.parent.parent, projectName), ) cw_dir.pack(padx=10, pady=10, expand="yes", fill="both") self.save_dir_btn_color = cw_dir.cget("background") # Add additional mandatory fields to allow the user to set default settings # handler = getHandlerByName(projectName, None, self.Session) # list_fields = getQueryFields( handler ) # for x in list_fields: # if handler.isMandatory( x ): # if x.lower() != "project": # field_options = handler.getFieldOptions(x) # if field_options is not None: # field_options.insert(0, x+" (Default Global Setting)") # self.dataset_fields[x] = show_field( self.parent, self.parent.control_frame1, x.capitalize(), field_options , x+" (Default Global Setting)", 1, 1 ) # Pmw.alignlabels( self.dataset_fields.values() ) # ---------------------------------------------------------------------------------------- # Create and pack a work online or off line RadioSelect widget # ---------------------------------------------------------------------------------------- self.parent.parent.offline = False self.parent.parent.offline_directories = None self.parent.parent.offline_datasetName = None self.on_off = Pmw.RadioSelect( self.parent.control_frame1, buttontype="radiobutton", orient="horizontal", labelpos="w", command=pub_controls.Command(self.evt_work_on_or_off_line), label_text="Work: ", label_font=bnFont, hull_borderwidth=2, hull_relief="ridge", ) self.on_off.pack(side="top", expand=1, padx=10, pady=10) # Add some buttons to the radiobutton RadioSelect. for text in ("On-line", "Off-line"): self.on_off.add(text, font=bnFont) self.on_off.setvalue("On-line") # ---------------------------------------------------------------------------------------- # Begin the creation of the file type selection # ---------------------------------------------------------------------------------------- tagFont = tkFont.Font( self.parent.parent, family=pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight, ) self.group_file_filter = Pmw.Group( self.parent.control_frame1, tag_text="Filter File Search", tag_font=tagFont, # hull_background = 'blue', tagindent=25, ) dfFont = tkFont.Font( self.parent.parent, family=pub_controls.combobox_font_type, size=pub_controls.combobox_font_size, weight=font_weight, ) self.data_filter = Pmw.ComboBox( self.group_file_filter.interior(), entryfield_value=pub_controls.datatypes[0], entry_font=dfFont, entry_state="readonly", entry_readonlybackground="aliceblue", listbox_font=dfFont, listbox_background="aliceblue", scrolledlist_items=pub_controls.datatypes, ) self.data_filter.pack(side="top", fill="x", pady=5) self.group_file_filter.pack(side="top", fill="x", pady=3) # ---------------------------------------------------------------------------------------- # End the creation of the file type selection # ---------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------- # Begin the creation of the directory, file, and combo directoy box # ---------------------------------------------------------------------------------------- glFont = tkFont.Font( self.parent.parent, family=pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight, ) self.group_list_generation = Pmw.Group( self.parent.control_frame1, tag_text="Generate List", tag_font=glFont, tagindent=25 ) self.parent.control_frame2 = self.group_list_generation.interior() self.directory_icon = Tkinter.PhotoImage(file=file2_gif) self.file_icon = Tkinter.PhotoImage(file=folder2_gif) self.stop_icon = Tkinter.PhotoImage(file=stop_gif) # Create and pack the LabeledWidgets for the directory selction bnFont = tkFont.Font( self.parent.parent, family=pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight, ) self.generating_file_list_flg = 0 self.lw_dir = Pmw.LabeledWidget( self.parent.control_frame2, labelpos="w", label_font=bnFont, label_text="Generate list from: " ) self.lw_dir.component("hull").configure(relief="sunken", borderwidth=2) self.lw_dir.pack(side="top", expand=1, fill="both", padx=10, pady=10) self.cw_dir = Tkinter.Button( self.lw_dir.interior(), text="Directory", font=bnFont, background="lightblue", foreground="black", command=pub_controls.Command(self.evt_popup_directory_window), ) self.cw_dir.pack(padx=10, pady=10, expand="yes", fill="both") self.save_dir_btn_color = self.cw_dir.cget("background") # Create and pack the LabeledWidgets for the file selction self.lw_file = Pmw.LabeledWidget( self.parent.control_frame2, labelpos="w", label_font=bnFont, label_text="Generate list from: " ) self.lw_file.component("hull").configure(relief="sunken", borderwidth=2) self.lw_file.pack(side="top", expand=1, fill="both", padx=10, pady=10) self.cw_file = Tkinter.Button( self.lw_file.interior(), text="Map File", font=bnFont, background="lightblue", foreground="black", command=pub_controls.Command(self.evt_popup_file_window), ) self.cw_file.pack(padx=10, pady=10, expand="yes", fill="both") self.save_file_btn_color = self.cw_file.cget("background") # Set up directory combo box d, f = _scn_a_dir(self.parent) self.directory_combo = Pmw.ComboBox( self.parent.control_frame2, scrolledlist_items=d, entryfield_value=os.getcwd(), entry_font=("Times", 16, "bold"), entry_background="white", entry_foreground="black", selectioncommand=pub_controls.Command(self.evt_enter_directory), ) self.directory_combo.component("entry").bind("<Key>", pub_controls.Command(self.evt_change_color)) self.directory_combo.component("entry").bind("<Return>", pub_controls.Command(self.evt_enter_directory)) self.directory_combo.component("entry").bind("<Tab>", pub_controls.Command(self.evt_tab)) self.directory_combo.component("entry").bind("<BackSpace>", pub_controls.Command(self.evt_backspace)) self.parent.control_frame2.pack(side="top", fill="x", pady=5) self.group_list_generation.pack(side="top", fill="x", pady=3) # ---------------------------------------------------------------------------------------- # End the creation of the directory, file, and combo directoy box # ---------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------- # Begin the regular expression widget # # We've decided that regular expression is no longer needed. # ---------------------------------------------------------------------------------------- self.group_list = Pmw.Group( self.parent.control_frame1, tag_text="Regular Expressions", tag_font=("Times", 18, "bold"), hull_background="orange", tagindent=25, ) ################################################################################### # To redisplay regular expression widget, just uncomment the 'pack' command below # self.group_list.pack(side='top', fill='x') ################################################################################### self.scl1 = Pmw.ScrolledText( self.group_list.interior(), text_background="aliceblue", text_foreground="black", text_wrap="none", text_padx=5, text_pady=5, usehullsize=1, hull_width=100, hull_height=50, ) # horizscrollbar_width=50, # vertscrollbar_width=50 ) self.scl1.pack(side="top", expand=1, fill="both") # Create and pack the LabeledWidgets for the compiling of the regular expression self.generating_file_list_flg = 0 self.lw_reg = Pmw.LabeledWidget(self.group_list.interior(), labelpos="w", label_text="Regular expression: ") self.lw_reg.component("hull").configure(relief="sunken", borderwidth=2) self.lw_reg.pack(side="top", expand=1, fill="both", padx=10, pady=10) self.cw_reg = Tkinter.Button( self.lw_reg.interior(), text="Go", command=pub_controls.Command(self.evt_compile_regular_expression) ) self.cw_reg.pack(padx=10, pady=10, expand="yes", fill="both") self.save_reg_btn_color = self.cw_reg.cget("background")
def __init__(self, parent): self.parent = parent self.Session = parent.parent.Session #---------------------------------------------------------------------------------------- # Display the Project selection #---------------------------------------------------------------------------------------- self.dataset_fields = {} projectOption = self.parent.parent.config.get('initialize', 'project_options') projectSpecs = splitRecord(projectOption) projectName = projectSpecs[0][0] projectList = [] for x in projectSpecs: projectList.append(x[0]) projectList.sort() self.dataset_fields["Project"] = self.project_dataset = show_field( self.parent, self.parent.control_frame1, "Project", projectList, projectName, 1, 1) # Create and pack the LabeledWidgets for setting additional mandatory fields bnFont = tkFont.Font(self.parent.parent, family=pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight) self.evt_fields_flg = False self.defaultGlobalValues = {} lw_dir = Pmw.LabeledWidget(self.parent.control_frame1, labelpos='w', label_font=bnFont, label_text='Set additional mandatory: ') lw_dir.component('hull').configure(relief='sunken', borderwidth=2) lw_dir.pack(side='top', expand=1, fill='both', padx=10, pady=10) cw_dir = Tkinter.Button(lw_dir.interior(), text='Fields', font=bnFont, background="lightblue", foreground='black', command=pub_controls.Command( self.evt_popup_fields_window, self.parent.parent, projectName)) cw_dir.pack(padx=10, pady=10, expand='yes', fill='both') self.save_dir_btn_color = cw_dir.cget("background") # Add additional mandatory fields to allow the user to set default settings # handler = getHandlerByName(projectName, None, self.Session) # list_fields = getQueryFields( handler ) # for x in list_fields: # if handler.isMandatory( x ): # if x.lower() != "project": # field_options = handler.getFieldOptions(x) # if field_options is not None: # field_options.insert(0, x+" (Default Global Setting)") # self.dataset_fields[x] = show_field( self.parent, self.parent.control_frame1, x.capitalize(), field_options , x+" (Default Global Setting)", 1, 1 ) # Pmw.alignlabels( self.dataset_fields.values() ) #---------------------------------------------------------------------------------------- # Create and pack a work online or off line RadioSelect widget #---------------------------------------------------------------------------------------- self.parent.parent.offline = False self.parent.parent.offline_directories = None self.parent.parent.offline_datasetName = None self.on_off = Pmw.RadioSelect( self.parent.control_frame1, buttontype='radiobutton', orient='horizontal', labelpos='w', command=pub_controls.Command(self.evt_work_on_or_off_line, ), label_text='Work: ', label_font=bnFont, hull_borderwidth=2, hull_relief='ridge', ) self.on_off.pack(side='top', expand=1, padx=10, pady=10) # Add some buttons to the radiobutton RadioSelect. for text in ('On-line', 'Off-line'): self.on_off.add(text, font=bnFont) self.on_off.setvalue('On-line') #---------------------------------------------------------------------------------------- # Begin the creation of the file type selection #---------------------------------------------------------------------------------------- tagFont = tkFont.Font(self.parent.parent, family=pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight) self.group_file_filter = Pmw.Group( self.parent.control_frame1, tag_text='Filter File Search', tag_font=tagFont, #hull_background = 'blue', tagindent=25) dfFont = tkFont.Font(self.parent.parent, family=pub_controls.combobox_font_type, size=pub_controls.combobox_font_size, weight=font_weight) self.data_filter = Pmw.ComboBox( self.group_file_filter.interior(), entryfield_value=pub_controls.datatypes[0], entry_font=dfFont, entry_state='readonly', entry_readonlybackground="aliceblue", listbox_font=dfFont, listbox_background="aliceblue", scrolledlist_items=pub_controls.datatypes, ) self.data_filter.pack(side='top', fill='x', pady=5) self.group_file_filter.pack(side='top', fill='x', pady=3) #---------------------------------------------------------------------------------------- # End the creation of the file type selection #---------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------- # Begin the creation of the directory, file, and combo directoy box #---------------------------------------------------------------------------------------- glFont = tkFont.Font(self.parent.parent, family=pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight) self.group_list_generation = Pmw.Group(self.parent.control_frame1, tag_text='Generate List', tag_font=glFont, tagindent=25) self.parent.control_frame2 = self.group_list_generation.interior() self.directory_icon = Tkinter.PhotoImage(file=file2_gif) self.file_icon = Tkinter.PhotoImage(file=folder2_gif) self.stop_icon = Tkinter.PhotoImage(file=stop_gif) # Create and pack the LabeledWidgets for the directory selction bnFont = tkFont.Font(self.parent.parent, family=pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight) self.generating_file_list_flg = 0 self.lw_dir = Pmw.LabeledWidget(self.parent.control_frame2, labelpos='w', label_font=bnFont, label_text='Generate list from: ') self.lw_dir.component('hull').configure(relief='sunken', borderwidth=2) self.lw_dir.pack(side='top', expand=1, fill='both', padx=10, pady=10) self.cw_dir = Tkinter.Button(self.lw_dir.interior(), text='Directory', font=bnFont, background="lightblue", foreground='black', command=pub_controls.Command( self.evt_popup_directory_window)) self.cw_dir.pack(padx=10, pady=10, expand='yes', fill='both') self.save_dir_btn_color = self.cw_dir.cget("background") # Create and pack the LabeledWidgets for the file selction self.lw_file = Pmw.LabeledWidget(self.parent.control_frame2, labelpos='w', label_font=bnFont, label_text='Generate list from: ') self.lw_file.component('hull').configure(relief='sunken', borderwidth=2) self.lw_file.pack(side='top', expand=1, fill='both', padx=10, pady=10) self.cw_file = Tkinter.Button(self.lw_file.interior(), text='Map File', font=bnFont, background="lightblue", foreground='black', command=pub_controls.Command( self.evt_popup_file_window)) self.cw_file.pack(padx=10, pady=10, expand='yes', fill='both') self.save_file_btn_color = self.cw_file.cget("background") # Set up directory combo box d, f = _scn_a_dir(self.parent) self.directory_combo = Pmw.ComboBox( self.parent.control_frame2, scrolledlist_items=d, entryfield_value=os.getcwd(), entry_font=('Times', 16, 'bold'), entry_background='white', entry_foreground='black', selectioncommand=pub_controls.Command(self.evt_enter_directory)) self.directory_combo.component('entry').bind( "<Key>", pub_controls.Command(self.evt_change_color)) self.directory_combo.component('entry').bind( "<Return>", pub_controls.Command(self.evt_enter_directory)) self.directory_combo.component('entry').bind( '<Tab>', pub_controls.Command(self.evt_tab)) self.directory_combo.component('entry').bind( "<BackSpace>", pub_controls.Command(self.evt_backspace)) self.parent.control_frame2.pack(side="top", fill='x', pady=5) self.group_list_generation.pack(side='top', fill='x', pady=3) #---------------------------------------------------------------------------------------- # End the creation of the directory, file, and combo directoy box #---------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------- # Begin the regular expression widget # # We've decided that regular expression is no longer needed. #---------------------------------------------------------------------------------------- self.group_list = Pmw.Group(self.parent.control_frame1, tag_text='Regular Expressions', tag_font=('Times', 18, 'bold'), hull_background='orange', tagindent=25) ################################################################################### # To redisplay regular expression widget, just uncomment the 'pack' command below # self.group_list.pack(side='top', fill='x') ################################################################################### self.scl1 = Pmw.ScrolledText(self.group_list.interior(), text_background='aliceblue', text_foreground='black', text_wrap='none', text_padx=5, text_pady=5, usehullsize=1, hull_width=100, hull_height=50) #horizscrollbar_width=50, #vertscrollbar_width=50 ) self.scl1.pack(side='top', expand=1, fill='both') # Create and pack the LabeledWidgets for the compiling of the regular expression self.generating_file_list_flg = 0 self.lw_reg = Pmw.LabeledWidget(self.group_list.interior(), labelpos='w', label_text='Regular expression: ') self.lw_reg.component('hull').configure(relief='sunken', borderwidth=2) self.lw_reg.pack(side='top', expand=1, fill='both', padx=10, pady=10) self.cw_reg = Tkinter.Button(self.lw_reg.interior(), text='Go', command=pub_controls.Command( self.evt_compile_regular_expression)) self.cw_reg.pack(padx=10, pady=10, expand='yes', fill='both') self.save_reg_btn_color = self.cw_reg.cget("background")
def __init__(self, parent): self.parent = parent self.Session = parent.parent.Session self.select_button = {} self.select_labelV = {} self.select_label = {} # ---------------------------------------------------------------------------------------- # Begin the creation of the dataset ID pulldown query selection # ---------------------------------------------------------------------------------------- glFont = tkFont.Font( self.parent.parent, family=pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight, ) bnFont = tkFont.Font( self.parent.parent, family=pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight, ) self.group_query = Pmw.Group(self.parent.control_frame4, tag_text="Query ID", tag_font=glFont, tagindent=25) # ---------------------------------------------------------------------------------------- # Create and pack the EntryFields # ---------------------------------------------------------------------------------------- self.query_entry = Pmw.EntryField( self.group_query.interior(), labelpos="w", label_text="Dataset Id:", label_font=bnFont, entry_width=200, validate=None, command=pub_controls.Command(self.evt_show_data_set_from_id), ) self.query_entry.pack(side="left", expand=1, padx=10, pady=10) # ---------------------------------------------------------------------------------------- # End the creation of the dataset ID pulldown query selection # ---------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------- # Begin the creation of the project pulldown query selection # ---------------------------------------------------------------------------------------- self.button_controls = Pmw.Group( self.parent.control_frame4, tag_text="Query Project Infomation", tag_font=glFont, tagindent=25 ) # ---------------------------------------------------------------------------------------- # Create an instance of the notebook # ---------------------------------------------------------------------------------------- ntk = generate_notebook(parent, self.Session) parent.parent.ntk = ntk # Set the first instance of the notebook self.bdataset_sframe = Pmw.ScrolledFrame(self.button_controls.interior()) self.bdataset_sframe.pack(side="top") self.bdataset_frame = self.bdataset_sframe.interior() # ---------------------------------------------------------------------------------------- # Display the Project selection # ---------------------------------------------------------------------------------------- projectOption = self.parent.parent.config.get("initialize", "project_options") projectSpecs = splitRecord(projectOption) projectName = projectSpecs[0][0] projectList = [] for x in projectSpecs: projectList.append(x[0]) projectList.sort() parent.query_fields = {} parent.validate = {} parent.query_fields["project"] = show_field( self.parent, self.bdataset_frame, "Project", projectList, projectName, 1, 1, for_query=True ) parent.validate["project"] = 1 handler = getHandlerByName(projectName, None, self.Session) list_fields = getQueryFields(handler) validate = [] mandatory = [] options = {} for x in list_fields: if handler.getFieldType(x) is not None: validate.append(handler.getFieldType(x)) else: validate.append(2) options[x] = handler.getFieldOptions(x) mandatory.append(handler.isMandatory(x)) for j in range(1, 5): for i in range(len(list_fields)): if list_fields[i] is not "project": if options[list_fields[i]] is None: value = "" else: value = options[list_fields[i]] # ganz bug fix [0] if validate[i] == 1: options[list_fields[i]].insert(0, "-Any-") value = "-Any-" if j == validate[i]: parent.query_fields[list_fields[i]] = show_field( self.parent, self.bdataset_frame, list_fields[i].capitalize(), options[list_fields[i]], value, mandatory[i], validate[i], for_query=True, ) parent.validate[list_fields[i]] = validate[i] Pmw.alignlabels(parent.query_fields.values()) # ---------------------------------------------------------------------------------------- # Create button to update extraction # ---------------------------------------------------------------------------------------- w = Tkinter.Button( self.button_controls.interior(), text="Query Data Information", font=bnFont, background="lightblue", command=pub_controls.Command(ntk.new_query_page, parent, None), ) w.pack(side="top", padx=0, pady=3) self.button_controls.pack(side="top", fill="x", pady=3)