本文整理汇总了Python中editxt.application.Application.save_window_state方法的典型用法代码示例。如果您正苦于以下问题:Python Application.save_window_state方法的具体用法?Python Application.save_window_state怎么用?Python Application.save_window_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.application.Application
的用法示例。
在下文中一共展示了Application.save_window_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from editxt.application import Application [as 别名]
# 或者: from editxt.application.Application import save_window_state [as 别名]
def test(with_id=True, fail=False):
with tempdir() as tmp:
state_path = os.path.join(tmp, const.STATE_DIR)
window = TestConfig(state=[42], id=9)
args = (window.id,) if with_id else ()
app = Application(tmp)
app.setup_profile(windows=True)
state_name = app.save_window_state(window, state_path, *args)
if fail:
window = window(state="should not be written")
def dump_fail(state, fh=None):
if fh is not None:
fh.write("should not be seen")
raise Exception("dump fail!")
with replattr(mod, "dump_yaml", dump_fail, sigcheck=False):
state_name = app.save_window_state(window, state_path, *args)
assert os.path.isdir(state_path), state_path
with open(os.path.join(state_path, state_name)) as f:
eq_(load_yaml(f), [42])