I am building out an inventory screen. The InventoryManager is a defined class with an inventory dictionary as a property and some methods for adding InventoryItems to and taking them away from the dictionary. The inventory screen contains a grid, and I iterate through the inventory dictionary keys (which are the item names) to obtain all of the items and populate the grid with the associated images (each InventoryItem has a file string field). I then populate the empty grid spaces with empty strings (so as not to get the unfilled grid error):
Code: Select all
grid 5 2 xpos 137 ypos 335:
$ total = len(inventory.inventory.keys())
for key in inventory.inventory.keys():
$ img = str(inventory.inventory[key].image)
imagebutton auto "[img]_%s.png" action Null
$ rem = 10 - total
for i in range(0, rem):
text "{size=+10}{font=architect.ttf}{/font}{/size}"
Thank you!