Пример #1
0
    def __init__(self, master, parent_dialog, row, column, datasets_file_manager):

        self.parent_dialog = parent_dialog

        headers = ["Dataset", "Exists"]

        GridBox.__init__(self, master, headers, row, column)

        self.pop_menu.add_command(label="Add Existing", command=self.add)
        self.pop_menu_add.add_command(label="Add Existing", command=self.add)

        self.datasets_file_manager = datasets_file_manager
        self.add_items(self.datasets_file_manager)
Пример #2
0
    def addFormElements(self, master):

        self.description = self.addEntry(master, "Description:", ValidateNotBlank(master), self.config.description)

        #Items
        label = Label(master, text="Portfolio Items:")
        label.grid(row=self.row, sticky=W, column=self.titleColumn, columnspan = 2)
        self.row += 1     
        
        self.itemsListBoxEntry = self.addListBox(master, "Items ListBox", height = 10)   

        self.validateItems = ValidatePortfolioItems(master, self.itemsListBoxEntry.listbox)
        self.validations.append(self.validateItems)
        self.validateItems.messageLabel.grid(row=self.row, sticky=W, column=self.messageColumn)
        
        headers = ["Description","Diameter","HubHeight","RatedPower","CutOutWindSpeed","Datasets"]
        self.items_grid_box = GridBox(master, headers)
        self.items_grid_box.edit = self.edit_item

        if not self.isNew:
                for item in self.config.items:                    
                        self.items_grid_box.add_item(item)

        self.validateItems.validate()   
Пример #3
0
 def remove(self):
     selected = self.get_selected()
     self.datasets_file_manager.remove(selected)
     GridBox.remove(self)
     self.parent_dialog.validate_datasets.validate()   
Пример #4
0
class PortfolioDialog:
        
    def getInitialFileName(self):
        return "portfolio"
            
    def getInitialFolder(self):        
        return preferences.portfolio_last_opened_dir()
                
    def addFormElements(self, master):

        self.description = self.addEntry(master, "Description:", ValidateNotBlank(master), self.config.description)

        #Items
        label = Label(master, text="Portfolio Items:")
        label.grid(row=self.row, sticky=W, column=self.titleColumn, columnspan = 2)
        self.row += 1     
        
        self.itemsListBoxEntry = self.addListBox(master, "Items ListBox", height = 10)   

        self.validateItems = ValidatePortfolioItems(master, self.itemsListBoxEntry.listbox)
        self.validations.append(self.validateItems)
        self.validateItems.messageLabel.grid(row=self.row, sticky=W, column=self.messageColumn)
        
        headers = ["Description","Diameter","HubHeight","RatedPower","CutOutWindSpeed","Datasets"]
        self.items_grid_box = GridBox(master, headers)
        self.items_grid_box.edit = self.edit_item

        if not self.isNew:
                for item in self.config.items:                    
                        self.items_grid_box.add_item(item)

        self.validateItems.validate()   
                
    def setConfigValues(self):
        
        self.config.path = self.filePath.get()
        self.config.description = self.description.get()

        #exclusions
        self.config.items = []
        
        for i in range(self.itemsListBoxEntry.listbox.size()):
            if i > 0:
                values = extractPortfolioItemValuesFromText(self.itemsListBoxEntry.listbox.get(i))
                self.config.addItem(description = values[0], \
                                    diameter = values[1], \
                                    hubHeight = values[2], \
                                    ratedPower = values[3], \
                                    cutOutWindSpeed = values[4], \
                                    datasets = values[5])

    def new_item(self):

        PortfolioItemDialog(self, configuration.RelativePath(self.filePath.get()), self.status, self.addPortfolioItemFromText)
        self.validateItems.validate()   
        
    def edit_item(self, event = None):

        items = self.itemsListBoxEntry.listbox.curselection()

        if len(items) == 1:

                idx = int(items[0])

                if idx > 0:

                    text = self.itemsListBoxEntry.listbox.get(items[0])                        
                    
                    try:
                        PortfolioItemDialog(self, configuration.RelativePath(self.filePath.get()), self.status, self.addPortfolioItemFromText, text, idx)                                
                    except ExceptionType as e:
                        self.status.addMessage("ERROR loading config (%s): %s" % (text, e))
        

    def remove_item(self):

        items = self.itemsListBoxEntry.listbox.curselection()
        pos = 0
        
        for i in items:
            
            idx = int(i) - pos
            
            if idx > 0:
                self.itemsListBoxEntry.listbox.delete(idx, idx)

            pos += 1

        self.validateItems.validate()   
        
    def addPortfolioItemFromText(self, text, index = None):

            if index != None:
                    self.itemsListBoxEntry.listbox.delete(index, index)
                    self.itemsListBoxEntry.listbox.insert(index, text)
            else:
                    self.itemsListBoxEntry.listbox.insert(END, text)