一旦我的程序运行,我希望我的 wxChoice 被我指定的列表中的项目填充。我正在使用 wxFormBuilder 来处理程序的 GUI 元素。
我的代码:
def onDropDownSelection(self, parent):
#Open designated file
lines = tuple(open("/Users/it/Desktop/Classbook/masterClassList.txt", 'r'))
#Strips the first line of the file, splits the elements, assigns to "one"
lines[1].rstrip()
one = lines[1].split("|")
#My attempt to populate the wxChoice with my list "one"
self.firstChoice.SetItems(one)
当用户单击下拉(wxChoice)菜单时激活此事件,并在每次单击时重新填充。
有没有一种方法可以在程序首次打开/运行时填充我的 wxChoice,仅一次?
我已将此代码放置在创建 wxChoice 的位置。但是,我现在在第 44 行遇到“取消缩进与任何外部缩进级别不匹配”的情况。如何解决此问题?
最佳答案
检查您的缩进。有时如果你复制粘贴,这可能会把事情搞砸。 只需重写它或用其他语句替换它即可。看这里: IndentationError: unindent does not match any outer indentation level
问题是,如果您使用制表符进行缩进,然后从示例页面复制粘贴一些代码,其中缩进是使用空格进行的。然后你就有了混合的缩进。我已经经历过很多次了。
关于python - 在程序运行开始时填充 wxChoice | Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27625215/