Esempio n. 1
0
 def __init_tables(self, num):
     for i in xrange(num):
         table_widget = TableWidget()
         table_widget.setObjectName(u"table%d" % i)
         table_widget.setStyleSheet(u"QWidget#table%d{background-image: url(:/img/tablen.bmp);}" % i)
         self.gridLayout.addWidget(table_widget, i / 4, i % 4, 1, 1)
         table_widget.left_btn.clicked.connect(self.mapper.map)
         table_widget.right_btn.clicked.connect(self.mapper.map)
         self.mapper.setMapping(table_widget.left_btn, i * 100 + 0)
         self.mapper.setMapping(table_widget.right_btn, i * 100 + 1)
Esempio n. 2
0
    def __init__(self):
        super().__init__()

        self.title = "Glorified Rectangle Creator"
        self.setWindowTitle(self.title)

        self.data_dir = ""

        self.left = 0
        self.top = 0
        self.width = 1024
        self.height = 768
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.tab_panel = TableWidget(self)

        file_list = FileListWidget()
        self.tab_panel.tab1.layout.addWidget(file_list)

        class_list = ClassListWidget()
        self.tab_panel.tab1.layout.addWidget(class_list)

        self.image_panel = ImageWidget(self)
        self.image_panel_controls = ImageControlsWidget()
        self.tab_panel.tab2.layout.addWidget(self.image_panel)
        self.tab_panel.tab2.layout.addWidget(self.image_panel_controls)

        self.setCentralWidget(self.tab_panel)

        self.center()

        self.show()
Esempio n. 3
0
 def new_file(self):
     self.hex_data_manager = HexDataManager("")
     table_widget = TableWidget(self.hex_data_manager)
     self.current_table_widget.close()
     self.box_l.replaceWidget(self.current_table_widget,
                              table_widget)
     self.current_table_widget = table_widget
     self.controller_widget.set_table_widget(table_widget)
     self.controller_widget.update_current_page_label()
Esempio n. 4
0
 def __init__(self):
     super().__init__()
     self.hex_data_manager = HexDataManager("")
     self.current_table_widget: TableWidget = TableWidget(
         self.hex_data_manager)
     self.controller_widget = ControllerWidget(self.current_table_widget,
                                               self)
     self.box_l = QHBoxLayout()
     self.box_l.addWidget(self.current_table_widget)
     self.box_l.addWidget(self.controller_widget)
     self.setLayout(self.box_l)
Esempio n. 5
0
    def open_file(self):

        file_name, _ = QFileDialog.getOpenFileName()
        if os.path.isfile(file_name):
            self.hex_data_manager = HexDataManager(file_name)
            table_widget = TableWidget(self.hex_data_manager)
            self.current_table_widget.close()
            self.box_l.replaceWidget(self.current_table_widget,
                                     table_widget)
            self.current_table_widget = table_widget
            self.controller_widget.set_table_widget(table_widget)
            self.controller_widget.update_current_page_label()
Esempio n. 6
0
 def __init_tables(self, num):
     for i in xrange(num):
         table_widget = TableWidget()
         table_widget.setObjectName(u"table%d" % i)
         table_widget.setStyleSheet(
             u"QWidget#table%d{background-image: url(:/img/tablen.bmp);}" %
             i)
         self.gridLayout.addWidget(table_widget, i / 4, i % 4, 1, 1)
         table_widget.left_btn.clicked.connect(self.mapper.map)
         table_widget.right_btn.clicked.connect(self.mapper.map)
         self.mapper.setMapping(table_widget.left_btn, i * 100 + 0)
         self.mapper.setMapping(table_widget.right_btn, i * 100 + 1)
Esempio n. 7
0
    def init_main_screen(self):
        """
            Инициализатор главного экрана игры
        """
        user_cards_scroll = UserCardListWidget()
        table_widget = TableWidget(callback=self.select_row)
        panel_widget = PanelWidget(start_game=self.start_tour,
                                   choose_card=self.choose_card)
        arena_widget = ArenaWidget()

        self.user_cards_scroll = user_cards_scroll
        self.table_widget = table_widget
        self.panel_widget = panel_widget
        self.arena_widget = arena_widget

        width = self.frameGeometry().width()
        height = self.frameGeometry().height()

        #user_cards_scroll.setMinimumWidth(self.width)  #!!!
        user_cards_scroll.setMaximumHeight(CardWidget.STANDARD_HEIGHT + 50)
        table_widget.setMinimumWidth(0.42 * self.width)
        table_widget.setMinimumHeight(self.height)  #!!!
        panel_widget.setMinimumWidth(0.2 * self.width)
        panel_widget.setMaximumWidth(0.2 * self.width)
        #user_cards_scroll.setMaximumWidth(self.width)
        #width = mainWindow.frameGeometry().width()

        selected_number_widget = QLineEdit()
        selected_number_widget.setPlaceholderText('Номер для удаления')

        h_layout = QHBoxLayout()
        #h_layout.addWidget(table_widget)  #!!!
        h_layout.addWidget(arena_widget)
        h_layout.addWidget(panel_widget)

        v_layout = QVBoxLayout()
        v_layout.addLayout(h_layout)
        v_layout.addWidget(user_cards_scroll)

        layout = QHBoxLayout()  #!!!
        layout.addWidget(table_widget)  #!!!
        layout.addLayout(v_layout)  #!!!

        widget = QWidget()
        widget.setLayout(layout)  #!!!
        #widget.setLayout(v_layout)  #!!!

        return widget
Esempio n. 8
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(1024, 736)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout_8 = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8"))
        self.splitter_2 = QtGui.QSplitter(self.centralwidget)
        self.splitter_2.setOrientation(QtCore.Qt.Vertical)
        self.splitter_2.setObjectName(_fromUtf8("splitter_2"))
        self.splitter = QtGui.QSplitter(self.splitter_2)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.logWidget = LogWidget(self.splitter)
        self.logWidget.setObjectName(_fromUtf8("logWidget"))
        self.tabWidget = QtGui.QTabWidget(self.splitter)
        self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName(_fromUtf8("tab_2"))
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.tab_2)
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.paramView = PropertyExplorer(self.tab_2)
        self.paramView.setObjectName(_fromUtf8("paramView"))
        self.verticalLayout_3.addWidget(self.paramView)
        self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
        self.tab_3 = QtGui.QWidget()
        self.tab_3.setObjectName(_fromUtf8("tab_3"))
        self.verticalLayout_4 = QtGui.QVBoxLayout(self.tab_3)
        self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
        self.tabWidget2 = QtGui.QTabWidget(self.tab_3)
        self.tabWidget2.setObjectName(_fromUtf8("tabWidget2"))
        self.tab_5 = QtGui.QWidget()
        self.tab_5.setObjectName(_fromUtf8("tab_5"))
        self.verticalLayout_5 = QtGui.QVBoxLayout(self.tab_5)
        self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5"))
        self.dataView1 = PropertyExplorer(self.tab_5)
        self.dataView1.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.dataView1.setObjectName(_fromUtf8("dataView1"))
        self.verticalLayout_5.addWidget(self.dataView1)
        self.tabWidget2.addTab(self.tab_5, _fromUtf8(""))
        self.tab_6 = QtGui.QWidget()
        self.tab_6.setObjectName(_fromUtf8("tab_6"))
        self.verticalLayout_6 = QtGui.QVBoxLayout(self.tab_6)
        self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6"))
        self.dataView2 = PropertyExplorer(self.tab_6)
        self.dataView2.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.dataView2.setObjectName(_fromUtf8("dataView2"))
        self.verticalLayout_6.addWidget(self.dataView2)
        self.tabWidget2.addTab(self.tab_6, _fromUtf8(""))
        self.tab_7 = QtGui.QWidget()
        self.tab_7.setObjectName(_fromUtf8("tab_7"))
        self.verticalLayout_7 = QtGui.QVBoxLayout(self.tab_7)
        self.verticalLayout_7.setObjectName(_fromUtf8("verticalLayout_7"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.label_4 = QtGui.QLabel(self.tab_7)
        self.label_4.setMinimumSize(QtCore.QSize(120, 0))
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.horizontalLayout.addWidget(self.label_4)
        self.spbAddr = QtGui.QSpinBox(self.tab_7)
        self.spbAddr.setMinimum(1)
        self.spbAddr.setMaximum(65000)
        self.spbAddr.setProperty("value", 11)
        self.spbAddr.setObjectName(_fromUtf8("spbAddr"))
        self.horizontalLayout.addWidget(self.spbAddr)
        self.horizontalLayout.setStretch(1, 1)
        self.verticalLayout_7.addLayout(self.horizontalLayout)
        self.groupBox = QtGui.QGroupBox(self.tab_7)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.gridLayout = QtGui.QGridLayout(self.groupBox)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.label = QtGui.QLabel(self.groupBox)
        self.label.setMinimumSize(QtCore.QSize(110, 0))
        self.label.setObjectName(_fromUtf8("label"))
        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
        self.leGroupNum = QtGui.QLineEdit(self.groupBox)
        self.leGroupNum.setEnabled(False)
        self.leGroupNum.setObjectName(_fromUtf8("leGroupNum"))
        self.gridLayout.addWidget(self.leGroupNum, 0, 1, 1, 1)
        self.label_2 = QtGui.QLabel(self.groupBox)
        self.label_2.setMinimumSize(QtCore.QSize(110, 0))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.leTrNum = QtGui.QLineEdit(self.groupBox)
        self.leTrNum.setEnabled(False)
        self.leTrNum.setObjectName(_fromUtf8("leTrNum"))
        self.gridLayout.addWidget(self.leTrNum, 1, 1, 1, 1)
        self.verticalLayout_7.addWidget(self.groupBox)
        self.groupBox_2 = QtGui.QGroupBox(self.tab_7)
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_2)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.label_8 = QtGui.QLabel(self.groupBox_2)
        self.label_8.setMinimumSize(QtCore.QSize(110, 0))
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.gridLayout_2.addWidget(self.label_8, 0, 0, 1, 1)
        self.leGroupNum_2 = QtGui.QLineEdit(self.groupBox_2)
        self.leGroupNum_2.setEnabled(False)
        self.leGroupNum_2.setObjectName(_fromUtf8("leGroupNum_2"))
        self.gridLayout_2.addWidget(self.leGroupNum_2, 0, 1, 1, 1)
        self.label_7 = QtGui.QLabel(self.groupBox_2)
        self.label_7.setMinimumSize(QtCore.QSize(110, 0))
        self.label_7.setObjectName(_fromUtf8("label_7"))
        self.gridLayout_2.addWidget(self.label_7, 1, 0, 1, 1)
        self.leTrNum_2 = QtGui.QLineEdit(self.groupBox_2)
        self.leTrNum_2.setEnabled(False)
        self.leTrNum_2.setObjectName(_fromUtf8("leTrNum_2"))
        self.gridLayout_2.addWidget(self.leTrNum_2, 1, 1, 1, 1)
        self.verticalLayout_7.addWidget(self.groupBox_2)
        self.label_3 = QtGui.QLabel(self.tab_7)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.verticalLayout_7.addWidget(self.label_3)
        self.twRec = QtGui.QTableWidget(self.tab_7)
        self.twRec.setEnabled(True)
        self.twRec.setObjectName(_fromUtf8("twRec"))
        self.twRec.setColumnCount(4)
        self.twRec.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(3, item)
        self.twRec.horizontalHeader().setStretchLastSection(True)
        self.twRec.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_7.addWidget(self.twRec)
        self.tabWidget2.addTab(self.tab_7, _fromUtf8(""))
        self.verticalLayout_4.addWidget(self.tabWidget2)
        self.tabWidget.addTab(self.tab_3, _fromUtf8(""))
        self.tab = QtGui.QWidget()
        self.tab.setObjectName(_fromUtf8("tab"))
        self.verticalLayout_13 = QtGui.QVBoxLayout(self.tab)
        self.verticalLayout_13.setObjectName(_fromUtf8("verticalLayout_13"))
        self.tabWidget_3 = QtGui.QTabWidget(self.tab)
        self.tabWidget_3.setObjectName(_fromUtf8("tabWidget_3"))
        self.tab_10 = QtGui.QWidget()
        self.tab_10.setObjectName(_fromUtf8("tab_10"))
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.tab_10)
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
        self.unitView = PropertyExplorer(self.tab_10)
        self.unitView.setObjectName(_fromUtf8("unitView"))
        self.verticalLayout_2.addWidget(self.unitView)
        self.tabWidget_3.addTab(self.tab_10, _fromUtf8(""))
        self.tab_11 = QtGui.QWidget()
        self.tab_11.setObjectName(_fromUtf8("tab_11"))
        self.verticalLayout_11 = QtGui.QVBoxLayout(self.tab_11)
        self.verticalLayout_11.setObjectName(_fromUtf8("verticalLayout_11"))
        self.cableView = PropertyExplorer(self.tab_11)
        self.cableView.setObjectName(_fromUtf8("cableView"))
        self.verticalLayout_11.addWidget(self.cableView)
        self.tabWidget_3.addTab(self.tab_11, _fromUtf8(""))
        self.tab_12 = QtGui.QWidget()
        self.tab_12.setObjectName(_fromUtf8("tab_12"))
        self.verticalLayout_15 = QtGui.QVBoxLayout(self.tab_12)
        self.verticalLayout_15.setObjectName(_fromUtf8("verticalLayout_15"))
        self.splitter_3 = QtGui.QSplitter(self.tab_12)
        self.splitter_3.setOrientation(QtCore.Qt.Vertical)
        self.splitter_3.setObjectName(_fromUtf8("splitter_3"))
        self.widget = QtGui.QWidget(self.splitter_3)
        self.widget.setObjectName(_fromUtf8("widget"))
        self.verticalLayout_12 = QtGui.QVBoxLayout(self.widget)
        self.verticalLayout_12.setMargin(0)
        self.verticalLayout_12.setObjectName(_fromUtf8("verticalLayout_12"))
        self.label_5 = QtGui.QLabel(self.widget)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.verticalLayout_12.addWidget(self.label_5)
        self.twFailures = TableWidget(self.widget)
        self.twFailures.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twFailures.setObjectName(_fromUtf8("twFailures"))
        self.twFailures.setColumnCount(5)
        self.twFailures.setRowCount(9)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(6, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(7, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(8, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(4, item)
        self.twFailures.horizontalHeader().setStretchLastSection(True)
        self.twFailures.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_12.addWidget(self.twFailures)
        self.widget_2 = QtGui.QWidget(self.splitter_3)
        self.widget_2.setObjectName(_fromUtf8("widget_2"))
        self.verticalLayout_14 = QtGui.QVBoxLayout(self.widget_2)
        self.verticalLayout_14.setMargin(0)
        self.verticalLayout_14.setObjectName(_fromUtf8("verticalLayout_14"))
        self.label_6 = QtGui.QLabel(self.widget_2)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.verticalLayout_14.addWidget(self.label_6)
        self.twFailures_2 = QtGui.QTableWidget(self.widget_2)
        self.twFailures_2.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twFailures_2.setObjectName(_fromUtf8("twFailures_2"))
        self.twFailures_2.setColumnCount(7)
        self.twFailures_2.setRowCount(5)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(6, item)
        self.twFailures_2.horizontalHeader().setStretchLastSection(True)
        self.twFailures_2.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_14.addWidget(self.twFailures_2)
        self.verticalLayout_15.addWidget(self.splitter_3)
        self.tabWidget_3.addTab(self.tab_12, _fromUtf8(""))
        self.verticalLayout_13.addWidget(self.tabWidget_3)
        self.tabWidget.addTab(self.tab, _fromUtf8(""))
        self.groupBox_3 = QtGui.QGroupBox(self.splitter_2)
        self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
        self.verticalLayout = QtGui.QVBoxLayout(self.groupBox_3)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.tabWidget_2 = QtGui.QTabWidget(self.groupBox_3)
        self.tabWidget_2.setObjectName(_fromUtf8("tabWidget_2"))
        self.tab_4 = QtGui.QWidget()
        self.tab_4.setObjectName(_fromUtf8("tab_4"))
        self.verticalLayout_9 = QtGui.QVBoxLayout(self.tab_4)
        self.verticalLayout_9.setObjectName(_fromUtf8("verticalLayout_9"))
        self.twAbon = QtGui.QTableWidget(self.tab_4)
        self.twAbon.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.twAbon.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twAbon.setObjectName(_fromUtf8("twAbon"))
        self.twAbon.setColumnCount(9)
        self.twAbon.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(6, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(7, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(8, item)
        self.twAbon.horizontalHeader().setDefaultSectionSize(75)
        self.twAbon.horizontalHeader().setStretchLastSection(True)
        self.twAbon.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_9.addWidget(self.twAbon)
        self.tabWidget_2.addTab(self.tab_4, _fromUtf8(""))
        self.tab_8 = QtGui.QWidget()
        self.tab_8.setObjectName(_fromUtf8("tab_8"))
        self.verticalLayout_10 = QtGui.QVBoxLayout(self.tab_8)
        self.verticalLayout_10.setObjectName(_fromUtf8("verticalLayout_10"))
        self.twRegl = QtGui.QTableWidget(self.tab_8)
        self.twRegl.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.twRegl.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twRegl.setObjectName(_fromUtf8("twRegl"))
        self.twRegl.setColumnCount(18)
        self.twRegl.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(6, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(7, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(8, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(9, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(10, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(11, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(12, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(13, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(14, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(15, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(16, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(17, item)
        self.twRegl.horizontalHeader().setDefaultSectionSize(50)
        self.twRegl.horizontalHeader().setMinimumSectionSize(30)
        self.twRegl.horizontalHeader().setStretchLastSection(True)
        self.twRegl.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_10.addWidget(self.twRegl)
        self.tabWidget_2.addTab(self.tab_8, _fromUtf8(""))
        self.verticalLayout.addWidget(self.tabWidget_2)
        self.verticalLayout_8.addWidget(self.splitter_2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1024, 26))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menu = QtGui.QMenu(self.menubar)
        self.menu.setObjectName(_fromUtf8("menu"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.actionRequestConnect = QtGui.QAction(MainWindow)
        self.actionRequestConnect.setObjectName(_fromUtf8("actionRequestConnect"))
        self.actionConnectGeneral = QtGui.QAction(MainWindow)
        self.actionConnectGeneral.setObjectName(_fromUtf8("actionConnectGeneral"))
        self.actionConnectReserve = QtGui.QAction(MainWindow)
        self.actionConnectReserve.setObjectName(_fromUtf8("actionConnectReserve"))
        self.actionQuit = QtGui.QAction(MainWindow)
        self.actionQuit.setObjectName(_fromUtf8("actionQuit"))
        self.actionDisconnect = QtGui.QAction(MainWindow)
        self.actionDisconnect.setObjectName(_fromUtf8("actionDisconnect"))
        self.menu.addAction(self.actionRequestConnect)
        self.menu.addSeparator()
        self.menu.addAction(self.actionConnectGeneral)
        self.menu.addAction(self.actionConnectReserve)
        self.menu.addAction(self.actionDisconnect)
        self.menu.addSeparator()
        self.menu.addAction(self.actionQuit)
        self.menubar.addAction(self.menu.menuAction())

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        self.tabWidget2.setCurrentIndex(0)
        self.tabWidget_3.setCurrentIndex(0)
        self.tabWidget_2.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Esempio n. 9
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(1024, 736)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout_8 = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8"))
        self.splitter_2 = QtGui.QSplitter(self.centralwidget)
        self.splitter_2.setOrientation(QtCore.Qt.Vertical)
        self.splitter_2.setObjectName(_fromUtf8("splitter_2"))
        self.splitter = QtGui.QSplitter(self.splitter_2)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.logWidget = LogWidget(self.splitter)
        self.logWidget.setObjectName(_fromUtf8("logWidget"))
        self.tabWidget = QtGui.QTabWidget(self.splitter)
        self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName(_fromUtf8("tab_2"))
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.tab_2)
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.paramView = PropertyExplorer(self.tab_2)
        self.paramView.setObjectName(_fromUtf8("paramView"))
        self.verticalLayout_3.addWidget(self.paramView)
        self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
        self.tab_3 = QtGui.QWidget()
        self.tab_3.setObjectName(_fromUtf8("tab_3"))
        self.verticalLayout_4 = QtGui.QVBoxLayout(self.tab_3)
        self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
        self.tabWidget2 = QtGui.QTabWidget(self.tab_3)
        self.tabWidget2.setObjectName(_fromUtf8("tabWidget2"))
        self.tab_5 = QtGui.QWidget()
        self.tab_5.setObjectName(_fromUtf8("tab_5"))
        self.verticalLayout_5 = QtGui.QVBoxLayout(self.tab_5)
        self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5"))
        self.dataView1 = PropertyExplorer(self.tab_5)
        self.dataView1.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.dataView1.setObjectName(_fromUtf8("dataView1"))
        self.verticalLayout_5.addWidget(self.dataView1)
        self.tabWidget2.addTab(self.tab_5, _fromUtf8(""))
        self.tab_6 = QtGui.QWidget()
        self.tab_6.setObjectName(_fromUtf8("tab_6"))
        self.verticalLayout_6 = QtGui.QVBoxLayout(self.tab_6)
        self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6"))
        self.dataView2 = PropertyExplorer(self.tab_6)
        self.dataView2.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.dataView2.setObjectName(_fromUtf8("dataView2"))
        self.verticalLayout_6.addWidget(self.dataView2)
        self.tabWidget2.addTab(self.tab_6, _fromUtf8(""))
        self.tab_7 = QtGui.QWidget()
        self.tab_7.setObjectName(_fromUtf8("tab_7"))
        self.verticalLayout_7 = QtGui.QVBoxLayout(self.tab_7)
        self.verticalLayout_7.setObjectName(_fromUtf8("verticalLayout_7"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.label_4 = QtGui.QLabel(self.tab_7)
        self.label_4.setMinimumSize(QtCore.QSize(120, 0))
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.horizontalLayout.addWidget(self.label_4)
        self.spbAddr = QtGui.QSpinBox(self.tab_7)
        self.spbAddr.setMinimum(1)
        self.spbAddr.setMaximum(65000)
        self.spbAddr.setProperty("value", 11)
        self.spbAddr.setObjectName(_fromUtf8("spbAddr"))
        self.horizontalLayout.addWidget(self.spbAddr)
        self.horizontalLayout.setStretch(1, 1)
        self.verticalLayout_7.addLayout(self.horizontalLayout)
        self.groupBox = QtGui.QGroupBox(self.tab_7)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.gridLayout = QtGui.QGridLayout(self.groupBox)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.label = QtGui.QLabel(self.groupBox)
        self.label.setMinimumSize(QtCore.QSize(110, 0))
        self.label.setObjectName(_fromUtf8("label"))
        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
        self.leGroupNum = QtGui.QLineEdit(self.groupBox)
        self.leGroupNum.setEnabled(False)
        self.leGroupNum.setObjectName(_fromUtf8("leGroupNum"))
        self.gridLayout.addWidget(self.leGroupNum, 0, 1, 1, 1)
        self.label_2 = QtGui.QLabel(self.groupBox)
        self.label_2.setMinimumSize(QtCore.QSize(110, 0))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.leTrNum = QtGui.QLineEdit(self.groupBox)
        self.leTrNum.setEnabled(False)
        self.leTrNum.setObjectName(_fromUtf8("leTrNum"))
        self.gridLayout.addWidget(self.leTrNum, 1, 1, 1, 1)
        self.verticalLayout_7.addWidget(self.groupBox)
        self.groupBox_2 = QtGui.QGroupBox(self.tab_7)
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_2)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.label_8 = QtGui.QLabel(self.groupBox_2)
        self.label_8.setMinimumSize(QtCore.QSize(110, 0))
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.gridLayout_2.addWidget(self.label_8, 0, 0, 1, 1)
        self.leGroupNum_2 = QtGui.QLineEdit(self.groupBox_2)
        self.leGroupNum_2.setEnabled(False)
        self.leGroupNum_2.setObjectName(_fromUtf8("leGroupNum_2"))
        self.gridLayout_2.addWidget(self.leGroupNum_2, 0, 1, 1, 1)
        self.label_7 = QtGui.QLabel(self.groupBox_2)
        self.label_7.setMinimumSize(QtCore.QSize(110, 0))
        self.label_7.setObjectName(_fromUtf8("label_7"))
        self.gridLayout_2.addWidget(self.label_7, 1, 0, 1, 1)
        self.leTrNum_2 = QtGui.QLineEdit(self.groupBox_2)
        self.leTrNum_2.setEnabled(False)
        self.leTrNum_2.setObjectName(_fromUtf8("leTrNum_2"))
        self.gridLayout_2.addWidget(self.leTrNum_2, 1, 1, 1, 1)
        self.verticalLayout_7.addWidget(self.groupBox_2)
        self.label_3 = QtGui.QLabel(self.tab_7)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.verticalLayout_7.addWidget(self.label_3)
        self.twRec = QtGui.QTableWidget(self.tab_7)
        self.twRec.setEnabled(True)
        self.twRec.setObjectName(_fromUtf8("twRec"))
        self.twRec.setColumnCount(4)
        self.twRec.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twRec.setHorizontalHeaderItem(3, item)
        self.twRec.horizontalHeader().setStretchLastSection(True)
        self.twRec.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_7.addWidget(self.twRec)
        self.tabWidget2.addTab(self.tab_7, _fromUtf8(""))
        self.verticalLayout_4.addWidget(self.tabWidget2)
        self.tabWidget.addTab(self.tab_3, _fromUtf8(""))
        self.tab = QtGui.QWidget()
        self.tab.setObjectName(_fromUtf8("tab"))
        self.verticalLayout_13 = QtGui.QVBoxLayout(self.tab)
        self.verticalLayout_13.setObjectName(_fromUtf8("verticalLayout_13"))
        self.tabWidget_3 = QtGui.QTabWidget(self.tab)
        self.tabWidget_3.setObjectName(_fromUtf8("tabWidget_3"))
        self.tab_10 = QtGui.QWidget()
        self.tab_10.setObjectName(_fromUtf8("tab_10"))
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.tab_10)
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
        self.unitView = PropertyExplorer(self.tab_10)
        self.unitView.setObjectName(_fromUtf8("unitView"))
        self.verticalLayout_2.addWidget(self.unitView)
        self.tabWidget_3.addTab(self.tab_10, _fromUtf8(""))
        self.tab_11 = QtGui.QWidget()
        self.tab_11.setObjectName(_fromUtf8("tab_11"))
        self.verticalLayout_11 = QtGui.QVBoxLayout(self.tab_11)
        self.verticalLayout_11.setObjectName(_fromUtf8("verticalLayout_11"))
        self.cableView = PropertyExplorer(self.tab_11)
        self.cableView.setObjectName(_fromUtf8("cableView"))
        self.verticalLayout_11.addWidget(self.cableView)
        self.tabWidget_3.addTab(self.tab_11, _fromUtf8(""))
        self.tab_12 = QtGui.QWidget()
        self.tab_12.setObjectName(_fromUtf8("tab_12"))
        self.verticalLayout_15 = QtGui.QVBoxLayout(self.tab_12)
        self.verticalLayout_15.setObjectName(_fromUtf8("verticalLayout_15"))
        self.splitter_3 = QtGui.QSplitter(self.tab_12)
        self.splitter_3.setOrientation(QtCore.Qt.Vertical)
        self.splitter_3.setObjectName(_fromUtf8("splitter_3"))
        self.widget = QtGui.QWidget(self.splitter_3)
        self.widget.setObjectName(_fromUtf8("widget"))
        self.verticalLayout_12 = QtGui.QVBoxLayout(self.widget)
        self.verticalLayout_12.setMargin(0)
        self.verticalLayout_12.setObjectName(_fromUtf8("verticalLayout_12"))
        self.label_5 = QtGui.QLabel(self.widget)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.verticalLayout_12.addWidget(self.label_5)
        self.twFailures = TableWidget(self.widget)
        self.twFailures.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twFailures.setObjectName(_fromUtf8("twFailures"))
        self.twFailures.setColumnCount(5)
        self.twFailures.setRowCount(9)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(6, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(7, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setVerticalHeaderItem(8, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures.setHorizontalHeaderItem(4, item)
        self.twFailures.horizontalHeader().setStretchLastSection(True)
        self.twFailures.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_12.addWidget(self.twFailures)
        self.widget_2 = QtGui.QWidget(self.splitter_3)
        self.widget_2.setObjectName(_fromUtf8("widget_2"))
        self.verticalLayout_14 = QtGui.QVBoxLayout(self.widget_2)
        self.verticalLayout_14.setMargin(0)
        self.verticalLayout_14.setObjectName(_fromUtf8("verticalLayout_14"))
        self.label_6 = QtGui.QLabel(self.widget_2)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.verticalLayout_14.addWidget(self.label_6)
        self.twFailures_2 = QtGui.QTableWidget(self.widget_2)
        self.twFailures_2.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twFailures_2.setObjectName(_fromUtf8("twFailures_2"))
        self.twFailures_2.setColumnCount(7)
        self.twFailures_2.setRowCount(5)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setVerticalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twFailures_2.setHorizontalHeaderItem(6, item)
        self.twFailures_2.horizontalHeader().setStretchLastSection(True)
        self.twFailures_2.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_14.addWidget(self.twFailures_2)
        self.verticalLayout_15.addWidget(self.splitter_3)
        self.tabWidget_3.addTab(self.tab_12, _fromUtf8(""))
        self.verticalLayout_13.addWidget(self.tabWidget_3)
        self.tabWidget.addTab(self.tab, _fromUtf8(""))
        self.groupBox_3 = QtGui.QGroupBox(self.splitter_2)
        self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
        self.verticalLayout = QtGui.QVBoxLayout(self.groupBox_3)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.tabWidget_2 = QtGui.QTabWidget(self.groupBox_3)
        self.tabWidget_2.setObjectName(_fromUtf8("tabWidget_2"))
        self.tab_4 = QtGui.QWidget()
        self.tab_4.setObjectName(_fromUtf8("tab_4"))
        self.verticalLayout_9 = QtGui.QVBoxLayout(self.tab_4)
        self.verticalLayout_9.setObjectName(_fromUtf8("verticalLayout_9"))
        self.twAbon = QtGui.QTableWidget(self.tab_4)
        self.twAbon.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.twAbon.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twAbon.setObjectName(_fromUtf8("twAbon"))
        self.twAbon.setColumnCount(9)
        self.twAbon.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(6, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(7, item)
        item = QtGui.QTableWidgetItem()
        self.twAbon.setHorizontalHeaderItem(8, item)
        self.twAbon.horizontalHeader().setDefaultSectionSize(75)
        self.twAbon.horizontalHeader().setStretchLastSection(True)
        self.twAbon.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_9.addWidget(self.twAbon)
        self.tabWidget_2.addTab(self.tab_4, _fromUtf8(""))
        self.tab_8 = QtGui.QWidget()
        self.tab_8.setObjectName(_fromUtf8("tab_8"))
        self.verticalLayout_10 = QtGui.QVBoxLayout(self.tab_8)
        self.verticalLayout_10.setObjectName(_fromUtf8("verticalLayout_10"))
        self.twRegl = QtGui.QTableWidget(self.tab_8)
        self.twRegl.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.twRegl.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.twRegl.setObjectName(_fromUtf8("twRegl"))
        self.twRegl.setColumnCount(18)
        self.twRegl.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(4, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(5, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(6, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(7, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(8, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(9, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(10, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(11, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(12, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(13, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(14, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(15, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(16, item)
        item = QtGui.QTableWidgetItem()
        self.twRegl.setHorizontalHeaderItem(17, item)
        self.twRegl.horizontalHeader().setDefaultSectionSize(50)
        self.twRegl.horizontalHeader().setMinimumSectionSize(30)
        self.twRegl.horizontalHeader().setStretchLastSection(True)
        self.twRegl.verticalHeader().setDefaultSectionSize(20)
        self.verticalLayout_10.addWidget(self.twRegl)
        self.tabWidget_2.addTab(self.tab_8, _fromUtf8(""))
        self.verticalLayout.addWidget(self.tabWidget_2)
        self.verticalLayout_8.addWidget(self.splitter_2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1024, 26))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menu = QtGui.QMenu(self.menubar)
        self.menu.setObjectName(_fromUtf8("menu"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.actionRequestConnect = QtGui.QAction(MainWindow)
        self.actionRequestConnect.setObjectName(_fromUtf8("actionRequestConnect"))
        self.actionConnectGeneral = QtGui.QAction(MainWindow)
        self.actionConnectGeneral.setObjectName(_fromUtf8("actionConnectGeneral"))
        self.actionConnectReserve = QtGui.QAction(MainWindow)
        self.actionConnectReserve.setObjectName(_fromUtf8("actionConnectReserve"))
        self.actionQuit = QtGui.QAction(MainWindow)
        self.actionQuit.setObjectName(_fromUtf8("actionQuit"))
        self.actionDisconnect = QtGui.QAction(MainWindow)
        self.actionDisconnect.setObjectName(_fromUtf8("actionDisconnect"))
        self.menu.addAction(self.actionRequestConnect)
        self.menu.addSeparator()
        self.menu.addAction(self.actionConnectGeneral)
        self.menu.addAction(self.actionConnectReserve)
        self.menu.addAction(self.actionDisconnect)
        self.menu.addSeparator()
        self.menu.addAction(self.actionQuit)
        self.menubar.addAction(self.menu.menuAction())

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        self.tabWidget2.setCurrentIndex(0)
        self.tabWidget_3.setCurrentIndex(0)
        self.tabWidget_2.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "Имитатор 1863", None))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Параметры", None))
        self.tabWidget2.setTabText(self.tabWidget2.indexOf(self.tab_5), _translate("MainWindow", "Комплект 1", None))
        self.tabWidget2.setTabText(self.tabWidget2.indexOf(self.tab_6), _translate("MainWindow", "Комплект 2", None))
        self.label_4.setText(_translate("MainWindow", "Собственный адрес", None))
        self.groupBox.setTitle(_translate("MainWindow", "Направление 1", None))
        self.label.setText(_translate("MainWindow", "N группы", None))
        self.leGroupNum.setText(_translate("MainWindow", "1", None))
        self.label_2.setText(_translate("MainWindow", "N частоты ПРД", None))
        self.leTrNum.setText(_translate("MainWindow", "2", None))
        self.groupBox_2.setTitle(_translate("MainWindow", "Направление 2", None))
        self.label_8.setText(_translate("MainWindow", "N группы", None))
        self.leGroupNum_2.setText(_translate("MainWindow", "3", None))
        self.label_7.setText(_translate("MainWindow", "N частоты ПРД", None))
        self.leTrNum_2.setText(_translate("MainWindow", "4", None))
        self.label_3.setText(_translate("MainWindow", "Частоты ПРМ", None))
        item = self.twRec.horizontalHeaderItem(0)
        item.setText(_translate("MainWindow", "Абонент", None))
        item = self.twRec.horizontalHeaderItem(1)
        item.setText(_translate("MainWindow", "N частоты", None))
        item = self.twRec.horizontalHeaderItem(2)
        item.setText(_translate("MainWindow", "Направление", None))
        self.tabWidget2.setTabText(self.tabWidget2.indexOf(self.tab_7), _translate("MainWindow", "Текущие частоты", None))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("MainWindow", "Радиоданные", None))
        self.tabWidget_3.setTabText(self.tabWidget_3.indexOf(self.tab_10), _translate("MainWindow", "Радиосредства", None))
        self.tabWidget_3.setTabText(self.tabWidget_3.indexOf(self.tab_11), _translate("MainWindow", "Кабельные соединения", None))
        self.label_5.setText(_translate("MainWindow", "Отказы трактов при контроле уровня проходящей мощности", None))
        item = self.twFailures.verticalHeaderItem(0)
        item.setText(_translate("MainWindow", "1", None))
        item = self.twFailures.verticalHeaderItem(1)
        item.setText(_translate("MainWindow", "2", None))
        item = self.twFailures.verticalHeaderItem(2)
        item.setText(_translate("MainWindow", "3", None))
        item = self.twFailures.verticalHeaderItem(3)
        item.setText(_translate("MainWindow", "4", None))
        item = self.twFailures.verticalHeaderItem(4)
        item.setText(_translate("MainWindow", "5", None))
        item = self.twFailures.verticalHeaderItem(5)
        item.setText(_translate("MainWindow", "6", None))
        item = self.twFailures.verticalHeaderItem(6)
        item.setText(_translate("MainWindow", "7", None))
        item = self.twFailures.verticalHeaderItem(7)
        item.setText(_translate("MainWindow", "8", None))
        item = self.twFailures.verticalHeaderItem(8)
        item.setText(_translate("MainWindow", "10", None))
        item = self.twFailures.horizontalHeaderItem(0)
        item.setText(_translate("MainWindow", "Частота", None))
        item = self.twFailures.horizontalHeaderItem(1)
        item.setText(_translate("MainWindow", "ПРД", None))
        item = self.twFailures.horizontalHeaderItem(2)
        item.setText(_translate("MainWindow", "Мощность", None))
        item = self.twFailures.horizontalHeaderItem(3)
        item.setText(_translate("MainWindow", "Причина", None))
        item = self.twFailures.horizontalHeaderItem(4)
        item.setText(_translate("MainWindow", "Отказ", None))
        self.label_6.setText(_translate("MainWindow", "Отказы трактов при замыкании шлейфа", None))
        item = self.twFailures_2.verticalHeaderItem(0)
        item.setText(_translate("MainWindow", "1", None))
        item = self.twFailures_2.verticalHeaderItem(1)
        item.setText(_translate("MainWindow", "2", None))
        item = self.twFailures_2.verticalHeaderItem(2)
        item.setText(_translate("MainWindow", "3", None))
        item = self.twFailures_2.verticalHeaderItem(3)
        item.setText(_translate("MainWindow", "4", None))
        item = self.twFailures_2.verticalHeaderItem(4)
        item.setText(_translate("MainWindow", "5", None))
        item = self.twFailures_2.horizontalHeaderItem(0)
        item.setText(_translate("MainWindow", "Ант", None))
        item = self.twFailures_2.horizontalHeaderItem(1)
        item.setText(_translate("MainWindow", "Мод", None))
        item = self.twFailures_2.horizontalHeaderItem(2)
        item.setText(_translate("MainWindow", "Частота", None))
        item = self.twFailures_2.horizontalHeaderItem(3)
        item.setText(_translate("MainWindow", "ПРМ", None))
        item = self.twFailures_2.horizontalHeaderItem(4)
        item.setText(_translate("MainWindow", "ПРД", None))
        item = self.twFailures_2.horizontalHeaderItem(5)
        item.setText(_translate("MainWindow", "Причина", None))
        item = self.twFailures_2.horizontalHeaderItem(6)
        item.setText(_translate("MainWindow", "Отказ", None))
        self.tabWidget_3.setTabText(self.tabWidget_3.indexOf(self.tab_12), _translate("MainWindow", "Массив отказов", None))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Состояние", None))
        self.groupBox_3.setTitle(_translate("MainWindow", "Каналы", None))
        item = self.twAbon.horizontalHeaderItem(0)
        item.setText(_translate("MainWindow", "ИАДР", None))
        item = self.twAbon.horizontalHeaderItem(1)
        item.setText(_translate("MainWindow", "ВЗБ", None))
        item = self.twAbon.horizontalHeaderItem(2)
        item.setText(_translate("MainWindow", "Порт", None))
        item = self.twAbon.horizontalHeaderItem(3)
        item.setText(_translate("MainWindow", "ПРМ", None))
        item = self.twAbon.horizontalHeaderItem(4)
        item.setText(_translate("MainWindow", "Порт", None))
        item = self.twAbon.horizontalHeaderItem(5)
        item.setText(_translate("MainWindow", "Тип ОА", None))
        item = self.twAbon.horizontalHeaderItem(6)
        item.setText(_translate("MainWindow", "Скор", None))
        item = self.twAbon.horizontalHeaderItem(7)
        item.setText(_translate("MainWindow", "Изл", None))
        item = self.twAbon.horizontalHeaderItem(8)
        item.setText(_translate("MainWindow", "Сост", None))
        self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_4), _translate("MainWindow", "Работа", None))
        item = self.twRegl.horizontalHeaderItem(0)
        item.setText(_translate("MainWindow", "Ант", None))
        item = self.twRegl.horizontalHeaderItem(1)
        item.setText(_translate("MainWindow", "Мод", None))
        item = self.twRegl.horizontalHeaderItem(2)
        item.setText(_translate("MainWindow", "ПРМ", None))
        item = self.twRegl.horizontalHeaderItem(3)
        item.setText(_translate("MainWindow", "Порт", None))
        item = self.twRegl.horizontalHeaderItem(4)
        item.setText(_translate("MainWindow", "Скор", None))
        item = self.twRegl.horizontalHeaderItem(5)
        item.setText(_translate("MainWindow", "Част", None))
        item = self.twRegl.horizontalHeaderItem(6)
        item.setText(_translate("MainWindow", "КИ", None))
        item = self.twRegl.horizontalHeaderItem(7)
        item.setText(_translate("MainWindow", "Ант", None))
        item = self.twRegl.horizontalHeaderItem(8)
        item.setText(_translate("MainWindow", "Мод", None))
        item = self.twRegl.horizontalHeaderItem(9)
        item.setText(_translate("MainWindow", "ПРД", None))
        item = self.twRegl.horizontalHeaderItem(10)
        item.setText(_translate("MainWindow", "Порт", None))
        item = self.twRegl.horizontalHeaderItem(11)
        item.setText(_translate("MainWindow", "Скор", None))
        item = self.twRegl.horizontalHeaderItem(12)
        item.setText(_translate("MainWindow", "Част", None))
        item = self.twRegl.horizontalHeaderItem(13)
        item.setText(_translate("MainWindow", "УМ", None))
        item = self.twRegl.horizontalHeaderItem(14)
        item.setText(_translate("MainWindow", "Мощн", None))
        item = self.twRegl.horizontalHeaderItem(15)
        item.setText(_translate("MainWindow", "КИ", None))
        item = self.twRegl.horizontalHeaderItem(16)
        item.setText(_translate("MainWindow", "Изл", None))
        item = self.twRegl.horizontalHeaderItem(17)
        item.setText(_translate("MainWindow", "Сост", None))
        self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_8), _translate("MainWindow", "Регламент", None))
        self.menu.setTitle(_translate("MainWindow", "Команды", None))
        self.actionRequestConnect.setText(_translate("MainWindow", "Запрос связи", None))
        self.actionRequestConnect.setShortcut(_translate("MainWindow", "Ctrl+R", None))
        self.actionConnectGeneral.setText(_translate("MainWindow", "Подключить ПРДК основной", None))
        self.actionConnectGeneral.setShortcut(_translate("MainWindow", "Ctrl+1", None))
        self.actionConnectReserve.setText(_translate("MainWindow", "Подключить ПРДК резервный", None))
        self.actionConnectReserve.setShortcut(_translate("MainWindow", "Ctrl+2", None))
        self.actionQuit.setText(_translate("MainWindow", "Выход", None))
        self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q", None))
        self.actionDisconnect.setText(_translate("MainWindow", "Разорвать соединение с ПРДК", None))
        self.actionDisconnect.setShortcut(_translate("MainWindow", "Ctrl+D", None))
Esempio n. 10
0
    def __init__(self, settings):
        super().__init__()
        self.settings = settings

        self.alert_icon_path = self.resource_path('Alert.ico')
        self.window_icon_path = self.resource_path('Tagger.ico')

        self.alertIcon = QIcon()
        self.windowIcon = QIcon()

        if self.alert_icon_path is None:
            self.log.warning(f'Did not find alert icon.')
        else:
            self.alertIcon.addFile(self.alert_icon_path)

        if self.window_icon_path is None:
            self.log.warning(f'Did not find window icon.')
        else:
            self.windowIcon.addFile(self.window_icon_path)
            self.setWindowIcon(self.windowIcon)

        if 'folder' not in settings:
            folder = ''
        else:
            folder = settings['folder']

        intro = True
        while not folder:
            if intro:
                self.alert_message(
                    'Hello!',
                    'Please select the folder with music files.',
                    '',
                    icon=self.windowIcon)
                intro = False

            folder = self.settings[
                'folder'] = QFileDialog.getExistingDirectory()
            if not folder:
                result = self.alert_message('Error',
                                            'You need to select a folder!',
                                            'Do you want to try again?', True)
                if result != QMessageBox.Yes:
                    sys.exit(1)

        self.folder_path = folder

        self.log = get_logger('Tagger.gui')
        self.log.info('\n' + '-' * 40)
        self.log.info(f'{time.strftime("%c")}')
        self.log.info(f'Starting... Current folder path "{self.folder_path}".')

        # TODO: Exception handling for tagging!
        # TODO: Add icons!

        self.word_filter = WordFilter()
        self.setWindowTitle('Tagger')
        self.table = TableWidget(folder, parent=self)

        self.setStyleSheet(stylesheet)
        self.log.debug('Stylesheet set.')
        # self.items.setRowCount(4)

        self.table.setColumnCount(5)

        self.table.setHorizontalHeaderLabels(
            ['Old name', 'New name', 'Filetype', 'Title', 'Artist'])
        self.table.horizontalHeader().setVisible(True)
        # self.items.verticalHeader().setVisible(False)
        self.log.debug('Fetching files and populating table...')
        self.get_names()
        self.log.debug('Table populated!')
        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()

        # self.table.resizeColumnsToContents()
        # self.table.resizeRowsToContents()

        horizontal_header = self.table.horizontalHeader()
        horizontal_header.setSectionResizeMode(0, QHeaderView.Stretch)
        horizontal_header.setSectionResizeMode(1, QHeaderView.Stretch)

        self.log.debug('Table resized to contents')

        # shortcut = QShortcut("Ctrl+N", self.items)
        # shortcut.em

        self.vertical_layout = QVBoxLayout()
        self.vertical_layout.addWidget(self.table)
        self.qwidget = QWidget(self)
        self.qwidget.setLayout(self.vertical_layout)
        self.setCentralWidget(self.qwidget)

        self.bottom_bar_layout = QHBoxLayout()
        self.rename_btn = QPushButton('Rename songs')
        self.rename_btn.setFixedWidth(
            self.rename_btn.fontMetrics().width(self.rename_btn.text()) + 10)
        self.rename_btn.clicked.connect(self.write_to_files)

        self.tagall_btn = QPushButton('Tag all songs')
        self.tagall_btn.setFixedWidth(
            self.tagall_btn.fontMetrics().width(self.tagall_btn.text()) + 10)
        self.tagall_btn.clicked.connect(self.tag_all_songs)

        self.progressbar = QProgressBar(parent=self)

        self.bottom_bar_layout.addWidget(self.progressbar)
        self.bottom_bar_layout.addWidget(self.tagall_btn)
        self.bottom_bar_layout.addWidget(self.rename_btn)
        self.vertical_layout.addLayout(self.bottom_bar_layout)

        self.renamer = Renamer(self.table, folder, self)
        self.renamer.renamer_started.connect(self.started_renaming)
        self.renamer.renamer_update.connect(self.update_gui)
        self.renamer.finished.connect(self.rename_finished)

        bar = self.menuBar()
        file = bar.addMenu("File")
        set_folder = QAction("Select music folder", self)
        set_folder.triggered.connect(self.select_music_folder)
        log_opener = QAction('Open Log', self)
        log_opener.triggered.connect(self.open_log)
        file.addAction(set_folder)
        file.addAction(log_opener)

        about = bar.addMenu("Help")
        info = QAction('About')
        git = QAction('GitHub')

        self.log.debug('Showing window...')
        self.logwindow = QTextBrowser()
        self.logwindow.setFont(QFont('consolas'))
        self.logwindow.setFontPointSize(12)
        self.logwindow.setMinimumSize(800, 600)

        self.showMaximized()
Esempio n. 11
0
class GUI(QMainWindow):
    def __init__(self, settings):
        super().__init__()
        self.settings = settings

        self.alert_icon_path = self.resource_path('Alert.ico')
        self.window_icon_path = self.resource_path('Tagger.ico')

        self.alertIcon = QIcon()
        self.windowIcon = QIcon()

        if self.alert_icon_path is None:
            self.log.warning(f'Did not find alert icon.')
        else:
            self.alertIcon.addFile(self.alert_icon_path)

        if self.window_icon_path is None:
            self.log.warning(f'Did not find window icon.')
        else:
            self.windowIcon.addFile(self.window_icon_path)
            self.setWindowIcon(self.windowIcon)

        if 'folder' not in settings:
            folder = ''
        else:
            folder = settings['folder']

        intro = True
        while not folder:
            if intro:
                self.alert_message(
                    'Hello!',
                    'Please select the folder with music files.',
                    '',
                    icon=self.windowIcon)
                intro = False

            folder = self.settings[
                'folder'] = QFileDialog.getExistingDirectory()
            if not folder:
                result = self.alert_message('Error',
                                            'You need to select a folder!',
                                            'Do you want to try again?', True)
                if result != QMessageBox.Yes:
                    sys.exit(1)

        self.folder_path = folder

        self.log = get_logger('Tagger.gui')
        self.log.info('\n' + '-' * 40)
        self.log.info(f'{time.strftime("%c")}')
        self.log.info(f'Starting... Current folder path "{self.folder_path}".')

        # TODO: Exception handling for tagging!
        # TODO: Add icons!

        self.word_filter = WordFilter()
        self.setWindowTitle('Tagger')
        self.table = TableWidget(folder, parent=self)

        self.setStyleSheet(stylesheet)
        self.log.debug('Stylesheet set.')
        # self.items.setRowCount(4)

        self.table.setColumnCount(5)

        self.table.setHorizontalHeaderLabels(
            ['Old name', 'New name', 'Filetype', 'Title', 'Artist'])
        self.table.horizontalHeader().setVisible(True)
        # self.items.verticalHeader().setVisible(False)
        self.log.debug('Fetching files and populating table...')
        self.get_names()
        self.log.debug('Table populated!')
        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()

        # self.table.resizeColumnsToContents()
        # self.table.resizeRowsToContents()

        horizontal_header = self.table.horizontalHeader()
        horizontal_header.setSectionResizeMode(0, QHeaderView.Stretch)
        horizontal_header.setSectionResizeMode(1, QHeaderView.Stretch)

        self.log.debug('Table resized to contents')

        # shortcut = QShortcut("Ctrl+N", self.items)
        # shortcut.em

        self.vertical_layout = QVBoxLayout()
        self.vertical_layout.addWidget(self.table)
        self.qwidget = QWidget(self)
        self.qwidget.setLayout(self.vertical_layout)
        self.setCentralWidget(self.qwidget)

        self.bottom_bar_layout = QHBoxLayout()
        self.rename_btn = QPushButton('Rename songs')
        self.rename_btn.setFixedWidth(
            self.rename_btn.fontMetrics().width(self.rename_btn.text()) + 10)
        self.rename_btn.clicked.connect(self.write_to_files)

        self.tagall_btn = QPushButton('Tag all songs')
        self.tagall_btn.setFixedWidth(
            self.tagall_btn.fontMetrics().width(self.tagall_btn.text()) + 10)
        self.tagall_btn.clicked.connect(self.tag_all_songs)

        self.progressbar = QProgressBar(parent=self)

        self.bottom_bar_layout.addWidget(self.progressbar)
        self.bottom_bar_layout.addWidget(self.tagall_btn)
        self.bottom_bar_layout.addWidget(self.rename_btn)
        self.vertical_layout.addLayout(self.bottom_bar_layout)

        self.renamer = Renamer(self.table, folder, self)
        self.renamer.renamer_started.connect(self.started_renaming)
        self.renamer.renamer_update.connect(self.update_gui)
        self.renamer.finished.connect(self.rename_finished)

        bar = self.menuBar()
        file = bar.addMenu("File")
        set_folder = QAction("Select music folder", self)
        set_folder.triggered.connect(self.select_music_folder)
        log_opener = QAction('Open Log', self)
        log_opener.triggered.connect(self.open_log)
        file.addAction(set_folder)
        file.addAction(log_opener)

        about = bar.addMenu("Help")
        info = QAction('About')
        git = QAction('GitHub')

        self.log.debug('Showing window...')
        self.logwindow = QTextBrowser()
        self.logwindow.setFont(QFont('consolas'))
        self.logwindow.setFontPointSize(12)
        self.logwindow.setMinimumSize(800, 600)

        self.showMaximized()

    def closeEvent(self, *args, **kwargs):
        self.logwindow.close()  # Ensure log is closed
        super(GUI, self).closeEvent(*args, **kwargs)

    def open_log(self):
        if os.path.isfile(LOG_FILE):
            with open(LOG_FILE, 'r', encoding='utf-8') as f:
                self.logwindow.setText(f.read())

            self.logwindow.show()

    def select_music_folder(self):
        temp_path = QFileDialog.getExistingDirectory()
        if not temp_path:
            return
        result = self.alert_message('Warning!',
                                    'Any unwritten changes will be lost!',
                                    'Do you want to load a new folder?', True)
        if result == QMessageBox.Yes:
            self.folder_path = self.settings['folder'] = temp_path
            self.rename_finished(0, True)

    def tag_all_songs(self):
        items = []
        for row in range(self.table.rowCount()):
            items.append(self.table.item(row, 1))

        self.table.create_tag([cell for cell in items if cell.column() == 1])

    @staticmethod
    def resource_path(relative_path):
        """ Get absolute path to resource, works for dev and for PyInstaller """

        try:
            # PyInstaller creates a temp folder and stores path in _MEIPASS
            base_path = sys._MEIPASS
        except AttributeError:
            base_path = os.path.abspath(".")

        path = os.path.join(base_path, relative_path)

        if os.path.isfile(path) and os.access(path, os.X_OK):
            return path
        else:
            return None

    def alert_message(self,
                      title,
                      text,
                      info_text,
                      question=False,
                      allow_cancel=False,
                      icon=None):
        warning_window = QMessageBox(parent=self)
        warning_window.setText(text)
        warning_window.setIcon(QMessageBox.Warning)
        if icon is None:
            warning_window.setWindowIcon(self.alertIcon)
        else:
            warning_window.setWindowIcon(icon)
            warning_window.setIconPixmap(
                icon.pixmap(self.alertIcon.availableSizes()[-2]))
        warning_window.setWindowTitle(title)

        if info_text:
            warning_window.setInformativeText(info_text)
        if question and allow_cancel:
            warning_window.setStandardButtons(QMessageBox.Yes | QMessageBox.No
                                              | QMessageBox.Cancel)
        elif question:
            warning_window.setStandardButtons(QMessageBox.Yes | QMessageBox.No)

        return warning_window.exec()

    def rename_finished(self, results, skip_results=False):
        if not skip_results:
            self.alert_message(*results)
        # Reload table
        self.table.blockSignals(True)
        self.log.debug('Clearing table')
        self.table.clearContents()
        self.table.setRowCount(0)
        self.log.debug('Getting files in folder.')
        self.get_names()
        self.log.debug('Resizing to contents.')
        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()

        horizontal_header = self.table.horizontalHeader()
        horizontal_header.setSectionResizeMode(0, QHeaderView.Stretch)
        horizontal_header.setSectionResizeMode(1, QHeaderView.Stretch)

        self.table.blockSignals(False)
        if not skip_results:
            self.log.debug('File renaming complete!\n{}'.format('-' * 40))

        self.table.setDisabled(False)
        self.progressbar.reset()
        self.rename_btn.setDisabled(False)

    def started_renaming(self, current, total):
        self.progressbar.setRange(0, total)
        self.progressbar.setValue(current)

    def update_gui(self, value):
        self.progressbar.setValue(value)

    def write_to_files(self):
        self.log.debug('Disabling table!')
        self.table.setDisabled(True)
        self.rename_btn.setDisabled(True)
        self.renamer.start()

    def get_names(self):
        """
        path = folder path + name + extension
        file = name + extension
        """
        old_col, new_col, ext_col, title_col, artist_col = range(5)
        row = 0
        # max_files = -1

        # self.items.insertRow(0)
        self.table.blockSignals(True)

        # folder = os.listdir(self.folder_path)

        folder = sorted(
            os.listdir(self.folder_path),
            key=lambda x: os.path.getctime(os.path.join(self.folder_path, x)))

        # if len(folder) > 500:
        #     result = self.alert_message('Note!', 'This folder has a lot of files',
        #                                 'Do you only want to load all of them?', True, True)
        #
        #     if result == QMessageBox.Cancel:
        #         sys.exit(0)
        #
        #     elif result == QMessageBox.No:
        #         max_files = self.get_max_files()
        #     elif result == QMessageBox.Yes:
        #         pass
        #     else:
        #         log.warning('Unexpected response from dialog!')

        for file in reversed(folder):
            path = os.path.join(self.folder_path, file)
            if not os.path.isfile(path):
                self.log.info(f'Ignored folder: {file}')
                continue

            name, ext = os.path.splitext(file)
            ext = ext[1:]
            if ext.lower() not in ('mp3', 'wav', 'flac', 'ogg'):
                continue

            # TODO: Introduce a supported files list

            title_item = TableWidgetItem('')
            artist_item = TableWidgetItem('')

            artist_item.setFlags(artist_item.flags() ^ Qt.ItemIsEditable)
            title_item.setFlags(title_item.flags() ^ Qt.ItemIsEditable)

            try:
                meta = EasyID3(path)
                if meta.keys():
                    if 'title' in meta.keys():
                        title_item.setText(meta['title'][0])
                    if 'artist' in meta.keys():
                        artist_item.setText(meta['artist'][0])
                else:
                    pass
                    # has_id_item.setBackground(QColor)
            except mutagen.id3.ID3NoHeaderError as e:
                self.log.info(e)
            except KeyError as e:
                self.log.info(f'{file} has no title/artist in tag.')

            self.table.insertRow(row)

            # Old column
            old_item = TableWidgetItem(name)
            old_item.setFlags(old_item.flags() ^ Qt.ItemIsEditable)

            # New column
            new_name = self.word_filter(name)
            new_name = capitalize(new_name)
            new_filename = ''.join((new_name, '.', ext))

            count = 1
            if new_filename != file:
                while new_filename in folder:
                    self.log.info(
                        f'New name already exists for {new_filename}')
                    new_name = f'{new_name} ({count})'
                    new_filename = ''.join((new_name, '.', ext))
                    count += 1

            new_item = TableWidgetItem(new_name)
            new_item.setData(TableWidget.HANDLED_STATE, TableWidget.UNHANDLED)
            # If a box was added.
            if new_name.count(' - ') != 1 or count > 1:
                new_item.setBackground(QColor('#e38c00'))

            # Extension column
            extension_item = TableWidgetItem(ext.upper())
            extension_item.setTextAlignment(Qt.AlignCenter)
            extension_item.setFlags(extension_item.flags() ^ Qt.ItemIsEditable)

            # Inserting to table
            self.table.setItem(row, old_col, old_item)
            self.table.setItem(row, new_col, new_item)
            self.table.setItem(row, ext_col, extension_item)
            self.table.setItem(row, title_col, title_item)
            self.table.setItem(row, artist_col, artist_item)

            row += 1
            # if row == max_files:
            #     break

        self.table.blockSignals(False)
        return row

    def get_max_files(self):
        dialog = Dialog(self, 'How many?',
                        'Select the number of files you want to load!')

        if dialog.exec_() == QDialog.Accepted:
            return dialog.get_value()
        else:
            sys.exit(0)