-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
52 lines (37 loc) · 1.17 KB
/
test.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
42
43
44
45
46
47
48
49
50
51
52
# importing libraries
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
class HoverButton(QPushButton):
def __init__(self, parent=None):
super(HoverButton, self).__init__(parent)
self.setStyleSheet("background-color : yellow; border-radius : 50;")
def resizeEvent(self, event):
self.setMask(QRegion(self.rect(), QRegion.Ellipse))
QPushButton.resizeEvent(self, event)
class Window(QMainWindow):
def __init__(self):
super().__init__()
# setting title
self.setWindowTitle("Python ")
# setting geometry
self.setGeometry(100, 100, 600, 400)
# calling method
self.UiComponents()
# showing all the widgets
self.show()
def UiComponents(self):
button = HoverButton(self)
button.setGeometry(200, 150, 100, 100)
button.clicked.connect(self.clickme)
# action method
def clickme(self):
# printing pressed
print("pressed")
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app
sys.exit(App.exec())