Fixed UI bugs when buying new units in base defense menu.

This commit is contained in:
Khopa 2020-09-25 00:36:13 +02:00
parent c96b5cf4d7
commit ce257a31bb

View File

@ -35,10 +35,12 @@ class QBaseDefenseGroupInfo(QGroupBox):
def buildLayout(self):
unit_dict = {}
for i in range(self.unit_layout.count()):
item = self.unit_layout.itemAt(i)
if item is not None and item.widget() is not None:
self.unit_layout.removeItem(item)
for i in range(self.unit_layout.rowCount()):
for j in range(self.unit_layout.columnCount()):
item = self.unit_layout.itemAtPosition(i, j)
if item is not None and item.widget() is not None:
item.widget().setParent(None)
print("Remove " + str(i) + ", " + str(j))
for g in self.ground_object.groups:
for u in g.units:
@ -58,6 +60,11 @@ class QBaseDefenseGroupInfo(QGroupBox):
self.unit_layout.addWidget(QLabel(str(v) + " x " + "<strong>" + k + "</strong>"), i, 1)
i = i + 1
if len(unit_dict.items()) == 0:
self.unit_layout.addWidget(QLabel("/"), 0, 0)
self.setLayout(self.main_layout)
def onManage(self):