Here is a sample resource file for 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 },
] } ] } }
With this source file:
from PythonCard import model
class Sounds(model.Background):
# Some irrelevant methods... #
if __name__ == '__main__':
app = model.Application(Sounds)
app.MainLoop()
How would I go about dynamically obtaining a list of all the "Button" components (for example) from within the GUI class?
Components are accessed in the manner self.components.<component name>
so my initial thought was for x in self.components: ...
, but self.components
is not iterable.