Exemple #1
0
 def addCategory(self, title):
     item = QListWidgetItem(title)
     item.setBackground(QBrush(lightBlue()))
     item.setForeground(QBrush(Qt.darkBlue))
     item.setFlags(Qt.ItemIsEnabled)
     f = item.font()
     f.setBold(True)
     item.setFont(f)
     self.list.addItem(item)
Exemple #2
0
 def __set_file_text(self, data):
     """
     Displayed in the chat of the user who sends a file
     """
     tab = self.set_data_to_correct_tab(data['type'])
     font = QFont()
     font.setStyle(QFont.StyleItalic)
     item = QListWidgetItem(tab.children()[0])
     item.setFont(font)
     item.setText("%s: Send file" % self.members[data['username']].username)
Exemple #3
0
 def send_file(self, main_window_instance):
     index_first_tab = main_window_instance.tab_widget.currentIndex()
     if index_first_tab != 0:
         file_text = QFileDialog().getOpenFileName()
         current_tab = main_window_instance.tab_widget.currentWidget()
         current_widget = current_tab.children()[0]
         font = QFont()
         font.setStyle(QFont.StyleItalic)
         item = QListWidgetItem(current_widget)
         item.setFont(font)
         item.setText("%s: %s" % (self.username, "Sending File..."))
         self.client.send(file_text, current_tab, is_file=True)
Exemple #4
0
 def add_no_found(self):
     #Load no results found message
     noFoundItem = QListWidgetItem(
         QIcon(resources.IMAGES['delete']),
             'No results were found!')
     font = noFoundItem.font()
     font.setBold(True)
     noFoundItem.setSizeHint(QSize(20, 30))
     noFoundItem.setBackground(QBrush(Qt.lightGray))
     noFoundItem.setForeground(QBrush(Qt.black))
     noFoundItem.setFont(font)
     self.listWidget.addItem(noFoundItem)
Exemple #5
0
 def __set_text_after_save_file(self, data, path):
     """
     Specifies the text after the file has been sent
     """
     tab = self.set_data_to_correct_tab(data['type'])
     font = QFont()
     font.setWeight(QFont.Bold)
     item = QListWidgetItem(tab.children()[0])
     item.setFont(font)
     message = "the file was saved on the following path: %s" % path
     item.setText("%s: %s" % (self.members[data['username']].username,
                              message))
 def refresh(self):
     """
     Public slot to refresh the list of queues.
     """
     self.queuesList.clear()
     queuesList, activeQueue = self.__getQueuesList()
     for queue in sorted(queuesList):
         itm = QListWidgetItem(queue, self.queuesList)
         if queue == activeQueue:
             font = itm.font()
             font.setBold(True)
             itm.setFont(font)
Exemple #7
0
    def updateSheets(self):
        if self.sheets is not None and self.ownsheet is not None:
            self.listSheetItems = {}
            self.listWidget.clear()
            for sheetId in self.sheets:
                if not sheetId == self.ownsheet:
                    newItem = QListWidgetItem(self.sheets[sheetId])
                    newItem.setToolTip(str(sheetId))
                    newItem.setData(Qt.UserRole, sheetId)
                    self.listSheetItems[sheetId] = newItem
                    self.listWidget.addItem(newItem)

                    if sheetId == self.selectedSheet:
                        boldFont = QFont()
                        boldFont.setBold(True)
                        newItem.setFont(boldFont)
Exemple #8
0
    def _makeItem(self, layer):
        isDefault = layer is self._layerSet.defaultLayer
        name = layer.name
        color = layer.color
        item = QListWidgetItem()
        item.setText(name)
        if color:
            pixmap = QPixmap(100, 100)
            # change color
            pixmap.fill(QColor.fromRgbF(*color))
            icon = QIcon(pixmap)
        else:
            icon = QIcon(":/resources/defaultColor.svg")
        item.setIcon(icon)

        if isDefault:
            font = item.font()
            font.setBold(True)
            item.setFont(font)

        item.setFlags(item.flags() | Qt.ItemIsEditable)

        return item;
 def __init__(self, guards, activeGuards=None, listOnly=False, parent=None):
     """
     Constructor
     
     @param guards list of guards to select from (list of strings)
     @keyparam activeGuards list of active guards (list of strings)
     @param listOnly flag indicating to only list the guards (boolean)
     @param parent reference to the parent widget (QWidget)
     """
     super(HgQueuesGuardsSelectionDialog, self).__init__(parent)
     self.setupUi(self)
     
     for guard in guards:
         itm = QListWidgetItem(guard, self.guardsList)
         if activeGuards is not None and guard in activeGuards:
             font = itm.font()
             font.setBold(True)
             itm.setFont(font)
     self.guardsList.sortItems()
     
     if listOnly:
         self.buttonBox.button(QDialogButtonBox.Cancel).hide()
         self.guardsList.setSelectionMode(QAbstractItemView.NoSelection)
         self.setWindowTitle(self.tr("Active Guards"))
Exemple #10
0
 def __init__(self, elements,icons):
     self.items = []
     i = 0
     for text,icon in elements:
        
             
         print(text)
         print(icon)
         item = QListWidgetItem()
         if i == 0:
             item.setBackground(QBrush(QColor(66,69,71)))
             item.setFont(QFont("Arial",20))
             item.setText(text)
             sizeHint = item.sizeHint()
             item.setSizeHint(QSize(sizeHint.width(),sizeHint.height()+80))
         elif i % 2:
             item.setBackground(QBrush(QColor(92,89,94)))  
             item.setFont(QFont("Arial",18))
             item.setText(" " + text)
             sizeHint = item.sizeHint()
             item.setSizeHint(QSize(sizeHint.width(),sizeHint.height()+65))
         else:
             item.setBackground(QBrush(QColor(92,85,94)))  
             item.setFont(QFont("Arial",18))
             item.setText(" " + text)
             sizeHint = item.sizeHint()
             item.setSizeHint(QSize(sizeHint.width(),sizeHint.height()+65))
         
         
        
         item.setIcon(QIcon(icons.getIcon(icon)))        
         self.items.append(item)
         i = i + 1
     spacerItem = QListWidgetItem()
     spacerItem.setFlags(Qt.NoItemFlags)
     self.items.append(spacerItem)
Exemple #11
0
    def __init__(self, app):
        self.app = app
        widget = QWidget()
        grid = QGridLayout()
        layout = QHBoxLayout()
        splitter = QSplitter()

        self.jobs = jobsearch.jobSearch()
        queries_dict = self.jobs.create_queries()

        self.list_widget = QListWidget()
        self.web = QWebEngineView()

        job_title_label = QLabel()
        job_title_label.setText("Job title:")
        location_label = QLabel()
        location_label.setText("Location:")
        radius_label = QLabel()
        radius_label.setText("Radius:")

        button = QPushButton()
        button.setText("Search")
        button.clicked.connect(self.on_button_click)

        self.line_edit_jobtitle = QLineEdit()
        self.line_edit_jobtitle.setText(
            self.jobs.search_queries_default['jobtitle'])
        self.line_edit_location = QLineEdit()
        self.line_edit_location.setText(
            self.jobs.search_queries_default['location'])
        self.line_edit_radius = QLineEdit()
        self.line_edit_radius.setText(
            self.jobs.search_queries_default['radius'])

        header_layout_1 = QHBoxLayout()
        header_layout_1.addWidget(button)
        header_layout_1.addWidget(job_title_label)
        header_layout_1.addWidget(self.line_edit_jobtitle)
        header_layout_1.addWidget(location_label)
        header_layout_1.addWidget(self.line_edit_location)
        header_layout_1.addWidget(radius_label)
        header_layout_1.addWidget(self.line_edit_radius)
        grid.addLayout(header_layout_1, 0, 0)

        self.checkbox_monster = QCheckBox("Monster")
        self.checkbox_indeed = QCheckBox("Indeed")
        self.checkbox_stepstone = QCheckBox("Stepstone")

        header_layout_2 = QHBoxLayout()
        header_layout_2.addWidget(self.checkbox_monster)
        header_layout_2.addWidget(self.checkbox_indeed)
        header_layout_2.addWidget(self.checkbox_stepstone)
        grid.addLayout(header_layout_2, 1, 0)

        self.my_font = PyQt5.QtGui.QFont()
        self.my_font.setBold(True)
        self.my_font.setFamily("Arial")
        self.my_font.setPointSize(10)

        for engine in queries_dict:
            page = self.jobs.request_page(queries_dict[engine])
            results = self.jobs.parse_page(page, engine)
            for result in results:
                item = QListWidgetItem()
                item.setFont(self.my_font)
                item.setText('{}\n\t({})'.format(result[0], result[1]))
                item.setData(32, result[2])
                self.list_widget.addItem(item)

        self.web.load(QUrl(self.list_widget.item(0).data(32)))

        self.list_widget.itemActivated.connect(self.load_website_for_list_item)
        self.list_widget.itemClicked.connect(self.load_website_for_list_item)
        self.list_widget.setCurrentItem(self.list_widget.item(0))

        splitter.addWidget(self.list_widget)
        splitter.addWidget(self.web)

        layout.addWidget(splitter)
        grid.addLayout(layout, 2, 0)
        widget.setLayout(grid)
        widget.show()

        self.app.exec_()
Exemple #12
0
    def updateGui(self):
        # update status on GUI
        ##############
        if self.lblStatus != None:
            # set alternating color
            if self.statusCnt % 2:
                self.lblStatus.setStyleSheet('QLabel {background-color: ' +
                                             "lightgreen" +
                                             '; border: 1px solid black}')
            else:
                self.lblStatus.setStyleSheet('QLabel {background-color: ' +
                                             "lightgray" +
                                             '; border: 1px solid black}')
            # set alternating symbol
            self.lblStatus.setText(" " + self.status[self.statusCnt])
            self.statusCnt = (self.statusCnt + 1) % 4

        # update counters
        ##########
        self.statusHostsRequested.setText(
            str(self.sniffer.getNumberOfHostsRequested()))
        self.statusHostsSolved.setText(
            str(self.sniffer.getNumberOfHostsSolved()))
        self.statusHostsFailed.setText(
            str(self.sniffer.getNumberOfHostsFailed()))
        self.statusConnections.setText(
            str(self.sniffer.getNumberOfConnections()))
        self.statusNodes.setText(str(self.sniffer.getNumberOfNodes()))
        self.statusBadNodes.setText(str(self.sniffer.getNumberOfBadNodes()))

        # nodes
        #####
        nodes = self.sniffer.getDictOfNodes()
        if nodes:
            for key, value in nodes.items():
                if key in self.node_dict_gui:
                    # update list with modified item
                    currIdx = self.item_index[key]
                    guiString = str(value)[str(value).find("pos") + 4:]
                    self.listWidgetNodes.item(currIdx).setText(guiString)
                    ##################################
                    if value.killed == True:
                        self.listWidgetNodes.item(currIdx).setBackground(
                            QColor('pink'))
                    elif value.local == True:
                        self.listWidgetNodes.item(currIdx).setBackground(
                            QColor('lightblue'))  # ('blue'))
                    elif value.bad == True:
                        self.listWidgetNodes.item(currIdx).setBackground(
                            QColor('red'))  # ('red'))
                    elif value.host_resolved == False:
                        self.listWidgetNodes.item(currIdx).setBackground(
                            QColor('yellow'))
                    elif value.ping == False:
                        self.listWidgetNodes.item(currIdx).setBackground(
                            QColor('lightyellow'))
                    else:
                        self.listWidgetNodes.item(currIdx).setBackground(
                            QColor('lightgreen'))
                    ##################################
                    font = QFont()
                    if value.conn_established == True:
                        font.setBold(True)
                    else:
                        font.setBold(False)
                    self.listWidgetNodes.item(currIdx).setFont(font)
                    ##################################
                else:
                    # update list with new item
                    new_item = QListWidgetItem()
                    guiString = str(value)[str(value).find("pos") + 4:]
                    new_item.setText(guiString)
                    ##################################
                    if value.killed == True:
                        new_item.setBackground(QColor('pink'))
                    elif value.local == True:
                        new_item.setBackground(
                            QColor('lightblue'))  # ('blue'))
                    elif value.bad == True:
                        new_item.setBackground(QColor('red'))  # ('red'))
                    elif value.host_resolved == False:
                        new_item.setBackground(QColor('yellow'))
                    elif value.ping == False:
                        new_item.setBackground(QColor('lightyellow'))
                    else:
                        new_item.setBackground(QColor('lightgreen'))
                    ##################################
                    font = QFont()
                    if value.conn_established == True:
                        font.setBold(True)
                    else:
                        font.setBold(False)
                    new_item.setFont(font)
                    ##################################
                    self.listWidgetNodes.addItem(new_item)
                    ############
                    # auto-scroll
                    if configuration.AUTO_SCROLL_NODE_LIST:
                        self.listWidgetNodes.scrollToBottom()
                    ############
                    # store dict element: IP -> index to be able to access listWidgetNodes element using IP
                    self.item_index[key] = self.indexCount
                    self.indexCount = self.indexCount + 1

                # new IPs added to combo-box
                #################
                if key not in self.node_dict_gui:
                    self.comboPing.addItem(key)
                    # and select it..to show it..
                    # but only if IP selection option is NOT checked:
                    if self.cbPingIP.isChecked() == False:
                        self.comboPing.setCurrentIndex(self.comboPing.count() -
                                                       1)
                # add/modify node to module dict
                self.node_dict_gui[key] = value

                # add new host (owner name) ?
                #################
                # find Owner Name:
                if str(value.whosip).find("Owner Name:") != -1:
                    startIndex = str(value.whosip).find("Owner Name:") + 14
                    # find comma
                    endIndex = startIndex + str(
                        value.whosip)[startIndex:].find(",")
                    hostTextFromOnwerName = str(
                        value.whosip)[startIndex:endIndex]
                    if hostTextFromOnwerName not in self.listOfHosts:
                        self.listOfHosts.append(hostTextFromOnwerName)
                        self.comboShowHost.addItem(hostTextFromOnwerName)
                        # update text in GUI
                        self.comboShowHost.updateText()

            # create(update) report file
            ##################
            self.createReportFile()
            self.generateIps()

            # update combo-box with current connections
            #########################
            selectedIpTemp = str(self.comboKill.currentText())
            self.comboKill.clear()
            for key, value in self.node_dict_gui.items():
                if value.conn_established:
                    self.comboKill.addItem(key)
                    # and select it..to show it..
                    # but only if IP selection option is NOT checked:
                    if (self.cbKillIP.isChecked()
                            == False) or (key == selectedIpTemp):
                        self.comboKill.setCurrentIndex(self.comboKill.count() -
                                                       1)

        # killed nodes
        ########
        nrKilledNodes = self.sniffer.getNumberOfKilledNodes()
        ####################################
        if nrKilledNodes > self.listWidgetKilledProcesses.count():
            self.statusKilledNodes.setText(str(nrKilledNodes))
            listKilledNodes = self.sniffer.getListOfKilledNodes()
            for i in range(nrKilledNodes -
                           self.listWidgetKilledProcesses.count()):
                new_item = QListWidgetItem()
                new_item.setText(listKilledNodes[nrKilledNodes - i - 1])
                self.listWidgetKilledProcesses.addItem(new_item)
        ####################################
        # TX max limit alarm handling
        #################
        txKiloBytes = self.sniffer.getNumberOfTxKiloBytes()
        if txKiloBytes > configuration.MAX_TX_KILOBYTES:
            if self.toggle == 0:
                self.statusTxBytes.setStyleSheet('color: red')
                self.labelTXBytes.setStyleSheet('color: red')
            else:
                self.statusTxBytes.setStyleSheet('color: black')
                self.labelTXBytes.setStyleSheet('color: black')
            self.toggle = not self.toggle
        self.statusTxBytes.setText(str(txKiloBytes))
        #################
        rxKiloBytes = str(self.sniffer.getNumberOfRxKiloBytes())
        self.statusRxBytes.setText(rxKiloBytes)
Exemple #13
0
 def add_help(self):
     #Load help
     fileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-file']),
         '@\t(Filter only by Files)')
     font = fileItem.font()
     font.setBold(True)
     fileItem.setSizeHint(QSize(20, 30))
     fileItem.setBackground(QBrush(Qt.lightGray))
     fileItem.setForeground(QBrush(Qt.black))
     fileItem.setFont(font)
     self.listWidget.addItem(fileItem)
     classItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-class']),
         '<\t(Filter only by Classes)')
     self.listWidget.addItem(classItem)
     classItem.setSizeHint(QSize(20, 30))
     classItem.setBackground(QBrush(Qt.lightGray))
     classItem.setForeground(QBrush(Qt.black))
     classItem.setFont(font)
     methodItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-function']),
         '>\t(Filter only by Methods)')
     self.listWidget.addItem(methodItem)
     methodItem.setSizeHint(QSize(20, 30))
     methodItem.setBackground(QBrush(Qt.lightGray))
     methodItem.setForeground(QBrush(Qt.black))
     methodItem.setFont(font)
     attributeItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-attributes']),
         '-\t(Filter only by Attributes)')
     self.listWidget.addItem(attributeItem)
     attributeItem.setSizeHint(QSize(20, 30))
     attributeItem.setBackground(QBrush(Qt.lightGray))
     attributeItem.setForeground(QBrush(Qt.black))
     attributeItem.setFont(font)
     thisFileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-on-this-file']),
         '.\t(Filter only by Classes and Methods in this File)')
     font = thisFileItem.font()
     font.setBold(True)
     thisFileItem.setSizeHint(QSize(20, 30))
     thisFileItem.setBackground(QBrush(Qt.lightGray))
     thisFileItem.setForeground(QBrush(Qt.black))
     thisFileItem.setFont(font)
     self.listWidget.addItem(thisFileItem)
     tabsItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-tab']),
         '/\t(Filter only by the current Tabs)')
     font = tabsItem.font()
     font.setBold(True)
     tabsItem.setSizeHint(QSize(20, 30))
     tabsItem.setBackground(QBrush(Qt.lightGray))
     tabsItem.setForeground(QBrush(Qt.black))
     tabsItem.setFont(font)
     self.listWidget.addItem(tabsItem)
     lineItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-line']),
         ':\t(Go to Line)')
     font = lineItem.font()
     font.setBold(True)
     lineItem.setSizeHint(QSize(20, 30))
     lineItem.setBackground(QBrush(Qt.lightGray))
     lineItem.setForeground(QBrush(Qt.black))
     lineItem.setFont(font)
     self.listWidget.addItem(lineItem)
     nonPythonItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-nonpython']),
         '!\t(Filter only by Non Python Files)')
     self.listWidget.addItem(nonPythonItem)
     nonPythonItem.setSizeHint(QSize(20, 30))
     nonPythonItem.setBackground(QBrush(Qt.lightGray))
     nonPythonItem.setForeground(QBrush(Qt.black))
     nonPythonItem.setFont(font)
Exemple #14
0
class LeftTabWidget(QWidget):
    '''左侧选项栏'''
    pointlist = []  #########

    def __init__(self):
        super(LeftTabWidget, self).__init__()
        self.setObjectName('LeftTabWidget')

        self.setWindowTitle('LeftTabWidget')
        self.list_style = ('''
            QListWidget, QListView, QTreeWidget, QTreeView {
                outline: 0px;
            }

            QListWidget {
                min-width: 200px;
                max-width: 200px;
                
                color: White;
                background:#454545;
            }

            QListWidget::Item:selected {
                background: lightGray;
                border-left: 5px solid #EE9A00;
                color: black
            }
            HistoryPanel:hover {
                background: rgb(52, 52, 52);
            }
        ''')

        #####################################################ZL
        self.left = 200
        self.top = 200
        self.width = 1000
        self.height = 800
        self.setGeometry(self.left, self.top, self.width, self.height)
        #####################################################ZL

        self.main_layout = QHBoxLayout(self, spacing=0)  #窗口的整体布局
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        self.left_widget = QListWidget()  #左侧选项列表
        self.left_widget.setStyleSheet(self.list_style)
        self.main_layout.addWidget(self.left_widget)

        self.right_widget = QStackedWidget()
        self.main_layout.addWidget(self.right_widget)

        self._setup_ui()

        f = open('/home/robot/waypoints.xml', 'r')  #############
        pointlist = re.findall(r"(?<=<Name>).+?(?=</Name>)", f.read(),
                               re.S)  ########
        f.close()  #######
        self.comboBox2.addItems(pointlist)  ######

    def _setup_ui(self):
        '''加载界面ui'''

        self.left_widget.currentRowChanged.connect(
            self.right_widget.setCurrentIndex)  #list和右侧窗口的index对应绑定

        self.left_widget.setFrameShape(QListWidget.NoFrame)  #去掉边框

        self.left_widget.setVerticalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)  #隐藏滚动条
        self.left_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        list_str = [
            '功能选择', '扫地', '导航', '取物', '关于MOSS', '使用方法', '注意事项', '硬件设置',
            '联系与帮助', '遇到问题', '联系lzz'
        ]

        for i in range(11):
            self.item = QListWidgetItem(list_str[i],
                                        self.left_widget)  #左侧选项的添加
            self.item.setFont(QFont("等线", 11))
            if i == 0 or i == 4 or i == 8:
                self.item.setBackground(QColor('#EE9A00'))
                self.item.setFont(QFont("等线", 13, QFont.Bold))
                if i == 0:
                    self.item.setIcon(
                        qtawesome.icon('fa.hand-pointer-o', color='white'))
                elif i == 4:
                    self.item.setIcon(qtawesome.icon('fa.tags', color='white'))
                elif i == 8:
                    self.item.setIcon(
                        qtawesome.icon('fa.envelope', color='white'))

            self.item.setSizeHint(QSize(60, 65))
            self.item.setTextAlignment(Qt.AlignCenter)  #居中显示

            if i == 1:
                self.centralWidget1 = QtWidgets.QWidget()
                self.centralWidget1.setStyleSheet(
                    '''background:black;border-width:0;''')
                self.layout1 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget1.setLayout(self.layout1)

                self.edit1_1 = QtWidgets.QLineEdit()
                self.edit1_1.setPlaceholderText("请输入速度(两位小数,0.0-1.0)")
                self.edit1_1.setStyleSheet(
                    '''color:white;background:transparent;border-width:0;
                                                border-style:outset;border-bottom:1px solid white;
                                                font-size:20px; font-family:等线;'''
                )
                self.vel_reg = QRegExp(r"^(0)|(0\.[0-9])|(1)|(1\.0)$")
                self.vel_validator = QRegExpValidator(self.vel_reg,
                                                      self.edit1_1)
                self.edit1_1.setValidator(self.vel_validator)

                self.edit1_2 = QtWidgets.QLineEdit()
                self.edit1_2.setPlaceholderText("请输入时间(三位整数)")
                self.edit1_2.setStyleSheet(
                    '''color:white;background:transparent;border-width:0;
                                                border-style:outset;border-bottom:1px solid white;
                                                font-size:20px; font-family:等线;'''
                )
                self.time_reg = QRegExp("^[0-9]{3}$")
                self.time_validator = QRegExpValidator(self.time_reg,
                                                       self.edit1_2)
                self.edit1_2.setValidator(self.time_validator)

                self.label1_1 = QtWidgets.QLabel()  #设置label
                self.label1_1.setTextFormat(QtCore.Qt.AutoText)
                self.label1_1.setText("速度")
                self.label1_1.setStyleSheet(
                    '''color:white;font-size:23px; font-family:等线;''')
                self.label1_1.setAlignment(Qt.AlignCenter)

                self.label1_2 = QtWidgets.QLabel()
                self.label1_2.setTextFormat(QtCore.Qt.AutoText)
                self.label1_2.setText("时间")
                self.label1_2.setStyleSheet(
                    '''color:white;font-size:23px; font-family:等线;''')
                self.label1_2.setAlignment(Qt.AlignCenter)

                self.label1_3 = QtWidgets.QLabel()
                self.label1_3.setTextFormat(QtCore.Qt.AutoText)
                self.label1_3.setText("扫地")
                self.label1_3.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(100,100,100,80;background:#454545);
                                                font-family:等线;''')
                self.label1_3.setAlignment(Qt.AlignCenter)

                self.button1 = QtWidgets.QPushButton()
                self.button1.setText("开始")
                self.button1.setFixedSize(100, 40)
                self.button1.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:10px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button1.clicked.connect(self.button1_1click)

                self.layout1.setColumnStretch(0, 2)
                self.layout1.setColumnStretch(1, 2)
                self.layout1.setColumnStretch(2, 2)
                self.layout1.setColumnStretch(3, 2)
                self.layout1.setColumnStretch(5, 2)
                self.layout1.setColumnStretch(6, 2)
                self.layout1.setColumnStretch(7, 2)
                self.layout1.setColumnStretch(8, 2)
                self.layout1.setColumnStretch(4, 1)

                self.layout1.addWidget(self.label1_3, 0, 0, 1, 9)
                self.layout1.addWidget(self.label1_1, 4, 2, 2, 2)
                self.layout1.addWidget(self.label1_2, 6, 2, 2, 2)
                self.layout1.addWidget(self.edit1_1, 4, 4, 2, 3)
                self.layout1.addWidget(self.edit1_2, 6, 4, 2, 3)
                self.layout1.addWidget(self.button1, 9, 4, 2, 2)
                self.right_widget.addWidget(self.centralWidget1)

            elif i == 2:
                self.centralWidget2 = QtWidgets.QWidget()

                self.centralWidget2.setStyleSheet(
                    '''background:black;border-width:0;''')
                self.layout2 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget2.setLayout(self.layout2)

                self.button2_1 = QtWidgets.QPushButton(self.centralWidget2)
                #self.button2_1.setGeometry(QtCore.QRect(210, 110, 100, 60))
                self.button2_1.setObjectName("button1")
                self.button2_1.setText("构建地图")
                self.button2_1.clicked.connect(self.button2_1click)
                self.button2_1.setFixedSize(200, 80)
                self.button2_1.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )

                self.button2_2 = QtWidgets.QPushButton(self.centralWidget2)
                #self.button2_2.setGeometry(QtCore.QRect(350, 110, 100, 60))
                self.button2_2.setObjectName("button2")
                self.button2_2.setText("保存地图")
                self.button2_2.clicked.connect(self.button2_2click)
                self.button2_2.setFixedSize(200, 80)
                self.button2_2.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )

                self.button2_3 = QtWidgets.QPushButton(self.centralWidget2)
                #self.button2_3.setGeometry(QtCore.QRect(210, 210, 100, 60))
                self.button2_3.setObjectName("button3")
                self.button2_3.setText("设立航点")
                self.button2_3.clicked.connect(self.button2_3click)
                self.button2_3.setFixedSize(200, 80)
                self.button2_3.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )

                self.button2_4 = QtWidgets.QPushButton(self.centralWidget2)
                #self.button2_4.setGeometry(QtCore.QRect(350, 210, 100, 60))
                self.button2_4.setObjectName("button4")
                self.button2_4.setText("保存航点")
                self.button2_4.clicked.connect(self.button2_4click)
                self.button2_4.setFixedSize(200, 80)
                self.button2_4.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )

                self.button2_5 = QtWidgets.QPushButton(self.centralWidget2)
                #self.button2_5.setGeometry(QtCore.QRect(210, 310, 240, 60))
                self.button2_5.setObjectName("button5")
                self.button2_5.setText("开始导航")
                self.button2_5.clicked.connect(self.button2_5click)
                self.button2_5.setFixedSize(466, 80)
                self.button2_5.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )

                self.comboBox2 = QtWidgets.QComboBox(self.centralWidget2)
                #self.comboBox2.setGeometry(QtCore.QRect(210, 410, 100, 30))
                self.comboBox2.setObjectName("comboBox")
                #self.comboBox2.addItems(self.pointlist)
                self.comboBox2.setFixedSize(200, 50)
                self.comboBox2.setStyleSheet(
                    '''QComboBox{background:#EE9A00;border-radius:10px;font-family:等线;
                                               font-size:18px;color:white}QComboBox:hover{background:#EEDC82;}'''
                )

                self.button2_6 = QtWidgets.QPushButton(self.centralWidget2)
                #self.button2_6.setGeometry(QtCore.QRect(350, 410, 100, 30))
                self.button2_6.setObjectName("button6")
                self.button2_6.setText("G O !")
                self.button2_6.clicked.connect(self.button2_6click)
                self.button2_6.setFixedSize(200, 50)
                self.button2_6.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )

                self.label2_1 = QtWidgets.QLabel()
                self.label2_1.setTextFormat(QtCore.Qt.AutoText)
                self.label2_1.setText("导航")
                self.label2_1.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(100,100,100,100);
                                                font-family:等线;''')
                self.label2_1.setAlignment(Qt.AlignCenter)

                self.layout2.setColumnStretch(0, 1)
                self.layout2.setColumnStretch(1, 1)
                self.layout2.setColumnStretch(2, 1)
                self.layout2.setColumnStretch(3, 1)
                self.layout2.setColumnStretch(4, 1)
                self.layout2.setColumnStretch(5, 1)
                self.layout2.setColumnStretch(6, 1)
                self.layout2.setColumnStretch(7, 1)
                self.layout2.setColumnStretch(8, 1)
                self.layout2.setColumnStretch(9, 1)
                self.layout2.setColumnStretch(10, 1)
                self.layout2.setColumnStretch(11, 1)
                self.layout2.setColumnStretch(12, 1)

                self.layout2.addWidget(self.label2_1, 0, 0, 1, 13)
                self.layout2.addWidget(self.button2_1, 2, 3, 2, 3)
                self.layout2.addWidget(self.button2_2, 2, 7, 2, 3)
                self.layout2.addWidget(self.button2_3, 6, 3, 2, 3)
                self.layout2.addWidget(self.button2_4, 6, 7, 2, 3)
                self.layout2.addWidget(self.button2_5, 10, 3, 2, 7)
                self.layout2.addWidget(self.button2_6, 14, 7, 2, 3)
                self.layout2.addWidget(self.comboBox2, 14, 3, 2, 3)

                self.right_widget.addWidget(self.centralWidget2)

            else:
                self.centralWidget0 = QtWidgets.QWidget()
                self.centralWidget0.setStyleSheet(
                    '''background:white;border-width:0;''')
                self.right_widget.addWidget(self.centralWidget0)

    def button1_1click(self):
        vel = 0
        time = 0

        if self.edit1_1.text() == "":
            vel = 0.5
        else:
            vel = float(self.edit1_1.text())

        if self.edit1_2.text() == "":
            time = 60
        else:
            time = int(self.edit1_2.text())

        self.setConfig(vel, time)

        os.system(free_walk_cmd)

    def setConfig(self, vel, time):
        vel_pattern = re.compile(vel_config)
        time_pattern = re.compile(time_config)

        with open(config_path, "w") as f:
            f.truncate()
            f.write(str(vel))
            f.write("\n")
            f.write(str(time))

    def button2_1click(self):
        print("roslaunch wpb_home_tutorials gmapping.launch")
        #os.system("roslaunch wpb_home_tutorials gmapping.launch")
        os.system(
            "gnome-terminal -e 'bash -c \"roslaunch wpb_home_tutorials gmapping.launch\"'"
        )
        #os.system("gnome-terminal -e 'bash -c \"ls\"'")
        #os.system("gnome-terminal -e 'bash -c \"roslaunch wpb_home_tutorials gmapping.launch; exec bash\"'")
    def button2_2click(self):
        print("rosrun map_server map_saver -f map")
        os.system(
            "gnome-terminal -e 'bash -c \"rosrun map_server map_saver -f map&&cp /home/robot/catkin_ws/src/team_201/map.yaml /home/robot/catkin_ws/src/wpb_home/wpb_home_tutorials/maps/map.yaml&&cp /home/robot/catkin_ws/src/team_201/map.pgm /home/robot/catkin_ws/src/wpb_home/wpb_home_tutorials/maps/map.pgm\"'"
        )  ##yidong

#save in the main dir
#print("移动指令")
#may be we do not need to really change the map path, because we can change the map path in some launch files
#such as, in add_waypoint.launch, we can change
#args="$(find wpb_home_tutorials)/maps/map.yaml"/>
#into
#args="/home/robot/map.yaml"/>

    def button2_3click(self):
        print("roslaunch waterplus_map_tools add_waypoint.launch")
        os.system(
            "gnome-terminal -e 'bash -c \"roslaunch waterplus_map_tools add_waypoint.launch\"'"
        )
        ###???????????????????????????????????
    def button2_4click(self):
        print("rosrun waterplus_map_tools wp_saver")
        os.system(
            "gnome-terminal -e 'bash -c \"cd /home/robot/&&rosrun waterplus_map_tools wp_saver\"'"
        )
        time.sleep(2)
        #os.system("rosrun waterplus_map_tools wp_saver")
        #os.system("gnome-terminal -e 'bash -c \"rosrun waterplus_map_tools wp_saver; exec bash\"'")
        #save waypoints.xml into /home/robot/
        self.comboBox2.clear()
        f = open('/home/robot/waypoints.xml', 'r')
        pointlist = re.findall(r"(?<=<Name>).+?(?=</Name>)", f.read(), re.S)
        print(pointlist)
        self.comboBox2.addItems(pointlist)
        f.close()

    def button2_5click(self):
        print("roslaunch wpb_home_apps 6_path_plan.launch")
        os.system(
            "gnome-terminal -e 'bash -c \"roslaunch wpb_home_apps 6_path_plan.launch; exec bash\"'"
        )

    def button2_6click(self):
        print(self.comboBox2.currentIndex() + 1)
        #get to the chosed point
        pointoutput = open('/home/robot/point.txt', 'w')
        pointoutput.write(str(self.comboBox2.currentIndex() + 1))
        pointoutput.close()
Exemple #15
0
    def initUI(self):
        """# Global """
        self.setWindowTitle('Option')
        self.setFixedSize(800, 450)

        self.list_option = QListWidget(self)
        self.stack_window = QStackedWidget(self)

        self.style_list_option = "QListWidget{\
                                min-width: 120px;\
                                max-width: 120px;\
                                color: white;\
                                background: grey;}"

        self.style_groupbox = "QGroupBox{\
                               border: None;}"

        self.style_groupbox_font = "QGroupBox{\
                                    font-family: MonoxRegular;\
                                    font-size: 20px;}"

        layout_main = QHBoxLayout(spacing=0)
        layout_main.setContentsMargins(0, 0, 0, 0)

        layout_main.addWidget(self.list_option)
        layout_main.addWidget(self.stack_window)
        self.setLayout(layout_main)

        self.list_option.setStyleSheet(self.style_list_option)
        """# List Option"""
        self.list_option.setFrameShape(QListWidget.NoFrame)
        self.list_option.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.list_option.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self.list_option.currentRowChanged.connect(
            self.stack_window.setCurrentIndex)

        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(20)

        item = QListWidgetItem()
        item.setFont(font)
        item.setText('DIY')
        item.setSizeHint(QSize(0, 60))
        item.setTextAlignment(Qt.AlignCenter)
        self.list_option.addItem(item)

        item = QListWidgetItem()
        item.setFont(font)
        item.setText('PRO')
        item.setSizeHint(QSize(0, 60))
        item.setTextAlignment(Qt.AlignCenter)
        self.list_option.addItem(item)

        self.page0_pre()
        self.page0tab0()
        self.page0tab1()
        self.page0global()
        self.page1_pre()
        self.page1tab0()
        self.page1tab1()
        self.page1global()
Exemple #16
0
    def plot_data(self):
        today = date.today() if config.環境 == "本番" else config.デバッグ日付

        if self.提供日 is None:  #デフォルトでは今日発注のものを表示
            self.注文リスト = find注文発注日(today, self.社員.社員番号)
            if len(self.注文リスト) > 0:
                self.提供日 = self.注文リスト[0].提供日
            else:  #今日注文したものがない場合は翌日提供日のメニューを出すのがデフォルト
                self.提供日 = today + timedelta(days=1)
        else:
            self.注文リスト = find注文提供日(self.提供日, self.社員.社員番号)

        #締切時間表示
        if self.提供日 == today + timedelta(days=1):
            self.ui.labelDeadLine.setVisible(True)
            self.ui.labelDeadLine.setText(
                f"発注締切時刻: {time.strftime(config.発注締切時刻, '%H時%M分')}")
        else:
            self.ui.labelDeadLine.setVisible(False)

        self.メニューリスト = findメニュー提供日(self.提供日)

        self.ui.labelToday.setText(date.strftime(self.提供日, '%m月%d日(%a)'))
        self.ui.labelStaffName.setText(self.社員.社員名称)

        self.ui.listMorning.clear()
        self.ui.listLunch.clear()

        for 食事種類 in 食事種類型:  #朝、昼でそれぞれメニューを抽出してループ処理
            抽出メニューリスト = list(filter(lambda メニュー: メニュー.種類 == 食事種類,
                                    self.メニューリスト))

            #提供時刻表示
            targetLabel = self.ui.labelMorningTime if 食事種類 == 食事種類型.朝食 else self.ui.labelLunchTime
            if len(抽出メニューリスト) > 0:
                (開始時刻, _) = find提供時刻(self.社員, 抽出メニューリスト[0])
                targetLabel.setText(time.strftime(開始時刻, '%H:%M'))
            else:
                targetLabel.setText("")

            for メニュー in 抽出メニューリスト:
                menuItem = QListWidgetItem(メニュー.内容)
                menuItem.setFont(QFont(QFont().defaultFamily(), 48))
                注文検索結果 = list(
                    filter(lambda 注文: 注文.メニューID == メニュー.メニューID, self.注文リスト))
                if len(注文検索結果) > 0:  #注文あり
                    self.setStatus(menuItem, checkStatus.On)
                else:  #注文なし
                    self.setStatus(menuItem, checkStatus.Off)

                #カロリー、食塩などの情報行
                最大提供数表示 = ""
                if not メニュー.isUnlimit:
                    最大提供数表示 = f"最大提供数:{メニュー.最大提供数}"
                extraInfoItem = QListWidgetItem(
                    f"カロリー:{メニュー.カロリー}kcal 食塩:{メニュー.食塩}g 注文数:{self.getCurrentOrderAmount(メニュー)} {最大提供数表示}   "
                )
                extraInfoItem.setFont(QFont(QFont().defaultFamily(), 20))
                extraInfoItem.setTextAlignment(Qt.AlignRight)
                extraInfoItem.setFlags(Qt.ItemIsEnabled)

                blankItem = QListWidgetItem("")
                blankItem.setFont(QFont(QFont().defaultFamily(), 14))
                blankItem.setFlags(menuItem.flags() ^ Qt.ItemIsSelectable)

                #注文可能数を超えてないか確認
                if self.isOrderLimit(メニュー) and not self.isAlreadyOrder(メニュー):
                    menuItem.setFlags(menuItem.flags() ^ Qt.ItemIsEnabled)
                    extraInfoItem.setFlags(extraInfoItem.flags()
                                           ^ Qt.ItemIsEnabled)
                else:
                    menuItem.setData(Qt.UserRole, メニュー.内容)  # hidden data

                targetList = self.ui.listMorning if 食事種類 == 食事種類型.朝食 else self.ui.listLunch
                targetList.addItem(menuItem)
                targetList.addItem(extraInfoItem)
                targetList.addItem(blankItem)
Exemple #17
0
def cmd_whisper(view, sender, content):
    item = QListWidgetItem(f"[Message privé de {sender}] {content}")
    item.setFont(QtGui.QFont('Tahoma', 8, QtGui.QFont.Bold))
    return item
Exemple #18
0
    def initUI(self):
        self.setWindowTitle('Graph')
        self.setFixedSize(1000, 800)

        self.list_channel = QListWidget(self)
        self.stack_window = QStackedWidget(self)
        self.channel_monitor = QWidget()
        self.graph_control = QWidget()

        layout_main = QHBoxLayout(spacing=0)
        layout_main.setContentsMargins(0, 0, 0, 0)

        layout_main.addWidget(self.list_channel)
        layout_main.addWidget(self.stack_window)
        layout_main.addWidget(self.channel_monitor)
        layout_main.addWidget(self.graph_control)

        self.setLayout(layout_main)

        """# List Channel"""
        self.list_channel.setFrameShape(QListWidget.NoFrame)
        self.list_channel.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.list_channel.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.list_channel.currentRowChanged.connect(self.stack_window.setCurrentIndex)

        self.list_channel.setStyleSheet("""
                                       QListWidget{
                                       min-width: 150px;
                                       max-width: 150px;
                                       color: white;
                                       background: grey;
                                       }
                                       """)

        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(20)

        for i in range(6):
            item = QListWidgetItem()
            item.setFont(font)
            item.setText('%03d - %03d' % (32*i + 1, 32*(i + 1)))
            item.setSizeHint(QSize(0, 60))
            item.setTextAlignment(Qt.AlignCenter)
            self.list_channel.addItem(item)
        item = QListWidgetItem()
        item.setFont(font)
        item.setText('Custom')
        item.setSizeHint(QSize(0, 60))
        item.setTextAlignment(Qt.AlignCenter)
        self.list_channel.addItem(item)

        """# Stack Window"""
        self.list_page_widget = []
        self.list_graph_show = []
        self.list_layout_page = []
        self.list_tabwidget = []

        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')
        list_stringaxis = []

        for i in range(7):
            list_stringaxis.append(CustomAxis({1:'a', 2: 'b'}, orientation='left'))
            self.list_page_widget.append(QWidget())
            self.list_graph_show.append(PlotWidgetCol(axisItems={'left':list_stringaxis[i]}))
            self.list_layout_page.append(QHBoxLayout())
            self.list_layout_page[i].setContentsMargins(0, 0, 0, 0)
            self.list_tabwidget.append(QTabWidget())

        for i in range(7):
            self.list_page_widget[i].setLayout(self.list_layout_page[i])
            self.list_layout_page[i].addWidget(self.list_tabwidget[i])
            self.stack_window.addWidget(self.list_page_widget[i])
            tab_graph = QWidget()
            tab_monitor = QWidget()
            self.list_tabwidget[i].addTab(tab_graph, 'Graph')
            self.list_tabwidget[i].addTab(tab_monitor, 'Monitor')
            layout_page = QHBoxLayout()
            layout_graph = QHBoxLayout()
            layout_graph.addWidget(self.list_graph_show[i])
            tab_graph.setLayout(layout_graph)
            layout_monitor = QGridLayout()
            tab_monitor.setLayout(layout_monitor)

        tab_custom_option = QWidget()
        layout_tab_custom_option = QVBoxLayout()
        tab_custom_option.setLayout(layout_tab_custom_option)
        self.list_tabwidget[6].addTab(tab_custom_option, 'Select')

        """# Page Custom Tab Select"""
        layout_tab_custom_option_up = QHBoxLayout()
        layout_tab_custom_option_mid = QHBoxLayout()
        layout_tab_custom_option_down = QHBoxLayout()
        layout_tab_custom_option.addLayout(layout_tab_custom_option_up)
        layout_tab_custom_option.addLayout(layout_tab_custom_option_mid)
        layout_tab_custom_option.addLayout(layout_tab_custom_option_down)

        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(12)

        label_custom_select_num = QLabel('Profile ID        ')
        label_custom_select_num.setFont(font)

        self.label_custom_select_num = QLabel('00 / 32')
        self.label_custom_select_num.setFont(font)
        self.lineedit_custom_select_num = QLineEdit(16*'0' + '-' + 16*'0' + '-' + 16*'0')
        self.lineedit_custom_select_num.setFont(font)
        self.data_lineedit_custom_select_num = self.lineedit_custom_select_num.text()

        self.pushbutton_custom_select_num = QPushButton('&Ok')

        layout_tab_custom_option_up.addWidget(label_custom_select_num)
        layout_tab_custom_option_up.addWidget(self.lineedit_custom_select_num)
        layout_tab_custom_option_up.addWidget(self.pushbutton_custom_select_num)
        layout_tab_custom_option_down.addStretch(1)
        layout_tab_custom_option_down.setAlignment(Qt.AlignBottom)
        layout_tab_custom_option_down.addWidget(self.label_custom_select_num)

        groupbox_custom_option_channel_a = QGroupBox('A')
        groupbox_custom_option_channel_a.setAlignment(Qt.AlignCenter)
        groupbox_custom_option_channel_a.setStyleSheet("""
                                                     QGroupBox{
                                                     font-family: MonoxRegular;
                                                     font-size: 20px;
                                                     }
                                                     """)
        groupbox_custom_option_channel_b = QGroupBox('B')
        groupbox_custom_option_channel_b.setAlignment(Qt.AlignCenter)
        groupbox_custom_option_channel_b.setStyleSheet("""
                                                     QGroupBox{
                                                     font-family: MonoxRegular;
                                                     font-size: 20px;
                                                     }
                                                     """)
        groupbox_custom_option_channel_c = QGroupBox('C')
        groupbox_custom_option_channel_c.setAlignment(Qt.AlignCenter)
        groupbox_custom_option_channel_c.setStyleSheet("""
                                                     QGroupBox{
                                                     font-family: MonoxRegular;
                                                     font-size: 20px;
                                                     }
                                                     """)
        self.list_checkbox_channel = []
        for i in range(192):
            checkbox_select = QCheckBox('%03i' % (i + 1))
            checkbox_select.setStyleSheet("""
                                          QCheckBox{
                                          font-family: MonoxRegular;
                                          font-size: 15px;
                                          }
                                          """)
            self.list_checkbox_channel.append(checkbox_select)

        layout_tab_custom_option_mid.addWidget(groupbox_custom_option_channel_a)
        layout_tab_custom_option_mid.addWidget(groupbox_custom_option_channel_b)
        layout_tab_custom_option_mid.addWidget(groupbox_custom_option_channel_c)

        list_layout_custom_option_channel_global = []
        for i in range(3):
            list_layout_custom_option_channel_global.append(QHBoxLayout())

        groupbox_custom_option_channel_a.setLayout(list_layout_custom_option_channel_global[0])
        groupbox_custom_option_channel_b.setLayout(list_layout_custom_option_channel_global[1])
        groupbox_custom_option_channel_c.setLayout(list_layout_custom_option_channel_global[2])

        list_layout_custom_option_channel = []

        num = 12
        for i in range(num):
            list_layout_custom_option_channel.append(QVBoxLayout())
            list_layout_custom_option_channel[i].setAlignment(Qt.AlignCenter)

        for i in range(3):
            for j in range(num // 3):
                list_layout_custom_option_channel_global[i].addLayout(list_layout_custom_option_channel[(num // 3)*i + j])

        for i in range(num):
            for j in range(192 // num):
                list_layout_custom_option_channel[i].addWidget(self.list_checkbox_channel[(192 // num)*i + j])

        layout_graph_control = QVBoxLayout()
        layout_graph_control.setAlignment(Qt.AlignBottom)
        #layout_graph_control.setSpacing()
        self.graph_control.setLayout(layout_graph_control)

        self.lcdnumber_countdown = QLCDNumber()
        self.lcdnumber_countdown.setDigitCount(4)
        self.lcdnumber_countdown.setMode(QLCDNumber.Dec)
        self.lcdnumber_countdown.setSegmentStyle(QLCDNumber.Flat)
        self.lcdnumber_countdown.setStyleSheet("""
                                               QLCDNumber{
                                               min-width: 150px;
                                               max-width: 150px;
                                               min-height: 80px;
                                               max-height: 80px;
                                               }
                                               """)
        layout_graph_control.addWidget(self.lcdnumber_countdown)

        self.lcdnumber_countdown_num = QLCDNumber()
        self.lcdnumber_countdown_num.setDigitCount(4)
        self.lcdnumber_countdown_num.setMode(QLCDNumber.Dec)
        self.lcdnumber_countdown_num.setSegmentStyle(QLCDNumber.Flat)
        self.lcdnumber_countdown_num.setStyleSheet("""
                                               QLCDNumber{
                                               min-width: 150px;
                                               max-width: 150px;
                                               min-height: 80px;
                                               max-height: 80px;
                                               }
                                               """)
        layout_graph_control.addWidget(self.lcdnumber_countdown_num)

        self.pushbutton_graph_save = QPushButton('Save')
        self.pushbutton_graph_save.setStyleSheet("""
                                                 QPushButton{
                                                 min-width: 150px;
                                                 min-height: 60px;
                                                 }
                                                 """)
        widget_control_button = QWidget()
        widget_control_button.setStyleSheet("""
                                            QWidget{
                                            min-height: 300px;
                                            }
                                            """)
        layout_graph_control_button = QVBoxLayout()
        widget_control_button.setLayout(layout_graph_control_button)
        layout_graph_control_button.setAlignment(Qt.AlignBottom)
        layout_graph_control_button.addWidget(self.pushbutton_graph_save)
        layout_graph_control.addWidget(widget_control_button)
Exemple #19
0
class LeftTabWidget(QWidget):
    '''左侧选项栏'''
    pointlist = []  #########
    renameIndex = 1

    def __init__(self):
        super(LeftTabWidget, self).__init__()
        self.setObjectName('LeftTabWidget')

        self.setWindowTitle('LeftTabWidget')
        self.list_style = ('''
            QListWidget, QListView, QTreeWidget, QTreeView {
                outline: 0px;
            }
            QListWidget {
                min-width: 200px;
                max-width: 200px;
                
                color: White;
                background:#454545                            }
            QListWidget::Item:selected {
                background: lightGray;
                border-left: 5px solid #EE9A00;
                color: black
            }
            HistoryPanel:hover {
                background: rgb(52, 52, 52);
            }
        ''')

        #####################################################ZL
        self.left = 200
        self.top = 200
        self.width = 1000
        self.height = 800
        self.setGeometry(self.left, self.top, self.width, self.height)
        #####################################################ZL

        self.main_layout = QHBoxLayout(self, spacing=0)  #窗口的整体布局
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        self.left_widget = QListWidget()  #左侧选项列表
        self.left_widget.setStyleSheet(self.list_style)
        self.main_layout.addWidget(self.left_widget)

        self.right_widget = QStackedWidget()
        self.main_layout.addWidget(self.right_widget)

        self._setup_ui()
        '''
        if os.path.exists('/home/robot/waypoints.xml') == False :
            file = open('/home/robot/waypoints.xml','w')
            file.write('<Waterplus>\n</Waterplus>')
            file.close()
        f=open('/home/robot/waypoints.xml', 'r')#############
        pointlist=re.findall(r"(?<=<Name>).+?(?=</Name>)", f.read(), re.S)########
        f.close()#######
        self.comboBox2.addItems(pointlist)######
        '''

    def _setup_ui(self):
        '''加载界面ui'''

        self.left_widget.currentRowChanged.connect(
            self.right_widget.setCurrentIndex)  #list和右侧窗口的index对应绑定

        self.left_widget.setFrameShape(QListWidget.NoFrame)  #去掉边框

        self.left_widget.setVerticalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)  #隐藏滚动条
        self.left_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        list_str = [
            '功能选择', '扫地', '导航', '取物', '关于MOSS', '使用方法', '注意事项', '硬件设置',
            '联系与帮助', '遇到问题', '联系我们'
        ]

        for i in range(11):
            self.item = QListWidgetItem(list_str[i],
                                        self.left_widget)  #左侧选项的添加
            self.item.setFont(QFont("等线", 11))
            if i == 0 or i == 4 or i == 8:
                self.item.setBackground(QColor('#EE9A00'))
                self.item.setFont(QFont("等线", 13, QFont.Bold))
                if i == 0:
                    self.item.setIcon(
                        qtawesome.icon('fa.hand-pointer-o', color='white'))
                elif i == 4:
                    self.item.setIcon(qtawesome.icon('fa.tags', color='white'))
                elif i == 8:
                    self.item.setIcon(
                        qtawesome.icon('fa.envelope', color='white'))

            self.item.setSizeHint(QSize(60, 65))
            self.item.setTextAlignment(Qt.AlignCenter)  #居中显示

            if i == 1:
                self.centralWidget1 = QtWidgets.QWidget()
                self.centralWidget1.setStyleSheet(
                    '''background:black;border-width:0;''')
                self.layout1 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget1.setLayout(self.layout1)

                self.edit1_1 = QtWidgets.QLineEdit()
                self.edit1_1.setPlaceholderText("请输入速度(两位小数,0.0-1.0)")
                self.edit1_1.setStyleSheet(
                    '''color:white;background:transparent;border-width:0;
                                                border-style:outset;border-bottom:1px solid white;
                                                font-size:20px; font-family:等线;'''
                )
                self.vel_reg = QRegExp(r"^(0)|(0\.[0-9])|(1)|(1\.0)$")
                self.vel_validator = QRegExpValidator(self.vel_reg,
                                                      self.edit1_1)
                self.edit1_1.setValidator(self.vel_validator)

                self.edit1_2 = QtWidgets.QLineEdit()
                self.edit1_2.setPlaceholderText("请输入时间(三位整数)")
                self.edit1_2.setStyleSheet(
                    '''color:white;background:transparent;border-width:0;
                                                border-style:outset;border-bottom:1px solid white;
                                                font-size:20px; font-family:等线;'''
                )
                self.time_reg = QRegExp("^[0-9]{3}$")
                self.time_validator = QRegExpValidator(self.time_reg,
                                                       self.edit1_2)
                self.edit1_2.setValidator(self.time_validator)

                self.label1_1 = QtWidgets.QLabel()  #设置label
                self.label1_1.setTextFormat(QtCore.Qt.AutoText)
                self.label1_1.setText("速度")
                self.label1_1.setStyleSheet(
                    '''color:white;font-size:23px; font-family:等线;''')
                self.label1_1.setAlignment(Qt.AlignCenter)

                self.label1_2 = QtWidgets.QLabel()
                self.label1_2.setTextFormat(QtCore.Qt.AutoText)
                self.label1_2.setText("时间")
                self.label1_2.setStyleSheet(
                    '''color:white;font-size:23px; font-family:等线;''')
                self.label1_2.setAlignment(Qt.AlignCenter)

                self.label1_3 = QtWidgets.QLabel()
                self.label1_3.setTextFormat(QtCore.Qt.AutoText)
                self.label1_3.setText("扫地")
                self.label1_3.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(100,100,100,80;background:#454545);
                                                font-family:等线;''')
                self.label1_3.setAlignment(Qt.AlignCenter)

                self.button1 = QtWidgets.QPushButton()
                self.button1.setText("开始")
                self.button1.setFixedSize(100, 40)
                self.button1.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:10px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button1.clicked.connect(self.button1_1click)

                self.layout1.setColumnStretch(0, 2)
                self.layout1.setColumnStretch(1, 2)
                self.layout1.setColumnStretch(2, 2)
                self.layout1.setColumnStretch(3, 2)
                self.layout1.setColumnStretch(5, 2)
                self.layout1.setColumnStretch(6, 2)
                self.layout1.setColumnStretch(7, 2)
                self.layout1.setColumnStretch(8, 2)
                self.layout1.setColumnStretch(4, 1)

                self.layout1.addWidget(self.label1_3, 0, 0, 1, 9)
                self.layout1.addWidget(self.label1_1, 4, 2, 2, 2)
                self.layout1.addWidget(self.label1_2, 6, 2, 2, 2)
                self.layout1.addWidget(self.edit1_1, 4, 4, 2, 3)
                self.layout1.addWidget(self.edit1_2, 6, 4, 2, 3)
                self.layout1.addWidget(self.button1, 9, 4, 2, 2)
                self.right_widget.addWidget(self.centralWidget1)

            elif i == 2:
                self.centralWidget2 = QtWidgets.QWidget()

                self.centralWidget2.setStyleSheet(
                    '''background:black;border-width:0;''')
                self.layout2 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget2.setLayout(self.layout2)

                self.button2_1 = QtWidgets.QPushButton(self.centralWidget2)
                self.button2_1.setObjectName("button1")
                self.button2_1.setText("构建地图")
                self.button2_1.clicked.connect(self.button2_1click)
                self.button2_1.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button2_1.setFixedHeight(40)

                self.button2_2 = QtWidgets.QPushButton(self.centralWidget2)
                self.button2_2.setObjectName("button2")
                self.button2_2.setText("保存地图")
                self.button2_2.clicked.connect(self.button2_2click)
                self.button2_2.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button2_2.setFixedHeight(40)

                self.button2_3 = QtWidgets.QPushButton(self.centralWidget2)
                self.button2_3.setObjectName("button3")
                self.button2_3.setText("设立航点")
                self.button2_3.clicked.connect(self.button2_3click)
                self.button2_3.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button2_3.setFixedHeight(40)

                self.button2_4 = QtWidgets.QPushButton(self.centralWidget2)
                self.button2_4.setObjectName("button4")
                self.button2_4.setText("保存航点")
                self.button2_4.clicked.connect(self.button2_4click)
                self.button2_4.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button2_4.setFixedHeight(40)

                self.button2_5 = QtWidgets.QPushButton(self.centralWidget2)
                self.button2_5.setObjectName("button5")
                self.button2_5.setText("开始导航")
                self.button2_5.clicked.connect(self.button2_5click)
                self.button2_5.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button2_5.setFixedHeight(40)

                self.comboBox2 = QtWidgets.QComboBox(self.centralWidget2)
                self.comboBox2.setObjectName("comboBox")
                self.comboBox2.setStyleSheet(
                    '''QComboBox{background:#EE9A00;border-radius:10px;font-family:等线;
                                               font-size:18px;color:white}QComboBox:hover{background:#EEDC82;}'''
                )
                self.comboBox2.setFixedHeight(40)

                self.button2_6 = QtWidgets.QPushButton(self.centralWidget2)
                self.button2_6.setObjectName("button6")
                self.button2_6.setText("G O !")
                self.button2_6.clicked.connect(self.button2_6click)
                self.button2_6.setStyleSheet(
                    '''QPushButton{background:#EE9A00;border-radius:20px;font-family:等线;
                                               font-size:18px;color:white}QPushButton:hover{background:#EEDC82;}'''
                )
                self.button2_6.setFixedHeight(40)

                self.label2_1 = QtWidgets.QLabel()
                self.label2_1.setTextFormat(QtCore.Qt.AutoText)
                self.label2_1.setText("导航")
                self.label2_1.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(100,100,100,80;background:#454545);
                                                font-family:等线;''')
                self.label2_1.setAlignment(Qt.AlignCenter)

                self.label2_2 = QtWidgets.QLabel()
                self.label2_2.setTextFormat(QtCore.Qt.AutoText)
                self.label2_2.setText("")
                self.label2_2.setAlignment(Qt.AlignCenter)

                self.layout2.setColumnStretch(0, 1)
                self.layout2.setColumnStretch(1, 2)
                self.layout2.setColumnStretch(2, 2)
                self.layout2.setColumnStretch(3, 1)
                self.layout2.setColumnStretch(4, 2)
                self.layout2.setColumnStretch(5, 2)
                self.layout2.setColumnStretch(6, 1)
                self.layout2.setRowStretch(0, 2)
                self.layout2.setRowStretch(1, 2)
                self.layout2.setRowStretch(2, 2)
                self.layout2.setRowStretch(3, 2)
                self.layout2.setRowStretch(4, 2)
                self.layout2.setRowStretch(5, 2)
                self.layout2.setRowStretch(6, 2)
                self.layout2.setRowStretch(7, 2)
                self.layout2.setRowStretch(8, 2)
                self.layout2.setHorizontalSpacing(5)
                self.layout2.setVerticalSpacing(5)

                self.layout2.addWidget(self.label2_1, 0, 0, 1, 7)
                self.layout2.addWidget(self.button2_1, 2, 1, 1, 2)
                self.layout2.addWidget(self.button2_2, 2, 4, 1, 2)
                self.layout2.addWidget(self.button2_3, 4, 1, 1, 2)
                self.layout2.addWidget(self.button2_4, 4, 4, 1, 2)
                self.layout2.addWidget(self.button2_5, 6, 1, 1, 5)
                self.layout2.addWidget(self.button2_6, 8, 4, 1, 2)
                self.layout2.addWidget(self.comboBox2, 8, 1, 1, 2)
                self.layout2.addWidget(self.label2_2, 9, 1, 1, 7)

                self.right_widget.addWidget(self.centralWidget2)

            elif i == 6:
                self.centralWidget6 = QtWidgets.QWidget()
                self.centralWidget6.setStyleSheet(
                    '''background:black;border-width:0;''')

                self.layout6 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget6.setLayout(self.layout6)

                ##start coding
                self.label6_1 = QtWidgets.QLabel()
                self.label6_1.setTextFormat(QtCore.Qt.AutoText)
                self.label6_1.setText("注意事项")
                self.label6_1.setStyleSheet(
                    '''color:white;font-size:23px;background:#FF9900;
                                                font-family:Times new Romans;'''
                )
                self.label6_1.setAlignment(Qt.AlignCenter)

                self.label6_2 = QtWidgets.QLabel()
                self.label6_2.setTextFormat(QtCore.Qt.AutoText)
                self.label6_2.setText('环境要求:\n\
                1、机器人一定要在室内运行,且空间不能过于狭窄。\n\
                2、最好时刻保证机器人的工作温度在15°C到35°C间。\n\
                3、避免与雨水、雾、积水以及任何其他液体接触等。')
                self.label6_2.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label6_2.setAlignment(Qt.AlignCenter)

                self.label6_3 = QtWidgets.QLabel()
                self.label6_3.setTextFormat(QtCore.Qt.AutoText)
                self.label6_3.setText("避免损伤:\n\
                1、避免因机器人速度过快造成的损伤。\n\
                2、避免机器人接近地图边界时的碰撞。\n\
                3、注意机械臂在抓取时的姿态和力度。")
                self.label6_3.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label6_3.setAlignment(Qt.AlignCenter)

                self.layout6.addWidget(self.label6_1, 0, 0, 1, 4)
                self.layout6.addWidget(self.label6_2, 1, 0, 1, 2)
                self.layout6.addWidget(self.label6_3, 1, 2, 1, 2)
                #self.layout6.addWidget(self.label6_4,2,0,1,2)
                #self.layout6.addWidget(self.label6_5,2,2,1,2)

                self.right_widget.addWidget(self.centralWidget6)
            elif i == 7:
                self.centralWidget7 = QtWidgets.QWidget()
                self.centralWidget7.setStyleSheet(
                    '''background:black;border-width:0;''')

                self.layout7 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget7.setLayout(self.layout7)

                ##start coding
                self.label7_1 = QtWidgets.QLabel()
                self.label7_1.setTextFormat(QtCore.Qt.AutoText)
                self.label7_1.setText("硬件设置")
                self.label7_1.setStyleSheet(
                    '''color:white;font-size:23px;background:#FF9900;
                                                font-family:Times new Romans;'''
                )
                self.label7_1.setAlignment(Qt.AlignCenter)

                self.label7_2 = QtWidgets.QLabel()
                self.label7_2.setTextFormat(QtCore.Qt.AutoText)
                self.label7_2.setPixmap(QPixmap('structure.png'))
                self.label7_2.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                #self.label7_2.setScaledContents(True)
                self.label7_2.setAlignment(Qt.AlignCenter)

                self.label7_3 = QtWidgets.QLabel()
                self.label7_3.setTextFormat(QtCore.Qt.AutoText)
                self.label7_3.setPixmap(QPixmap('panel.png'))
                self.label7_3.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label7_3.setAlignment(Qt.AlignCenter)

                self.label7_4 = QtWidgets.QLabel()
                self.label7_4.setTextFormat(QtCore.Qt.AutoText)
                self.label7_4.setText("结构组成")
                self.label7_4.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label7_4.setAlignment(Qt.AlignCenter)

                self.label7_5 = QtWidgets.QLabel()
                self.label7_5.setTextFormat(QtCore.Qt.AutoText)
                self.label7_5.setText("开关面板")
                self.label7_5.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label7_5.setAlignment(Qt.AlignCenter)

                self.layout7.addWidget(self.label7_1, 0, 0, 1, 4)
                self.layout7.addWidget(self.label7_2, 1, 0, 1, 2)
                self.layout7.addWidget(self.label7_3, 1, 2, 1, 2)
                self.layout7.addWidget(self.label7_4, 2, 0, 1, 2)
                self.layout7.addWidget(self.label7_5, 2, 2, 1, 2)

                self.right_widget.addWidget(self.centralWidget7)
            elif i == 9:
                self.centralWidget9 = QtWidgets.QWidget()
                self.centralWidget9.setStyleSheet(
                    '''background:black;border-width:0;''')

                self.layout9 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget9.setLayout(self.layout9)

                self.label9_1 = QtWidgets.QLabel()
                self.label9_1.setTextFormat(QtCore.Qt.AutoText)
                self.label9_1.setText("遇到问题")
                self.label9_1.setStyleSheet(
                    '''color:white;font-size:23px;background:#FF9900;
                                                font-family:Times new Romans;'''
                )
                self.label9_1.setAlignment(Qt.AlignCenter)

                self.label9_2 = QtWidgets.QLabel()
                self.label9_2.setTextFormat(QtCore.Qt.AutoText)
                self.label9_2.setText("机器人不能运动:\n检查是否有充足电量(23%+)及急停按钮是否被释放")
                self.label9_2.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label9_2.setAlignment(Qt.AlignCenter)

                self.label9_3 = QtWidgets.QLabel()
                self.label9_3.setTextFormat(QtCore.Qt.AutoText)
                self.label9_3.setText("机器人部件损坏:\n联系我们、厂家进行维修")
                self.label9_3.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label9_3.setAlignment(Qt.AlignCenter)

                self.label9_4 = QtWidgets.QLabel()
                self.label9_4.setTextFormat(QtCore.Qt.AutoText)
                self.label9_4.setText("机器人撞击障碍物:\n立即使用急停按钮紧急停止并联系我们")
                self.label9_4.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label9_4.setAlignment(Qt.AlignCenter)

                self.label9_5 = QtWidgets.QLabel()
                self.label9_5.setTextFormat(QtCore.Qt.AutoText)
                self.label9_5.setText("其他未知错误信息:\n联系我们并报告相关信息(如发生错误前后的操作)")
                self.label9_5.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label9_5.setAlignment(Qt.AlignCenter)

                self.layout9.addWidget(self.label9_1, 0, 0, 1, 4)
                self.layout9.addWidget(self.label9_2, 1, 0, 1, 2)
                self.layout9.addWidget(self.label9_3, 1, 2, 1, 2)
                self.layout9.addWidget(self.label9_4, 2, 0, 1, 2)
                self.layout9.addWidget(self.label9_5, 2, 2, 1, 2)

                self.right_widget.addWidget(self.centralWidget9)

            elif i == 10:
                self.centralWidget10 = QtWidgets.QWidget()
                self.centralWidget10.setStyleSheet(
                    '''background:black;border-width:0;''')

                self.layout10 = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
                self.centralWidget10.setLayout(self.layout10)

                self.label10_1 = QtWidgets.QLabel()
                self.label10_1.setTextFormat(QtCore.Qt.AutoText)
                self.label10_1.setText("Contact us!")
                self.label10_1.setStyleSheet(
                    '''color:white;font-size:23px;background:#FF9900;
                                                font-family:Times new Romans;'''
                )
                self.label10_1.setAlignment(Qt.AlignCenter)

                self.label10_2 = QtWidgets.QLabel()
                self.label10_2.setTextFormat(QtCore.Qt.AutoText)
                self.label10_2.setPixmap(QPixmap('lzz.png'))
                self.label10_2.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,0,0);
                                                border-width:10;border-style:outset;border-color:red;
                                                font-family:等线;''')
                self.label10_2.setAlignment(Qt.AlignCenter)

                self.label10_3 = QtWidgets.QLabel()
                self.label10_3.setTextFormat(QtCore.Qt.AutoText)
                self.label10_3.setText(
                    "组长 李贞子\n邮箱:[email protected]\n负责:UI架构、自由避障行走、抓取\n格言:我是傻猪"
                )
                self.label10_3.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,00);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label10_3.setAlignment(Qt.AlignCenter)

                self.label10_4 = QtWidgets.QLabel()
                self.label10_4.setTextFormat(QtCore.Qt.AutoText)
                self.label10_4.setPixmap(QPixmap('wrz.png'))
                self.label10_4.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,0,0);
                                                border-width:10;border-style:outset;border-color:red;
                                                font-family:等线;''')
                self.label10_4.setAlignment(Qt.AlignCenter)

                self.label10_5 = QtWidgets.QLabel()
                self.label10_5.setTextFormat(QtCore.Qt.AutoText)
                self.label10_5.setText(
                    "组员:王润泽\n邮箱:[email protected]\n负责:自由避障行走以及抓取部分UI\n格言:广告位招租"
                )
                self.label10_5.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(00,0,0,0);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label10_5.setAlignment(Qt.AlignCenter)

                self.label10_6 = QtWidgets.QLabel()
                self.label10_6.setTextFormat(QtCore.Qt.AutoText)
                self.label10_6.setPixmap(QPixmap('zl.png'))
                self.label10_6.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,00,0);
                                                border-width:10;border-style:outset;border-color:red;
                                                font-family:等线;''')
                self.label10_6.setAlignment(Qt.AlignCenter)

                self.label10_7 = QtWidgets.QLabel()
                self.label10_7.setTextFormat(QtCore.Qt.AutoText)
                self.label10_7.setText(
                    "组员:张璐\n邮箱:[email protected]\n负责:导航部分功能\n格言:好好学习天天向上")
                self.label10_7.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,00,0,0);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label10_7.setAlignment(Qt.AlignCenter)

                self.label10_8 = QtWidgets.QLabel()
                self.label10_8.setTextFormat(QtCore.Qt.AutoText)
                self.label10_8.setPixmap(QPixmap('zjl.png'))
                self.label10_8.setStyleSheet('''color:white;font-size:23px;
                                                border-width:10;border-style:outset;border-color:red;
                                                background:rgb(100,100,100,100);
                                                font-family:等线;''')
                self.label10_8.setAlignment(Qt.AlignCenter)

                self.label10_9 = QtWidgets.QLabel()
                self.label10_9.setTextFormat(QtCore.Qt.AutoText)
                self.label10_9.setText(
                    "组员:张佳琳\n邮箱:[email protected]\n负责:导航部分UI\n格言:戏说不是胡说,改编不是乱编"
                )
                self.label10_9.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,0,0);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label10_9.setAlignment(Qt.AlignCenter)

                self.label10_10 = QtWidgets.QLabel()
                self.label10_10.setTextFormat(QtCore.Qt.AutoText)
                self.label10_10.setPixmap(QPixmap('lty.png'))
                self.label10_10.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(00,00,0,0);
                                                 border-width:10;border-style:outset;border-color:red;
                                                font-family:等线;''')
                self.label10_10.setAlignment(Qt.AlignCenter)

                self.label10_11 = QtWidgets.QLabel()
                self.label10_11.setTextFormat(QtCore.Qt.AutoText)
                self.label10_11.setText(
                    "组员:李天宇\n邮箱:[email protected]\n负责:动态避障功能\n格言:我不做人啦")
                self.label10_11.setStyleSheet(
                    '''color:white;font-size:23px;background:rgb(0,0,0,0);
                                                border-width:5;border-style:ridge;border-color:#FF9900;
                                                font-family:等线;''')
                self.label10_11.setAlignment(Qt.AlignCenter)

                #self.layout10.setColumnStretch(0, 1)
                self.layout10.addWidget(self.label10_1, 1, 1, 1, 6)

                self.layout10.addWidget(self.label10_2, 2, 1)
                self.layout10.addWidget(self.label10_3, 3, 1, 2, 1)

                self.layout10.addWidget(self.label10_4, 2, 2)
                self.layout10.addWidget(self.label10_5, 3, 2, 2, 1)

                self.layout10.addWidget(self.label10_6, 2, 3)
                self.layout10.addWidget(self.label10_7, 3, 3, 2, 1)

                self.layout10.addWidget(self.label10_8, 2, 4)
                self.layout10.addWidget(self.label10_9, 3, 4, 2, 1)

                self.layout10.addWidget(self.label10_10, 2, 5)
                self.layout10.addWidget(self.label10_11, 3, 5, 2, 1)

                self.right_widget.addWidget(self.centralWidget10)

            else:
                self.centralWidget0 = QtWidgets.QWidget()
                self.centralWidget0.setStyleSheet(
                    '''background:white;border-width:0;''')
                self.right_widget.addWidget(self.centralWidget0)

    def button1_1click(self):
        vel = 0
        time = 0

        if self.edit1_1.text() == "":
            vel = 0.5
        else:
            vel = float(self.edit1_1.text())

        if self.edit1_2.text() == "":
            time = 60
        else:
            time = int(self.edit1_2.text())

        self.setConfig(vel, time)

        os.system(free_walk_cmd)

    def setConfig(self, vel, time):
        vel_pattern = re.compile(vel_config)
        time_pattern = re.compile(time_config)

        with open(config_path, "w") as f:
            f.truncate()
            f.write(str(vel))
            f.write("\n")
            f.write(str(time))

    def button2_1click(self):
        '''
        print("roslaunch wpb_home_tutorials gmapping.launch")
        #os.system("roslaunch wpb_home_tutorials gmapping.launch")
        os.system("gnome-terminal -e 'bash -c \"roslaunch wpb_home_tutorials gmapping.launch\"'")
        #os.system("gnome-terminal -e 'bash -c \"ls\"'")
        #os.system("gnome-terminal -e 'bash -c \"roslaunch wpb_home_tutorials gmapping.launch; exec bash\"'")
        '''
        pass

    def button2_2click(self):
        '''
        print("rosrun map_server map_saver -f map")
        os.system("gnome-terminal -e 'bash -c \"rosrun map_server map_saver -f map&&cp map.yaml /home/robot/catkin_ws/src/wpb_home/wpb_home_tutorials/maps/map.yaml&&cp map.pgm /home/robot/catkin_ws/src/wpb_home/wpb_home_tutorials/maps/map.pgm\"'")##yidong
	#save in the main dir
        #print("移动指令")
	#may be we do not need to really change the map path, because we can change the map path in some launch files
	#such as, in add_waypoint.launch, we can change 
	#args="$(find wpb_home_tutorials)/maps/map.yaml"/>
	#into
	#args="/home/robot/map.yaml"/>
    '''
        pass

    def button2_3click(self):
        '''
        print("roslaunch waterplus_map_tools add_waypoint.launch")
        os.system("gnome-terminal -e 'bash -c \"roslaunch waterplus_map_tools add_waypoint.launch\"'")
        ###???????????????????????????????????
        '''
        pass

    def button2_4click(self):
        '''
        def indexRename(matched):
                self.renameIndex+=1;
                return str(self.renameIndex-1);
        print("rosrun waterplus_map_tools wp_saver")
        os.system("gnome-terminal -e 'bash -c \"cd /home/robot/&&rosrun waterplus_map_tools wp_saver\"'")
        time.sleep(2)
        #os.system("rosrun waterplus_map_tools wp_saver")
        #os.system("gnome-terminal -e 'bash -c \"rosrun waterplus_map_tools wp_saver; exec bash\"'")
	#save waypoints.xml into /home/robot/
        self.comboBox2.clear()
        if os.path.exists('/home/robot/waypoints.xml') == False :
            file = open('/home/robot/waypoints.xml','w')
            file.write('<Waterplus>\n</Waterplus>')
            file.close()
        f=open('/home/robot/waypoints.xml', 'r')
        newFile=re.sub(r"(?<=<Name>).+?(?=</Name>)",indexRename,f.read())
        f.close()
        f=open('/home/robot/waypoints.xml', 'w')
        f.write(newFile)
        f.close()
        self.renameIndex = 1
        f=open('/home/robot/waypoints.xml', 'r')
        pointlist=re.findall(r"(?<=<Name>).+?(?=</Name>)", f.read(), re.S)
        print(pointlist)
        self.comboBox2.addItems(pointlist)
        f.close()
        '''
        pass

    def button2_5click(self):
        '''
        print("roslaunch wpb_home_apps 6_path_plan.launch")
        os.system("gnome-terminal -e 'bash -c \"roslaunch wpb_home_apps 6_path_plan.launch; exec bash\"'")
        '''
        pass

    def button2_6click(self):
        pass
        '''
        print(self.comboBox2.currentIndex()+1)
	#get to the chosed point
        pointoutput = open('/home/robot/point.txt', 'w')
        pointoutput.write(str(self.comboBox2.currentIndex()+1))
        pointoutput.close()
        '''

    def button3_1click(self):
        os.system("roslaunch myshop shopping_201.launch")

    def button3_2click(self):
        r = os.popen("roslaunch darknet_ros darknet_ros.launch")
        text = r.read()
        textlist = text.split("\n")
        for text in textlist:
            if text.startswith("[ERROR]"):
                button3_2click()
                return
Exemple #20
0
class Ui_Form(object):
    def setupUi(self, Form):
        self.form = Form
        self.O_answer = {}
        self.A_answer = {}
        self.file_list = os.listdir("Images")
        with open("count") as f:
            self.num = int(f.read())
        self.add_a = True
        self.add_o = False
        self.A_extra = {}
        self.O_extra = {}
        f = open('Attribute', encoding='utf-8-sig')
        self.A_dict = {}
        for line in f.readlines():
            temp = line[:-1].split(':')
            self.A_dict[temp[0]] = temp[1].split(',')
        print(self.A_dict)
        f.close()
        f = open('Object', encoding='utf-8-sig')
        self.O_dict = {}
        for line in f.readlines():
            temp = line[:-1].split(':')
            self.O_dict[temp[0]] = temp[1].split(',')
        f.close()
        print(self.O_dict)
        Form.setObjectName("Form")
        Form.resize(1179, 803)
        self.label_16 = QtWidgets.QLabel(Form)
        self.label_16.setGeometry(QtCore.QRect(30, 40, 441, 331))
        pixmap = QPixmap("./Images/" + self.file_list[self.num])
        self.label_16.setPixmap(pixmap)
        self.label_16.setScaledContents(True)

        self.label_17 = QtWidgets.QLabel(Form)
        self.label_17.setGeometry(QtCore.QRect(610, 720, 111, 31))
        pixmap = QPixmap("logo_iair.png")
        self.label_17.setPixmap(pixmap)
        self.label_17.setScaledContents(True)

        self.label_18 = QtWidgets.QLabel(Form)
        self.label_18.setGeometry(QtCore.QRect(400, 720, 201, 31))
        pixmap = QPixmap("xjtu_logo.png")
        self.label_18.setPixmap(pixmap)
        self.label_18.setScaledContents(True)

        self.groupBox = QtWidgets.QGroupBox(Form)
        self.groupBox.setGeometry(QtCore.QRect(490, 10, 351, 411))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.groupBox.setFont(font)
        self.groupBox.setObjectName("groupBox")

        self.A_comboBox_list = []
        self.A_label_list = []
        with open('QListWidgetQSS.qss', 'r') as f:  # 导入QListWidget的qss样式
            self.list_style = f.read()
        font = QtGui.QFont()
        font.setPointSize(10)
        self.left_widget = QListWidget(self.groupBox)  # 左侧选项列表
        self.left_widget.setGeometry(QtCore.QRect(40, 40, 181, 360))
        self.left_widget.setStyleSheet(self.list_style)
        self.right_widget = QStackedWidget(self.groupBox)
        self.right_widget.setGeometry(QtCore.QRect(190, 40, 181, 360))

        with open('oQListWigetQSS.qss', 'r') as f:  # 导入QListWidget的qss样式
            self.olist_style = f.read()

        self.groupBox_5 = QtWidgets.QGroupBox(Form)
        self.groupBox_5.setGeometry(QtCore.QRect(850, 10, 291, 361))
        font = QtGui.QFont()
        font.setPointSize(10)
        self.oleft_widget = QListWidget(self.groupBox_5)  # 左侧选项列表
        self.oleft_widget.setGeometry(QtCore.QRect(10, 40, 181, 300))
        self.oleft_widget.setStyleSheet(self.olist_style)
        self.oright_widget = QStackedWidget(self.groupBox_5)
        self.oright_widget.setGeometry(QtCore.QRect(150, 40, 181, 300))

        font = QtGui.QFont()
        font.setPointSize(18)
        self.groupBox_5.setFont(font)
        self.groupBox_5.setAutoFillBackground(False)
        self.groupBox_5.setObjectName("groupBox_5")
        self.O_comboBox_list = []
        self.O_label_list = []
        self.pushButton = QtWidgets.QPushButton(Form)
        font = QtGui.QFont()
        font.setPointSize(18)
        self.pushButton.setFont(font)
        self.pushButton.setGeometry(QtCore.QRect(570, 630, 551, 61))
        self.pushButton.clicked.connect(self.btn_save)
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(Form)
        font = QtGui.QFont()
        font.setPointSize(18)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setGeometry(QtCore.QRect(570, 560, 551, 61))
        self.pushButton_2.clicked.connect(self.btn_add_class)
        self.pushButton_2.setObjectName("pushButton_2")
        self.comboBox_11 = QtWidgets.QComboBox(Form)
        self.comboBox_11.setGeometry(QtCore.QRect(40, 440, 241, 31))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.comboBox_11.setFont(font)
        self.comboBox_11.setEditable(False)
        self.comboBox_11.setObjectName("comboBox_11")
        for i, key in enumerate(self.A_dict.keys()):
            self.comboBox_11.addItem("")
        for i, key in enumerate(self.O_dict.keys()):
            self.comboBox_11.addItem("")
        self.lineEdit_2 = QtWidgets.QLineEdit(Form)
        self.lineEdit_2.setGeometry(QtCore.QRect(930, 480, 201, 21))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.pushButton_3 = QtWidgets.QPushButton(Form)
        font = QtGui.QFont()
        font.setPointSize(18)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setGeometry(QtCore.QRect(40, 530, 461, 61))
        self.pushButton_3.clicked.connect(self.btn_add_val)
        self.pushButton_3.setObjectName("pushButton_3")
        self.radioButton = QtWidgets.QRadioButton(Form)
        self.radioButton.setGeometry(QtCore.QRect(580, 480, 100, 20))
        self.radioButton.setChecked(True)
        self.radioButton.toggled.connect(self.radio_msg)
        self.radioButton.setObjectName("radioButton")
        self.radioButton_2 = QtWidgets.QRadioButton(Form)
        self.radioButton_2.setGeometry(QtCore.QRect(670, 480, 100, 20))
        self.radioButton_2.toggled.connect(self.radio_msg)
        self.radioButton_2.setObjectName("radioButton_2")
        self.textEdit = QtWidgets.QTextEdit(Form)
        self.textEdit.setGeometry(QtCore.QRect(300, 440, 201, 81))
        self.textEdit.setObjectName("textEdit")
        self.label_11 = QtWidgets.QLabel(Form)
        self.label_11.setGeometry(QtCore.QRect(40, 410, 60, 31))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.label_11.setFont(font)
        self.label_11.setObjectName("label_11")
        self.label_12 = QtWidgets.QLabel(Form)
        self.label_12.setGeometry(QtCore.QRect(850, 480, 61, 21))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")
        self.label_13 = QtWidgets.QLabel(Form)
        self.label_13.setGeometry(QtCore.QRect(300, 410, 141, 21))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.label_13.setFont(font)
        self.label_13.setObjectName("label_13")
        self.label_9 = QtWidgets.QLabel(Form)
        self.label_9.setGeometry(QtCore.QRect(30, 380, 551, 31))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.label_15 = QtWidgets.QLabel(Form)
        self.label_15.setGeometry(QtCore.QRect(860, 510, 71, 21))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.label_15.setFont(font)
        self.label_15.setObjectName("label_15")
        self.lineEdit_3 = QtWidgets.QLineEdit(Form)
        self.lineEdit_3.setGeometry(QtCore.QRect(930, 510, 201, 21))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.checkBox = QtWidgets.QCheckBox(Form)
        self.checkBox.setGeometry(QtCore.QRect(580, 510, 87, 20))
        self.checkBox.setObjectName("checkBox")
        self.pushButton_4 = QtWidgets.QPushButton(Form)
        font = QtGui.QFont()
        font.setPointSize(18)
        self.pushButton_4.setFont(font)
        self.pushButton_4.setGeometry(QtCore.QRect(930, 380, 211, 41))
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.clicked.connect(self.btn4_back)
        self.pushButton_jump = QtWidgets.QPushButton(Form)
        self.pushButton_jump.setFont(font)
        self.pushButton_jump.setGeometry(QtCore.QRect(930, 430, 211, 41))
        self.pushButton_jump.setObjectName("pushButton_4")
        self.pushButton_jump.clicked.connect(self.btn_jump)
        self.QTextEdit = QtWidgets.QTextEdit(Form)
        self.QTextEdit.setGeometry(QtCore.QRect(40, 610, 461, 91))
        self.QTextEdit.setObjectName("QTextEdit")
        self.label_left = QtWidgets.QLabel(Form)
        self.label_left.setGeometry(QtCore.QRect(800, 700, 551, 31))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.label_left.setFont(font)
        self.label_left.setObjectName("label_left")

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

    def retranslateUi(self, Form):
        '''加载界面ui'''

        self.left_widget.currentRowChanged.connect(
            self.right_widget.setCurrentIndex)  # list和右侧窗口的index对应绑定
        self.oleft_widget.currentRowChanged.connect(
            self.oright_widget.setCurrentIndex)  # list和右侧窗口的index对应绑定

        # self.left_widget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)  # 隐藏滚动条
        self.left_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        for i, att_cl in enumerate(self.A_dict.keys()):
            self.item = QListWidgetItem(att_cl, self.left_widget)  # 左侧选项的添加
            font = QtGui.QFont()
            font.setPointSize(15)
            self.item.setFont(font)
            self.item.setSizeHint(QSize(15, 25))
            self.item.setTextAlignment(Qt.AlignCenter)  # 居中显示

            locals()['stack' + str(i)] = QListWidget()  # 左侧选项列表
            locals()['stack' + str(i)].setGeometry(QtCore.QRect(
                0, 0, 181, 360))
            locals()['stack' + str(i)].setStyleSheet(self.list_style)
            for att_v in self.A_dict[att_cl]:
                self.ritem = QListWidgetItem(att_v,
                                             locals()['stack' +
                                                      str(i)])  # 左侧选项的添加
                font = QtGui.QFont()
                font.setPointSize(15)
                self.ritem.setFont(font)
                self.ritem.setSizeHint(QSize(15, 25))
                self.ritem.setTextAlignment(Qt.AlignCenter)  # 居中显示
            self.right_widget.addWidget(locals()['stack' + str(i)])
            self.A_comboBox_list.append(locals()["stack" + str(i)])
            locals()['stack' + str(i)].currentRowChanged.connect(
                self.row_change)

        for i, obj_cl in enumerate(self.O_dict.keys()):
            self.oitem = QListWidgetItem(obj_cl, self.oleft_widget)  # 左侧选项的添加
            font = QtGui.QFont()
            font.setPointSize(15)
            self.oitem.setFont(font)
            self.oitem.setSizeHint(QSize(15, 25))
            self.oitem.setTextAlignment(Qt.AlignCenter)  # 居中显示

            locals()['ostack' + str(i)] = QListWidget()  # 左侧选项列表
            locals()['ostack' + str(i)].setGeometry(
                QtCore.QRect(0, 0, 181, 360))
            locals()['ostack' + str(i)].setStyleSheet(self.olist_style)
            for obj_v in self.O_dict[obj_cl]:
                self.oritem = QListWidgetItem(obj_v,
                                              locals()['ostack' +
                                                       str(i)])  # 左侧选项的添加
                font = QtGui.QFont()
                font.setPointSize(15)
                self.oritem.setFont(font)
                self.oritem.setSizeHint(QSize(15, 25))
                self.oritem.setTextAlignment(Qt.AlignCenter)  # 居中显示
            self.oright_widget.addWidget(locals()['ostack' + str(i)])
            self.O_comboBox_list.append(locals()["ostack" + str(i)])
            locals()['ostack' + str(i)].currentRowChanged.connect(
                self.orow_change)

        _translate = QtCore.QCoreApplication.translate
        for i, key in enumerate(self.A_dict.keys()):
            self.comboBox_11.setItemText(i, _translate("Form", key))
        for i, key in enumerate(self.O_dict.keys()):
            self.comboBox_11.setItemText(i + len(self.A_dict.keys()),
                                         _translate("Form", key))
        Form.setWindowTitle(_translate("Form", "Anotation Tool"))
        self.groupBox.setTitle(_translate("Form", "属性"))
        self.groupBox_5.setTitle(_translate("Form", "对象"))
        self.pushButton_3.setText(_translate("Form", "完成添加"))
        self.radioButton.setText(_translate("Form", "属性"))
        self.radioButton_2.setText(_translate("Form", "对象"))
        self.label_11.setText(_translate("Form", "名称:"))
        self.label_12.setText(_translate("Form", "名称:"))
        self.label_13.setText(_translate("Form", "值:"))
        self.label_9.setText(
            _translate("Form", "文件名称:" + self.file_list[self.num]))
        self.label_left.setText(
            _translate(
                "Form", "图片已标注:" + str(len(os.listdir("Labels/"))) + ",还剩:" +
                str(len(self.file_list) - len(os.listdir("Labels/")))))
        self.pushButton.setText(_translate("Form", "注释图片"))
        self.pushButton_2.setText(_translate("Form", "属性/对象完成添加"))
        self.label_15.setText(_translate("Form", "值:"))
        self.checkBox.setText(_translate("Form", "更新到图表"))
        self.pushButton_4.setText(_translate("Form", "上一张图片"))
        self.pushButton_jump.setText(_translate("Form", "跳过图片"))

    def btn_jump(self):
        self.num += 1
        with open("count", "w") as f:
            f.write(str(self.num))
        shutil.copy("./Images/" + self.file_list[self.num - 1],
                    "./SkipImages/")
        if self.num > len(self.file_list) - 1:
            sys.exit(0)
        pixmap = QPixmap("./Images/" + self.file_list[self.num])
        self.label_16.setPixmap(pixmap)
        self.label_16.setScaledContents(True)
        self.left_widget.reset()
        self.oleft_widget.reset()
        _translate = QtCore.QCoreApplication.translate
        self.label_9.setText(
            _translate("Form", "Image Name:" + self.file_list[self.num]))
        self.label_left.setText(
            _translate(
                "Form", "图片已标注:" + str(len(os.listdir("Labels/"))) + ",还剩:" +
                str(len(self.file_list) - len(os.listdir("Labels/")))))
        for comboBox_i in self.A_comboBox_list:
            comboBox_i.reset()
        for comboBox_i in self.O_comboBox_list:
            comboBox_i.reset()
        self.A_answer = {}
        self.O_answer = {}
        self.QTextEdit.clear()

    def row_change(self):
        cv = self.left_widget.currentIndex().data()
        i = self.left_widget.currentIndex().row()
        j = self.A_comboBox_list[i].currentIndex().row()
        vv = self.A_comboBox_list[i].currentIndex().data()
        self.A_answer[cv] = vv
        self.QTextEdit.setPlainText(
            str("对象:\n") + str(self.O_answer) + "\n" + str("属性:\n") +
            str(self.A_answer) + "\n")

    def orow_change(self):
        cv = self.oleft_widget.currentIndex().data()
        i = self.oleft_widget.currentIndex().row()
        j = self.O_comboBox_list[i].currentIndex().row()
        vv = self.O_comboBox_list[i].currentIndex().data()
        self.O_answer[cv] = vv
        self.QTextEdit.setPlainText(
            str("对象:\n") + str(self.O_answer) + "\n" + str("属性:\n") +
            str(self.A_answer) + "\n")

    def btn_save(self):
        self.num += 1
        with open("count", "w") as f:
            f.write(str(self.num))
        text = self.QTextEdit.toPlainText()
        O_an = eval(text.split('\n')[1])
        A_an = eval(text.split('\n')[3])
        if os.path.exists("./Labels/" + self.file_list[self.num - 1] +
                          ".json"):
            os.remove("./Labels/" + self.file_list[self.num - 1] + ".json")
        dic = {}
        dic['object'] = O_an
        A_an_list = []
        for att in A_an.keys():
            A_an_list.append({att: A_an[att]})
        dic['attributes'] = A_an_list
        with open("./Labels/" + self.file_list[self.num - 1] + ".json",
                  mode="a") as f:
            json.dump(dic, f, ensure_ascii=False)
        if self.num > len(self.file_list) - 1:
            sys.exit(0)
        pixmap = QPixmap("./Images/" + self.file_list[self.num])
        self.label_16.setPixmap(pixmap)
        self.label_16.setScaledContents(True)
        self.left_widget.reset()
        self.oleft_widget.reset()
        _translate = QtCore.QCoreApplication.translate
        self.label_9.setText(
            _translate("Form", "Image Name:" + self.file_list[self.num]))
        self.label_left.setText(
            _translate(
                "Form", "图片已标注:" + str(len(os.listdir("Labels/"))) + ",还剩:" +
                str(len(self.file_list) - len(os.listdir("Labels/")))))
        for comboBox_i in self.A_comboBox_list:
            comboBox_i.reset()
        for comboBox_i in self.O_comboBox_list:
            comboBox_i.reset()
        self.A_answer = {}
        self.O_answer = {}
        self.QTextEdit.clear()

    def btn_add_val(self):
        my_key = self.comboBox_11.currentText()
        text = self.textEdit.toPlainText()
        text_list = text.split(',')
        _translate = QtCore.QCoreApplication.translate
        for i, key in enumerate(self.A_dict.keys()):
            if key == my_key:
                lines = []
                with open("Attribute", encoding='utf-8-sig') as f:
                    for line in f.readlines():
                        temp = line[:-1].split(':')
                        if temp[0] == my_key:
                            lines.append(line[:-1] + ',' + text + '\n')
                        else:
                            lines.append(line)
                with open("Attribute", 'w', encoding='utf-8') as f:
                    s = ''.join(lines)
                    f.write(str(s))
                for txt in text_list:
                    self.item = QListWidgetItem(
                        txt, self.A_comboBox_list[i])  # 左侧选项的添加
                    font = QtGui.QFont()
                    font.setPointSize(15)
                    self.item.setFont(font)
                    self.item.setSizeHint(QSize(15, 25))
                    self.item.setTextAlignment(Qt.AlignCenter)  # 居中显示
                self.A_dict[key] += text_list
        for i, key in enumerate(self.O_dict.keys()):
            if key == my_key:
                lines = []
                with open("Object", encoding="utf-8-sig") as f:
                    for line in f.readlines():
                        temp = line[:-1].split(':')
                        if temp[0] == my_key:
                            lines.append(line[:-1] + ',' + text + '\n')
                        else:
                            lines.append(line)
                with open("Object", 'w', encoding='utf-8') as f:
                    s = ''.join(lines)
                    f.write(str(s))
                for txt in text_list:
                    self.oitem = QListWidgetItem(
                        txt, self.O_comboBox_list[i])  # 左侧选项的添加
                    font = QtGui.QFont()
                    font.setPointSize(15)
                    self.oitem.setFont(font)
                    self.oitem.setSizeHint(QSize(15, 25))
                    self.oitem.setTextAlignment(Qt.AlignCenter)  # 居中显示
                self.O_dict[key] += text_list
        print([my_key, text])

        self.textEdit.setText("")

    def radio_msg(self):
        if self.radioButton.isChecked():
            self.add_a = True
            self.add_o = False
        if self.radioButton_2.isChecked():
            self.add_o = True
            self.add_a = False

    def btn_add_class(self):
        if self.add_a:
            self.radioButton.setChecked(True)
            my_key = self.lineEdit_2.text()
            my_val = self.lineEdit_3.text()
            my_val = my_val.split(",")
            _translate = QtCore.QCoreApplication.translate
            if self.checkBox.isChecked():
                if len(my_key) != 0:
                    i = len(self.A_comboBox_list)
                    self.item = QListWidgetItem(my_key,
                                                self.left_widget)  # 左侧选项的添加
                    font = QtGui.QFont()
                    font.setPointSize(15)
                    self.item.setFont(font)
                    self.item.setSizeHint(QSize(15, 25))
                    self.item.setTextAlignment(Qt.AlignCenter)  # 居中显示

                    locals()['stack' + str(i)] = QListWidget()  # 左侧选项列表
                    locals()['stack' + str(i)].setGeometry(
                        QtCore.QRect(0, 0, 181, 360))
                    locals()['stack' + str(i)].setStyleSheet(self.list_style)
                    for att_v in my_val:
                        self.ritem = QListWidgetItem(
                            att_v,
                            locals()['stack' + str(i)])  # 左侧选项的添加
                        font = QtGui.QFont()
                        font.setPointSize(15)
                        self.ritem.setFont(font)
                        self.ritem.setSizeHint(QSize(15, 25))
                        self.ritem.setTextAlignment(Qt.AlignCenter)  # 居中显示
                    self.right_widget.addWidget(locals()['stack' + str(i)])
                    self.A_comboBox_list.append(locals()["stack" + str(i)])
                    locals()['stack' + str(i)].currentRowChanged.connect(
                        self.row_change)
                    self.A_dict[my_key] = my_val
                    lines = []
                    with open("Attribute", encoding="utf-8-sig") as f:
                        for line in f.readlines():
                            lines.append(line)
                        lines.append('\n' + my_key + ":" + ",".join(my_val))
                    with open("Attribute", 'w', encoding="utf-8") as f:
                        s = ''.join(lines)
                        f.write(str(s))
                    self.comboBox_11.addItem("")
                    self.comboBox_11.setItemText(
                        len(self.A_dict.keys()) + len(self.O_dict.keys()) - 1,
                        _translate("Form", my_key))
            else:
                text = self.QTextEdit.toPlainText()
                if len(text) != 0:
                    self.A_answer = eval(text.split('\n')[3])
                    self.O_answer = eval(text.split('\n')[1])
                else:
                    self.A_answer = {}
                    self.O_answer = {}
                # print(A_an)
                self.A_answer[my_key] = my_val[0]
                self.QTextEdit.setPlainText(
                    str("对象:\n") + str(self.O_answer) + "\n" + str("属性:\n") +
                    str(self.A_answer) + "\n")
        if self.add_o:
            self.add_o = False
            self.radioButton.setChecked(True)
            my_key = self.lineEdit_2.text()
            my_val = self.lineEdit_3.text()
            my_val = my_val.split(",")
            _translate = QtCore.QCoreApplication.translate
            if self.checkBox.isChecked():
                if len(my_key) != 0:
                    i = len(self.O_comboBox_list)
                    self.oitem = QListWidgetItem(my_key,
                                                 self.oleft_widget)  # 左侧选项的添加
                    font = QtGui.QFont()
                    font.setPointSize(15)
                    self.oitem.setFont(font)
                    self.oitem.setSizeHint(QSize(15, 25))
                    self.oitem.setSizeHint(QSize(15, 20))
                    self.oitem.setTextAlignment(Qt.AlignCenter)  # 居中显示

                    locals()['ostack' + str(i)] = QListWidget()  # 左侧选项列表
                    locals()['ostack' + str(i)].setGeometry(
                        QtCore.QRect(0, 0, 181, 360))
                    locals()['ostack' + str(i)].setStyleSheet(self.olist_style)
                    for obj_v in my_val:
                        self.oritem = QListWidgetItem(
                            obj_v,
                            locals()['ostack' + str(i)])  # 左侧选项的添加
                        font = QtGui.QFont()
                        font.setPointSize(15)
                        self.oritem.setFont(font)
                        self.oritem.setSizeHint(QSize(15, 25))
                        self.oritem.setTextAlignment(Qt.AlignCenter)  # 居中显示
                    self.oright_widget.addWidget(locals()['ostack' + str(i)])
                    self.O_comboBox_list.append(locals()["ostack" + str(i)])
                    locals()['ostack' + str(i)].currentRowChanged.connect(
                        self.orow_change)
                    self.O_dict[my_key] = my_val
                    lines = []
                    with open("Object", encoding="utf-8-sig") as f:
                        for line in f.readlines():
                            lines.append(line)
                        lines.append('\n' + my_key + ":" + ",".join(my_val))
                    with open("Object", 'w', encoding="utf-8") as f:
                        s = ''.join(lines)
                        f.write(str(s))
                    self.comboBox_11.addItem("")
                    self.comboBox_11.setItemText(
                        len(self.A_dict.keys()) + len(self.O_dict.keys()) - 1,
                        _translate("Form", my_key))
            else:
                text = self.QTextEdit.toPlainText()
                if len(text) != 0:
                    self.A_answer = eval(text.split('\n')[3])
                    self.O_answer = eval(text.split('\n')[1])
                else:
                    self.A_answer = {}
                    self.O_answer = {}
                self.O_answer[my_key] = my_val[0]
                self.QTextEdit.setPlainText(
                    str("对象:\n") + str(self.O_answer) + "\n" + str("属性:\n") +
                    str(self.A_answer) + "\n")
        self.radio_flag = False

        self.checkBox.setChecked(False)
        self.lineEdit_2.setText("")
        self.lineEdit_3.setText("")

    def btn4_back(self):
        if self.num < 1:
            sys.exit(0)
        self.num = self.num - 1
        with open("count", "w") as f:
            f.write(str(self.num))
        pixmap = QPixmap("./Images/" + self.file_list[self.num])
        self.label_16.setPixmap(pixmap)
        self.label_16.setScaledContents(True)
        _translate = QtCore.QCoreApplication.translate
        self.label_9.setText(
            _translate("Form", "Image Name:" + self.file_list[self.num]))
        for comboBox_i in self.A_comboBox_list:
            comboBox_i.reset()
        for comboBox_i in self.O_comboBox_list:
            comboBox_i.reset()
        self.QTextEdit.clear()
Exemple #21
0
    def initUI(self):
        """# Global """
        self.setWindowTitle('Option')
        self.setFixedSize(800, 450)

        self.list_option = QListWidget(self)
        self.stack_window = QStackedWidget(self)

        layout_main = QHBoxLayout(spacing=0)
        layout_main.setContentsMargins(0, 0, 0, 0)

        layout_main.addWidget(self.list_option)
        layout_main.addWidget(self.stack_window)
        self.setLayout(layout_main)

        self.list_option.setStyleSheet("""
                                       QListWidget{
                                       min-width: 120px;
                                       max-width: 120px;
                                       color: white;
                                       background: grey;
                                       }
                                       """)


        """# List Option"""
        self.list_option.setFrameShape(QListWidget.NoFrame)
        self.list_option.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.list_option.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self.list_option.currentRowChanged.connect(self.stack_window.setCurrentIndex)

        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(20)

        item = QListWidgetItem()
        item.setFont(font)
        item.setText('Lite')
        item.setSizeHint(QSize(0, 60))
        item.setTextAlignment(Qt.AlignCenter)
        self.list_option.addItem(item)

        item = QListWidgetItem()
        item.setFont(font)
        item.setText('Pro')
        item.setSizeHint(QSize(0, 60))
        item.setTextAlignment(Qt.AlignCenter)
        self.list_option.addItem(item)


        """# Stack Window"""
        """# Page 0"""
        self.page0 = QWidget()

        self.tabwidget_page0 = QTabWidget(self.page0)

        self.tab0_page0 = QWidget(self.page0)
        self.tab1_page0 = QWidget(self.page0)

        self.tabwidget_page0.addTab(self.tab0_page0, 'Info')
        self.tabwidget_page0.addTab(self.tab1_page0, 'Option')

        """# Page0 Tab0"""
        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(12)

        label_date_page0 = QLabel('Date      ')
        label_date_page0.setFont(font)

        label_time_page0 = QLabel('Time      ')
        label_time_page0.setFont(font)

        label_loc_page0 = QLabel('Location  ')
        label_loc_page0.setFont(font)

        label_users_name_page0 = QLabel('Name     ')
        label_users_name_page0.setFont(font)

        font_spe = QFont()
        font_spe.setFamily('MonoxRegular Bold')
        font_spe.setPointSize(12)
        label_users_gender_page0 = QLabel('Gender')
        label_users_gender_page0.setFont(font_spe)

        label_note_page0 = QLabel('Note')
        label_note_page0.setFont(font)

        self.dateedit_date_page0 = QDateEdit(QDate.currentDate())
        self.dateedit_date_page0.setDisplayFormat('yyyy/MM/dd')
        self.dateedit_date_page0.setCalendarPopup(True)
        self.dateedit_date_page0.setFont(font)
        self.timeedit_time_page0 = QTimeEdit(QTime.currentTime())
        self.timeedit_time_page0.setDisplayFormat('HH : mm')
        self.timeedit_time_page0.setFont(font)
        self.lineedit_loc_page0 = QLineEdit('Mars')
        self.lineedit_loc_page0.setFont(font)
        self.lineedit_users_name_page0 = QLineEdit('Object')
        self.lineedit_users_name_page0.setFont(font)

        self.radiobutton_users_gender_male_page0 = QRadioButton('Male')
        self.radiobutton_users_gender_female_page0 = QRadioButton('Female')
        self.radiobutton_users_gender_secret_page0 = QRadioButton('Secret')

        self.textedit_note_page0 = QTextEdit('None')
        self.textedit_note_page0.setFont(font)

        line_split_page0 = QFrame()
        line_split_page0.setFrameShape(QFrame.VLine)
        line_split_page0.setFrameShadow(QFrame.Sunken)

        groupbox_radio_button = QGroupBox()
        groupbox_radio_button.setStyleSheet("""
                                            QGroupBox{
                                            border: None;
                                            }
                                            """)

        layout_groupbox_radio_button = QHBoxLayout()
        layout_groupbox_radio_button.addWidget(self.radiobutton_users_gender_male_page0)
        layout_groupbox_radio_button.addWidget(self.radiobutton_users_gender_female_page0)
        layout_groupbox_radio_button.addWidget(self.radiobutton_users_gender_secret_page0)
        groupbox_radio_button.setLayout(layout_groupbox_radio_button)

        layout_tab0_page0_global = QVBoxLayout(self.tab0_page0)

        layout_info_page0 = QHBoxLayout()
        layout_note_page0 = QVBoxLayout()

        layout_time_page0 = QVBoxLayout()
        layout_user_page0 = QVBoxLayout()

        layout_date_page0 = QHBoxLayout()
        layout_date_page0.setAlignment(Qt.AlignLeft)
        layout_clock_page0 = QHBoxLayout()
        layout_clock_page0.setAlignment(Qt.AlignLeft)
        layout_loc_page0 = QHBoxLayout()
        layout_loc_page0.setAlignment(Qt.AlignLeft)
        layout_name_page0 = QHBoxLayout()
        layout_gender_page0 = QVBoxLayout()

        layout_date_page0.addWidget(label_date_page0)
        layout_date_page0.addWidget(self.dateedit_date_page0)
        layout_clock_page0.addWidget(label_time_page0)
        layout_clock_page0.addWidget(self.timeedit_time_page0)
        layout_loc_page0.addWidget(label_loc_page0)
        layout_loc_page0.addWidget(self.lineedit_loc_page0)
        layout_name_page0.addWidget(label_users_name_page0)
        layout_name_page0.addWidget(self.lineedit_users_name_page0)
        layout_gender_page0.addWidget(label_users_gender_page0)
        layout_gender_page0.addWidget(groupbox_radio_button)

        layout_time_page0.addLayout(layout_date_page0)
        layout_time_page0.addLayout(layout_clock_page0)
        layout_time_page0.addLayout(layout_loc_page0)
        layout_user_page0.addLayout(layout_name_page0)
        layout_user_page0.addLayout(layout_gender_page0)

        layout_info_page0.addLayout(layout_time_page0)
        layout_info_page0.addWidget(line_split_page0)
        layout_info_page0.addLayout(layout_user_page0)

        layout_note_page0.addWidget(label_note_page0)
        layout_note_page0.addWidget(self.textedit_note_page0)

        layout_tab0_page0_global.addLayout(layout_info_page0)
        layout_tab0_page0_global.addLayout(layout_note_page0)

        self.tab0_page0.setLayout(layout_tab0_page0_global)

        """# Page0 Tab1"""



        """# Page0 Global"""
        self.pushbutton_ok_page0 = QPushButton('&Ok')
        self.pushbutton_re_page0 = QPushButton('&Reset')
        self.pushbutton_de_page0 = QPushButton('&Cancel')

        layout_page0_option = QHBoxLayout()
        layout_page0_option.addStretch(1)
        layout_page0_option.addWidget(self.pushbutton_ok_page0)
        layout_page0_option.addWidget(self.pushbutton_re_page0)
        layout_page0_option.addWidget(self.pushbutton_de_page0)


        layout_page0_global = QVBoxLayout(self.page0)
        layout_page0_global.addWidget(self.tabwidget_page0)
        layout_page0_global.addLayout(layout_page0_option)

        self.stack_window.addWidget(self.page0)

        """# Page 1"""
        self.page1 = QWidget()

        self.tabwidget_page1 = QTabWidget(self.page1)

        self.tab0_page1 = QWidget(self.page1)
        self.tab1_page1 = QWidget(self.page1)

        self.tabwidget_page1.addTab(self.tab0_page1, 'Info')
        self.tabwidget_page1.addTab(self.tab1_page1, 'Option')

        """# Page1 Tab0"""
        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(12)

        label_date_page1 = QLabel('Date      ')
        label_date_page1.setFont(font)

        label_time_page1 = QLabel('Time      ')
        label_time_page1.setFont(font)

        label_loc_page1 = QLabel('Location  ')
        label_loc_page1.setFont(font)

        label_users_name_page1 = QLabel('Name     ')
        label_users_name_page1.setFont(font)

        label_users_gender_page1 = QLabel('Gender')
        label_users_gender_page1.setFont(font)

        label_note_page1 = QLabel('Note')
        label_note_page1.setFont(font)

        line_split_page1 = QFrame()
        line_split_page1.setFrameShape(QFrame.VLine)
        line_split_page1.setFrameShadow(QFrame.Sunken)

        self.dateedit_date_page1 = QDateEdit(QDate.currentDate())
        self.dateedit_date_page1.setDisplayFormat('yyyy/MM/dd')
        self.dateedit_date_page1.setCalendarPopup(True)
        self.dateedit_date_page1.setFont(font)
        self.timeedit_time_page1 = QTimeEdit(QTime.currentTime())
        self.timeedit_time_page1.setDisplayFormat('HH : mm')
        self.timeedit_time_page1.setFont(font)
        self.lineedit_loc_page1 = QLineEdit('Mars')
        self.lineedit_loc_page1.setFont(font)
        self.lineedit_users_name_page1 = QLineEdit('Object')
        self.lineedit_users_name_page1.setFont(font)

        self.radiobutton_users_gender_male_page1 = QRadioButton('Male')
        self.radiobutton_users_gender_female_page1 = QRadioButton('Female')
        self.radiobutton_users_gender_secret_page1 = QRadioButton('Secret')

        self.textedit_note_page1 = QTextEdit('None')
        self.textedit_note_page1.setFont(font)

        groupbox_radio_button = QGroupBox()
        groupbox_radio_button.setStyleSheet("""
                                            QGroupBox{
                                            border: None;
                                            }
                                            """)

        layout_groupbox_radio_button = QHBoxLayout()
        layout_groupbox_radio_button.addWidget(self.radiobutton_users_gender_male_page1)
        layout_groupbox_radio_button.addWidget(self.radiobutton_users_gender_female_page1)
        layout_groupbox_radio_button.addWidget(self.radiobutton_users_gender_secret_page1)
        groupbox_radio_button.setLayout(layout_groupbox_radio_button)

        layout_tab0_page1_global = QVBoxLayout(self.tab0_page1)

        layout_info_page1 = QHBoxLayout()
        layout_note_page1 = QVBoxLayout()

        layout_time_page1 = QVBoxLayout()
        layout_user_page1 = QVBoxLayout()

        layout_date_page1 = QHBoxLayout()
        layout_date_page1.setAlignment(Qt.AlignLeft)
        layout_clock_page1 = QHBoxLayout()
        layout_clock_page1.setAlignment(Qt.AlignLeft)
        layout_loc_page1 = QHBoxLayout()
        layout_loc_page1.setAlignment(Qt.AlignLeft)
        layout_name_page1 = QHBoxLayout()
        layout_gender_page1 = QVBoxLayout()

        layout_date_page1.addWidget(label_date_page1)
        layout_date_page1.addWidget(self.dateedit_date_page1)
        layout_clock_page1.addWidget(label_time_page1)
        layout_clock_page1.addWidget(self.timeedit_time_page1)
        layout_loc_page1.addWidget(label_loc_page1)
        layout_loc_page1.addWidget(self.lineedit_loc_page1)
        layout_name_page1.addWidget(label_users_name_page1)
        layout_name_page1.addWidget(self.lineedit_users_name_page1)
        layout_gender_page1.addWidget(label_users_gender_page1)
        layout_gender_page1.addWidget(groupbox_radio_button)

        layout_time_page1.addLayout(layout_date_page1)
        layout_time_page1.addLayout(layout_clock_page1)
        layout_time_page1.addLayout(layout_loc_page1)
        layout_user_page1.addLayout(layout_name_page1)
        layout_user_page1.addLayout(layout_gender_page1)

        layout_info_page1.addLayout(layout_time_page1)
        layout_info_page1.addWidget(line_split_page1)
        layout_info_page1.addLayout(layout_user_page1)

        layout_note_page1.addWidget(label_note_page1)
        layout_note_page1.addWidget(self.textedit_note_page1)

        layout_tab0_page1_global.addLayout(layout_info_page1)
        layout_tab0_page1_global.addLayout(layout_note_page1)

        self.tab0_page1.setLayout(layout_tab0_page1_global)

        """# Page1 Tab1"""
        font = QFont()
        font.setFamily('MonoxLight')
        font.setPointSize(12)

        label_filter_or_not = QLabel('Filter')
        label_filter_or_not.setFont(font)

        label_filter_hz1 = QLabel('Hz')
        label_filter_hz1.setFont(font)
        label_filter_hz2 = QLabel('Hz')
        label_filter_hz2.setFont(font)
        label_filter_hz3 = QLabel('Hz')
        label_filter_hz3.setFont(font)
        label_filter_hz4 = QLabel('Hz')
        label_filter_hz4.setFont(font)

        label_sampling_freq = QLabel('Sampling Frequency')
        label_sampling_freq.setFont(font)

        label_notch_filter = QLabel('Notch Filter')
        label_notch_filter.setFont(font)

        label_bandpass_filter = QLabel('Bandpass Filter')
        label_bandpass_filter.setFont(font)

        label_bandpass_filter_to = QLabel('to')
        label_bandpass_filter_to.setFont(font)

        label_set_num = QLabel('Set Number')
        label_set_num.setFont(font)

        label_set_time = QLabel('Set Time')
        label_set_time.setFont(font)

        label_set_interval = QLabel('Auto Restart')
        label_set_interval.setFont(font)

        label_set_interval_s = QLabel('s')
        label_set_interval_s.setFont(font)

        label_tcp_address = QLabel('TCP Address')
        label_tcp_address.setFont(font)

        label_tcp_port = QLabel('TCP Port')
        label_tcp_port.setFont(font)

        label_filetype_save = QLabel('Filetype')
        label_filetype_save.setFont(font)

        label_channel_num = QLabel('Channel Number')
        label_channel_num.setFont(font)

        self.spinbox_set_num = QSpinBox()
        self.spinbox_set_time = QSpinBox()

        self.lineedit_tcp_address = QLineEdit()
        self.lineedit_tcp_address.setFont(font)

        self.lineedit_tcp_port = QLineEdit()
        self.lineedit_tcp_port.setFont(font)

        self.combobox_bandpass_high = QComboBox()
        self.combobox_bandpass_high.addItem('1')
        self.combobox_bandpass_high.addItem('5')
        self.combobox_bandpass_high.addItem('10')
        self.combobox_bandpass_high.addItem('20')

        self.combobox_bandpass_low = QComboBox()
        self.combobox_bandpass_low.addItem('50')
        self.combobox_bandpass_low.addItem('100')
        self.combobox_bandpass_low.addItem('200')
        self.combobox_bandpass_low.addItem('450')

        self.combobox_sampling_freq = QComboBox()
        self.combobox_sampling_freq.addItem('250')
        self.combobox_sampling_freq.addItem('500')
        self.combobox_sampling_freq.addItem('1000')
        self.combobox_sampling_freq.addItem('2000')

        self.combobox_notch_filter = QComboBox()
        self.combobox_notch_filter.addItem('50')
        self.combobox_notch_filter.addItem('60')

        self.combobox_filetype_save = QComboBox()
        self.combobox_filetype_save.addItem('csv')
        self.combobox_filetype_save.addItem('npy')

        self.combobox_channel_num = QComboBox()
        self.combobox_channel_num.addItem('64')
        self.combobox_channel_num.addItem('128')
        self.combobox_channel_num.addItem('192')

        self.checkbox_notch_filter = QCheckBox('Notch Filter')
        self.checkbox_bandpass_filter = QCheckBox('Bandpass Filter')

        self.radiobutton_restart_auto = QRadioButton('Auto Restart')
        self.radiobutton_restart_press = QRadioButton('Manual Restart')

        self.spinbox_restart_auto = QSpinBox()

        self.pushbutton_reset_filter = QPushButton('Reset')
        self.pushbutton_reset_data = QPushButton('Reset')
        self.pushbutton_reset_tcpip = QPushButton('Reset')

        groupbox_filter_page1 = QGroupBox('Filter')
        groupbox_filter_page1.setStyleSheet("""
                                            QGroupBox{
                                            font-family: MonoxRegular;
                                            font-size: 20px;
                                            }
                                            """)
        groupbox_data_page1 = QGroupBox('Data')
        groupbox_data_page1.setStyleSheet("""
                                            QGroupBox{
                                            font-family: MonoxRegular;
                                            font-size: 20px;
                                            }
                                        """)
        groupbox_tcpip_page1 = QGroupBox('TCP/IP')
        groupbox_tcpip_page1.setStyleSheet("""
                                            QGroupBox{
                                            font-family: MonoxRegular;
                                            font-size: 20px;
                                            }
                                        """)


        layout_filter_or_not = QHBoxLayout()
        layout_filter_notch = QHBoxLayout()
        layout_filter_bandpass = QHBoxLayout()
        layout_sampling_freq = QHBoxLayout()
        layout_button_filter_reset = QHBoxLayout()

        layout_filter_or_not.addWidget(label_filter_or_not)
        layout_filter_or_not.addWidget(self.checkbox_notch_filter)
        layout_filter_or_not.addWidget(self.checkbox_bandpass_filter)

        layout_filter_notch.addWidget(label_notch_filter)
        layout_filter_notch.addWidget(self.combobox_notch_filter)
        layout_filter_notch.addWidget(label_filter_hz1)

        layout_filter_bandpass.addWidget(label_bandpass_filter)
        layout_filter_bandpass.addWidget(self.combobox_bandpass_high)
        layout_filter_bandpass.addWidget(label_filter_hz2)
        layout_filter_bandpass.addWidget(label_bandpass_filter_to)
        layout_filter_bandpass.addWidget(self.combobox_bandpass_low)
        layout_filter_bandpass.addWidget(label_filter_hz3)

        layout_sampling_freq.addWidget(label_sampling_freq)
        layout_sampling_freq.addWidget(self.combobox_sampling_freq)
        layout_sampling_freq.addWidget(label_filter_hz4)

        layout_button_filter_reset.addWidget(self.pushbutton_reset_filter)

        layout_data_channel_num = QHBoxLayout()
        layout_data_set = QHBoxLayout()
        layout_data_interval = QVBoxLayout()
        layout_data_filetype = QHBoxLayout()
        layout_button_data_reset = QHBoxLayout()

        layout_data_channel_num.addWidget(label_channel_num)
        layout_data_channel_num.addWidget(self.combobox_channel_num)
        layout_data_interval_auto = QHBoxLayout()
        layout_data_interval_press = QHBoxLayout()
        layout_data_interval_auto.addWidget(self.radiobutton_restart_auto)
        layout_data_interval_auto.addWidget(self.spinbox_restart_auto)
        layout_data_interval_auto.addWidget(label_set_interval_s)
        layout_data_interval_press.addWidget(self.radiobutton_restart_press)

        layout_data_interval.addLayout(layout_data_interval_auto)
        layout_data_interval.addLayout(layout_data_interval_press)

        layout_data_set.addWidget(label_set_num)
        layout_data_set.addWidget(self.spinbox_set_num)
        layout_data_set.addWidget(label_set_time)
        layout_data_set.addWidget(self.spinbox_set_time)

        layout_data_filetype.addWidget(label_filetype_save)
        layout_data_filetype.addWidget(self.combobox_filetype_save)

        layout_button_data_reset.addWidget(self.pushbutton_reset_data)

        layout_filter_page1 = QVBoxLayout()
        layout_filter_page1.addLayout(layout_filter_or_not)
        layout_filter_page1.addLayout(layout_filter_notch)
        layout_filter_page1.addLayout(layout_filter_bandpass)
        layout_filter_page1.addLayout(layout_sampling_freq)
        layout_filter_page1.addLayout(layout_button_filter_reset)

        layout_data_page1 = QVBoxLayout()
        layout_data_page1.addLayout(layout_data_channel_num)
        layout_data_page1.addLayout(layout_data_set)
        layout_data_page1.addLayout(layout_data_interval)
        layout_data_page1.addLayout(layout_data_filetype)
        layout_data_page1.addLayout(layout_button_data_reset)

        layout_tcpip_page1_global = QVBoxLayout()
        layout_tcpip_data = QHBoxLayout()
        layout_tcpip_button_reset = QHBoxLayout()

        layout_tcpip_data.addWidget(label_tcp_address)
        layout_tcpip_data.addWidget(self.lineedit_tcp_address)
        layout_tcpip_data.addWidget(label_tcp_port)
        layout_tcpip_data.addWidget(self.lineedit_tcp_port)

        layout_tcpip_button_reset.addWidget(self.pushbutton_reset_tcpip)

        layout_tcpip_page1_global.addLayout(layout_tcpip_data)
        layout_tcpip_page1_global.addLayout(layout_tcpip_button_reset)

        groupbox_filter_page1.setLayout(layout_filter_page1)
        groupbox_data_page1.setLayout(layout_data_page1)
        groupbox_tcpip_page1.setLayout(layout_tcpip_page1_global)

        layout_tab1_page1_up = QHBoxLayout()
        layout_tab1_page1_down = QHBoxLayout()

        layout_tab1_page1_up.addWidget(groupbox_filter_page1)
        layout_tab1_page1_up.addWidget(groupbox_data_page1)
        layout_tab1_page1_down.addWidget(groupbox_tcpip_page1)

        layout_tab1_page1_global = QVBoxLayout()
        layout_tab1_page1_global.addLayout(layout_tab1_page1_up)
        layout_tab1_page1_global.addLayout(layout_tab1_page1_down)

        self.tab1_page1.setLayout(layout_tab1_page1_global)


        """# Page1 Global"""
        self.pushbutton_ok_page1 = QPushButton('&Ok')
        self.pushbutton_de_page1 = QPushButton('&Cancel')
        self.pushbutton_re_page1 = QPushButton('&Reset')

        layout_page1_option = QHBoxLayout()
        layout_page1_option.addStretch(1)
        layout_page1_option.addWidget(self.pushbutton_ok_page1)
        layout_page1_option.addWidget(self.pushbutton_re_page1)
        layout_page1_option.addWidget(self.pushbutton_de_page1)

        layout_page1_global = QVBoxLayout()
        layout_page1_global.addWidget(self.tabwidget_page1)
        layout_page1_global.addLayout(layout_page1_option)

        self.page1.setLayout(layout_page1_global)

        self.stack_window.addWidget(self.page1)