#!/usr/bin/env python## ankiqt - a qt flashcard program based on libanki## Copyright (C) 2006, 2007 Damien Elmes <anki@repose.cx>## anki is free software; you can redistribute it and/or modify## it under the terms of the GNU General Public License as published by## the Free Software Foundation; either version 2, or (at your option)## any later version.## anki is distributed in the hope that it will be useful,## but WITHOUT ANY WARRANTY; without even the implied warranty of## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the## GNU General Public License for more details.## You should have received a copy of the GNU General Public License## along with anki; see the file COPYING. If not, write to the## Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,## Boston, MA 02110-1301, USA.import os, sys, optparse, refrom PyQt4.QtCore import *from PyQt4.QtGui import *appName="Anki"appVersion="0.2.6.3"appWebsite="http://repose.cx/anki/download/"appHelpSite="http://repose.cx/anki/help.html"appIssueTracker="http://repose.ath.cx/tracker/anki/"runningDir=os.path.dirname(sys.argv[0])# App initialisation##########################################################################if __name__ == "__main__": app = QApplication(sys.argv) if not sys.platform.startswith("darwin"): app.setStyle("plastique") # set up paths sys.path.append(os.path.join(runningDir, "libanki")) sys.path.append(os.path.join( os.path.join(runningDir, ".."), "libanki")) # add our pre-packaged kakasi to the path if sys.platform == "win32": os.environ['PATH'] += ";" + runningDir + "\\kakasi\\bin" shareDir = runningDir + "\\kakasi\\share\\kakasi\\" os.environ['ITAIJIDICT'] = shareDir + "\\itaijidict" os.environ['KANWADICT'] = shareDir + "\\kanwadict" elif sys.platform.startswith("darwin"): os.environ['PATH'] += ":" + runningDir + "/kakasi" os.environ['ITAIJIDICT'] = runningDir + "/kakasi/itaijidict" os.environ['KANWADICT'] = runningDir + "/kakasi/kanwadict" # parse args parser = optparse.OptionParser() parser.usage = "%prog [<deck.fc>]" parser.add_option("-c", "--config", help="path to config file", default=os.path.expanduser("~/.anki")) (opts, args) = parser.parse_args(sys.argv[1:]) # configuration import config conf = config.Config(opts.config) # load main window import ui ankiqt = ui.main.AnkiQt(app, conf, args) try: styleFile = open(opts.config + ".css") ankiqt.setStyleSheet(styleFile.read()) except (IOError, OSError): pass app.exec_()