wxWidgets Python 在文本中保存复选框和其他元素值

wxWidgets Python save checkbox and other elements values in a text

如何保存(和恢复)Python中wxWidgets图形元素的值? 我想要一些更友好的方式,也许使用 for 来抓取所有元素,并在关闭 window 时将当前值保存在 txt 中,并在加载应用程序时恢复。我不想为我添加的每个新元素键入 2 行代码(保存和恢复)。

@Igor,感谢使用提示config_base。我创建此代码基于:

configHandle = wx.Config(CONFIG_FILE)
# Sweep all elements in `self()` to find the grafical ones
# instance of the wxPython and salve the specific configuration.
for wxElement_name, wxElement_handle in self.__dict__.items():
    # Each wxPython object have a specific parameter value
    # to be saved and restored in the software initialization.
    if isinstance(wxElement_handle, wx._core.TextCtrl):
        configHandle.Write(wxElement_name, wxElement_handle.GetValue() )
    elif isinstance(wxElement_handle, wx._core.CheckBox):
        configHandle.Write(wxElement_name, ('True' if wxElement_handle.GetValue() else 'False') )
    elif isinstance(wxElement_handle, wx._core.SpinCtrl):
        configHandle.Write(wxElement_name, str(wxElement_handle.GetValue()) )
    .
    .
    .

为了恢复,我使用了这段代码的反向逻辑。