-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTirGui.py
119 lines (96 loc) · 3.64 KB
/
TirGui.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
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 26 14:32:54 2018
Control tir laview
@author: loa
"""
from PyQt6 import QtCore
import qdarkstyle
from PyQt6.QtGui import QKeySequence
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWidgets import QWidget,QMessageBox,QVBoxLayout,QPushButton,QHBoxLayout
from PyQt6.QtGui import QShortcut
import time
import sys
import tirSalleJaune as tirSJ
# import moteurRSAI as RSAI # Moteur RSAI
PY = sys.version_info[0]
if PY<3:
print('wrong version of python : Python 3.X must be used')
#%%
class TIRGUI(QWidget) :
"""
User interface for shooting class :
"""
def __init__(self,parent=None):
super(TIRGUI, self).__init__(parent)
self.isWinOpen=False
self.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt6'))
self.setup()
self.actionButton()
self.setWindowFlags(QtCore.Qt.WindowType.WindowStaysOnTopHint)
def setup(self):
vbox1=QVBoxLayout()
self.tirButton=QPushButton('LASER SHOT')
self.tirButton.setMinimumHeight(150)
self.tirButton.setStyleSheet("background-color: red ;border-radius:75px")
vbox1.addWidget(self.tirButton)
hbox=QHBoxLayout()
self.connectButton=QPushButton('Connect')
hbox.addWidget(self.connectButton)
self.disconnectButton=QPushButton('Disconnect')
hbox.addWidget(self.disconnectButton)
vbox1.addLayout(hbox)
self.setLayout(vbox1)
def actionButton(self):
self.setWindowTitle('Tir Salle Jaune')# affichage nom du moteur sur la barre de la fenetre
self.connectButton.clicked.connect(self.Connect)
self.disconnectButton.clicked.connect(self.Disconnect)
self.tirButton.clicked.connect(self.TirAct)
self.shortcut = QShortcut(QKeySequence("Ctrl+t"), self)
self.shortcut.activated.connect(self.TirAct)
def closeEvent(self, event):
""" when closing the window
"""
self.fini()
time.sleep(0.1)
event.accept()
def fini(self): # a la fermeture de la fenetre on arrete le thread secondaire
self.isWinOpen=False
time.sleep(0.1)
def Connect(self):
a=tirSJ.tirConnect()
print (a)
if a==1:
self.connectButton.setStyleSheet("background-color: green")
self.connectButton.setText("Connected")
self.TirConnected=1
else :
self.connectButton.setStyleSheet("background-color: gray")
self.connectButton.setText("Connection")
self.TirConnected=0
def Disconnect(self):
tirSJ.disconnect()
self.connectButton.setStyleSheet("background-color: gray")
self.connectButton.setText("Connection")
self.TirConnected=0
def TirAct(self):
a=tirSJ.Tir()
self.setWindowFlags(QtCore.Qt.WindowType.WindowStaysOnTopHint)
print( "tir :",a)
if a==0 or a=="":
self.TirConnected=0
print( "Probleme tir")
msg = QMessageBox()
msg.setIcon(QMessageBox.Icon.Critical)
msg.setText("Not connected !")
msg.setInformativeText("Please connect !!")
msg.setWindowTitle("Warning ...")
msg.setWindowFlags(QtCore.Qt.WindowType.WindowStaysOnTopHint)
msg.exec_()
if __name__ =='__main__':
appli=QApplication(sys.argv)
tt=TIRGUI()
tt.show()
appli.exec_()