以下是PythonCard的示例资源文件:
{ 'application':{ 'type':'Application',
'name':'Test Sounds',
'backgrounds':
[
{ 'type':'Background',
'name':'Test Sounds',
'title':'Test Sounds',
'position':( 5, 5 ),
'size':( 300, 200 ),
'components':
[
{ 'type':'TextField', 'name':'fldFilename', 'position':( 5, 4 ), 'size':( 200, -1 ), 'text':'anykey.wav' },
{ 'type':'Button', 'name':'btnFile', 'position':( 210, 5 ), 'size':( -1, -1), 'label':'Select File' },
{ 'type':'Button', 'name':'btnPlay', 'position':( 5, 40 ), 'size':( -1, -1 ), 'label':'Play' },
{ 'type':'CheckBox', 'name':'chkAsync', 'position':( 5, 70 ), 'size':( -1, -1 ), 'label':'Async I/O', 'checked':0 },
{ 'type':'CheckBox', 'name':'chkLoop', 'position':( 5, 90 ), 'size':( -1, -1 ), 'label':'Loop sound', 'checked':0 },
] } ] } }
使用此源文件:
^{pr2}$我该如何从GUI类中动态地获取所有“Button”组件的列表(例如)?在
组件是以self.components.<component name>
的方式访问的,所以我最初的想法是for x in self.components: ...
,但是{
如果您能够从其他地方获得组件列表,则会更干净,但我认为,如果您执行以下操作,它应该会有效:
相关问题 更多 >
编程相关推荐