本文整理汇总了Python中editxt.application.Application.editors方法的典型用法代码示例。如果您正苦于以下问题:Python Application.editors方法的具体用法?Python Application.editors怎么用?Python Application.editors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.application.Application
的用法示例。
在下文中一共展示了Application.editors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from editxt.application import Application [as 别名]
# 或者: from editxt.application.Application import editors [as 别名]
def test(ed_count, all_settings, result, add_eds=True):
ac = Application()
m = Mocker()
defaults = m.mock(NSUserDefaults)
df_class = m.replace("editxt.application.NSUserDefaults")
eds = [m.mock(Editor) for x in xrange(ed_count)]
if add_eds:
df_class.standardUserDefaults() >> defaults
defaults.arrayForKey_(const.WINDOW_SETTINGS_DEFAULTS_KEY) >> all_settings
ac.editors = eds
with m:
window_settings = ac.load_window_settings(eds[-1])
eq_(window_settings, result)
示例2: test
# 需要导入模块: from editxt.application import Application [as 别名]
# 或者: from editxt.application.Application import editors [as 别名]
def test(config, unordered=0):
"""
config - represents a list of window controllers in on-screen z-order
with the front-most window controller first. Key:
None - generic NSWindowController (not EditorWindowController)
<int> - Editor index in ac.editors
unordered - (optional, default 0) number of editors in
ac.editors that are not in the on-screen z-order window
list.
"""
ac = Application()
m = Mocker()
app_class = m.replace(ak, 'NSApp')
app = app_class()
eds = {}
unordered_eds = []
z_windows = []
for item in config:
if item is None:
wc = m.mock(ak.NSWindowController)
else:
wc = m.mock(EditorWindowController)
ed = m.mock(Editor)
print(ed, item)
if item != 7:
(wc.editor << ed).count(3)
unordered_eds.append(ed)
else:
wc.editor >> ed
eds[item] = ed
win = m.mock(ak.NSWindow)
win.windowController() >> wc
z_windows.append(win)
for x in range(unordered):
unordered_eds.append(m.mock(Editor))
ac.editors = unordered_eds # + [v for k, v in sorted(eds.items())]
app.orderedWindows() >> z_windows
sorted_eds = [eds[i] for i in config if i not in (None, 7)]
sorted_eds.extend(ed for ed in unordered_eds if ed not in sorted_eds)
with m:
result = list(ac.iter_editors())
eq_(result, sorted_eds)