-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeypad_Mdl.py
107 lines (86 loc) · 3.51 KB
/
keypad_Mdl.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from PyQt5.QtWidgets import QDialog,QApplication
from PyQt5.QtGui import QValidator,QDoubleValidator
#from PyQt5.QtCore import QObject
from functools import partial
import sys
import keypadN
class keypadForm(QDialog,keypadN.Ui_Dialog):
def __init__(self,f_obj):
super(keypadForm, self).__init__()
self.f_obj=f_obj
self.setupUi(self)
self.btn_list=[self.pushButton,self.pushButton_2,self.pushButton_3,self.pushButton_4,
self.pushButton_5,self.pushButton_6,self.pushButton_7,self.pushButton_8,
self.pushButton_9,self.pushButton_10,self.pushButton_11]
self.lineEdit.setText(self.f_obj.text())
self.lineEdit=self.f_obj
# par_validator=self.f_obj.validator()
# par_validator.setNotation(QDoubleValidator.StandardNotation)
# self.lineEdit.setValidator(par_validator)
# print(self.f_obj.validator())
self.girilenDeger=self.f_obj.text()
self.onay=False
self.my_tuple=(self.girilenDeger,self.onay)
for obj in self.btn_list:
#self.cmd=partial()
obj.clicked.connect(self.degerGirise)
self.pushButton_14.clicked.connect(self.onayDeger)
self.pushButton_12.clicked.connect(self.kapatForm)
self.pushButton_13.clicked.connect(self.degerSil)
self.pushButton_15.clicked.connect(self.temizle)
def degerGirise(self):
sender=self.sender() #burada Qobject.sender() medtodu çağırılıyor sender=QObject.sender(self) ile aynı
if sender.text()=='.' and '.' in self.girilenDeger:
return
self.girilenDeger+=sender.text()
self.lineEdit.setText(self.girilenDeger)
# print(sender.text())
# print(self.girilenDeger)
def onayDeger(self):
if not (self.girilenDeger=='' or self.girilenDeger==None):
# a=self.degerKontrol(self.f_obj, self.girilenDeger)
# if a==True:
self.onay=True
self.my_tuple=(self.girilenDeger,self.onay)
self.f_obj.setText(self.girilenDeger)
self.f_obj.clearFocus()
self.f_obj.setReadOnly(True)
self.close()
def degerSil(self):
kardiz=self.girilenDeger
if len(kardiz)!=0:
a=len(kardiz)-1
self.girilenDeger=kardiz[:a]
self.lineEdit.setText(self.girilenDeger)
def temizle(self):
self.girilenDeger=''
self.lineEdit.setText('')
def degerAl(self):
return self.my_tuple
def kapatForm(self):
self.f_obj.clearFocus()
self.f_obj.setReadOnly(True)
self.close()
# def degerKontrol(self, obj, text):
# state = obj.validator.validate(text, 0)[0]
# if "," in text:
# return (False,"virgül yerine nokta kullanılmalı")
# elif state ==QValidator.Intermediate:
# return (False,"girilen desen boyu belirlenen aralıkta değil")
# else:
# return (True,"başarılı")
if __name__ == '__main__':
app=QApplication(sys.argv)
# hata yakalama için ilave edildi
sys._excepthook = sys.excepthook
def my_exception_hook(exctype, value, traceback):
# Print the error and traceback
print("program hatalar", exctype, value, traceback)
# Call the normal Exception hook after
sys._excepthook(exctype, value, traceback)
sys.exit(1)
# Set the exception hook to our wrapping function
sys.excepthook = my_exception_hook
f=keypadForm()
f.show()
sys.exit(app.exec_())