【发布时间】:2012-11-08 21:52:26
【问题描述】:
我想知道何时调整了框架的大小,以便保存大小并在下次应用程序启动时记住它。这是我的on_resize 方法:
def on_resize(self, event):
logic.config_set('main_frame_size',
(event.Size.width, event.Size.height))
event.Skip()
它是这样绑定的:
self.Bind(wx.EVT_SIZE, self.on_resize)
问题在于性能。为安全起见,我的逻辑模块在每次设置更改时都会保存配置文件,而每次触发调整大小事件时都编写配置文件对性能造成太大影响。
当用户完成调整框架大小时,最好/最简单的监控方式是什么?
更新
我的config_set 功能:
def config_set(key, value):
"""Set a value to the config file."""
vprint(2, 'Setting config value: "{}": "{}"'.format(key, value))
config[key] = value
# Save the config file.
with open(config_file_path, 'w') as f:
pickle.dump(config, f)
【问题讨论】: