def _SetDataFile(self, datafile, create=False):
        wx.Yield()
        wx.BeginBusyCursor()
        try:
            self.tree.PruneAll()
            self.tag_tree.PruneAll()
            self._SetEntryModified(False)
            self._SetDiaryModified(False)
            self.panel.Show(False)
            self.conf.data_file = datafile
            if datafile:
                datafile = os.path.abspath(datafile)
                if not os.path.exists(datafile) and not create:
                    wx.MessageBox("Unable to find datafile '%s'." %
                                 (datafile),
                                 "Datafile Missing", wx.OK | wx.ICON_ERROR,
                                 self.frame)
                    return
                elif create:
                    if os.path.exists(datafile):
                        os.remove(datafile)
                    self._SaveData(datafile, None)
                self.frame.SetStatusText('Loading %s...' % datafile)
                try:
                    self.entries = tk_data.parse_data(datafile)
                except tk_data.TKDataVersionException, e:
                    wx.MessageBox("Datafile format used by '%s' is not "
                                 "supported ." % (datafile),
                                 "Datafile Version Error",
                                 wx.OK | wx.ICON_ERROR,
                                 self.frame)
                    return
                timestruct = time.localtime()
    
                def _AddEntryToTree(entry):
                    year, month, day = entry.get_date()
                    id = entry.get_id()
                    self.tree.EntryChangedListener(entry, year, month,
                                                   day, id, False)
                self.entries.enumerate_entries(_AddEntryToTree)
                
                def _AddEntryToTagTree(entry, tag):
                    self.tag_tree.EntryChangedListener(tag, entry, True)
                self.entries.enumerate_tag_entries(_AddEntryToTagTree)
                
                self.tag_tree.CollapseTree()
                self.tree.CollapseTree()
                stack = filter(None, self.tree.GetDateStack(timestruct[0],
                                                            timestruct[1],
                                                            timestruct[2],
                                                            None))
                for item in stack:
                    self.tree.Expand(item)
                self.entries.register_listener(self.tree.EntryChangedListener)
                self.entries.register_listener(self.cal.EntryChangedListener)
                self.entries.register_tag_listener(
                                            self.tag_tree.EntryChangedListener)
                self._SetEntryFormDate(timestruct[0],
                                       timestruct[1],
                                       timestruct[2])
                self.cal.HighlightEvents(self.entries)
                self.panel.Show(True)
                self._DiaryMenuEnable(True)
                self.frame.Layout()
                self._UpdateAuthorBox()
            self.datafile = datafile
            self._SetTitle()
            if create:
                self._FileDiaryOptionsMenu(None)
        finally:
            wx.EndBusyCursor()
Set the active datafile, possible creating one on disk.
dataset/ETHPy150Open cmpilato/thotkeeper/lib/tk_main.py/ThotKeeper._SetDataFile