-
Notifications
You must be signed in to change notification settings - Fork 0
/
infowidget.py
41 lines (33 loc) · 1.1 KB
/
infowidget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from PyQt4 import QtGui, QtCore
Qt = QtCore.Qt
class Infowidget (QtGui.QTableWidget):
def __init__ ( self, parent = None ):
super().__init__(parent)
@staticmethod
def tower_type_data (tower_type):
return (
('Name' , tower_type.name)
, ('Range' , tower_type.attack_range)
, ('Cooldown' , tower_type.attack_time)
, ('Cost' , tower_type.money)
, ('Damage' , tower_type.damage)
)
@staticmethod
def attacker_type_data (attacker_type):
return (
('Name' , attacker_type.name)
, ('Speed' , attacker_type.speed)
, ('Maximum Life' , attacker_type.hp)
, ('Value' , attacker_type.money)
)
def show_tower_type ( self, tower_type ):
return self.show_data ( self.tower_type_data (tower_type) )
def show_attacker_type ( self, attacker_type ):
return self.show_data ( self.attacker_type_data (attacker_type) )
def show_data ( self, items ):
self.clear()
self.setRowCount(len(items))
self.setColumnCount(2)
for (i, (name, value)) in enumerate(items):
self.setItem (i, 0, QtGui.QTableWidgetItem ( name ) )
self.setItem (i, 1, QtGui.QTableWidgetItem ( str(value) ) )