Beispiel #1
0
    def __init__(self):
        #init
        QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        Ui_GenerateDocConfirm.__init__(self)
        Ui_databaseSetting.__init__(self)
        Ui_WordPad.__init__(self)
        self.setupUi(self)

        #connect
        self.initToolBar()
        self.connectButton()
        self.connectText()
        self.connectList()

        #message dialog
        self.msgDialog = MessageDialog()

        #graph style
        self.setupVars()

        # use wordPad
        self.connectWordPad()

        #sample dir
        self.init_Samples()
Beispiel #2
0
class MainUIObj(QMainWindow):
    def __init__(self):
        super(MainUIObj, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.model = load_model("./models/cnn")

    def predictNum(self):
        screen = QApplication.primaryScreen()
        # SmoothTransformation
        img = screen.grabWindow(self.ui.widget.winId()).toImage().scaled(
            QSize(28, 28), transformMode=1)
        num_pixel = []
        for y in range(img.height()):
            for x in range(img.width()):
                curr_pixel = img.pixelColor(x, y).red()
                if curr_pixel != 240:
                    num_pixel.append(1)
                else:
                    num_pixel.append(0)
        num_pixel = np.array(num_pixel)
        num_pixel = num_pixel.reshape(1, 28, 28, 1)
        index_num = np.argmax(self.model.predict(num_pixel)[0])
        self.ui.plainTextEdit.setPlainText(str(index_num))

        pass

    def clearPad(self):
        self.ui.widget.clearPad()
        pass
Beispiel #3
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     subject = []
     self.login_window = None
     self.show()
     self.bind_events()
Beispiel #4
0
    def __init__(self):
##Page 0 - Main Page side menu
        self.main_win = QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self.main_win)

        self.ui.stackedWidget.setCurrentWidget(self.ui.page_home)

        self.ui.button_home.clicked.connect(self.show_page_home)
        self.ui.button_drawingrenamer.clicked.connect(self.show_page_drawingrenamer)
        self.ui.button_standardssearch.clicked.connect(self.show_page_standardssearch)
        self.ui.button_imagetools.clicked.connect(self.show_page_image_tools)
        self.ui.button_drawingstamper.clicked.connect(self.show_page_drawing_stamper)
        self.welcome_text()

## Page 1 - Home Page
        self.ui.about_the_author.setOpenExternalLinks(True)

## Page 2 - Drawing Renamer ############################################################################
        self.ui.pushButton_enter_path.clicked.connect(self.enter_path)
        self.ui.pushButton_enter_beginningtext.clicked.connect(self.enter_beginningtext)
        self.ui.pushButton_enter_endtext.clicked.connect(self.enter_endtext)
        self.ui.pushButton_enter_replace_text.clicked.connect(self.enter_replace_text)
        self.ui.pushButton_enter_titleblock_search.clicked.connect(self.enter_titleblock_search)
        self.ui.pushButton_rename.clicked.connect(self.rename_file)
        self.ui.pushButton_enter_excel_export.clicked.connect(self.excel_list_export)
        self.ui.pushButton_enter_excel_export_2.clicked.connect(self.excel_list_import)


## Page 3 - Standards Search ############################################################################
        self.ui.pushButton_enter_path_standards.clicked.connect(self.enter_path_standards)
        self.ui.pushButton_enter_path_standards_2.clicked.connect(self.standards_search_bsi)
        self.ui.pushButton_enter_path_standards_3.clicked.connect(self.export_standards_to_text_file)

## Page 4 - Image Tools ############################################################################
        self.ui.pushButton_enter_path_imagetools.clicked.connect(self.enter_path_imagetools)
        self.ui.pushButton_compress_pictures.clicked.connect(self.compress_pictures)
        self.ui.pushButton_enter_path_imagetools_2.clicked.connect(self.enter_path_imagetools_logo)
        self.ui.pushButton_add_a_logo.clicked.connect(self.add_a_logo)

## Page 5 - Drawing Stamper ############################################################################
        self.ui.pushButton_enter_path_drawing_stamper.clicked.connect(self.enter_path_drawingstostamp)
        self.ui.pushButton_enter_path_drawing_stamper_2.clicked.connect(self.enter_path_logotostamp)
        self.ui.pushButton_drawing_stamp_go.clicked.connect(self.process_drawing_stamps)
        self.ui.pushButton_refresh_drawing_stamp.clicked.connect(self.refresh_stamp)
 def openNewWindow(self):
     feature = {
         'car1': self.carCAM1.isChecked(),
         'mpa1': self.monitorCAM1.isChecked(),
         'person1': self.personSearchingCAM1.isChecked(),
         'illegal1': self.illegalCAM1.isChecked(),
         'car2': self.carCAM2.isChecked(),
         'mpa2': self.monitorCAM2.isChecked(),
         'person2': self.personSearchingCAM2.isChecked(),
         'illegal2': self.illegalCAM2.isChecked(),
         'car3': self.carCAM3.isChecked(),
         'mpa3': self.monitorCAM3.isChecked(),
         'person3': self.personSearchingCAM3.isChecked(),
         'illegal3': self.illegalCAM3.isChecked()
     }
     self.window = QtWidgets.QWidget()
     self.ui = Ui_MainWindow(feature=feature)
     self.ui.setupUi(self.window)
     Form.hide()
     self.window.show()
     print(feature)
Beispiel #6
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        subject = []
        self.login_window = None
        self.show()
        self.bind_events()

    def bind_events(self):
        self.ui.pushAdd.clicked.connect(self.show_add_student_window)
        self.ui.pushrecognize.clicked.connect(self.recognize_face)

    def show_add_student_window(self):
        self.ui.pushrecognize.hide()
        self.ui.pushAdd.hide()
        self.add_student_window = AddStudentWindow()
        self.ui.mdiArea.addSubWindow(self.add_student_window)
        self.add_student_window.show()
        self.show()

    def recognize_face(self):
        self.ui.pushrecognize.hide()
        self.ui.pushAdd.hide()
        db = connect()
        c = db.cursor()
        students = sqlite3utils.get_students(c)
        names = {}
        for id, name in list(students):
            names[id] = name

        trainall()
        self.endcapture = False
        predictall(self.finishrecognize, names)

    def finishrecognize(self):
        return self.endcapture
Beispiel #7
0
class MainWindow:
    def __init__(self):
        pass

    """This function is connected to the Beeper Test button"""

    def run_beeper_test(self):
        beepertest = beeperTest()
        beepertest.start()

    app = QApplication(sys.argv)
    window = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(window)

    #connect button clicks to server routines
    ui.btnBeeperTest.clicked.connect(run_beeper_test)

    window.show()
    sys.exit(app.exec_())
Beispiel #8
0
# -*- coding: utf-8 -*-

import sys, os
from PyQt5.QtWidgets import QApplication, QMainWindow

#通过pyuic产生的py文件
from MainUI import Ui_MainWindow

#导入pyuid产生的py文件对应的信号事件函数
from MainUIConn import setBMIndexBtnConn,setGaiKuangBtnConn,setXXGKIndexColumnBtnConn,\
    setXXGKStaticInfoBtnConn,setBMGGGSBtnConn

if __name__ == '__main__':
    app = QApplication(sys.argv)
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()

    #设置UI界面
    ui.setupUi(MainWindow)
    #设置子界面是否打开标志列表
    SubWinList = {
        'BMIndex': 0,
        'GaiKuang': 0,
        'XXGKIndexColumn': 0,
        'XXGKStaticInfo': 0,
        'BMGGGS': 0
    }

    # 获取当前文件路径
    current_path = os.path.abspath(__file__)
    # 获取当前文件的父目录
class Ui_Form(object):
    def openNewWindow(self):
        feature = {
            'car1': self.carCAM1.isChecked(),
            'mpa1': self.monitorCAM1.isChecked(),
            'person1': self.personSearchingCAM1.isChecked(),
            'illegal1': self.illegalCAM1.isChecked(),
            'car2': self.carCAM2.isChecked(),
            'mpa2': self.monitorCAM2.isChecked(),
            'person2': self.personSearchingCAM2.isChecked(),
            'illegal2': self.illegalCAM2.isChecked(),
            'car3': self.carCAM3.isChecked(),
            'mpa3': self.monitorCAM3.isChecked(),
            'person3': self.personSearchingCAM3.isChecked(),
            'illegal3': self.illegalCAM3.isChecked()
        }
        self.window = QtWidgets.QWidget()
        self.ui = Ui_MainWindow(feature=feature)
        self.ui.setupUi(self.window)
        Form.hide()
        self.window.show()
        print(feature)

    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(229, 495)
        Form.setMaximumSize(QtCore.QSize(229, 495))
        self.finishBtn = QtWidgets.QPushButton(Form)
        self.finishBtn.setGeometry(QtCore.QRect(60, 440, 111, 31))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.finishBtn.setFont(font)
        self.finishBtn.setObjectName("finishBtn")
        self.layoutWidget = QtWidgets.QWidget(Form)
        self.layoutWidget.setGeometry(QtCore.QRect(40, 300, 159, 116))
        self.layoutWidget.setObjectName("layoutWidget")
        self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.layoutWidget)
        self.verticalLayout_6.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_6.setObjectName("verticalLayout_6")
        self.label_19 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_19.setFont(font)
        self.label_19.setAlignment(QtCore.Qt.AlignCenter)
        self.label_19.setObjectName("label_19")
        self.verticalLayout_6.addWidget(self.label_19)
        self.verticalLayout_3 = QtWidgets.QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_9.setObjectName("horizontalLayout_9")
        self.label_9 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.horizontalLayout_9.addWidget(self.label_9)
        self.monitorCAM3 = QtWidgets.QCheckBox(self.layoutWidget)
        self.monitorCAM3.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.monitorCAM3.setText("")
        self.monitorCAM3.setObjectName("monitorCAM3")
        self.horizontalLayout_9.addWidget(self.monitorCAM3)
        self.verticalLayout_3.addLayout(self.horizontalLayout_9)
        self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
        self.label_10 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_10.setFont(font)
        self.label_10.setObjectName("label_10")
        self.horizontalLayout_10.addWidget(self.label_10)
        self.carCAM3 = QtWidgets.QCheckBox(self.layoutWidget)
        self.carCAM3.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.carCAM3.setText("")
        self.carCAM3.setObjectName("carCAM3")
        self.horizontalLayout_10.addWidget(self.carCAM3)
        self.verticalLayout_3.addLayout(self.horizontalLayout_10)
        self.horizontalLayout_11 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_11.setObjectName("horizontalLayout_11")
        self.label_11 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_11.setFont(font)
        self.label_11.setObjectName("label_11")
        self.horizontalLayout_11.addWidget(self.label_11)
        self.illegalCAM3 = QtWidgets.QCheckBox(self.layoutWidget)
        self.illegalCAM3.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.illegalCAM3.setText("")
        self.illegalCAM3.setObjectName("illegalCAM3")
        self.horizontalLayout_11.addWidget(self.illegalCAM3)
        self.verticalLayout_3.addLayout(self.horizontalLayout_11)
        self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.label_12 = QtWidgets.QLabel(self.layoutWidget)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")
        self.horizontalLayout_12.addWidget(self.label_12)
        self.personSearchingCAM3 = QtWidgets.QCheckBox(self.layoutWidget)
        self.personSearchingCAM3.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.personSearchingCAM3.setText("")
        self.personSearchingCAM3.setObjectName("personSearchingCAM3")
        self.horizontalLayout_12.addWidget(self.personSearchingCAM3)
        self.verticalLayout_3.addLayout(self.horizontalLayout_12)
        self.verticalLayout_6.addLayout(self.verticalLayout_3)
        self.layoutWidget1 = QtWidgets.QWidget(Form)
        self.layoutWidget1.setGeometry(QtCore.QRect(40, 20, 159, 116))
        self.layoutWidget1.setObjectName("layoutWidget1")
        self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.layoutWidget1)
        self.verticalLayout_7.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_7.setObjectName("verticalLayout_7")
        self.label_17 = QtWidgets.QLabel(self.layoutWidget1)
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_17.setFont(font)
        self.label_17.setAlignment(QtCore.Qt.AlignCenter)
        self.label_17.setObjectName("label_17")
        self.verticalLayout_7.addWidget(self.label_17)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(self.layoutWidget1)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.monitorCAM1 = QtWidgets.QCheckBox(self.layoutWidget1)
        self.monitorCAM1.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.monitorCAM1.setText("")
        self.monitorCAM1.setObjectName("monitorCAM1")
        self.horizontalLayout.addWidget(self.monitorCAM1)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label_2 = QtWidgets.QLabel(self.layoutWidget1)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_2.addWidget(self.label_2)
        self.carCAM1 = QtWidgets.QCheckBox(self.layoutWidget1)
        self.carCAM1.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.carCAM1.setText("")
        self.carCAM1.setObjectName("carCAM1")
        self.horizontalLayout_2.addWidget(self.carCAM1)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_3 = QtWidgets.QLabel(self.layoutWidget1)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout_3.addWidget(self.label_3)
        self.illegalCAM1 = QtWidgets.QCheckBox(self.layoutWidget1)
        self.illegalCAM1.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.illegalCAM1.setText("")
        self.illegalCAM1.setObjectName("illegalCAM1")
        self.horizontalLayout_3.addWidget(self.illegalCAM1)
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.label_4 = QtWidgets.QLabel(self.layoutWidget1)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_4.addWidget(self.label_4)
        self.personSearchingCAM1 = QtWidgets.QCheckBox(self.layoutWidget1)
        self.personSearchingCAM1.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.personSearchingCAM1.setText("")
        self.personSearchingCAM1.setObjectName("personSearchingCAM1")
        self.horizontalLayout_4.addWidget(self.personSearchingCAM1)
        self.verticalLayout.addLayout(self.horizontalLayout_4)
        self.verticalLayout_7.addLayout(self.verticalLayout)
        self.layoutWidget2 = QtWidgets.QWidget(Form)
        self.layoutWidget2.setGeometry(QtCore.QRect(40, 160, 159, 116))
        self.layoutWidget2.setObjectName("layoutWidget2")
        self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.layoutWidget2)
        self.verticalLayout_5.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_5.setObjectName("verticalLayout_5")
        self.label_18 = QtWidgets.QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_18.setFont(font)
        self.label_18.setAlignment(QtCore.Qt.AlignCenter)
        self.label_18.setObjectName("label_18")
        self.verticalLayout_5.addWidget(self.label_18)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.label_5 = QtWidgets.QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.horizontalLayout_5.addWidget(self.label_5)
        self.monitorCAM2 = QtWidgets.QCheckBox(self.layoutWidget2)
        self.monitorCAM2.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.monitorCAM2.setText("")
        self.monitorCAM2.setObjectName("monitorCAM2")
        self.horizontalLayout_5.addWidget(self.monitorCAM2)
        self.verticalLayout_2.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.label_6 = QtWidgets.QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_6.addWidget(self.label_6)
        self.carCAM2 = QtWidgets.QCheckBox(self.layoutWidget2)
        self.carCAM2.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.carCAM2.setText("")
        self.carCAM2.setObjectName("carCAM2")
        self.horizontalLayout_6.addWidget(self.carCAM2)
        self.verticalLayout_2.addLayout(self.horizontalLayout_6)
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.label_7 = QtWidgets.QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.horizontalLayout_7.addWidget(self.label_7)
        self.illegalCAM2 = QtWidgets.QCheckBox(self.layoutWidget2)
        self.illegalCAM2.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.illegalCAM2.setText("")
        self.illegalCAM2.setObjectName("illegalCAM2")
        self.horizontalLayout_7.addWidget(self.illegalCAM2)
        self.verticalLayout_2.addLayout(self.horizontalLayout_7)
        self.horizontalLayout_8 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.label_8 = QtWidgets.QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.horizontalLayout_8.addWidget(self.label_8)
        self.personSearchingCAM2 = QtWidgets.QCheckBox(self.layoutWidget2)
        self.personSearchingCAM2.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.personSearchingCAM2.setText("")
        self.personSearchingCAM2.setObjectName("personSearchingCAM2")
        self.horizontalLayout_8.addWidget(self.personSearchingCAM2)
        self.verticalLayout_2.addLayout(self.horizontalLayout_8)
        self.verticalLayout_5.addLayout(self.verticalLayout_2)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

        self.finishBtn.clicked.connect(self.openNewWindow)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.finishBtn.setText(_translate("Form", "FINISH"))
        self.label_19.setText(_translate("Form", "IP - CAM III"))
        self.label_9.setText(_translate("Form", "Monitor Prohibited area"))
        self.label_10.setText(_translate("Form", "Car protection"))
        self.label_11.setText(_translate("Form", "Illegal access action"))
        self.label_12.setText(_translate("Form", "Persion Searching"))
        self.label_17.setText(_translate("Form", "IP - CAM I"))
        self.label.setText(_translate("Form", "Monitor Prohibited area"))
        self.label_2.setText(_translate("Form", "Car protection"))
        self.label_3.setText(_translate("Form", "Illegal access action"))
        self.label_4.setText(_translate("Form", "Persion Searching"))
        self.label_18.setText(_translate("Form", "IP - CAM II"))
        self.label_5.setText(_translate("Form", "Monitor Prohibited area"))
        self.label_6.setText(_translate("Form", "Car protection"))
        self.label_7.setText(_translate("Form", "Illegal access action"))
        self.label_8.setText(_translate("Form", "Persion Searching"))
Beispiel #10
0
import sys
from PyQt4.QtGui import QApplication, QDialog
from MainUI import Ui_MainWindow

app = QApplication(sys.argv)
window = QDialog()
ui = Ui_MainWindow()
ui.setupUi(window)

window.show()
sys.exit(app.exec_())
from PyQt5.QtGui import *
from PyQt5.QtCore import Qt
from MainUI import  Ui_MainWindow
from VocaWindow import  Ui_self
from attribute_sheet_window import Ui_AttributeWindow
from predictive_parsing_window import Ui_MyPreAnalyseWindow
from dga_window import My_DGA_window
from AutoMata_Ui import Auto_Mata
from Op_First_Ui import Op_First
# from opfirst_window import My_Op_window

if __name__ == "__main__":

    app = QApplication(sys.argv)
    mainwindow = QMainWindow()
    Ui = Ui_MainWindow()
    # Ui = Ui_MyPreAnalyseWindow()
    Ui.setupUi(mainwindow)

    qw = Ui_self()
    Ui.Voca.triggered.connect(qw.insert_data)

    sw1 = Ui_AttributeWindow()
    Ui.Midwaycode.triggered.connect(sw1.insert_data_m)
    sw2 = Ui_AttributeWindow()

    # 预测分析界面
    pre_analyse_widget = QWidget()
    pre_analyse_window = Ui_MyPreAnalyseWindow()
    pre_analyse_window.setupUi(pre_analyse_widget)
    Ui.LL_1.triggered.connect(pre_analyse_widget.show)
Beispiel #12
0
class MainWindow:
    def __init__(self):
##Page 0 - Main Page side menu
        self.main_win = QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self.main_win)

        self.ui.stackedWidget.setCurrentWidget(self.ui.page_home)

        self.ui.button_home.clicked.connect(self.show_page_home)
        self.ui.button_drawingrenamer.clicked.connect(self.show_page_drawingrenamer)
        self.ui.button_standardssearch.clicked.connect(self.show_page_standardssearch)
        self.ui.button_imagetools.clicked.connect(self.show_page_image_tools)
        self.ui.button_drawingstamper.clicked.connect(self.show_page_drawing_stamper)
        self.welcome_text()

## Page 1 - Home Page
        self.ui.about_the_author.setOpenExternalLinks(True)

## Page 2 - Drawing Renamer ############################################################################
        self.ui.pushButton_enter_path.clicked.connect(self.enter_path)
        self.ui.pushButton_enter_beginningtext.clicked.connect(self.enter_beginningtext)
        self.ui.pushButton_enter_endtext.clicked.connect(self.enter_endtext)
        self.ui.pushButton_enter_replace_text.clicked.connect(self.enter_replace_text)
        self.ui.pushButton_enter_titleblock_search.clicked.connect(self.enter_titleblock_search)
        self.ui.pushButton_rename.clicked.connect(self.rename_file)
        self.ui.pushButton_enter_excel_export.clicked.connect(self.excel_list_export)
        self.ui.pushButton_enter_excel_export_2.clicked.connect(self.excel_list_import)


## Page 3 - Standards Search ############################################################################
        self.ui.pushButton_enter_path_standards.clicked.connect(self.enter_path_standards)
        self.ui.pushButton_enter_path_standards_2.clicked.connect(self.standards_search_bsi)
        self.ui.pushButton_enter_path_standards_3.clicked.connect(self.export_standards_to_text_file)

## Page 4 - Image Tools ############################################################################
        self.ui.pushButton_enter_path_imagetools.clicked.connect(self.enter_path_imagetools)
        self.ui.pushButton_compress_pictures.clicked.connect(self.compress_pictures)
        self.ui.pushButton_enter_path_imagetools_2.clicked.connect(self.enter_path_imagetools_logo)
        self.ui.pushButton_add_a_logo.clicked.connect(self.add_a_logo)

## Page 5 - Drawing Stamper ############################################################################
        self.ui.pushButton_enter_path_drawing_stamper.clicked.connect(self.enter_path_drawingstostamp)
        self.ui.pushButton_enter_path_drawing_stamper_2.clicked.connect(self.enter_path_logotostamp)
        self.ui.pushButton_drawing_stamp_go.clicked.connect(self.process_drawing_stamps)
        self.ui.pushButton_refresh_drawing_stamp.clicked.connect(self.refresh_stamp)

    def show(self):
        self.main_win.show()

    def show_page_home(self):
        self.ui.stackedWidget.setCurrentWidget(self.ui.page_home)
    def show_page_drawingrenamer(self):
        self.ui.stackedWidget.setCurrentWidget(self.ui.page_drawing_renamer)
    def show_page_standardssearch(self):
        self.ui.stackedWidget.setCurrentWidget(self.ui.page_standards_search)
    def show_page_image_tools(self):
        self.ui.stackedWidget.setCurrentWidget(self.ui.page_image_tools)
    def show_page_drawing_stamper(self):
        self.ui.stackedWidget.setCurrentWidget(self.ui.page_stamper)

    def welcome_text(self):
        global current_version_number
        self.ui.listWidget_home.clear()
        self.ui.listWidget_home.addItem("Welcome")
        self.ui.listWidget_home.addItem("Checking for updates...\n")
        try:
            version_number = Check_For_Updates()
            new_version_number = version_number.return_version_number()
            print(new_version_number)
            self.ui.listWidget_home.addItem(f"Version number is {current_version_number}, latest version is {new_version_number}")
            change_log = version_number.return_change_log()
            print(change_log)
            self.ui.listWidget_home.addItem(f"=================\n\nChange Log:\n\n{change_log}")
        except Exception as e:
            self.ui.listWidget_home.addItem(f"Unable to check for updates.\n {e}")



## Page 2 - Drawing Renamer #################################
    def enter_path(self):
        self.main_file_list = {}
        self.main_file_list.clear()
        self.file_path = QFileDialog.getExistingDirectory(None, "Open a folder", "C:\\", QFileDialog.ShowDirsOnly)
        file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
        self.main_file_list = file_details.return_list_of_files()
        self.ui.label_pathname.setText(self.file_path)
        self.ui.listWidget.clear()
        for file_name in self.main_file_list:
            self.ui.listWidget.addItem(file_name)
        return

    def enter_beginningtext(self):
        file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
        beginning_text = self.ui.lineEdit_enter_beginningtext.text()
        self.ui.listWidget.clear()
        self.main_file_list = file_details.enter_beginningtext(beginning_text)
        for key, values in self.main_file_list.items():
            text_to_print = f'{key} =====> {values}'
            self.ui.listWidget.addItem(text_to_print)
        return

    def enter_endtext(self):
        file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
        end_text = self.ui.lineEdit_enter_endtext.text()
        self.ui.listWidget.clear()
        self.main_file_list = file_details.enter_endtext(end_text)
        for key, values in self.main_file_list.items():
            text_to_print = f'{key} =====> {values}'
            self.ui.listWidget.addItem(text_to_print)
        return

    def enter_replace_text(self):
        file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
        replace_text_before = self.ui.lineEdit_enter_replace_text_before.text()
        replace_text_after = self.ui.lineEdit_enter_replace_text_after.text()
        self.ui.listWidget.clear()
        self.main_file_list = file_details.enter_replace_text(replace_text_before, replace_text_after)
        for key, values in self.main_file_list.items():
            text_to_print = f'{key} =====> {values}'
            self.ui.listWidget.addItem(text_to_print)
        return

    def enter_titleblock_search(self):
        file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
        sample_drawing_number = self.ui.lineEdit_enter_titleblock_search.text()
        self.ui.listWidget.clear()
        self.ui.listWidget.addItem("Please wait - this may take a while...")
        self.ui.listWidget.addItem("Do not close window until complete - new drawings will list as they are found\n")
        for item in self.main_file_list:
            try:
                file_extension = item.split(".")[-1]
                full_file_path = f'{self.file_path}/{item}'
                best_guess_drawing_number = file_details.enter_titleblock_search(full_file_path, sample_drawing_number)
                self.main_file_list[item] = f'{best_guess_drawing_number}.{file_extension}'
                self.ui.listWidget.addItem(best_guess_drawing_number)
                QtCore.QCoreApplication.processEvents()
            # If it all goes wrong leave filename as is
            except Exception as e:
                self.main_file_list[item] = item
                self.ui.listWidget.addItem(e)
        for key, values in self.main_file_list.items():
            text_to_print = f'{key} =====> {values}'
            self.ui.listWidget.addItem(text_to_print)
        return

    def rename_file(self):
        file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
        self.ui.listWidget.clear()
        self.ui.listWidget.addItem("Renaming files")
        temp_dict = {}
        try:
            for key, values in self.main_file_list.items():
                new_file_name = self.file_path + "/" + values
                old_file_name = self.file_path + "/" + key
                file_details.rename_file(old_file_name, new_file_name)
                self.ui.listWidget.addItem("Renaming files")
                text_to_print = f'{old_file_name} =====> {new_file_name}'
                self.ui.listWidget.addItem(text_to_print)
                temp_dict[values] = values
        except Exception as e:
            self.ui.listWidget.addItem(e)
        main_file_list = temp_dict
        self.ui.listWidget.addItem("Rename Completed Successfully")

    def excel_list_export(self):
        try:
            file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
            self.ui.listWidget.clear()
            self.ui.listWidget.addItem("Saving files to excel sheet...")
            file_details.excel_list_export()
            self.ui.listWidget.clear()
            self.ui.listWidget.addItem("Excel file called \'Drawing_list\' has been saved in the same folder as the drawings")
            self.ui.listWidget.addItem("\n\nAdd your new drawing numbers into Column C")
            self.ui.listWidget.addItem("\n\nOnce complete make sure the file is closed, then press \'2.Import\'")
        except Exception as e:
            self.ui.listWidget.clear()
            self.ui.listWidget.addItem("Something has gone wrong - see exception below:\n\n")
            self.ui.listWidget.addItem(e)

    def excel_list_import(self):
        try:
            file_details = Drawing_Renamer_Tools(self.file_path, self.main_file_list)
            self.ui.listWidget.clear()
            self.main_file_list = file_details.excel_list_import()
            self.ui.listWidget.addItem("Displaying Values:\n")
            for key, values in self.main_file_list.items():
                text_to_print = f'{key} =====> {values}'
                self.ui.listWidget.addItem(text_to_print)
        except Exception as e:
            self.ui.listWidget.clear()
            self.ui.listWidget.addItem("Something has gone wrong - see exception below:\n\n")
            self.ui.listWidget.addItem(e)

## Page 3 - Standards Search ############################################################################

    def enter_path_standards(self):
        self.ui.listWidget.clear()
        try:
            self.file_path_standards = QFileDialog.getOpenFileName(None, "Open a folder", "C:\\")
            self.file_path_standards = self.file_path_standards[0]
            print(self.file_path_standards)
            self.ui.label_pathname_standards.setText(self.file_path_standards)
            self.ui.listWidget_standards.clear()
            self.ui.listWidget_standards.addItem("File Loaded Successfully")
            self.ui.listWidget_standards.addItem("Searching for Standards - please wait...")
            QtCore.QCoreApplication.processEvents()
            file_details = Standards_Search_Tools(self.file_path_standards)
            full_text_from_document = file_details.extract_text_from_pdf()
            print(full_text_from_document)
            self.list_of_standards = file_details.text_search_for_standards(full_text_from_document)
            self.ui.listWidget_standards.clear()
            self.ui.listWidget_standards.addItem("Standards found within the document:\n")
            for item in self.list_of_standards:
                self.ui.listWidget_standards.addItem(item)
        except Exception as e:
            self.ui.listWidget_standards.addItem(e)

    def standards_search_bsi(self):
        file_details = Standards_Search_Tools(self.file_path_standards)
        self.ui.listWidget_standards.clear()
        self.ui.listWidget_standards.addItem("Searching the BSI website for status")
        QtCore.QCoreApplication.processEvents()
        self.document_to_write = ""
        for standard_name in self.list_of_standards:
            QtCore.QCoreApplication.processEvents()
            temp_document_to_write = ""
            returned_text = file_details.return_list_of_standards(standard_name)
            temp_document_to_write += "\n\n==============================================================================\n\n"
            temp_document_to_write += standard_name
            temp_document_to_write += "\n\n\n"
            for item in returned_text:
                temp_document_to_write += f"Name: {item[0]}\n"
                temp_document_to_write += f"Title: {item[1]}\n"
                temp_document_to_write += f"Publish Date: {item[3]} \n"
                temp_document_to_write += f"Status: {item[5]} \n\n"
            self.document_to_write += temp_document_to_write
            self.ui.listWidget_standards.addItem(f"Searching BSI for {standard_name}")
        QtCore.QCoreApplication.processEvents()
        self.ui.listWidget_standards.clear()
        self.ui.listWidget_standards.addItem(f"Search Complete\n\n")
        self.ui.listWidget_standards.addItem(self.document_to_write)

    def export_standards_to_text_file(self):
        self.ui.listWidget_standards.clear()
        self.ui.listWidget_standards.addItem("Writing standards to a file...")
        try:
            file_details = Standards_Search_Tools(self.file_path_standards)
            file_details.write_to_file(self.document_to_write)
            self.ui.listWidget_standards.addItem("Writing complete. The file will be in the same directory as the source file")
        except Exception as e:
            self.ui.listWidget_standards.addItem(e)

## Page 4 - Image Tools ############################################################################
    def enter_path_imagetools(self):
        self.file_path_imagetools = QFileDialog.getExistingDirectory(None, "Open a folder", "C:\\", QFileDialog.ShowDirsOnly)
        file_details = Image_Tools(self.file_path_imagetools)
        self.list_of_images = file_details.return_list_of_files()
        self.ui.label_pathname_imagetools.setText(self.file_path_imagetools)
        self.ui.listWidget_image_tools.clear()
        self.ui.listWidget_image_tools.addItem("List of files in folder:\n")
        for image in self.list_of_images:
            self.ui.listWidget_image_tools.addItem(image)
        return


    def compress_pictures(self):
        compression_quality = self.ui.lineEdit_image_tools_quality.text()
        file_details = Image_Tools(self.file_path_imagetools)
        file_details.setup_directories()
        self.ui.listWidget_image_tools.clear()
        for image in self.list_of_images:
            try:
                file_details.compress_pictures(image, compression_quality)
                self.ui.listWidget_image_tools.addItem(f'Converting {image}')
                QtCore.QCoreApplication.processEvents()
            except Exception as e:
                self.ui.listWidget_image_tools.addItem(f'Unable to convert {image} - {e}')
        self.ui.listWidget_image_tools.addItem("\nProgramme Complete")


    def enter_path_imagetools_logo(self):
        self.logo_file_path = QFileDialog.getOpenFileName(None, "Open a folder", "C:\\")
        self.logo_file_path = self.logo_file_path[0]
        self.ui.label_pathname_imagetools_3.setText(self.file_path_imagetools)
        self.ui.listWidget_image_tools.clear()
        self.ui.listWidget_image_tools.addItem("Press \'2. Add a logo to the image\' to start the programme")


    def add_a_logo(self):
        try:
            self.ui.listWidget_image_tools.clear()
            file_details = Image_Tools(self.file_path_imagetools)
            for image in self.list_of_images:
                try:
                    print(self.file_path_imagetools)
                    print(image)
                    print(self.logo_file_path)
                    file_details.add_a_logo(image, self.logo_file_path)
                    self.ui.listWidget_image_tools.addItem(f'Adding a logo to {image}')
                    QtCore.QCoreApplication.processEvents()
                except Exception as e:
                    self.ui.listWidget_image_tools.addItem(f'Unable to process {image} - {e}')
            self.ui.listWidget_image_tools.addItem("\nProgramme Complete")
        except Exception as e:
            self.ui.listWidget_image_tools.clear()
            self.ui.listWidget_image_tools.addItem("Error - have you loaded the folder?")
            self.ui.listWidget_image_tools.addItem(str(e))


## Page 5 - Drawing Stamper ############################################################################
    def enter_path_drawingstostamp(self):
        self.ui.listWidget_drawing_stamper.clear()
        self.file_path_drawing_to_stamp = QFileDialog.getExistingDirectory(None, "Open a folder", "C:\\", QFileDialog.ShowDirsOnly)
        file_details = Image_Tools(self.file_path_drawing_to_stamp)
        self.list_of_drawingstostamp= file_details.return_list_of_files()
        for drawing in self.list_of_drawingstostamp:
            self.ui.listWidget_drawing_stamper.addItem(drawing)
        return

    def enter_path_logotostamp(self):
        try:
            self.file_path_logo_to_stamp = QFileDialog.getOpenFileName(None, "Open a file", "C:\\")
            disclaimer_words = self.ui.textEdit_drawing_stamper_disclaimer.toPlainText()
            logo_details = Image_Tools(self.file_path_logo_to_stamp)
            returned_stamp = logo_details.add_logo_to_drawing_stamp(self.file_path_logo_to_stamp, disclaimer_words, self.file_path_drawing_to_stamp)
            self.ui.listWidget_drawing_stamper.clear()
            self.ui.listWidget_drawing_stamper.addItem("Preview of drawing stamp:")
            myPixmap = QtGui.QPixmap.fromImage(returned_stamp[0])
            myScaledPixmap = myPixmap.scaled(self.ui.label_show_drawing_stamp.size(), QtCore.Qt.KeepAspectRatio)
            self.ui.label_show_drawing_stamp.setPixmap(myScaledPixmap)
            self.processed_file_stamp = returned_stamp[1]
        except Exception as e:
            self.ui.listWidget_drawing_stamper.clear()
            self.ui.listWidget_drawing_stamper.addItem("You must specify a file")
        return

    def refresh_stamp(self):
        disclaimer_words = self.ui.textEdit_drawing_stamper_disclaimer.toPlainText()
        logo_details = Image_Tools(self.file_path_logo_to_stamp)
        returned_stamp = logo_details.add_logo_to_drawing_stamp(self.file_path_logo_to_stamp, disclaimer_words, self.file_path_drawing_to_stamp)
        self.ui.listWidget_drawing_stamper.clear()
        self.ui.listWidget_drawing_stamper.addItem("Preview of drawing stamp:")
        myPixmap = QtGui.QPixmap.fromImage(returned_stamp[0])
        myScaledPixmap = myPixmap.scaled(self.ui.label_show_drawing_stamp.size(), QtCore.Qt.KeepAspectRatio)
        self.ui.label_show_drawing_stamp.setPixmap(myScaledPixmap)
        self.processed_file_stamp = returned_stamp[1]
        return

    def process_drawing_stamps(self):
        try:
            os.mkdir(f'{self.file_path_drawing_to_stamp}/Stamped')
        except Exception as e:
            print(e)
            self.ui.listWidget_drawing_stamper.clear()
            self.ui.listWidget_drawing_stamper.addItem("Unable to create directory - error code below:\n")
            self.ui.listWidget_drawing_stamper.addItem(str(e))

        today = date.today()
        today_date = today.strftime("%d/%m/%y")

        drawing_status = ""
        if self.ui.radioButton_status_a.isChecked() == True:
            drawing_status = "A"
        elif self.ui.radioButton_status_b.isChecked() == True:
            drawing_status = "B"
        elif self.ui.radioButton_status_c.isChecked() == True:
            drawing_status = "C"
        else:
            drawing_status = "Unknown"

        self.ui.listWidget_drawing_stamper.clear()
        self.ui.listWidget_drawing_stamper.addItem("Adding annotations:\n")
        for drawing in self.list_of_drawingstostamp:
            try:
                full_drawing_path = self.file_path_drawing_to_stamp + '/' + drawing
                self.ui.listWidget_drawing_stamper.addItem(drawing)
                QtCore.QCoreApplication.processEvents()
                full_path_drawing_stamp = self.file_path_drawing_to_stamp + "/Blank_Stamp.png"
                a = PdfAnnotator(full_drawing_path)
                a.add_annotation(
                    'image',
                    Location(x1=50, y1=50, x2=400, y2=400, page=0),
                    Appearance(image=full_path_drawing_stamp)
                )
            except Exception as e:
                print("Unable to add image")

            try:
                a.add_annotation(
                    'text',
                    Location(x1=120, y1=320, x2=300, y2=332, page=0),
                    Appearance(stroke_color=(1, 1, 1), stroke_width=5, content=self.ui.lineEdit_drawing_stamper_jobnumber.text(), fill=(0.705, 0.094, 0.125, 1))
                ) #https://doc.instantreality.org/tools/color_calculator/
                a.add_annotation(
                    'text',
                    Location(x1=130, y1=305, x2=300, y2=317, page=0),
                    Appearance(stroke_color=(1, 1, 1), stroke_width=5, content=self.ui.lineEdit_drawing_stamper_date.text(), fill=(0.705, 0.094, 0.125, 1))
                )
                a.add_annotation(
                    'text',
                    Location(x1=75, y1=276, x2=300, y2=288, page=0),
                    Appearance(stroke_color=(1, 1, 1), stroke_width=5, content=self.ui.lineEdit_drawing_stamper_reviewerinitials.text(), fill=(0.705, 0.094, 0.125, 1))
                )
                a.add_annotation(
                    'text',
                    Location(x1=200, y1=276, x2=320, y2=288, page=0),
                    Appearance(stroke_color=(1, 1, 1), stroke_width=5, content=f"Status {drawing_status}", fill=(0.705, 0.094, 0.125, 1))
                )
                a.add_annotation(
                    'text',
                    Location(x1=330, y1=276, x2=400, y2=288, page=0),
                    Appearance(stroke_color=(1, 1, 1), stroke_width=5, content=today_date, fill=(0.705, 0.094, 0.125, 1))
                )

                # Put an X in the box noting the status
                if drawing_status == "A":
                    a.add_annotation(
                        'text',
                        Location(x1=117, y1=203, x2=300, y2=215, page=0),
                        Appearance(stroke_color=(1, 1, 1), stroke_width=5,
                                   content="X", fill=(0.705, 0.094, 0.125, 1))
                    )
                if drawing_status == "B":
                    a.add_annotation(
                        'text',
                        Location(x1=117, y1=189, x2=300, y2=201, page=0),
                        Appearance(stroke_color=(1, 1, 1), stroke_width=5,
                                   content="X", fill=(0.705, 0.094, 0.125, 1))
                    )
                if drawing_status == "C":
                    a.add_annotation(
                        'text',
                        Location(x1=117, y1=174, x2=300, y2=186, page=0),
                        Appearance(stroke_color=(1, 1, 1), stroke_width=5,
                                   content="X", fill=(0.705, 0.094, 0.125, 1))
                    )

            except Exception as e:
                print(e)
                self.ui.listWidget_drawing_stamper.addItem("Unable to add annotation - error code below:\n")
                self.ui.listWidget_drawing_stamper.addItem(str(e))
                self.ui.listWidget_drawing_stamper.addItem("Check - is this file a PDF?")


            try:
                #Write the resultant file
                a.write(f'{self.file_path_drawing_to_stamp}/Stamped/{drawing}')
            except Exception as e:
                print(e)
                self.ui.listWidget_drawing_stamper.addItem("Unable to save file - error code below:\n")
                self.ui.listWidget_drawing_stamper.addItem(str(e))
                self.ui.listWidget_drawing_stamper.addItem("Check - do these files already exist?")
                return

        #Display success message
        self.ui.listWidget_drawing_stamper.clear()
        self.ui.listWidget_drawing_stamper.addItem("Stamps added successfully!")

        return
Beispiel #13
0
 def __init__(self):
     super(MainUIObj, self).__init__()
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     self.model = load_model("./models/cnn")
Beispiel #14
0
from Combat_Manager import Combat_manager
from Database_loader import Database_Loader
from MainUI import Ui_MainWindow
from PyQt5 import QtWidgets
import sys

app = QtWidgets.QApplication(sys.argv)
drv = Ui_MainWindow(app)
db = Database_Loader()
cm = Combat_manager(drv, db)