def __init__(self, *args, **kwargs): wx.Panel.__init__(self, *args, **kwargs) self.defbibtexchoice = wx.Choice(self, -1, choices=self.bibtexchoices.keys()) self.defbibtexchoice.SetStringSelection( PIE_CONFIG.get('Format', 'default_bibtex_entry_type')) tta = wx.ToolTip( _('Web pages and downloads will use this type by default')) self.defbibtexchoice.SetToolTip(tta) self.howpublishedtext = wx.TextCtrl(self, -1, validator=pieBibtexValidator(True)) ttb = wx.ToolTip( _('Web pages and downloads will use this text in the "howpublished" field by default' )) self.howpublishedtext.SetValue( PIE_CONFIG.get('Format', 'default_howpublished_text')) self.urlchoice = wx.Choice(self, -1, choices=self.uchz.keys()) ttc = wx.ToolTip( _("When referencing urls, should pieberry use the full URL, the page that referred to the full URL (where possible) or just the domain name of the site?" )) self.urlchoice.SetToolTip(ttc) self.urlchoice.SetStringSelection(self.uchz_rv[PIE_CONFIG.get( 'Format', 'url_level_represent')]) self.plaintextfmtchoice = wx.Choice(self, -1, choices=self.ptxtfchz.keys()) self.plaintextfmtchoice.SetStringSelection( self.ptxtfchz_rv[PIE_CONFIG.get('Format', 'plaintext_citation_format')]) self.protectcaps_cb = wx.CheckBox( self, -1, _('Prevent reformatting of capital letters in citations')) self.protectcaps_cb.SetValue( PIE_CONFIG.getboolean('Format', 'protect_all_caps_in_citations')) self.writepdf_cb = wx.CheckBox(self, -1, _('Write file metadata when possible')) ttd = wx.ToolTip( _(''' Pieberry will try to update metadata fields of pdf, office-xml and open document files to reflect the known bibliographic data to a limited extent (generally just the title and author). It doesn\'t always, however, work (but should fail safe)''')) self.writepdf_cb.SetToolTip(ttd) self.writepdf_cb.SetValue( PIE_CONFIG.getboolean('Format', 'write_file_metadata')) self.fnlen_spinner = wx.SpinCtrl(self, -1, min=40, max=255) self.fnlen_spinner.SetValue( PIE_CONFIG.getint('Format', 'filesystem_length_limit')) self._do_layout() self._do_bindings()
def __init__(self, *args, **kwargs): wx.Panel.__init__(self, *args, **kwargs) self.profileChoice = wx.Choice(self, -1, choices=PIE_CONFIG.get_profile_names()) self.profileChoice.SetStringSelection( PIE_CONFIG.get('TheProfile', 'current_profile')) tta = wx.ToolTip( _('A profile allows you to point Pieberry at different Pieberry directories and databases' )) self.profileChoice.SetToolTip(tta) self.profileaddbt = wx.Button(self, -1, _('Add')) self.rootdirctrl = wx.DirPickerCtrl(self, -1, path=PIE_CONFIG.get( 'Profile', 'rootdir'), style=wx.DIRP_USE_TEXTCTRL) self.rootdirctrl.SetPath(PIE_CONFIG.get('Profile', 'rootdir')) self.rootdiratstart = PIE_CONFIG.get('Profile', 'rootdir') self.desktopdirctrl = wx.DirPickerCtrl(self, -1, path=PIE_CONFIG.get( 'Profile', 'desktopdir'), style=wx.DIRP_USE_TEXTCTRL) self.desktopdirctrl.SetPath(PIE_CONFIG.get('Profile', 'desktopdir')) self.bib_cb = wx.CheckBox( self, -1, _('Export bibliography to pre-specified file')) # style=wx.ALIGN_RIGHT) ttb = wx.ToolTip( _("Setting the bibliography here means that Pieberry won't prompt you for a bibliography file every time you export it." )) self.bib_cb.SetToolTip(ttb) self.bib_cb.SetValue(PIE_CONFIG.getboolean('Profile', 'export_bibtex')) self.bibfilectrl = wx.FilePickerCtrl( self, -1, wildcard="BibTeX files (*.bib;*.bibtex)|*.bib;*.bibtex", style=wx.FLP_USE_TEXTCTRL | wx.FLP_SAVE) if PIE_CONFIG.getboolean('Profile', 'export_bibtex') == True: self.bibfilectrl.Enable(True) else: self.bibfilectrl.Enable(False) self.bibfilectrl.SetPath(PIE_CONFIG.get('Profile', 'bibliography_file')) self.bibexpstarred_cb = wx.CheckBox(self, -1, _('Export starred items only')) ttc = wx.ToolTip( _('Export only starred items with adequate bibliographic data (unchecking will export all with adequate bibliographic data in the library but not project folders)' )) self.bibexpstarred_cb.SetToolTip(ttc) self.bibexpstarred_cb.SetValue( PIE_CONFIG.getboolean('Profile', 'export_starred_only')) self._do_layout() self._do_bindings()
def __init__(self, *args, **kwargs): wx.Panel.__init__(self, *args, **kwargs) self.profileChoice = wx.Choice(self, -1, choices=PIE_CONFIG.get_profile_names()) self.profileChoice.SetStringSelection( PIE_CONFIG.get('TheProfile', 'current_profile')) tta = wx.ToolTip(_('A profile allows you to point Pieberry at different Pieberry directories and databases')) self.profileChoice.SetToolTip(tta) self.profileaddbt = wx.Button(self, -1, _('Add')) self.rootdirctrl = wx.DirPickerCtrl( self, -1, path = PIE_CONFIG.get('Profile', 'rootdir'), style = wx.DIRP_USE_TEXTCTRL) self.rootdirctrl.SetPath(PIE_CONFIG.get('Profile', 'rootdir')) self.rootdiratstart = PIE_CONFIG.get('Profile', 'rootdir') self.desktopdirctrl = wx.DirPickerCtrl( self, -1, path = PIE_CONFIG.get('Profile', 'desktopdir'), style = wx.DIRP_USE_TEXTCTRL) self.desktopdirctrl.SetPath(PIE_CONFIG.get('Profile', 'desktopdir')) self.bib_cb = wx.CheckBox(self, -1, _('Export bibliography to pre-specified file')) # style=wx.ALIGN_RIGHT) ttb = wx.ToolTip(_("Setting the bibliography here means that Pieberry won't prompt you for a bibliography file every time you export it.")) self.bib_cb.SetToolTip(ttb) self.bib_cb.SetValue(PIE_CONFIG.getboolean('Profile', 'export_bibtex')) self.bibfilectrl = wx.FilePickerCtrl( self, -1, wildcard = "BibTeX files (*.bib;*.bibtex)|*.bib;*.bibtex", style = wx.FLP_USE_TEXTCTRL|wx.FLP_SAVE) if PIE_CONFIG.getboolean('Profile', 'export_bibtex') == True: self.bibfilectrl.Enable(True) else: self.bibfilectrl.Enable(False) self.bibfilectrl.SetPath(PIE_CONFIG.get('Profile', 'bibliography_file')) self.bibexpstarred_cb = wx.CheckBox(self, -1, _('Export starred items only')) ttc = wx.ToolTip(_('Export only starred items with adequate bibliographic data (unchecking will export all with adequate bibliographic data in the library but not project folders)')) self.bibexpstarred_cb.SetToolTip(ttc) self.bibexpstarred_cb.SetValue( PIE_CONFIG.getboolean('Profile', 'export_starred_only')) self._do_layout() self._do_bindings()
def __init__(self, *args, **kwargs): wx.Panel.__init__(self, *args, **kwargs) self.defbibtexchoice = wx.Choice(self, -1, choices=self.bibtexchoices.keys()) self.defbibtexchoice.SetStringSelection( PIE_CONFIG.get('Format', 'default_bibtex_entry_type')) tta = wx.ToolTip(_('Web pages and downloads will use this type by default')) self.defbibtexchoice.SetToolTip(tta) self.howpublishedtext = wx.TextCtrl(self, -1, validator=pieBibtexValidator(True)) ttb = wx.ToolTip(_('Web pages and downloads will use this text in the "howpublished" field by default')) self.howpublishedtext.SetValue( PIE_CONFIG.get('Format', 'default_howpublished_text')) self.urlchoice = wx.Choice(self, -1, choices = self.uchz.keys()) ttc = wx.ToolTip(_("When referencing urls, should pieberry use the full URL, the page that referred to the full URL (where possible) or just the domain name of the site?")) self.urlchoice.SetToolTip(ttc) self.urlchoice.SetStringSelection( self.uchz_rv[PIE_CONFIG.get('Format', 'url_level_represent')]) self.plaintextfmtchoice = wx.Choice(self, -1, choices=self.ptxtfchz.keys()) self.plaintextfmtchoice.SetStringSelection( self.ptxtfchz_rv[PIE_CONFIG.get('Format', 'plaintext_citation_format')]) self.protectcaps_cb = wx.CheckBox(self, -1, _('Prevent reformatting of capital letters in citations')) self.protectcaps_cb.SetValue( PIE_CONFIG.getboolean('Format', 'protect_all_caps_in_citations')) self.writepdf_cb = wx.CheckBox(self, -1, _('Write file metadata when possible')) ttd = wx.ToolTip(_(''' Pieberry will try to update metadata fields of pdf, office-xml and open document files to reflect the known bibliographic data to a limited extent (generally just the title and author). It doesn\'t always, however, work (but should fail safe)''')) self.writepdf_cb.SetToolTip(ttd) self.writepdf_cb.SetValue( PIE_CONFIG.getboolean('Format', 'write_file_metadata')) self.fnlen_spinner = wx.SpinCtrl(self, -1, min=40, max=255) self.fnlen_spinner.SetValue( PIE_CONFIG.getint('Format', 'filesystem_length_limit')) self._do_layout() self._do_bindings()
def f_(text, protectcaps=False): if type(text) in (str, unicode): if protectcaps: text = protect_caps( text, PIE_CONFIG.getboolean( 'Format', 'protect_all_caps_in_citations') ) if texify: text = eblc(text) return text else: #this ain't text, don't touch it return text
import pieberry.pieconfig.config pieberry.pieconfig.config.make_config() print 'Create config' from pieberry.pieconfig.config import PIE_CONFIG # use gettext from pieberry.pieconfig.identity import PIE_APPNAME import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir( PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths
import wx, sys, datetime import wx.lib.mixins.listctrl as listmix from pprint import pprint from imagelist import PieImageList, MessageType from pieberry.pieconfig.config import PIE_CONFIG from pieberry.pieutility.date import fmtdate ATH = False if PIE_CONFIG.getboolean('Format', 'atom_title_hack'): ATH = True def filterout(filtertext, fields): '''determine whether to filter out a given term''' if not filtertext: return False to_filter_out = True for t in fields: if filtertext.lower() in t.lower(): to_filter_out = False if to_filter_out: return True else: return False class BaseListCtrl(wx.ListCtrl, listmix.ColumnSorterMixin, listmix.ListCtrlAutoWidthMixin): '''Control for displaying results in the download/scraping process''' columnheads = ('',) columnwidths = (480,) def __init__(self, parent): wx.ListCtrl.__init__(self, parent=parent, id=-1,
import wx, sys, datetime import wx.lib.mixins.listctrl as listmix from pprint import pprint from imagelist import PieImageList, MessageType from pieberry.pieconfig.config import PIE_CONFIG from pieberry.pieutility.date import fmtdate ATH = False if PIE_CONFIG.getboolean('Format', 'atom_title_hack'): ATH = True def filterout(filtertext, fields): '''determine whether to filter out a given term''' if not filtertext: return False to_filter_out = True for t in fields: if filtertext.lower() in t.lower(): to_filter_out = False if to_filter_out: return True else: return False class BaseListCtrl(wx.ListCtrl, listmix.ColumnSorterMixin, listmix.ListCtrlAutoWidthMixin): '''Control for displaying results in the download/scraping process''' columnheads = ('', ) columnwidths = (480, ) def __init__(self, parent):
def main(): print '__file__ =', __file__ frozen = getattr(sys, 'frozen', '') if not frozen: # not frozen: in regular python interpreter approot = GetAppdir() elif frozen in ('dll', 'console_exe', 'windows_exe'): # py2exe: approot = os.path.dirname(sys.executable) os.chdir(approot) sys.path.insert(0, approot) print 'Setting working directory:', approot # import global variables print 'Init global variables' from pieberry.pieconfig.globalvars import DEBUG, PY2EXE, PYNOTIFY, U_ERROR_BEHAV # set up system paths print 'Init system paths' import pieberry.pieconfig.initsys pieberry.pieconfig.initsys.init_config_location() pieberry.pieconfig.initsys.init_resource_locations() print 'Init config' # import config source import pieberry.pieconfig.config pieberry.pieconfig.config.make_config() print 'Create config' from pieberry.pieconfig.config import PIE_CONFIG # use gettext from pieberry.pieconfig.identity import PIE_APPNAME, PIE_VERSION import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir( PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths print 'Init user paths' import pieberry.pieconfig.paths pieberry.pieconfig.paths.init_storage_location( PIE_CONFIG.get('Profile', 'rootdir')) pieberry.pieconfig.paths.create_directories() pieberry.pieconfig.paths.init_desktop_location( PIE_CONFIG.get('Profile', 'desktopdir')) # clean up the cache pieberry.pieconfig.paths.clean_cache_path() # backup database and clean up backup dir from pieberry.piedb.backup import backup_db, clean_backups from pieberry.piedb.dbname import DBNAME from pieberry.pieconfig.paths import DBDIR if not os.path.exists(os.path.join(DBDIR, DBNAME)): dbstarting = True else: dbstarting = False clean_backups() backup_db(DBDIR) # init database print 'Init database' from pieberry.piedb import create_piedb_engine create_piedb_engine(pieberry.pieconfig.paths.DBDIR) from pieberry.piedb import SQLABase, engine, Session # clear out the directories if debugging # if DEBUG: # nuke_directories() # create_directories() # fill_desktopdir() print 'Init pieberry.pieobject' from pieberry.pieobject import PieObject from pieberry.pieobject.tags import init_tags, gen_tag_lookup from pieberry.pieobject.folder import generate_folder_list print 'Init tables' SQLABase.metadata.create_all(engine) if PIE_CONFIG.getboolean('Internal', 'first_run') or dbstarting: init_tags() gen_tag_lookup() print 'Establish internals' from pieberry.pieobject import PIE_INTERNALS PIE_INTERNALS.establish() print 'Generating initial folder list' generate_folder_list() print 'Init PIEBERRY.UI' from functionwindow import FunctionMainWindow frame_1 = FunctionMainWindow(None, -1, "") app.SetTopWindow(frame_1) frame_1.Show() frame_1.SetTitle(u'Pieberry [%s]' % PIE_CONFIG.get('TheProfile', 'current_profile')) PIE_CONFIG.set('Internal', 'first_run', 'False') PIE_CONFIG.write_pieconfig() if PIE_INTERNALS.getboolean('Identity', 'Hitherto_unset'): print 'Need to rectify object relationships' frame_1.DebugRectifyObjectRels(1) PIE_INTERNALS.set('Identity', 'Hitherto_unset', False) app.MainLoop()
def __init__(self, *args, **kwds): # begin wxGlade: GladeMainWindow.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self._mgr = wxaui.AuiManager(self) self.ContextPane = BetterContextPanel(self, -1) # self.TabPane = NBPanel(self) # self.TabBook = self.TabPane.nb self.TabBook = wxauip.AuiNotebook(self, -1) if PIE_CONFIG.get('Internal', 'tab_art') == 'simple': self.TabBook.SetArtProvider(wxauip.AuiSimpleTabArt()) # self.TabBook.SetMinSize((500,500)) # self.TabBook = fnb.FlatNotebook(self, -1) self.StatusBar = wx.StatusBar(self, -1) if sys.platform != 'win32': self.StatusBar.SetStatusStyles([1, wx.SB_FLAT]) # Menu Bar menuBar = wx.MenuBar() fileMenu = wx.Menu() toolMenu = wx.Menu() locateMenu = wx.Menu() gatherMenu = wx.Menu() viewMenu = wx.Menu() helpMenu = wx.Menu() atomMenu = wx.Menu() debugMenu = wx.Menu() self.menu_savebibs = wx.MenuItem( fileMenu, -1, _('&Export Bibliography\tCtrl-shift-b'), _('Export all starred items with bibliographic data to a BibTeX file')) self.menu_savebibs.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_MENU, (16, 16))) self.menu_print = wx.MenuItem( fileMenu, -1, _('&Print\tCtrl-p'), _('Print notes or report')) self.menu_print.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_MENU)) self.menu_pagesetup = wx.MenuItem( fileMenu, -1, _('P&age setup'), _('Set up printer page layout')) self.menu_quit = wx.MenuItem( fileMenu, -1, _('&Quit\tCtrl-q'), _('Quit')) self.menu_quit.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_MENU)) self.menu_rescan = wx.MenuItem( fileMenu, -1, _('&Index folders now'), _('Make Pieberry scan and index files and folders in your Pieberry directory')) self.menu_config = wx.MenuItem(fileMenu, -1, _('S&ettings'), _('Configure Pieberry')) self.menu_about = wx.MenuItem(helpMenu, -1, _('&About'), _('About Pieberry')) # self.menu_pageref = wx.MenuItem( # toolMenu, # -1, # _('Create &reference for top-level page'), # _('Reference')) self.menu_emptyref = wx.MenuItem( toolMenu, -1, _('&Create new (empty) bibliography entry\tCtrl-n'), _('Bring up a dialog to allow you to enter bibliographic data')) self.menu_emptyref.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_MENU)) self.menu_manual = wx.MenuItem(helpMenu, -1, _('&Manual')) self.menu_atom_process = wx.MenuItem( atomMenu, -1, _('&Process files from desktop\tCtrl-m'), _('Get documents off your desktop and sort them into folders')) self.menu_atom_process.SetBitmap( wx.Bitmap(os.path.join(IMGDIR, 'ic_broom16.png'))) # self.menu_atom_settings = wx.MenuItem( # atomMenu, -1, _('Desktop cleaner settings'), 'Settings') self.menu_find = wx.MenuItem( toolMenu, -1, _('&Find items in bibliography\tCtrl-f'), _('Search Pieberry\'s internal database')) self.menu_find.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_FIND, wx.ART_MENU)) self.menu_find_in_folders = wx.MenuItem( toolMenu, -1, _('F&ind your files\tCtrl-shift-f'), _('Search database by file name')) self.menu_find_in_folders.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_FIND, wx.ART_MENU)) self.menu_scan_web_page = wx.MenuItem( gatherMenu, -1, _('Scan &web page for documents\tCtrl-w'), _('Read and find links to documents on a given web page')) self.menu_scan_web_page.SetBitmap( wx.Bitmap(os.path.join(IMGDIR, 'ic_globe16.png'))) self.menu_google_books = wx.MenuItem( gatherMenu, -1, _('Search &Google Books\tCtrl-g'), _('Search Google Books for relevant references')) self.menu_google_books.SetBitmap( wx.Bitmap(os.path.join(IMGDIR, 'ic_google16.png'))) if ZBAR: self.menu_scan_barcode = wx.MenuItem( gatherMenu, -1, _('Scan ISBN &barcode\tCtrl-shift-o'), _('Scan a book\'s barcode containing its ISBN and look it up in Google Books')) self.menu_import_pieslice = wx.MenuItem( gatherMenu, -1, _('Import from pieslice file'), _("Import bundled information in Pieberry's own 'pieslice' file format")) self.menu_import_bibtex = wx.MenuItem( gatherMenu, -1, _('&Import from BibTeX file'), _('Import biblographic items from a BibTeX file')) self.menu_paste_bibtex = wx.MenuItem( gatherMenu, -1, _('&Paste in BibTeX entries\tCtrl-shift-p'), _('Paste BibTeX format citations from a source like JStor')) self.menu_import_bibtex.SetBitmap( wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_MENU)) self.menu_filter = wx.MenuItem( locateMenu, -1, _('Fil&ter\tCtrl-t'), _('Filter the items in the current view')) self.menu_toggle_context = wx.MenuItem( viewMenu, -1, _('&Toggle context panel')) self.menu_toggle_context.SetCheckable(True) self.menu_view_starred = wx.MenuItem( viewMenu, -1, _('View &important documents\tCtrl-1')) self.menu_view_flagged = wx.MenuItem( viewMenu, -1, _('View documents &flagged for review/follow-up\tCtrl-2')) self.menu_view_recentact = wx.MenuItem( viewMenu, -1, _('View most r&ecently used documents\tCtrl-3')) self.menu_view_recent = wx.MenuItem( viewMenu, -1, _('View most &recently added documents\tCtrl-4')) self.menu_view_project_folders = wx.MenuItem( viewMenu, -1, _('&Navigate project folders\tCtrl-7')) self.menu_view_library_folders = wx.MenuItem( viewMenu, -1, _('N&avigate library folders\tCtrl-8')) self.menu_view_meetingpaper_folders = wx.MenuItem( viewMenu, -1, _('Na&vigate meeting paper folders\tCtrl-9')) self.menu_view_tags = wx.MenuItem( viewMenu, -1, _('View Tags\tCtrl-0')) # BEGIN debug menu if PIE_CONFIG.getboolean('Internal', 'show_debug_ui'): self.menu_debug_addwebpane = wx.MenuItem( debugMenu, -1, _('Add Web Pane')) self.menu_debug_addbibpane = wx.MenuItem( debugMenu, -1, _('Add Bib Pane')) self.menu_debug_adddlpane = wx.MenuItem( debugMenu, -1, _('Add Pane with dld items')) self.menu_debug_addatompane = wx.MenuItem( debugMenu, -1, _('Add Pane with desktop items')) self.menu_debug_forcescan = wx.MenuItem( debugMenu, -1, _('Force scan of folders')) self.menu_debug_notespane = wx.MenuItem( debugMenu, -1, 'Add notes pane') self.menu_debug_rectifyobjectrels = wx.MenuItem( debugMenu, -1, 'Rectify object relationships' ) debugMenu.AppendItem(self.menu_debug_addatompane) debugMenu.AppendItem(self.menu_debug_adddlpane) debugMenu.AppendItem(self.menu_debug_addwebpane) debugMenu.AppendItem(self.menu_debug_addbibpane) debugMenu.AppendItem(self.menu_debug_forcescan) debugMenu.AppendItem(self.menu_debug_notespane) debugMenu.AppendItem(self.menu_debug_rectifyobjectrels) self.Bind(wx.EVT_MENU, self.DebugAddNotesPane, self.menu_debug_notespane) self.Bind(wx.EVT_MENU, self.DebugAddAtomisePane, self.menu_debug_addatompane) self.Bind(wx.EVT_MENU, self.DebugAddDownloadedPane, self.menu_debug_adddlpane) self.Bind(wx.EVT_MENU, self.DebugAddWebPane, self.menu_debug_addwebpane) self.Bind(wx.EVT_MENU, self.DebugAddBibPane, self.menu_debug_addbibpane) self.Bind(wx.EVT_MENU, self.DebugForceScan, self.menu_debug_forcescan) self.Bind(wx.EVT_MENU, self.DebugRectifyObjectRels, self.menu_debug_rectifyobjectrels) # END debug menu fileMenu.AppendItem(self.menu_savebibs) fileMenu.AppendItem(self.menu_print) fileMenu.AppendItem(self.menu_pagesetup) fileMenu.AppendItem(self.menu_config) fileMenu.AppendItem(self.menu_rescan) fileMenu.AppendSeparator() fileMenu.AppendItem(self.menu_quit) helpMenu.AppendItem(self.menu_manual) helpMenu.AppendItem(self.menu_about) locateMenu.AppendItem(self.menu_find) locateMenu.AppendItem(self.menu_find_in_folders) locateMenu.AppendItem(self.menu_filter) gatherMenu.AppendItem(self.menu_scan_web_page) gatherMenu.AppendItem(self.menu_google_books) if ZBAR: gatherMenu.AppendItem(self.menu_scan_barcode) gatherMenu.AppendSeparator() gatherMenu.AppendItem(self.menu_emptyref) gatherMenu.AppendItem(self.menu_import_pieslice) gatherMenu.AppendItem(self.menu_import_bibtex) gatherMenu.AppendItem(self.menu_paste_bibtex) gatherMenu.AppendSeparator() gatherMenu.AppendItem(self.menu_atom_process) viewMenu.AppendItem(self.menu_toggle_context) viewMenu.AppendSeparator() viewMenu.AppendItem(self.menu_view_starred) viewMenu.AppendItem(self.menu_view_flagged) viewMenu.AppendItem(self.menu_view_recentact) viewMenu.AppendItem(self.menu_view_recent) viewMenu.AppendSeparator() viewMenu.AppendItem(self.menu_view_project_folders) viewMenu.AppendItem(self.menu_view_library_folders) viewMenu.AppendItem(self.menu_view_meetingpaper_folders) viewMenu.AppendSeparator() viewMenu.AppendItem(self.menu_view_tags) menuBar.Append(fileMenu, _('&File')) menuBar.Append(gatherMenu, _('&Gather')) menuBar.Append(locateMenu, _('&Locate')) menuBar.Append(viewMenu, _('&View')) menuBar.Append(helpMenu, _('&Help')) if PIE_CONFIG.getboolean('Internal', 'show_debug_ui'): menuBar.Append(debugMenu, _('&Debug')) self.SetMenuBar(menuBar) self.SetAutoLayout(True) self.Bind(wx.EVT_MENU, self.OnPrint, self.menu_print) self.Bind(wx.EVT_MENU, self.OnPageSetup, self.menu_pagesetup) self.Bind(wx.EVT_MENU, self.onFind, self.menu_find) self.Bind(wx.EVT_MENU, self.onFindInFolders, self.menu_find_in_folders) self.Bind(wx.EVT_MENU, self.OnDesktopProcessGen, self.menu_atom_process) self.Bind(wx.EVT_MENU, self.onSaveBibs, self.menu_savebibs) self.Bind(wx.EVT_MENU, self.onClose, self.menu_quit) wx.EVT_CLOSE(self, self.onClose) self.Bind(wx.EVT_MENU, self.onConfig, self.menu_config) self.Bind(wx.EVT_MENU, self.onAbout, self.menu_about) self.Bind(wx.EVT_MENU, self.OnCreateNewBibObj, self.menu_emptyref) self.Bind(wx.EVT_MENU, self.onShowManual, self.menu_manual) self.Bind(wx.EVT_MENU, self.ToggleWebPanel, self.menu_scan_web_page) self.Bind(wx.EVT_MENU, self.ToggleFilterPanel, self.menu_filter) self.Bind(wx.EVT_MENU, self.ToggleContextPanel, self.menu_toggle_context) self.Bind(wx.EVT_MENU, self.OnImportPieSlice, self.menu_import_pieslice) self.Bind(wx.EVT_MENU, self.OnImportBibtex, self.menu_import_bibtex) self.Bind(wx.EVT_MENU, self.OnPasteBibtex, self.menu_paste_bibtex) self.Bind(wx.EVT_MENU, self.OnViewMostRecent, self.menu_view_recent) self.Bind(wx.EVT_MENU, self.OnViewFlagged, self.menu_view_flagged) self.Bind(wx.EVT_MENU, self.OnViewRecentlyInteracted, self.menu_view_recentact) self.Bind(wx.EVT_MENU, self.OnViewStarred, self.menu_view_starred) self.Bind(wx.EVT_MENU, self.OnViewProjectFolders, self.menu_view_project_folders) self.Bind(wx.EVT_MENU, self.OnViewLibraryFolders, self.menu_view_library_folders) self.Bind(wx.EVT_MENU, self.OnViewMeetingPaperFolders, self.menu_view_meetingpaper_folders) self.Bind(wx.EVT_MENU, self.OnViewTags, self.menu_view_tags) self.Bind(wx.EVT_MENU, self.OnStartIndexer, self.menu_rescan) self.Bind(wx.EVT_MENU, self.ToggleGoogleSearchPanel, self.menu_google_books) if ZBAR: self.Bind(wx.EVT_MENU, self.OnScanBarcode, self.menu_scan_barcode) # self.menu_savebibs.Enable(False) # self.menu_discard.Enable(False) # Menu Bar end # Printing self.printer = wx.richtext.RichTextPrinting() self.__set_properties() self.__do_layout() self._do_bindings()
from pieberry.pieconfig.config import PIE_CONFIG # use gettext from pieberry.pieconfig.identity import PIE_APPNAME import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir(PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths
def main(): print '__file__ =', __file__ frozen = getattr(sys, 'frozen', '') if not frozen: # not frozen: in regular python interpreter approot = GetAppdir() elif frozen in ('dll', 'console_exe', 'windows_exe'): # py2exe: approot = os.path.dirname(sys.executable) os.chdir(approot) sys.path.insert(0, approot) print 'Setting working directory:', approot # import global variables print 'Init global variables' from pieberry.pieconfig.globalvars import DEBUG, PY2EXE, PYNOTIFY, U_ERROR_BEHAV # set up system paths print 'Init system paths' import pieberry.pieconfig.initsys pieberry.pieconfig.initsys.init_config_location() pieberry.pieconfig.initsys.init_resource_locations() print 'Init config' # import config source import pieberry.pieconfig.config pieberry.pieconfig.config.make_config() print 'Create config' from pieberry.pieconfig.config import PIE_CONFIG # use gettext from pieberry.pieconfig.identity import PIE_APPNAME, PIE_VERSION import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir(PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths print 'Init user paths' import pieberry.pieconfig.paths pieberry.pieconfig.paths.init_storage_location(PIE_CONFIG.get('Profile', 'rootdir')) pieberry.pieconfig.paths.create_directories() pieberry.pieconfig.paths.init_desktop_location(PIE_CONFIG.get('Profile', 'desktopdir')) # clean up the cache pieberry.pieconfig.paths.clean_cache_path() # backup database and clean up backup dir from pieberry.piedb.backup import backup_db, clean_backups from pieberry.piedb.dbname import DBNAME from pieberry.pieconfig.paths import DBDIR if not os.path.exists(os.path.join(DBDIR, DBNAME)): dbstarting = True else: dbstarting = False clean_backups() backup_db(DBDIR) # init database print 'Init database' from pieberry.piedb import create_piedb_engine create_piedb_engine(pieberry.pieconfig.paths.DBDIR) from pieberry.piedb import SQLABase, engine, Session # clear out the directories if debugging # if DEBUG: # nuke_directories() # create_directories() # fill_desktopdir() print 'Init pieberry.pieobject' from pieberry.pieobject import PieObject from pieberry.pieobject.tags import init_tags, gen_tag_lookup from pieberry.pieobject.folder import generate_folder_list print 'Init tables' SQLABase.metadata.create_all(engine) if PIE_CONFIG.getboolean('Internal', 'first_run') or dbstarting: init_tags() gen_tag_lookup() print 'Establish internals' from pieberry.pieobject import PIE_INTERNALS PIE_INTERNALS.establish() print 'Generating initial folder list' generate_folder_list() print 'Init PIEBERRY.UI' from functionwindow import FunctionMainWindow frame_1 = FunctionMainWindow(None, -1, "") app.SetTopWindow(frame_1) frame_1.Show() frame_1.SetTitle(u'Pieberry [%s]' % PIE_CONFIG.get('TheProfile', 'current_profile')) PIE_CONFIG.set('Internal', 'first_run', 'False') PIE_CONFIG.write_pieconfig() if PIE_INTERNALS.getboolean('Identity', 'Hitherto_unset'): print 'Need to rectify object relationships' frame_1.DebugRectifyObjectRels(1) PIE_INTERNALS.set('Identity', 'Hitherto_unset', False) app.MainLoop()