45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
import configparser
|
|
import sys
|
|
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
|
|
from ui_untitled import Ui_MainWindow;
|
|
from COM.COM_TCP import TCPClient
|
|
from Expection import ErrorCode
|
|
|
|
class MyWindow(QMainWindow,Ui_MainWindow):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
self.setWindowTitle("PySide6 Test")
|
|
|
|
self.setGeometry(100, 100, 300, 200)
|
|
|
|
self.button = QPushButton("Click Me!", self)
|
|
self.button.setGeometry(100, 100, 100, 40)
|
|
self.button.clicked.connect(self.on_button_click)
|
|
self.tcpClient=None
|
|
self.configReader=configparser.ConfigParser()
|
|
|
|
def on_button_click(self):
|
|
self.button.setText("Clicked!")
|
|
|
|
|
|
def init_Run(self):
|
|
self.configReader.read('Seting.ini')
|
|
ip = self.configReader.get('Robot', 'IPAddress')
|
|
port= self.configReader.get('Robot', 'Port')
|
|
self.tcpClient = TCPClient(ip, port)
|
|
self.tcpClient.CreatConnect()
|
|
if self.tcpClient.is_Connect():
|
|
return 0
|
|
else:
|
|
return ErrorCode.NETERROR
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication(sys.argv)
|
|
window = MyWindow()
|
|
window.show()
|
|
sys.exit(app.exec())
|