Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unpickle_file = cPickle.load(char_file)
- def createSaveFile(self):
- """Create the data files to be saved and save them.
- Creates a tuple comprised of a dictionary of general character information
- and the character's skills dictionary."""
- if self.file_name:
- self.save_data = ({'Name':self.charAttribs.name,
- <snip>
- self.charAttribs.char_skills_dict)
- self.file = open(self.file_name, 'w')
- cPickle.dump(self.save_data, self.file)
- self.file.close()
- def getCharFile(self, event): # wxGlade: CharSheet.<event_handler>
- """Retrieve pickled character file from disk."""
- wildcard = "Character files (*.char) | *.char | All files (*.*) | *.*"
- openDialog = wx.FileDialog(None, "Choose a character file", os.getcwd(),
- "", wildcard, wx.OPEN | wx.CHANGE_DIR)
- if openDialog.ShowModal() == wx.ID_OK:
- self.path = openDialog.GetPath()
- try:
- char_file = open(self.path, "r")
- unpickle_file = cPickle.load(char_file)
- char_data, char_skills = unpickle_file
- self.displayCharacter(char_data, char_skills)
- except IOError:
- self.importError = wx.MessageDialog(self,
- "The character file is not available!",
- "Character Import Error", wx.OK | wx.ICON_ERROR)
- self.importError.ShowModal()
- self.importError.Destroy()
- openDialog.Destroy()
- char_file = open('pickle.char', 'rb')
- char_file=open('filename.char','rU')
- char_file = open('filename.char','wb')
- cPickle.dumps(data, char_file)
- self.file = open(self.file_name, 'w')
- self.file = open(self.file_name, 'wb')
Add Comment
Please, Sign In to add comment