def initUI(self): self.parent.title('Select corresponding entities') #self.mainframe = ttk.Frame(self.parent) self.mainframe = TScrolledFrame(self.parent,width=1000, height=400) self.mainframe.pack(fill='both', expand=1)
class EntityMappingDialog: def __init__(self, parent, config, sqlSfMapping, databaseSchema, salesforceSchema): self.parent = parent self.config = config self.sqlSfMapping = sqlSfMapping self.initUI() self.initData(databaseSchema, salesforceSchema) def initUI(self): self.parent.title('Select corresponding entities') #self.mainframe = ttk.Frame(self.parent) self.mainframe = TScrolledFrame(self.parent,width=1000, height=400) self.mainframe.pack(fill='both', expand=1) #self.mainframe.grid(column=0,row=0,sticky=(N,W,E,S)) #self.mainframe.columnconfigure(0, weight=1) #self.mainframe.rowconfigure(0, weight=1) def initData(self, databaseSchema, salesforceSchema): self.selectedOptions = dict() self.comboBoxOptions = dict({'<None>': '<None>'}) for sObj in sorted(salesforceSchema.keys()): self.comboBoxOptions[sObj + '[' + salesforceSchema[sObj][u'name'] + ']'] = sObj #init service arrays that will allow to set recommended values as default optionsSObjects = list() optionsSObjectsLabels = list() for tbl in sorted(self.comboBoxOptions.keys()): optionsSObjects.append(tbl) optionsSObjectsLabels.append(self.comboBoxOptions[tbl]) RowsInColumn = self.config.getint('user-interface', 'rows') itemNumber = 0; for tbl in self.sqlSfMapping.keys(): colNumber = 2*(itemNumber%2) rowNumber = abs(itemNumber/2) ttk.Label(self.mainframe.frame(), text=tbl).grid(column=colNumber, row=rowNumber, sticky=E) self.selectedOptions[tbl] = StringVar(self.mainframe.frame()) dialogComboBox = ttk.Combobox(self.mainframe.frame(), textvariable=self.selectedOptions[tbl], values=optionsSObjects, width=60) dialogComboBox.grid(column=colNumber+1, row=rowNumber, sticky=W) dialogComboBox.current(optionsSObjectsLabels.index(self.sqlSfMapping[tbl]['sObject'])) itemNumber += 1 ttk.Button(self.mainframe.frame(), text="Apply", command=self.apply).grid(column=3, row=abs(itemNumber)+1, sticky=W) for child in self.mainframe.frame().winfo_children(): child.grid_configure(padx=5, pady=5) self.parent.bind('<Return>', self.apply) def getSelectedMapping(self): return self.sqlSfMapping def apply(self, event=None): for tbl in self.selectedOptions.keys(): selectedOption = self.selectedOptions[tbl].get() self.sqlSfMapping[tbl]['sObject'] = self.comboBoxOptions[selectedOption] self.parent.destroy()