def _check(*args): lattice = latticemenu.get() if lattice == 'drift': quadN.grid_remove() quadmenu.grid_remove() screenN.grid_remove() screenmenu.grid_remove() quadlab.grid() quadent.grid() driftlab.grid() driftent.grid() else: _, _, _, UC, diagnostics, _, _, _, _, _, _, _ = latt2py(lattice, False) elements = list(UC[0,:]) quads = range(1, (elements.count(3)+elements.count(4)+1)) quadlab.grid_remove() quadent.grid_remove() driftlab.grid_remove() driftent.grid_remove() screenmenu['menu'].delete(0, 'end') quadmenu['menu'].delete(0, 'end') [screenmenu['menu'].add_command(label=fom, command=_setit(screenmenuval, fom)) for fom in diagnostics] [quadmenu['menu'].add_command(label=quad, command=_setit(quadmenuval, quad)) for quad in quads] screenN.grid() quadN.grid() screenmenu.grid() quadmenu.grid()
def repopulateDayMenu(*args): # Delete all items in the option menu dayMenu["menu"].delete(0,"end") # As an example, populate the menu with numbers from 1 to a random numner lower than 30 for i in range(1, randint(1, 30)): # Add a new item (i - in this case an int) to the option menu dayMenu['menu'].add_command(label=i, command= _setit(dayVar,i)) dayVar.set(1)
def SetMenu(self, valueList, value=None): self['menu'].delete(0, 'end') for item in valueList: self['menu'].add_command(label=item, command=_setit(self.variable, item, self.command)) if value: self.variable.set(value)
def repopulateDayMenu(*args): # Delete all items in the option menu dayMenu["menu"].delete(0, "end") # As an example, populate the menu with numbers from 1 to a random numner lower than 30 for i in range(1, randint(1, 30)): # Add a new item (i - in this case an int) to the option menu dayMenu['menu'].add_command(label=i, command=_setit(dayVar, i)) dayVar.set(1)
def add(self, item, select = 0): """ add an item to the menu. item - new string select - should we highlight it? """ self['menu'].add_command(label=item, command=_setit(self.variable,item, self.command)) if select: self.variable.set(item)
def update_file_choices(self): self.list_files['menu'].delete(0, 'end') files = [] if self.files_list_hook is not None: files = self.files_list_hook() new_files = sorted([i for i in files if '*'+i not in self.file_buffer] + self.file_buffer.keys()) for f in new_files: self.list_files['menu'].add_command(label=f, command=_setit(self.selected_file, f)) return new_files
def update_disk_optionmenu(self): disk_list = controller.get_disk_list() menu = self.menu_choose_disk['menu'] # clear all options menu.delete(0, 'end') # add new if not disk_list: raise Exception("No Acceptable disks found") else: for disk in disk_list: menu.add_command(label=disk, command=_setit(self.disk_choice,disk)) self.disk_choice.set(disk)
def SetMenu(self,valueList,value=None): """ clear and reload the menu with a new set of options. valueList - list of new options value - initial value to set the optionmenu's menubutton to """ self['menu'].delete(0,'end') for item in valueList: self['menu'].add_command(label=item, command=_setit(self.variable,item,self.command)) if value: self.variable.set(value)
def _check(*args): lattice = latticemenu.get() def clearfigs1(tabs): close('all') for tab in tabs: # destroy all widgets in fram/tab and close all figures for widget in tab.winfo_children(): widget.destroy() def showfigs1(figs, tabs): clearfigs1(tabs) for fig, tab in zip(figs, tabs): canvas = FigureCanvasTkAgg(fig, master=tab) canvas.get_tk_widget().pack() canvas.draw() if lattice == 'drift': quadN.grid_remove() quadmenu.grid_remove() screenN.grid_remove() screenmenu.grid_remove() quadlab.grid() quadent.grid() driftlab.grid() driftent.grid() else: _, _, _, UC, diagnostics, _, _, _, _, _, _, _ = latt2py(lattice, False) elements = list(UC[0,:]) quads = range(1, (elements.count(3)+elements.count(4)+1)) quadlab.grid_remove() quadent.grid_remove() driftlab.grid_remove() driftent.grid_remove() screenmenu['menu'].delete(0, 'end') quadmenu['menu'].delete(0, 'end') [screenmenu['menu'].add_command(label=fom, command=_setit(screenmenuval, fom)) for fom in diagnostics] [quadmenu['menu'].add_command(label=quad, command=_setit(quadmenuval, quad)) for quad in quads] screenN.grid() quadN.grid() screenmenu.grid() quadmenu.grid()
def new_file(self): self.list_files['menu'].add_command(label=self.defaultname.format( self.fsettings.get('extension', '.mln')), command=_setit( self.selected_file, self.defaultname.format( self.fsettings.get( 'extension', '.mln')))) self.selected_file.set( self.defaultname.format(self.fsettings.get('extension', '.mln'))) self.file_buffer[self.defaultname.format( self.fsettings.get('extension', '.mln'))] = '' self.editor.delete("1.0", END) self.dirty = True
def update_file_choices(self): self.list_files['menu'].delete(0, 'end') files = [] if self.files_list_hook is not None: files = self.files_list_hook() new_files = sorted( [i for i in files if '*' + i not in self.file_buffer] + self.file_buffer.keys()) for f in new_files: self.list_files['menu'].add_command(label=f, command=_setit( self.selected_file, f)) return new_files
def update_project_choices(self): modulename = self.selected_module.get() module_path = self.prac.manifest(modulename).module_path # remove all items self.list_projects['menu'].delete(0, 'end') projects = [ y for y in os.listdir(module_path) if os.path.isfile(os.path.join(module_path, y)) and y.endswith('.pracmln') ] for p in projects: self.list_projects['menu'].add_command(label=p, command=_setit( self.selected_project, p))
def addProvider(self): instList = [] indivList = [] providerentry2 = self.providerName.get() if providerentry2 == '': box.showwarning( "Warnung", "Bitte geben Sie einen Namen für den Datengeber ein!") return for entry in self.providerList: code = entry.split(' - ') if code[1].lower() == providerentry2.lower(): box.showwarning( "Warnung", "Es gibt schon einen Datengeber mit der gleichen Bezeichnung!" ) return if code[0].isdigit(): instList.append(code) else: indivList.append(code) if self.instVar.get() == 1: providerentry1 = str(len(instList)).zfill(3) self.providerList.append(providerentry1 + ' - ' + providerentry2) else: providerentry1 = createRandomPart(3) while providerentry1.isdigit(): providerentry1 = createRandomPart(3) while providerentry1 in indivList: providerentry1 = createRandomPart(3) self.providerList.append(providerentry1 + ' - ' + providerentry2) box.showinfo( "", "Der Datengeber wurde mit dem folgenden Kürzel angelegt: \n" + providerentry1) sortedList = sorted(self.providerList) self.providerList = sortedList self.v.set('--') self.list['menu'].delete(0, 'end') #update provider list in drop down menu and file for entry in self.providerList: self.list['menu'].add_command(label=entry, command=_setit(self.v, entry)) with open('datengeber.txt', 'w') as file: for entry in self.providerList: file.write(entry + '\n')
def add_search_options(): legal = [d['dtext']] + self.refinements_by_key(d['rkey']) # Specifically for the Model, if there are no legal refinements, # then the Make has not been set. Indicate this to the user. if k == 'Model' and len(legal) == 1: legal = ['Model (choose a make first)'] self.w[k]['menu'].delete(0, 'end') if k in self.tv: self.v[k].trace_vdelete('w', self.tv[k]) del(self.tv[k]) self.v[k].set(legal[0]) for choice in legal: self.w[k]['menu'].add_command(label=choice, command=_setit(self.v[k], choice)) if len(legal) > 1: if k in self.tv: self.v[k].trace_vdelete('w', self.tv[k]) del(self.tv[k]) self.tv[k] = self.v[k].trace('w', self.search_modified)
def add_output_file(self): print "Adding output file..." path = askopenfilename(filetypes=[ ('csv files', '*.csv'), ('All files', '*') ], parent=self.parent) self.out_path=path csvfile = open(path, 'rU') reader = csv.reader(csvfile) self.output_column_headers = reader.next() self.constant_field_selection['menu'].delete(0, 'end') for header in self.output_column_headers: self.constant_field_selection['menu'].add_command(label=header, command=_setit(self.constant_field, header)) # self.constant_field_selection = apply(OptionMenu, (self.constants_bar, self.constant_field) + tuple(self.output_column_headers)) # self.constant_field_selection.pack(side=LEFT) csvfile.close() current_choices = len(self.output_boxes) if current_choices == 0: conversion_frame = self.conversion_frames[len(self.conversion_frames) - 1] output_box = apply(OptionMenu, (conversion_frame, self.conversions[len(self.conversions) - 1]["destination"]) + tuple(self.output_column_headers)) self.output_boxes.append(output_box) label = Label(conversion_frame, text=" map column to ") label.pack(side=LEFT) output_box.pack(side = LEFT) delim_label = Label(conversion_frame, text= " Delimeter (for combined entries):") delim_label.pack(side=LEFT) delimeter_entry = Entry(conversion_frame, textvar=self.conversions[len(self.conversions) - 1]["delimeter"]) self.delimeter_entries.append(delimeter_entry) delimeter_entry.pack(side=LEFT) conversion_frame.pack(side=TOP, fill=X) else: for box in self.output_boxes: box.config(values=self.output_column_headers)
def refresh(options): network_select['menu'].delete(0, 'end') for choice in options: network_select['menu'].add_command(label=choice, command=_setit(var, choice))
def refresh(options): network_select['menu'].delete(0, 'end') for choice in options: network_select['menu'].add_command(label = choice, command = _setit(var, choice))
def new_file(self): self.list_files['menu'].add_command(label=self.defaultname.format(self.fsettings.get('extension', '.mln')), command=_setit(self.selected_file, self.defaultname.format(self.fsettings.get('extension', '.mln')))) self.selected_file.set(self.defaultname.format(self.fsettings.get('extension', '.mln'))) self.file_buffer[self.defaultname.format(self.fsettings.get('extension', '.mln'))] = '' self.editor.delete("1.0", END) self.dirty = True