我正在开发我的第一个wxpython应用程序。它是一个命令行实用程序的GUI,需要连接到samba共享。现在我想将服务器选择作为单选按钮添加到菜单中。
Im将ConfigParser用于设置ini文件,该文件还保存默认服务器的配置以及
它应该连接的服务器。在
现在我想取消选择所有单选按钮,如果没有选择默认服务器,并且程序没有连接到
启动。在
以下是我在菜单中添加收音机选项的代码:
(我知道这可能会做得更好,但我仍在学习,我很高兴它起作用,欢迎任何推荐)# Create a List to be used as variables
for i in range(1,7):
list.append('radiobutton{}'.format(str(i)))
# Append the RadioButtons
for i in range(1,7):
num = str(i)
# Load Sections of ini (every server has its own section, up to 6 are allowed)
config_sec = Config.sections()
if filter(lambda x: 'Server{}'.format(num) in x, config_sec):
name = LoadConfig("Server{}".format(num))['connection name']
list[i] = wx.MenuItem(self.wpkg_server, 400+i, name, 'Connect to Server: {} ?'.