加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ui.py 33.01 KB
一键复制 编辑 原始数据 按行查看 历史
cxj_git 提交于 2022-12-09 22:34 . add HighDpiScaling
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'codesync.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow,QMessageBox,QApplication,QFrame
from PyQt5.QtCore import pyqtSignal,QThread,Qt
from os import path
from run import Runner
import os
import configparser
from time import sleep
from img import background
import base64
# UI设计类
class Ui_mainWindow(object):
def setupUi(self, mainWindow):
mainWindow.setObjectName("mainWindow")
mainWindow.resize(358, 576)
window_pale = QtGui.QPalette()
# 使用base64打包背景图
pngData = base64.b64decode(background)
pix = QtGui.QPixmap()
pix.loadFromData(pngData)
window_pale.setBrush(mainWindow.backgroundRole(), QtGui.QBrush(pix))
mainWindow.setPalette(window_pale)
font = QtGui.QFont()
font.setFamily("微软雅黑")
mainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(mainWindow)
#mainWindow.setStyleSheet('background-color:;')
self.centralwidget.setObjectName("centralwidget")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(131, 20, 160, 301))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.lineEdit_host = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_host.setMaximumSize(QtCore.QSize(16777215, 25))
self.lineEdit_host.setBaseSize(QtCore.QSize(100, 100))
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.lineEdit_host.setFont(font)
self.lineEdit_host.setToolTip("")
self.lineEdit_host.setStatusTip("")
self.lineEdit_host.setWhatsThis("")
self.lineEdit_host.setInputMethodHints(QtCore.Qt.ImhNone)
self.lineEdit_host.setObjectName("lineEdit_host")
self.verticalLayout.addWidget(self.lineEdit_host)
self.lineEdit_port = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_port.setMaximumSize(QtCore.QSize(16777215, 25))
self.lineEdit_port.setBaseSize(QtCore.QSize(100, 100))
self.lineEdit_port.setObjectName("lineEdit_port")
self.verticalLayout.addWidget(self.lineEdit_port)
self.lineEdit_username = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_username.setMaximumSize(QtCore.QSize(100000, 25))
self.lineEdit_username.setBaseSize(QtCore.QSize(0, 0))
self.lineEdit_username.setObjectName("lineEdit_username")
self.verticalLayout.addWidget(self.lineEdit_username)
self.lineEdit_password = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_password.setMaximumSize(QtCore.QSize(16777215, 25))
self.lineEdit_password.setBaseSize(QtCore.QSize(100, 100))
self.lineEdit_password.setObjectName("lineEdit_password")
self.verticalLayout.addWidget(self.lineEdit_password)
self.lineEdit_serverpath = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_serverpath.setMaximumSize(QtCore.QSize(16777215, 25))
self.lineEdit_serverpath.setBaseSize(QtCore.QSize(100, 100))
self.lineEdit_serverpath.setObjectName("lineEdit_serverpath")
self.verticalLayout.addWidget(self.lineEdit_serverpath)
self.lineEdit_localpath = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_localpath.setMaximumSize(QtCore.QSize(16777215, 25))
self.lineEdit_localpath.setBaseSize(QtCore.QSize(100, 100))
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.lineEdit_localpath.setFont(font)
self.lineEdit_localpath.setObjectName("lineEdit_localpath")
self.verticalLayout.addWidget(self.lineEdit_localpath)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setSpacing(0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.lineEdit_putinterval = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_putinterval.setMaximumSize(QtCore.QSize(40, 20))
self.lineEdit_putinterval.setBaseSize(QtCore.QSize(100, 100))
self.lineEdit_putinterval.setObjectName("lineEdit_putinterval")
self.horizontalLayout_2.addWidget(self.lineEdit_putinterval)
self.label_11 = QtWidgets.QLabel(self.verticalLayoutWidget)
self.label_11.setMaximumSize(QtCore.QSize(16777215, 25))
self.label_11.setStyleSheet("font: 9pt \"微软雅黑\";")
self.label_11.setObjectName("label_11")
self.horizontalLayout_2.addWidget(self.label_11)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.lineEdit_getinterval = QtWidgets.QLineEdit(self.verticalLayoutWidget)
self.lineEdit_getinterval.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_getinterval.sizePolicy().hasHeightForWidth())
self.lineEdit_getinterval.setSizePolicy(sizePolicy)
self.lineEdit_getinterval.setMaximumSize(QtCore.QSize(40, 20))
self.lineEdit_getinterval.setBaseSize(QtCore.QSize(100, 100))
self.lineEdit_getinterval.setObjectName("lineEdit_getinterval")
self.horizontalLayout.addWidget(self.lineEdit_getinterval)
self.label_10 = QtWidgets.QLabel(self.verticalLayoutWidget)
self.label_10.setMaximumSize(QtCore.QSize(16777215, 25))
self.label_10.setStyleSheet("font: 9pt \"微软雅黑\";")
self.label_10.setObjectName("label_10")
self.horizontalLayout.addWidget(self.label_10)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(0, 20, 131, 371))
self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.label = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label.setObjectName("label")
self.verticalLayout_2.addWidget(self.label)
self.label_2 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_2.setObjectName("label_2")
self.verticalLayout_2.addWidget(self.label_2)
self.label_3 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_3.setObjectName("label_3")
self.verticalLayout_2.addWidget(self.label_3)
self.label_4 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.label_4.setFont(font)
self.label_4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_4.setObjectName("label_4")
self.verticalLayout_2.addWidget(self.label_4)
self.label_5 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.label_5.setFont(font)
self.label_5.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_5.setObjectName("label_5")
self.verticalLayout_2.addWidget(self.label_5)
self.label_6 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.label_6.setFont(font)
self.label_6.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_6.setObjectName("label_6")
self.verticalLayout_2.addWidget(self.label_6)
self.label_8 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.label_8.setFont(font)
self.label_8.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_8.setObjectName("label_8")
self.verticalLayout_2.addWidget(self.label_8)
self.label_9 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.label_9.setFont(font)
self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_9.setObjectName("label_9")
self.verticalLayout_2.addWidget(self.label_9)
spacerItem = QtWidgets.QSpacerItem(10, 39, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.verticalLayout_2.addItem(spacerItem)
self.label_7 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
font = QtGui.QFont()
font.setFamily("微软雅黑")
self.label_7.setFont(font)
self.label_7.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_7.setObjectName("label_7")
self.verticalLayout_2.addWidget(self.label_7)
self.textEdit_ignore = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit_ignore.setGeometry(QtCore.QRect(130, 320, 161, 81))
self.textEdit_ignore.setObjectName("textEdit_ignore")
self.pushButton_put_start = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_put_start.setGeometry(QtCore.QRect(60, 420, 75, 23))
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pushButton_put_start.setFont(font)
self.pushButton_put_start.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.pushButton_put_start.setStyleSheet("QPushButton{\n"
"background-color: rgb(85, 211, 103);\n"
"border-radius: 10px;\n"
"border: 2px groove rgb(5, 50, 5);\n"
"border-style: outset;\n"
"}\n"
"QPushButton:pressed{\n"
"background-color: rgb(25, 111, 43);\n"
"}")
self.pushButton_put_start.setObjectName("pushButton_put_start")
self.pushButton_stop = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_stop.setGeometry(QtCore.QRect(260, 420, 75, 23))
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(164, 255, 183))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush)
brush = QtGui.QBrush(QtGui.QColor(110, 247, 138))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush)
brush = QtGui.QBrush(QtGui.QColor(28, 120, 47))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush)
brush = QtGui.QBrush(QtGui.QColor(37, 160, 62))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush)
brush = QtGui.QBrush(QtGui.QColor(155, 247, 174))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 220))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(164, 255, 183))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush)
brush = QtGui.QBrush(QtGui.QColor(110, 247, 138))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush)
brush = QtGui.QBrush(QtGui.QColor(28, 120, 47))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush)
brush = QtGui.QBrush(QtGui.QColor(37, 160, 62))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush)
brush = QtGui.QBrush(QtGui.QColor(155, 247, 174))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 220))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.PlaceholderText, brush)
brush = QtGui.QBrush(QtGui.QColor(28, 120, 47))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
brush = QtGui.QBrush(QtGui.QColor(164, 255, 183))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush)
brush = QtGui.QBrush(QtGui.QColor(110, 247, 138))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush)
brush = QtGui.QBrush(QtGui.QColor(28, 120, 47))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush)
brush = QtGui.QBrush(QtGui.QColor(37, 160, 62))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush)
brush = QtGui.QBrush(QtGui.QColor(28, 120, 47))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush)
brush = QtGui.QBrush(QtGui.QColor(28, 120, 47))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 103, 86))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush)
brush = QtGui.QBrush(QtGui.QColor(56, 240, 93))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 220))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush)
self.pushButton_stop.setPalette(palette)
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pushButton_stop.setFont(font)
self.pushButton_stop.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.pushButton_stop.setStyleSheet("QPushButton{\n"
"background-color: rgb(255, 103, 86);\n"
"border-radius: 10px;\n"
"border: 2px groove rgb(50, 5, 5);\n"
"border-style: outset;\n"
"color:rgb(0,0,0);\n"
"}\n"
"QPushButton:pressed{\n"
"background-color: rgb(155, 53, 36);\n"
"}")
self.pushButton_stop.setObjectName("pushButton_stop")
self.pushButton_stop.setEnabled(False)
self.pushButton_get_start = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_get_start.setGeometry(QtCore.QRect(160, 420, 75, 23))
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pushButton_get_start.setFont(font)
self.pushButton_get_start.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.pushButton_get_start.setStyleSheet("QPushButton{\n"
"background-color: rgb(85, 211, 103);\n"
"border-radius: 10px;\n"
"border: 2px groove rgb(5, 50, 5);\n"
"border-style: outset;\n"
"}\n"
"QPushButton:pressed{\n"
"background-color: rgb(25, 111, 43);\n"
"}")
self.pushButton_get_start.setObjectName("pushButton_get_start")
self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser.setGeometry(QtCore.QRect(10, 460, 341,91))
self.textBrowser.setObjectName("textBrowser")
self.textBrowser.setFrameShape(QFrame.Box)
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setPointSize(8)
self.textBrowser.setFont(font)
mainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(mainWindow)
self.statusbar.setObjectName("statusbar")
mainWindow.setStatusBar(self.statusbar)
lineStyle = 'border: 1px groove rgb(150,150,150);'
self.lineEdit_host.setStyleSheet(lineStyle)
self.lineEdit_port.setStyleSheet(lineStyle)
self.lineEdit_localpath.setStyleSheet(lineStyle)
self.lineEdit_serverpath.setStyleSheet(lineStyle)
self.lineEdit_putinterval.setStyleSheet(lineStyle)
self.lineEdit_username.setStyleSheet(lineStyle)
self.lineEdit_password.setStyleSheet(lineStyle)
self.lineEdit_getinterval.setStyleSheet(lineStyle)
self.textEdit_ignore.setStyleSheet(lineStyle)
self.retranslateUi(mainWindow)
QtCore.QMetaObject.connectSlotsByName(mainWindow)
def retranslateUi(self, mainWindow):
_translate = QtCore.QCoreApplication.translate
self.translate = QtCore.QCoreApplication.translate
mainWindow.setWindowTitle(_translate("mainWindow", "CodeSync"))
self.lineEdit_host.setPlaceholderText(_translate("mainWindow", "127.0.0.1"))
self.lineEdit_port.setPlaceholderText(_translate("mainWindow", "22"))
self.lineEdit_username.setPlaceholderText(_translate("mainWindow", "root"))
self.lineEdit_serverpath.setPlaceholderText(_translate("mainWindow", "服务器暂存目录"))
self.lineEdit_localpath.setPlaceholderText(_translate("mainWindow", "本地代码所在目录"))
self.label_11.setText(_translate("mainWindow", " 秒"))
self.label_10.setText(_translate("mainWindow", " 秒"))
self.label.setText(_translate("mainWindow", "服务器地址:"))
self.label_2.setText(_translate("mainWindow", "服务器端口:"))
self.label_3.setText(_translate("mainWindow", "用户名:"))
self.label_4.setText(_translate("mainWindow", "密码:"))
self.label_5.setText(_translate("mainWindow", "服务器目录:"))
self.label_6.setText(_translate("mainWindow", "本地目录:"))
self.label_8.setText(_translate("mainWindow", "上传间隔:"))
self.label_9.setText(_translate("mainWindow", "下载间隔:"))
self.label_7.setText(_translate("mainWindow", "忽略文件:"))
self.textEdit_ignore.setPlaceholderText(_translate("mainWindow", "忽略文件名使用相对路径,输入的本地目录为第一级目录,多个文件使用英文逗号\",\"分割"))
self.pushButton_put_start.setText(_translate("mainWindow", "上传同步"))
self.pushButton_stop.setText(_translate("mainWindow", "停止同步"))
self.pushButton_get_start.setText(_translate("mainWindow", "下载同步"))
self.lineEdit_getinterval.setText('3')
self.lineEdit_putinterval.setText('3')
# 线程连接类
class Connecter(QThread):
update_ui_signal=pyqtSignal(str,str)
def __init__(self,mode):
super(Connecter,self).__init__()
self.runner = None
self.mode = mode
def run(self):
try:
self.get_Runner()
status = self.runner.connect()
if status == 'sftp连接建立成功':
self.update_ui_signal.emit(status,'green')
if self.mode == 'put':
self.runner.putListener(self.update_ui_signal)
elif self.mode == 'get':
self.runner.getListener(self.update_ui_signal)
else:
pass
else:
self.update_ui_signal.emit(status,'red')
except:
self.runner.stop_run()
self.update_ui_signal.emit('连接异常断开','red')
def stop(self):
if self.runner:
self.runner.stop_run()
# 获取同步工具
def get_Runner(self):
if not self.runner:
self.runner = Runner()
self.init_runner()
# 初始化同步工具
def init_runner(self):
filepath = path.join(os.getcwd(),'conf.ini')
if not path.exists(filepath):
return
conf = configparser.ConfigParser()
conf.read(filepath,encoding="utf-8")
# 获取数据
self.runner.serverpath = conf['SETTING']['serverpath']
self.runner.localpath = conf['SETTING']['localpath']
self.runner.host = conf['SETTING']['host']
self.runner.port = conf['SETTING']['port']
self.runner.username = conf['SETTING']['username']
self.runner.password = conf['SETTING']['password']
self.runner.ignore = conf['SETTING']['ignore']
self.runner.putinterval = int(conf['SETTING']['putinterval'])
self.runner.getinterval = int(conf['SETTING']['getinterval'])
# 忽略文件处理
self.runner.ignore = self.runner.ignore.split(',')
if 'tempfile.zip' not in self.runner.ignore:
self.runner.ignore.append('tempfile.zip')
os.chdir(self.runner.localpath)
# 窗口类
class Gui(QMainWindow, Ui_mainWindow):
def __init__(self):
super(Gui, self).__init__(None)
# 初始化界面
self.setupUi(self)
self.initUI()
self.getconf()
def initUI(self):
# 信号与槽连接
self.pushButton_put_start.clicked.connect(self.putclick)
self.pushButton_get_start.clicked.connect(self.getclick)
self.pushButton_stop.clicked.connect(self.stopsync)
# 获取配置
def getconf(self):
filepath = path.join(os.getcwd(),'conf.ini')
if not path.exists(filepath):
return
conf = configparser.ConfigParser()
conf.read(filepath,encoding="utf-8")
self.lineEdit_serverpath.setText(conf['SETTING']['serverpath'])
self.lineEdit_localpath.setText(conf['SETTING']['localpath'])
self.lineEdit_host.setText(conf['SETTING']['host'])
self.lineEdit_port.setText(conf['SETTING']['port'])
self.lineEdit_username.setText(conf['SETTING']['username'])
self.lineEdit_password.setText(conf['SETTING']['password'])
self.lineEdit_putinterval.setText(conf['SETTING']['putinterval'])
self.lineEdit_getinterval.setText(conf['SETTING']['getinterval'])
self.textEdit_ignore.setText(conf['SETTING']['ignore'])
# 输入校验,并保存配置
def checkinput(self,mode):
# 获取输入值
self.serverpath = self.lineEdit_serverpath.text().strip()
self.localpath = self.lineEdit_localpath.text().strip()
self.host = self.lineEdit_host.text().strip()
self.port = self.lineEdit_port.text().strip()
self.username = self.lineEdit_username.text().strip()
self.password = self.lineEdit_password.text().strip()
self.putinterval = self.lineEdit_putinterval.text().strip()
self.getinterval = self.lineEdit_getinterval.text().strip()
self.ignore = self.textEdit_ignore.toPlainText().strip()
# 判断输入值
if self.host == '':
QMessageBox(QMessageBox.Critical, '错误', '服务器地址不能为空').exec_()
return False
if self.port == '':
QMessageBox(QMessageBox.Critical, '错误', '服务器端口不能为空').exec_()
return False
elif not self.port.isdigit():
QMessageBox(QMessageBox.Critical, '错误', '端口应该为数字').exec_()
return False
if self.username == '':
QMessageBox(QMessageBox.Critical, '错误', '用户名不能为空').exec_()
return False
if self.serverpath == '':
QMessageBox(QMessageBox.Critical, '错误', '服务器目录不能为空').exec_()
return False
if self.localpath == '':
QMessageBox(QMessageBox.Critical, '错误', '本地目录不能为空').exec_()
return False
elif not path.exists(self.localpath):
QMessageBox(QMessageBox.Critical, '错误', '本地目录不存在').exec_()
return False
if self.getinterval == '' and mode == 'get':
QMessageBox(QMessageBox.Critical, '错误', '下载间隔不能为空').exec_()
return False
elif not self.getinterval.isdigit() and mode == 'get':
QMessageBox(QMessageBox.Critical, '错误', '间隔应该为数字').exec_()
return False
if self.putinterval == '' and mode == 'put':
QMessageBox(QMessageBox.Critical, '错误', '上传间隔不能为空').exec_()
return False
elif not self.putinterval.isdigit() and mode == 'put':
QMessageBox(QMessageBox.Critical, '错误', '间隔应该为数字').exec_()
return False
conf = configparser.ConfigParser()
filepath = path.join(os.getcwd(),'conf.ini')
conf.add_section('SETTING')
conf.set('SETTING','serverpath',self.serverpath)
conf.set('SETTING','localpath',self.localpath)
conf.set('SETTING','host',self.host)
conf.set('SETTING','port',self.port)
conf.set('SETTING','username',self.username)
conf.set('SETTING','password',self.password)
conf.set('SETTING','ignore',self.ignore)
conf.set('SETTING','getinterval',str(self.getinterval))
conf.set('SETTING','putinterval',str(self.putinterval))
conf.write(open(filepath,'w'))
return True
# 控件禁用启用
def widgetEnable(self,flag:bool):
self.lineEdit_serverpath.setEnabled(flag)
self.lineEdit_localpath.setEnabled(flag)
self.lineEdit_host.setEnabled(flag)
self.lineEdit_port.setEnabled(flag)
self.lineEdit_username.setEnabled(flag)
self.lineEdit_password.setEnabled(flag)
self.textEdit_ignore.setEnabled(flag)
self.lineEdit_putinterval.setEnabled(flag)
self.lineEdit_getinterval.setEnabled(flag)
self.pushButton_get_start.setEnabled(flag)
self.pushButton_put_start.setEnabled(flag)
self.pushButton_stop.setEnabled(not flag)
def sendTip(self,msg,color='black'):
msg = f"<font color='{color}'>" + msg + "<font>"
self.textBrowser.append(msg)
def putclick(self):
if not self.checkinput('put'):
return
self.widgetEnable(False)
self.sendTip('***************')
self.sendTip('建立连接中...')
try:
self.thrun = Connecter('put')
self.thrun.update_ui_signal.connect(self.sendTip)
self.thrun.start()
except:
self.stopsync()
self.sendTip('无法启动连接线程')
def getclick(self):
if not self.checkinput('get'):
return
self.widgetEnable(False)
self.sendTip('***************')
self.sendTip('建立连接中...')
try:
self.thrun = Connecter('get')
self.thrun.update_ui_signal.connect(self.sendTip)
self.thrun.start()
except:
self.stopsync()
self.sendTip('无法启动连接线程')
# 按下停止按钮
def stopsync(self):
if not self.thrun:
self.sendTip('停止时线程丢失','red')
return
self.sendTip('**************')
self.sendTip('正在停止...')
self.thrun.stop()
self.widgetEnable(True)
if __name__ == '__main__':
# 自适应大小
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication([])
gui = Gui()
gui.show() # 去掉ui
app.exec_()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化