|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import sys
import PyQt5.QtCore as qc
import PyQt5.QtWidgets as qw
from test import Ui_MainWindow
from PyQt5.QtWidgets import QMainWindow, QApplication
from tool import Tool
class MyWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
super(MyWindow, self).__init__()
self.setupUi(self)
# 初始化窗口
self.statusbar.showMessage("status:ok")
#加载配置文件
self.settings = qc.QSettings("config.ini", qc.QSettings.IniFormat)
self.settings.setIniCodec("UTF-8")
self.config_uart_baud = self.settings.value("SETUP/UART_BAUD", 0, type=int)
print("uart baud(int) is %d" % self.config_uart_baud)
self.uart_port = "COM1"
# 初始化界面
self.radioButton_recv_ascii.setChecked(True)
self.radioButton_send_ascii.setChecked(True)
self.spinBox.setRange(100, 30 * 1000)
self.spinBox.setSingleStep(100)
self.spinBox.setWrapping(True)
self.spinBox.setValue(1000)
self.comboBox_bote.setCurrentText(str(self.config_uart_baud))
# 绑定信号与槽
self.comboBox_bote.currentIndexChanged.connect(self.comboBox_bote_cb)
self.btn_send.clicked.connect(self.btn_send_cb)
self.action_start.triggered.connect(self.action_start_cb)
self.action_pause.triggered.connect(self.action_pause_cb)
self.action_stop.triggered.connect(self.action_stop_cb)
self.action_clean.triggered.connect(self.action_clean_cb)
self.radioButton_recv_ascii.toggled.connect(self.radioButton_recv_ascii_cb)
self.radioButton_send_ascii.toggled.connect(self.radioButton_send_ascii_cb)
self.radioButton_recv_hex.toggled.connect(self.radioButton_recv_hex_cb)
self.radioButton_send_hex.toggled.connect(self.radioButton_send_hex_cb)
self.checkBox_zidonghuanhang.toggled.connect(self.checkBox_zidonghuanhang_cb)
self.checkBox_xianshifasong.toggled.connect(self.checkBox_xianshifasong_cb)
self.checkBox_xianshishijian.toggled.connect(self.checkBox_xianshishijian_cb)
self.checkBox_chongfufasong.toggled.connect(self.checkBox_chongfufasong_cb)
self.spinBox.valueChanged.connect(self.spinBox_cb)
#实例化Tool
self.tool = Tool(self)
def comboBox_bote_cb(self):
content = self.comboBox_bote.currentText()
print("combox's value is", content)
text = "您当前选中了%s" % content
qw.QMessageBox.information(self, "提示", text, qw.QMessageBox.Ok | qw.QMessageBox.Cancel)
def btn_send_cb(self):
print("you clicked btn_send.")
send_data = self.textEdit_get.toPlainText()
self.tool.uart.send_uart_data(send_data)
def action_start_cb(self):
print("you clicked action_start")
def action_pause_cb(self):
print("you clicked action_pause")
def action_stop_cb(self):
print("you clicked action_stop")
def action_clean_cb(self):
print("you clicked action_clean")
def radioButton_recv_ascii_cb(self):
print("you selected radioButton_recv_ascii")
def radioButton_send_ascii_cb(self):
print("you selected radioButton_send_ascii")
def radioButton_recv_hex_cb(self):
print("you selected radioButton_recv_hex")
def radioButton_send_hex_cb(self):
print("you selected radioButton_send_hex")
def checkBox_zidonghuanhang_cb(self):
print("you selected checkBox_auto_line")
res_auto_line = self.checkBox_zidonghuanhang.isChecked()
print("res_auto_line is ", res_auto_line)
res_show_send = self.checkBox_xianshifasong.isChecked()
print("res_show_send is ", res_show_send)
res_show_time = self.checkBox_xianshishijian.isChecked()
print("res_show_time is ", res_show_time)
res_repeat_send = self.checkBox_chongfufasong.isChecked()
print("res_repeat_send is ", res_repeat_send)
def checkBox_xianshifasong_cb(self):
print("you selected checkBox_show_send")
def checkBox_xianshishijian_cb(self):
print("you selected checkBox_show_time")
def checkBox_chongfufasong_cb(self):
print("you selected checkBox_repeat_send")
def spinBox_cb(self):
value = self.spinBox.value()
print("spinBox's current value is ", value)
if __name__ == '__main__':
app = QApplication(sys.argv)
myWin = MyWindow()
myWin.show()
sys.exit(app.exec_()) |
|