-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrgButton.py
More file actions
42 lines (31 loc) · 1.16 KB
/
OrgButton.py
File metadata and controls
42 lines (31 loc) · 1.16 KB
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
42
from PyQt5.QtCore import Qt, QPoint
from PyQt5.QtWidgets import QPushButton
from PyQt5.uic.properties import QtGui
from MenuKontekstowe import MenuKontekstowe
from Polozenie import Polozenie
from Swiat import Swiat
class OrgButton(QPushButton):
def __init__(self, parent, swiat: Swiat, x: int, y: int):
super(OrgButton, self).__init__(' ', parent)
self.swiat = swiat
self._x = x
self._y = y
self.menu = MenuKontekstowe(swiat, self, self)
self.clicked.connect(self.action)
self.setContextMenuPolicy(Qt.CustomContextMenu)
def paintEvent(self, q_paint_event):
o = self.swiat.zwroc_org_o_pol(Polozenie(self._x, self._y))
if o is not None:
self.setText(o.pobierz_znak())
self.setStyleSheet(o.pobierz_kolor())
else:
self.setStyleSheet("background-color : lightgreen")
self.setText('')
super().paintEvent(q_paint_event)
def action(self):
self.menu.popup(QPoint())
#self.swiat.dodaj_organizm
def zwrocX(self):
return self._x
def zwrocY(self):
return self._y