Exemple #1
0
 def initUI(self):
     self.setGeometry(600, 300, 700, 500)
     self.setWindowTitle('Huffman_Encoding_3')
     self.setWindowIcon(QIcon(mainpath + '\\source\\luffy.jpg'))
     self.setStyleSheet(
         "QWidget{background-color:#F0FFFF }QPushButton{background:#B0E0E6}QPushButton:hover{background:#E0FFFF}"
     )
     self.char_and_weight_directory = ''
     self.save_filename = ''
     self.save_directory = ''
     self.label_1 = QLabel(self)
     self.label_1.setText('文件中的内容需要是频度表 如(A 12) !')
     self.lineEdit_1 = QLineEdit()
     self.btn_1 = QPushButton('选择待编码文件')
     self.btn_1.clicked.connect(self.openfile)
     self.btn_2 = QPushButton('确认编码')
     self.btn_2.clicked.connect(self.encoding)
     self.label_2 = QLabel(self)
     self.label_2.setText('请输入保存文件名称:')
     self.lineEdit_2 = QLineEdit()
     self.btn_3 = QPushButton('确认保存文件名称')
     self.btn_3.clicked.connect(self.setfilename)
     self.lineEdit_3 = QLineEdit()
     self.btn_4 = QPushButton('选择文件保存路径')
     self.btn_4.clicked.connect(self.setdirecory)
     self.btn_5 = QPushButton('显示赫夫曼树')
     self.btn_5.clicked.connect(
         lambda: show_huffman_tree(self.save_directory + '/' + self.
                                   save_filename + '/' + self.save_filename
                                   + '_' + 'picture.png')
         if os.path.exists(self.save_directory + '/' + self.save_filename +
                           '/' + self.save_filename + '_' + 'picture.png')
         else show_error_message(self))  # 显示哈夫曼树
     self.send = QPushButton('发送文件')
     self.send.clicked.connect(lambda: send.send_file(
         self.save_directory + '/' + self.save_filename, self.save_filename
     ) if (self.save_directory != '' and self.save_filename != '') else
                               show_error_message(self))
     self.clear = QPushButton('清空')
     self.clear.clicked.connect(self.clear_cache)
     self.quit = QPushButton('退出', self)
     self.quit.clicked.connect(QCoreApplication.instance().quit)
     self.back = QPushButton('返回', self)
     self.back.clicked.connect(self.clear_cache)
     layout = QGridLayout()
     layout.addWidget(self.label_1, 0, 2)
     layout.addWidget(self.lineEdit_1, 1, 0, 1, 3)
     layout.addWidget(self.btn_1, 1, 3, 1, 2)
     layout.addWidget(self.label_2, 2, 0, 1, 1)
     layout.addWidget(self.lineEdit_2, 2, 1, 1, 3)
     layout.addWidget(self.btn_3, 2, 4, 1, 1)
     layout.addWidget(self.lineEdit_3, 4, 0, 1, 3)
     layout.addWidget(self.btn_4, 4, 3, 1, 2)
     layout.addWidget(self.btn_2, 5, 0, 1, 5)
     layout.addWidget(self.btn_5, 6, 0, 1, 5)
     layout.addWidget(self.send, 7, 0, 1, 5)
     layout.addWidget(self.clear, 8, 0, 1, 5)
     layout.addWidget(self.back, 9, 0, 1, 2)
     layout.addWidget(self.quit, 9, 3, 1, 2)
     self.setLayout(layout)
Exemple #2
0
    result_list = str(results).split(' ')
    for i in range(1, 4, 1):
        if float(result_list[i]) < 230 / 255:
            return False
    return True


if __name__ == '__main__':
    get_pixel_color_init()
    question_time = 0
    print("开始等待题目")
    while True:
        time.sleep(0.1)
        if is_white(53, 225) and is_white(368, 236):
            if is_white(255, 154):
                question_time += 1
                print("发现题目{},获取提示中:{}".format(question_time, time.time()))
                question_img = pag.screenshot(region=(40, 167, 330, 340))
                question_img.save(image_path)
                send.send_file(image_path)
                if question_time > 12:
                    break
                print("图片发送完毕: {}".format(time.time()))
                print(" 开始15秒的等待时间")
                for i in range(10):
                    print(i)
                    time.sleep(1)
            else:
                print("答案公布时间")
                time.sleep(0.3)
Exemple #3
0
 def initUI(self):
     self.setGeometry(600, 300, 700, 500)
     self.setWindowTitle('Huffman_Encoding_4')
     self.setWindowIcon(QIcon(mainpath + '\\source\\luffy.jpg'))
     self.setStyleSheet(
         "QWidget{background-color:#F0FFFF}QPushButton{background:#B0E0E6}QPushButton:hover{background:#E0FFFF}"
     )
     self.str_directory = ''
     self.save_filename = ''
     self.save_directory = ''
     self.encode_table_directory = ''
     self.encode_table_filename = ''
     self.code = ''
     self.label_1 = QLabel(self)
     self.label_1.setText('文件中的内容需要是字符串!')
     self.lineEdit_1 = QLineEdit()
     self.btn_1 = QPushButton('选择待编码文件')
     self.btn_1.clicked.connect(self.setencodefile)
     self.label_2 = QLabel(self)
     self.label_2.setText('请输入保存文件名称:')
     self.lineEdit_2 = QLineEdit()
     self.btn_2 = QPushButton('确认保存文件名称')
     self.btn_2.clicked.connect(self.setfilename)
     self.lineEdit_3 = QLineEdit()
     self.btn_3 = QPushButton('选择已有编码规范')
     self.btn_3.clicked.connect(self.openencodefile)
     self.lineEdit_4 = QLineEdit()
     self.btn_4 = QPushButton('选择文件保存路径')
     self.btn_4.clicked.connect(self.setdirecory)
     self.btn_5 = QPushButton('确认编码')
     self.btn_5.clicked.connect(self.encoding)
     self.btn_6 = QPushButton('显示赫夫曼树')
     self.btn_6.clicked.connect(self.show_huffman)
     self.btn_7 = QPushButton('显示编码结果')
     self.btn_7.clicked.connect(lambda: show_code(self, self.code))
     self.send = QPushButton('发送文件')
     self.send.clicked.connect(lambda: send.send_file(
         self.save_directory + '/' + self.save_filename, self.save_filename
     ) if (self.save_directory != '' and self.save_filename != '') else
                               show_error_message(self))
     self.clear = QPushButton('清空')
     self.clear.clicked.connect(self.clear_cache)
     self.quit = QPushButton('退出', self)
     self.quit.clicked.connect(QCoreApplication.instance().quit)
     self.back = QPushButton('返回', self)
     self.back.clicked.connect(self.clear_cache)
     layout = QGridLayout()
     layout.addWidget(self.label_1, 0, 2)
     layout.addWidget(self.lineEdit_1, 1, 0, 1, 3)
     layout.addWidget(self.btn_1, 1, 3, 1, 2)
     layout.addWidget(self.label_2, 3, 0, 1, 1)
     layout.addWidget(self.lineEdit_2, 3, 1, 1, 3)
     layout.addWidget(self.btn_2, 3, 4, 1, 1)
     layout.addWidget(self.lineEdit_3, 4, 0, 1, 3)
     layout.addWidget(self.btn_3, 4, 3, 1, 2)
     layout.addWidget(self.lineEdit_4, 5, 0, 1, 3)
     layout.addWidget(self.btn_4, 5, 3, 1, 2)
     layout.addWidget(self.btn_5, 6, 0, 1, 5)
     layout.addWidget(self.btn_6, 7, 0, 1, 5)
     layout.addWidget(self.btn_7, 8, 0, 1, 5)
     layout.addWidget(self.send, 9, 0, 1, 5)
     layout.addWidget(self.clear, 10, 0, 1, 5)
     layout.addWidget(self.back, 11, 0, 1, 2)
     layout.addWidget(self.quit, 11, 3, 1, 2)
     self.setLayout(layout)