假设我有一个GUI窗口的输入表单,要求新设置和该设置的值,然后将其传递给管理设置的另一个对象,并期望** kwargs作为输入:
class SettingsForm(someFormClass):
def onSubmit(self):
new_setting = self.content['new setting'].get()
new_value = self.content['value'].get()
settings_instance.add_setting(new_setting=new_value)
这会将new_value设置为文字字符串" new_setting'。我已经尝试了各种方法来解决这个问题,例如使用字典:
class SettingsForm(someFormClass):
def onSubmit(self):
new_setting = self.content['new setting'].get()
new_value = self.content['value'].get()
mydict = {}
mydict[new_setting] = new_value
settings_instance.add_setting(**mydict)
这是有效的,但对于一对价值观并没有多大意义......是否有一种明显的方法可以让我失踪?