Пример #1
0
 def OnImport(self, event):
     dlg = wx.FileDialog(self, "Import pyfa override file",
                         wildcard="pyfa override file (*.csv)|*.csv",
                         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     if dlg.ShowModal() == wx.ID_OK:
         path = dlg.GetPath()
         with open(path, 'rb') as csvfile:
             spamreader = csv.reader(csvfile)
             for row in spamreader:
                 itemID, attrID, value = row
                 item = getItem(int(itemID))
                 attr = getAttributeInfo(int(attrID))
                 item.setOverride(attr, float(value))
         self.itemView.updateItems(True)
Пример #2
0
 def OnImport(self, event):
     with wx.FileDialog(
         self, "Import pyfa override file",
         wildcard="pyfa override file (*.csv)|*.csv",
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
     ) as dlg:
         if dlg.ShowModal() == wx.ID_OK:
             path = dlg.GetPath()
             with open(path, 'r') as csvfile:
                 spamreader = csv.reader(csvfile)
                 for row in spamreader:
                     if len(row) == 0:  # csvwriter seems to added blank lines to the end sometimes
                         continue
                     itemID, attrID, value = row
                     item = getItem(int(itemID))
                     attr = getAttributeInfo(int(attrID))
                     item.setOverride(attr, float(value))
             self.itemView.updateItems(True)