-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (44 loc) · 1.32 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
# importing libraries
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
import webbrowser
class Window(QMainWindow):
def __init__(self):
super().__init__()
# setting title
self.setWindowTitle("Python ")
# setting geometry
self.setGeometry(100, 100, 500, 400)
# calling method
self.UiComponents()
# showing all the widgets
self.show()
# method for components
def UiComponents(self):
# counter value
self.n = 0
# creating label
label = QLabel("Counter", self)
# setting label geometry
label.setGeometry(100, 100, 100, 40)
# creating a command link button
cl_button = QCommandLinkButton("Next", self)
# setting geometry
cl_button.setGeometry(200, 100, 200, 40)
# adding action to the button
cl_button.clicked.connect(lambda: increment(self.n))
# method for incrementing the counter
def increment(n):
# increment
self.n = n + 1
# setting text to the label
label.setText(str(self.n))
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app
sys.exit(App.exec())