本文整理汇总了Python中mnemosyne.libmnemosyne.Mnemosyne.main_widget方法的典型用法代码示例。如果您正苦于以下问题:Python Mnemosyne.main_widget方法的具体用法?Python Mnemosyne.main_widget怎么用?Python Mnemosyne.main_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mnemosyne.libmnemosyne.Mnemosyne
的用法示例。
在下文中一共展示了Mnemosyne.main_widget方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyClient
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
os.system("rm -fr dot_benchmark")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_benchmark")))
self.mnemosyne.review_controller().reset()
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
self.sync("127.0.0.1", 8190, "user", "pass")
self.mnemosyne.database().save()
示例2: MyServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
class MyServer(Server):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
shutil.rmtree(os.path.abspath("dot_sync_server"), ignore_errors=True)
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True)
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("dot_sync_server"), automatic_upgrades=False)
self.mnemosyne.config().change_user_id("user_id")
self.mnemosyne.review_controller().reset()
self.supports_binary_transfer = lambda x : False
# Add 20 cards to database.
card_type = self.mnemosyne.card_type_with_id("1")
for i in range (20):
fact_data = {"f": "question %d" % (i,),
"b": "answer"}
self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
self.mnemosyne.database().release_connection()
def authorise(self, login, password):
return login == "user" and password == "pass"
def load_database(self, database_name):
self.mnemosyne.database().load(database_name)
return self.mnemosyne.database()
def unload_database(self, database):
self.mnemosyne.database().release_connection()
# Dirty way to make sure we restart the server and create a new database
# (as opposed to keep sending old history back and forth)'
self.wsgi_server.stop()
def run(self):
Server.__init__(self, "client_machine_id", 8186,
self.mnemosyne.main_widget())
self.serve_until_stopped()
示例3: MyServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
class MyServer(Server):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
stop_after_sync = True
def __init__(self):
os.system("rm -rf sync_from_here")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("sync_from_here"))
self.mnemosyne.config().change_user_id("user_id")
self.mnemosyne.review_controller().reset()
# Add 20 cards to database.
card_type = self.mnemosyne.card_type_by_id("1")
for i in range (20):
fact_data = {"q": "question %d" % (i,),
"a": "answer"}
self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
def authorise(self, login, password):
return login == "user" and password == "pass"
def open_database(self, database_name):
return self.mnemosyne.database()
def run(self):
Server.__init__(self, "client_machine_id", "192.168.2.54", 8186,
self.mnemosyne.main_widget())
# Because we stop_after_sync is True, serve_forever will actually stop
# after one sync.
self.serve_forever()
self.mnemosyne.finalise()
示例4: MyServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
class MyServer(Server, Thread):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
stop_after_sync = True
def __init__(self):
Thread.__init__(self)
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
def authorise(self, login, password):
return login == "user" and password == "pass"
def open_database(self, database_name):
return self.mnemosyne.database()
def run(self):
# We only open the database connection inside the thread to prevent
# access problems, as a single connection can only be used inside a
# single thread.
self.mnemosyne.initialise(os.path.abspath("sync_from_here"))
self.mnemosyne.review_controller().reset()
Server.__init__(self, "server_machine_id", "127.0.0.1", 8190,
self.mnemosyne.main_widget())
# Because we stop_after_sync is True, serve_forever will actually stop
# after one sync.
self.serve_forever()
self.mnemosyne.finalise()
示例5:
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
"DatabaseLogger"),
("mnemosyne.libmnemosyne.schedulers.SM2_mnemosyne",
"SM2Mnemosyne"),
("mnemosyne.libmnemosyne.stopwatch",
"Stopwatch"),
("mnemosyne.libmnemosyne.card_types.front_to_back",
"FrontToBack"),
("mnemosyne.libmnemosyne.card_types.both_ways",
"BothWays"),
("mnemosyne.libmnemosyne.card_types.vocabulary",
"Vocabulary"),
("mnemosyne.libmnemosyne.controllers.default_controller",
"DefaultController"),
("mnemosyne.libmnemosyne.review_controllers.SM2_controller",
"SM2Controller"),
("mnemosyne.libmnemosyne.card_types.map",
"MapPlugin"),
("mnemosyne.libmnemosyne.card_types.cloze",
"ClozePlugin"),
("mnemosyne.libmnemosyne.criteria.default_criterion",
"DefaultCriterion"),
("mnemosyne.libmnemosyne.databases.SQLite_criterion_applier",
"DefaultCriterionApplier") ]
# Run Mnemosyne.
mnemosyne.initialise(data_dir=data_dir)
mnemosyne.start_review()
app.mainframe = mnemosyne.main_widget()
app.run()
mnemosyne.finalise()
示例6: MyClient
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
shutil.rmtree(os.path.abspath("dot_sync_client"), ignore_errors=True)
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True)
self.mnemosyne.components = [
("mnemosyne.libmnemosyne.translator",
"NoTranslation"),
("mnemosyne.libmnemosyne.databases.SQLite",
"SQLite"),
("mnemosyne.libmnemosyne.configuration",
"Configuration"),
("mnemosyne.libmnemosyne.loggers.database_logger",
"DatabaseLogger"),
("mnemosyne.libmnemosyne.schedulers.SM2_mnemosyne",
"SM2Mnemosyne"),
("mnemosyne.libmnemosyne.stopwatch",
"Stopwatch"),
("mnemosyne.libmnemosyne.card_types.front_to_back",
"FrontToBack"),
("mnemosyne.libmnemosyne.card_types.both_ways",
"BothWays"),
("mnemosyne.libmnemosyne.card_types.vocabulary",
"Vocabulary"),
("mnemosyne.libmnemosyne.renderers.html_css",
"HtmlCss"),
("mnemosyne.libmnemosyne.filters.escape_to_html",
"EscapeToHtml"),
("mnemosyne.libmnemosyne.filters.expand_paths",
"ExpandPaths"),
("mnemosyne.libmnemosyne.filters.latex",
"Latex"),
("mnemosyne.libmnemosyne.render_chains.default_render_chain",
"DefaultRenderChain"),
("mnemosyne.libmnemosyne.render_chains.plain_text_chain",
"PlainTextChain"),
("mnemosyne.libmnemosyne.controllers.default_controller",
"DefaultController"),
("mnemosyne.libmnemosyne.review_controllers.SM2_controller",
"SM2Controller"),
("mnemosyne.libmnemosyne.card_types.map",
"MapPlugin"),
("mnemosyne.libmnemosyne.card_types.cloze",
"ClozePlugin"),
("mnemosyne.libmnemosyne.criteria.default_criterion",
"DefaultCriterion"),
("mnemosyne.libmnemosyne.databases.SQLite_criterion_applier",
"DefaultCriterionApplier"),
("mnemosyne.libmnemosyne.plugins.cramming_plugin",
"CrammingPlugin") ]
self.mnemosyne.components.append(("benchmark_sync_client", "Widget"))
self.mnemosyne.components.append(("benchmark_sync_client", "MyReviewWidget"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_sync_client")), automatic_upgrades=False)
self.mnemosyne.config().change_user_id("user_id")
self.check_for_edited_local_media_files = False
self.do_backup = False
self.mnemosyne.review_controller().reset()
# Do 200 reviews.
card_type = self.mnemosyne.card_type_with_id("1")
fact_data = {"f": "question",
"b": "answer"}
card = self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
self.mnemosyne.review_controller().show_new_question()
for i in range(200):
self.mnemosyne.review_controller().show_answer()
self.mnemosyne.review_controller().grade_answer(0)
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
#self.BUFFER_SIZE = 10*8192
#self.behind_proxy = True
self.sync("localhost", 8186, "user", "pass")
self.mnemosyne.database().save()
示例7: startup
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
#.........这里部分代码省略.........
if options.data_dir != None:
data_dir = os.path.abspath(options.data_dir)
elif os.path.exists(os.path.join(os.getcwdu(), "mnemosyne2")):
data_dir = os.path.abspath(os.path.join(os.getcwdu(), "mnemosyne2"))
# Filename argument.
if len(args) > 0:
filename = os.path.abspath(args[0])
else:
filename = None
# Load the Mnemosyne library.
mnemosyne = Mnemosyne(upload_science_logs=True)
# Initialise GUI toolkit.
a = QApplication(sys.argv)
a.setApplicationName("Mnemosyne")
# TODO: install translator for Qt messages.
# Under Windows, move out of library.zip to get the true prefix.
# from mnemosyne.pyqt_ui.main_window import prefix
#if sys.platform == "win32":
# prefix = os.path.split(prefix)[0]
# prefix = os.path.split(prefix)[0]
# prefix = os.path.split(prefix)[0]
#translator = QTranslator(a)
#translator.load("qt_" + loc + ".qm", os.path.join(prefix, 'locale'))
#a.installTranslator(translator)
# Add other components we need. The translator should obviously come first,
# and the UI components should come in the order they should be instantiated,
# but apart from that, the order does not matter.
mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.main_wdgt",
"MainWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.review_wdgt",
"ReviewWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.configuration",
"PyQtConfiguration"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.pyqt_render_chain",
"PyQtRenderChain"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.add_cards_dlg",
"AddCardsDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.edit_card_dlg",
"EditCardDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.browse_cards_dlg",
"BrowseCardsDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.activate_cards_dlg",
"ActivateCardsDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.cloned_card_types_list_dlg",
"ClonedCardTypesListDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.card_appearance_dlg",
"CardAppearanceDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.activate_plugins_dlg",
"ActivatePluginsDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_dlg",
"StatisticsDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.card_type_wdgt_generic",
"GenericCardTypeWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_wdgts_plotting",
"ScheduleWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_wdgts_plotting",
"RetentionScoreWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_wdgts_plotting",
"GradesWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_wdgts_plotting",
"EasinessWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_wdgts_plotting",
"CardsAddedWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.statistics_wdgt_html",
"HtmlStatisticsWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.criterion_wdgt_default",
"DefaultCriterionWdgt"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.configuration_dlg",
"ConfigurationDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.sync_dlg",
"SyncDlg"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.qt_sync_server",
"QtSyncServer"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.configuration_wdgt_main",
"ConfigurationWdgtMain"))
mnemosyne.components.append(("mnemosyne.pyqt_ui.configuration_wdgt_sync_server",
"ConfigurationWdgtSyncServer"))
mnemosyne.extra_components_for_plugin["CrammingPlugin"] = \
[("mnemosyne.pyqt_ui.review_wdgt_cramming",
"ReviewWdgtCramming")]
# Run Mnemosyne.
mnemosyne.initialise(data_dir=data_dir, filename=filename)
mnemosyne.main_widget().show()
mnemosyne.main_widget().raise_() # Needed for OSX.
# TODO: check first run wizard.
#if config()["first_run"] == True:
# w.productTour()
# config()["first_run"] = False
#elif config()["show_daily_tips"] == True:
# w.Tip()
a.exec_()
mnemosyne.finalise()
示例8:
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
("mnemosyne.libmnemosyne.statistics_pages.cards_added",
"CardsAdded"),
("mnemosyne.libmnemosyne.statistics_pages.cards_learned",
"CardsLearned"),
("mnemosyne.libmnemosyne.statistics_pages.grades",
"Grades"),
("mnemosyne.libmnemosyne.statistics_pages.easiness",
"Easiness"),
("mnemosyne.libmnemosyne.statistics_pages.current_card",
"CurrentCard"),
("main_wdgt",
"MainWdgt")]
mnemosyne.initialise(data_dir, filename=filename)
# Sync before starting the review server.
if mnemosyne.main_widget().show_question(\
"Perform sync?", "Yes", "No", "") == 0:
mnemosyne.controller().sync(sync_server, sync_port,
sync_username, sync_password)
# Make sure the config gets picked up when starting a new
# Mnemosyne instance in the web server.
mnemosyne.config().save()
# Start review server.
mnemosyne.database().release_connection()
from mnemosyne.web_server.web_server import WebServerThread
web_server_thread = WebServerThread\
(mnemosyne.component_manager, is_server_local=True)
web_server_thread.daemon = True
web_server_thread.start()
if mnemosyne.main_widget().show_question(\
"Review server started. Either let Mnemosyne start Chrome, or, if you have problems with sound, start Firefox yourself and go to 127.0.0.1:8513, otherwise click below to start Chrome.",
示例9: MyClient
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import main_widget [as 别名]
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
self.mnemosyne = Mnemosyne()
self.mnemosyne.components = [
("mnemosyne.libmnemosyne.translator",
"NoTranslation"),
("mnemosyne.libmnemosyne.databases.SQLite",
"SQLite"),
("mnemosyne.libmnemosyne.configuration",
"Configuration"),
("mnemosyne.libmnemosyne.loggers.database_logger",
"DatabaseLogger"),
("mnemosyne.libmnemosyne.schedulers.SM2_mnemosyne",
"SM2Mnemosyne"),
("mnemosyne.libmnemosyne.stopwatch",
"Stopwatch"),
("mnemosyne.libmnemosyne.card_types.front_to_back",
"FrontToBack"),
("mnemosyne.libmnemosyne.card_types.both_ways",
"BothWays"),
("mnemosyne.libmnemosyne.card_types.three_sided",
"ThreeSided"),
("mnemosyne.libmnemosyne.renderers.html_css_old",
"HtmlCssOld"),
("mnemosyne.libmnemosyne.filters.escape_to_html",
"EscapeToHtml"),
("mnemosyne.libmnemosyne.filters.expand_paths",
"ExpandPaths"),
("mnemosyne.libmnemosyne.filters.latex",
"Latex"),
("mnemosyne.libmnemosyne.controllers.default_controller",
"DefaultController"),
("mnemosyne.libmnemosyne.review_controllers.SM2_controller",
"SM2Controller"),
("mnemosyne.libmnemosyne.card_types.map",
"MapPlugin"),
("mnemosyne.libmnemosyne.card_types.cloze",
"ClozePlugin"),
("mnemosyne.libmnemosyne.activity_criteria.default_criterion",
"DefaultCriterion"),
("mnemosyne.libmnemosyne.databases.SQLite_criterion_applier",
"DefaultCriterionApplier"),
("mnemosyne.libmnemosyne.plugins.cramming_plugin",
"CrammingPlugin") ]
self.mnemosyne.components.append(("benchmark_sync_client", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_benchmark")))
self.mnemosyne.config().change_user_id("user_id")
self.mnemosyne.review_controller().reset()
# Do 200 reviews.
card_type = self.mnemosyne.card_type_by_id("1")
fact_data = {"q": "question",
"a": "answer"}
card = self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
self.mnemosyne.review_controller().new_question()
for i in range(200):
self.mnemosyne.review_controller().show_answer()
self.mnemosyne.review_controller().grade_answer(0)
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
self.sync("192.168.2.54", 8186, "user", "pass")
self.mnemosyne.database().save()