def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) backAction.triggered.connect(self.tbackward) homeAction.triggered.connect(self.thome) self.textBrowser.sourceChanged.connect(self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def __init__(self, parent): super().__init__(parent) self.setWindowTitle("muSync - Logs") self.resize(540, 250) self.setModal(False) logLayout = QVBoxLayout(self) self.__log = QTextBrowser(parent) self.__log.setAcceptRichText(True) self.__log.setReadOnly(True) self.__log.textChanged.connect(self.__scroll) logLayout.addWidget(self.__log) buttonsLayout = QHBoxLayout() self.__autoScroll = QCheckBox("Auto-scroll") self.__autoScroll.setChecked(True) buttonsLayout.addWidget(self.__autoScroll) clearButton = QPushButton(QIcon.fromTheme("edit-delete"), "C&lear") clearButton.clicked.connect(self.__log.clear) buttonsLayout.addWidget(clearButton) copyButton = QPushButton(QIcon.fromTheme("edit-copy"), "Co&py") copyButton.clicked.connect(self.__copy_log) buttonsLayout.addWidget(copyButton) closeButton = QPushButton(QIcon.fromTheme("dialog-close"), "&Close") closeButton.clicked.connect(self.close) buttonsLayout.addWidget(closeButton) logLayout.addLayout(buttonsLayout)
def load_pass_file(self, pass_file_object): """ populates the window with pass_file data :param pass_file_object: a PassFile :return: None """ self.clear() self.pass_file = pass_file_object password_field_label = QLabel('password') password_field = QLineEdit() password_field.setEchoMode(QLineEdit.EchoMode(2)) password_field.setDisabled(True) copy_password_button = QPushButton('copy') copy_password_button.clicked.connect(self.copy_password) self.layout().addWidget(password_field_label, 0, 0) self.layout().addWidget(password_field, 0, 1) self.layout().addWidget(copy_password_button, 0, 2) password_field.setText(self.pass_file.password) for key, value in self.pass_file.attributes: current_grid_view_row = self.layout().rowCount() additional_field_label = QLabel(key) additional_field = QLineEdit() self.layout().addWidget(additional_field_label, current_grid_view_row + 1, 0) self.layout().addWidget(additional_field, current_grid_view_row + 1, 1) additional_field.setText(value) comment_browser_label = QLabel('comments') comment_browser = QTextBrowser() self.layout().addWidget(comment_browser_label, self.layout().rowCount() + 1, 0) self.layout().addWidget(comment_browser, self.layout().rowCount(), 1) comment_browser.setPlainText(self.pass_file.comments)
def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(316, 593) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") self.textBrowser = QTextBrowser(self.centralwidget) self.textBrowser.setObjectName(u"textBrowser") self.textBrowser.setGeometry(QRect(30, 60, 256, 192)) self.textBrowser.setReadOnly(False) self.textBrowser_2 = QTextBrowser(self.centralwidget) self.textBrowser_2.setObjectName(u"textBrowser_2") self.textBrowser_2.setGeometry(QRect(30, 320, 256, 192)) self.textBrowser_2.setReadOnly(False) self.label = QLabel(self.centralwidget) self.label.setObjectName(u"label") self.label.setGeometry(QRect(100, 30, 121, 16)) self.label_2 = QLabel(self.centralwidget) self.label_2.setObjectName(u"label_2") self.label_2.setGeometry(QRect(130, 290, 121, 16)) self.pushButton = QPushButton(self.centralwidget) self.pushButton.setObjectName(u"pushButton") self.pushButton.setGeometry(QRect(110, 530, 93, 28)) self.pushButton.clicked.connect(self.delivery) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(u"statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, parent=None): super().__init__(parent) pythonVersion = sys.version pysideVersion = PySide2.__version__ qtVersion = PySide2.QtCore.qVersion() # Qt version used to run Qt for Python qtBuildVersion = PySide2.QtCore.__version__ # Qt version used to compile PySide2 osName = QSysInfo.prettyProductName() osKernelVersion = QSysInfo.kernelVersion() osCpuArchitecture = QSysInfo.currentCpuArchitecture() textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<dl><dt><strong>Application version</strong></dt>" "<dd>{0}</dd></dl>" "<dl><dt><strong>Qt for Python version</strong></dt>" "<dd>{1} runs on Qt {2} (Built against {3})</dd></dl>" "<dl><dt><strong>Python version</strong></dt>" "<dd>{4}</dd></dl>" "<dl><dt><strong>Operation System</strong></dt>" "<dd>{5} (Kernel {6} on {7})</dd></dl>" "</body></html>").format(QApplication.applicationVersion(), pysideVersion, qtVersion, qtBuildVersion, pythonVersion, osName, osKernelVersion, osCpuArchitecture)) # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(textBox)
def __init__(self): super().__init__() self.setWindowTitle("Repartition Reader") main_widget = QWidget() self.layout = QVBoxLayout() self.logs_window = QTextBrowser() self.pcb = PCombo() self.layout.addWidget(LeftAlignTitleLabel("Select project :")) self.layout.addWidget(self.pcb) self.layout.addWidget(self.logs_window) main_widget.setLayout(self.layout) self.setCentralWidget(main_widget) self.show() # ENCULE DE TES GRANDS MORTS print(self.pcb.selected) # Je voudrais que quand ce pcb.selected change ça relance mon with en dessous pour changer # les valeurs qui sont affichées et prendre d'autres valeurs qui sont dans mon json with open('repartition.json') as json_file: data = json.load(json_file) for a in data['projects'][self.pcb.selected]: self.log_it('Icon: ' + a['icon']) self.log_it('Grab: ' + a['grab']) self.log_it('')
def __init__(self, config, icon=None): super().__init__() self.config = config if icon: self.setWindowIcon(icon) # info panel about_html = self.generate_about_html(html_template) self.about = QTextBrowser() self.about.setOpenExternalLinks(True) self.about.setMinimumSize(400, 260) self.about.setHtml(about_html) # widgets self.clipboard = QClipboard(self) self.status_bar = QLabel() copy_button = QPushButton("Copy") copy_button.setMaximumWidth(75) copy_button.clicked.connect(self.copy_to_clipboard) close_button = QPushButton("Close") close_button.setMaximumWidth(75) close_button.clicked.connect(self.close) # layoyut clipboard_layout = QHBoxLayout() clipboard_layout.addWidget(self.status_bar) clipboard_layout.addWidget(copy_button) clipboard_layout.addWidget(close_button) # Create main layout and add widgets main_layout = QVBoxLayout() main_layout.addWidget(self.about) main_layout.addLayout(clipboard_layout) self.setLayout(main_layout)
def makeSearchView(self): #Later this should also add all of the interfaces listed in the config #class by comparing their names to modules in the 'interfaces' folder self.state = State() yt = contentdata.YtInf(self, 0) self.state.addInterface(yt) self.state.setSearchFunc(yt.getPage) topLayout = QHBoxLayout() self.tab1.addLayout(topLayout, 1, 0, 1, 2) self.searchSelector = QComboBox() self.searchBox = QLineEdit() topLayout.addWidget(self.searchSelector) topLayout.addWidget(self.searchBox) searchButton = QPushButton('Search') topLayout.addWidget(searchButton) searchButton.clicked.connect(self.state.searchFunc) #Setup navigator #self.navigator.setMaximumWidth(100) self.searchSelector.addItem('Youtube') #self.searchResults = QScrollArea() self.searchResults = self.makeResultStack() self.tab1.addWidget(self.searchResults, 2, 1) self.vidInfoPanel = QTextBrowser() self.vidInfoPanel.setMaximumWidth(200) self.tab1.addWidget(self.vidInfoPanel, 2, 0) topLayout.setAlignment(Qt.AlignTop) #Should be determined with configs. All views should be created and the same time and chosen from QStackedWidget according to config. https://www.tutorialspoint.com/pyqt/pyqt_qstackedwidget.htm self.makeYtView() return
def init_ui(self): self.layout = QGridLayout(self) self.setWindowTitle(self.tr("About")) self.setMinimumSize(400, 400) self.text = QTextBrowser() self.layout.addWidget(self.text, 0, 0) self.text.setMarkdown(about_md) self.text.setOpenExternalLinks(True)
def __init__(self, parent=None, *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.resize(850, 650) self.setWindowTitle("Evaluation") self.text_browser = QTextBrowser(parent=self) self.layout = QGridLayout() self.layout.addWidget(self.text_browser, 0, 0) self.setLayout(self.layout)
class Logger: def __init__(self, textBrowser, textLabel): self.logBox = QTextBrowser() self.labelBox = QLabel() self.logBox = textBrowser self.labelBox = textLabel self._enabled = True def log(self, logLine, type=None, special=None): if not self._enabled: return string = "" if logLine is "": try: logLine = specialLogs[special][0] if type is None: type = specialLogs[special][1] except: print("An invalid special log has been provided: ", special) color = "black" if type is None: type = "INFO" string = string + type + ": " if type in typeColors.keys(): color = typeColors[type] string = string + logLine self.logBox.append(string) self.labelBox.setStyleSheet("color: " + color) self.labelBox.setAlignment(Qt.AlignHCenter) if type in typeColors.keys(): self.labelBox.setText(logLine) def saveLog(self, filePath): try: if filePath[-4:] != ".txt": filePath = filePath + ".txt" with open(filePath, mode='a') as outFile: outFile.write( "\nThe following log has been saved at {} \n".format( datetime.now())) outFile.write(self.logBox.toPlainText()) except IOError: self.log("An error was found. Please check the output file path!", type="ERROR") return -1 return 0 def clearLog(self): self.logBox.clear() self.labelBox.clear() def enableLogging(self): self._enabled = True def disableLogging(self): self._enabled = False
def __init__(self, w=500, h=600): super(HelpDialog, self).__init__() layout = QVBoxLayout() self.setLayout(layout) # Use the QTextBrowser and configure it to allow clickable hyperlinks. self.help_text_edit = QTextBrowser() self.help_text_edit.setOpenLinks(True) self.help_text_edit.setOpenExternalLinks(True) layout.addWidget(self.help_text_edit) self.resize(w, h)
def __init__(self, pass_file_object=None): QGroupBox.__init__(self) self.setLayout(QGridLayout()) welcome_message = QTextBrowser() welcome_message.setText('Leeloo Dallas - Multipass!') self.layout().addWidget(welcome_message, 0, 0) self.setTitle('Password Details') self.pass_file = None if pass_file_object: self.load_pass_file(pass_file_object)
def _build_ui(self): layout = QVBoxLayout() self.results = QTextBrowser() font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.results.setFont(font) layout.insertWidget(0, self.results, 1) self.ui_area.setLayout(layout) self.manage(None)
def __init__(self, title, question, return_list): super().__init__() self.layout = QVBoxLayout(self) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Yes | QDialogButtonBox.No, parent=self) self.textbox = QTextBrowser(parent=self) self.setModal(True) self.title = title self.question = question self.return_list = return_list self.initUI()
def __init__(self): super(ICMPInfo, self).__init__('ICMP') content = QFormLayout() self.setLayout(content) self.TYPE = QLabel() content.addRow('Type: ', self.TYPE) self.CODE = QLabel() content.addRow('Code: ', self.CODE) self.checksum = QLabel() content.addRow('Checksum: ', self.checksum) self.DATA = QTextBrowser() content.addRow('Data: ', self.DATA)
class AboutPanel(QDialog): def __init__(self, parent=None): super().__init__(parent=parent, f=Qt.Window) self.init_ui() def init_ui(self): self.layout = QGridLayout(self) self.setWindowTitle(self.tr("About")) self.setMinimumSize(400, 400) self.text = QTextBrowser() self.layout.addWidget(self.text, 0, 0) self.text.setMarkdown(about_md) self.text.setOpenExternalLinks(True)
def __init__(self, master, model, description): """ :param master: Qt parent object :param model: {str} Enigma model :param description: {str} Wiki text """ super().__init__(master) # QT WINDOW SETTINGS =================================================== main_layout = QHBoxLayout() self.setLayout(main_layout) main_layout.setMargin(0) # MODEL IMAGE ========================================================== img = QLabel("") pixmap = QPixmap(VIEW_DATA[model]["img"]).scaled(400, 500) img.setPixmap(pixmap) img.setFrameStyle(QFrame.Panel | QFrame.Plain) img.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # MODEL WIKI =========================================================== wiki_text = QTextBrowser() wiki_text.setHtml(description) # setHtml sets html wiki_text.setStyleSheet(STYLESHEET) wiki_text.setMinimumWidth(350) # SHOW WIDGETS ========================================================= main_layout.addWidget(img) main_layout.addWidget(wiki_text)
def __init__(self, parent=None): super().__init__(parent) textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<dl><dt><strong>NotNypical</strong></dt>" "<dd>Created and developed by <a href=\"https://notnypical.github.io\" title=\"Visit author's homepage\">NotNypical</a>.</dd></dl>" "</body></html>")) # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(textBox)
def create_ui(self): label = QLabel( _("The developer sent a message on {}").format( self._motd.timestamp_string)) browser = QTextBrowser(self) label.setBuddy(browser) self.layout.addWidget(label, 0, 0, 1, 2) self.layout.addWidget(browser, 1, 0, 1, 2) browser.setTextInteractionFlags(Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse | Qt.LinksAccessibleByKeyboard | Qt.LinksAccessibleByMouse) browser.setOpenExternalLinks(True) browser.setMarkdown(self._motd.message) browser.setFocus()
def __init__(self, parent=None): super(SeedDialog, self).__init__(parent) self.setWindowTitle('Mnemonic') self.layout = QtWidgets.QVBoxLayout() self.text = QTextBrowser(self) self.layout.addWidget(self.text) self.print_button = QPushButton('Print') self.layout.addWidget(self.print_button) # noinspection PyUnresolvedReferences self.print_button.clicked.connect(self.print) self.setLayout(self.layout)
def __init__(self, parent=None): super().__init__(parent) textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<p>{0} is an open source editor tool written in Qt for Python and designed for easy creation and editing of documents with character-separated values.</p>" "<p>Copyright © 2020-2021 <a href=\"{1}\" title=\"Visit organization's homepage\">{2}</a>.</p>" "<p>This application is licensed under the terms of the <a href=\"https://www.gnu.org/licenses/gpl-3.0.en.html\" title=\"Visit license's homepage\">GNU General Public License, version 3</a>.</p>" "</body></html>").format(QApplication.applicationName(), QApplication.organizationDomain(), QApplication.organizationName())) # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(textBox)
def __init__(self, app_window=None, dpi=None, *args, **kwargs): super().__init__(parent=app_window, *args, **kwargs) self.app_window = app_window self.text_browser = QTextBrowser(parent=self) self.chessboard_widget = chess_board_widget(parent=self) self.new_pushbutton = QPushButton('New', parent=self) self.back_pushbutton = QPushButton('Back', parent=self) self.forward_pushbutton = QPushButton('Forward', parent=self) self.analyze_prev_pushbutton = QPushButton('Analyze Prev', parent=self) self.advise_next_pushbutton = QPushButton('Advise Next', parent=self) self.self_play_pushbutton = QPushButton('Self Play', parent=self) self.layout = QGridLayout() self.layout.addWidget(self.chessboard_widget, 0, 0, 1, 5) self.layout.addWidget(self.new_pushbutton, 1, 0, 1, 1) self.layout.addWidget(self.back_pushbutton, 1, 1, 1, 1) self.layout.addWidget(self.forward_pushbutton, 1, 2, 1, 1) self.layout.addWidget(self.analyze_prev_pushbutton, 1, 3, 1, 1) self.layout.addWidget(self.advise_next_pushbutton, 1, 4, 1, 1) self.layout.addWidget(self.self_play_pushbutton, 2, 0, 1, 1) self.layout.addWidget(self.text_browser, 3, 0, 1, 5) self.setLayout(self.layout) self.new_pushbutton.clicked.connect(self.chessboard_widget.new_game) self.back_pushbutton.clicked.connect(self.chessboard_widget.move_back) self.forward_pushbutton.clicked.connect( self.chessboard_widget.move_forward) self.analyze_prev_pushbutton.clicked.connect( self.chessboard_widget.analyze_prev) self.advise_next_pushbutton.clicked.connect( self.chessboard_widget.advise_next) self.self_play_pushbutton.clicked.connect( self.chessboard_widget.self_play) # self.analyze_prev_pushbutton.setEnabled(False)
class SeedDialog(QDialog): def __init__(self, parent=None): super(SeedDialog, self).__init__(parent) self.setWindowTitle('Mnemonic') self.layout = QtWidgets.QVBoxLayout() self.text = QTextBrowser(self) self.layout.addWidget(self.text) self.print_button = QPushButton('Print') self.layout.addWidget(self.print_button) # noinspection PyUnresolvedReferences self.print_button.clicked.connect(self.print) self.setLayout(self.layout) def show(self): self.exec_() def print(self): printer = QPrinter() # Create painter painter = QPainter() # Start painter painter.begin(printer) # Grab a widget you want to print screen = self.text.grab() # Draw grabbed pixmap painter.drawPixmap(10, 10, screen) # End painting painter.end() print_dialog = QPrintDialog(printer, self) print_dialog.exec_()
def setup_ui(self): vertical_layout = QVBoxLayout(self) vertical_layout.setSpacing(6) vertical_layout.setContentsMargins(11, 11, 11, 11) splitter_v = QSplitter(self) splitter_v.setOrientation(PySide2.QtCore.Qt.Vertical) size_policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth( splitter_v.sizePolicy().hasHeightForWidth()) splitter_v.setSizePolicy(size_policy) splitter_h = QSplitter(splitter_v) splitter_h.setOrientation(PySide2.QtCore.Qt.Horizontal) vertical_layout_widget = QWidget(splitter_h) self.vertical_layout_left = QVBoxLayout(vertical_layout_widget) self.vertical_layout_left.setSpacing(6) self.vertical_layout_left.setSizeConstraint( QLayout.SetDefaultConstraint) self.vertical_layout_left.setContentsMargins(0, 0, 0, 0) splitter_h.addWidget(vertical_layout_widget) vertical_layout_widget2 = QWidget(splitter_h) self.vertical_layout_right = QVBoxLayout(vertical_layout_widget2) self.vertical_layout_right.setContentsMargins(0, 0, 0, 0) splitter_h.addWidget(vertical_layout_widget2) splitter_v.addWidget(splitter_h) vertical_layout_widget3 = QWidget(splitter_v) vertical_layout_bottom = QVBoxLayout(vertical_layout_widget3) vertical_layout_bottom.setSpacing(6) vertical_layout_bottom.setSizeConstraint(QLayout.SetDefaultConstraint) vertical_layout_bottom.setContentsMargins(11, 0, 11, 11) text_browser = QTextBrowser(vertical_layout_widget3) vertical_layout_bottom.addWidget(text_browser) splitter_v.addWidget(vertical_layout_widget3) vertical_layout.addWidget(splitter_v)
def _create_ui(self): self._keyboard_ui = KeyboardUI() self._keyboard_ui.show() # TODO: Get rid of this in favor of os_interaction self._letter_ui = QLabel("-") self._letter_ui.setWindowTitle("Selected letter") self._letter_ui.setStyleSheet('font-size: 72pt') self._letter_ui.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self._letter_ui.setGeometry(600, 0, 100, 100) self._letter_ui.show() # TODO: Replace with more user-friendly log self._log_window = QTextBrowser() self._log_window.setWindowTitle("Session Log") self._log_window.setGeometry(700, 0, 500, 500) self._log_window.show()
def __init__(self, parent=None): super().__init__(parent) textBox = QTextBrowser() textBox.setFrameStyle(QFrame.NoFrame) textBox.setStyleSheet("background-color:transparent;") textBox.setOpenExternalLinks(True) textBox.setHtml(self.tr("<html><body>" "<dl><dt><strong>BreezeIcons project</strong></dt>" "<dd>Application logo and icons made by <a href=\"https://api.kde.org/frameworks/breeze-icons/html/\" title=\"Visit project's homepage\">BreezeIcons project</a>" "from <a href=\"https://kde.org\" title=\"Visit organization's homepage\">KDE</a>" "are licensed under <a href=\"https://www.gnu.org/licenses/lgpl-3.0.en.html\" title=\"Visit license's homepage\">LGPLv3</a>.</dd></dl>" "</body></html>")) # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(textBox)
def __init__(self, parent: QWidget = None): super().__init__(parent) self.setWindowTitle('Operation helper') self.body = QTextBrowser(self) self.body.setOpenExternalLinks(True) closeButton = QPushButton('Close', self) self.body.setBackgroundRole(QLabel().backgroundRole()) self.setWindowFlags(Qt.Tool) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.body.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.setMinimumWidth(500) self.setMaximumWidth(1000) closeButton.clicked.connect(self.close) layout = QVBoxLayout(self) layout.addWidget(self.body) layout.addWidget(closeButton, 0, Qt.AlignHCenter)
class EvaluationDialog(QDialog): def __init__(self, parent=None, *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.resize(850, 650) self.setWindowTitle("Evaluation") self.text_browser = QTextBrowser(parent=self) self.layout = QGridLayout() self.layout.addWidget(self.text_browser, 0, 0) self.setLayout(self.layout) def update_plot(self): #print(evaluation_history) score_cap = 50 score_history = [ 0, ] for this_evaluation_result in evaluation_history: this_score = this_evaluation_result['score'].pov( color=chess.WHITE).score(mate_score=MATE_SCORE) / 100 if abs(this_score) > score_cap: this_score = this_score / abs(this_score) * score_cap score_history.append(this_score) fig, ax = plt.subplots(1, 1, figsize=(8, 6)) ax.set_ylim(bottom=-score_cap, top=score_cap) ax.set_xlim(left=0, right=50) ax.xaxis.set_major_locator(MaxNLocator(integer=True)) plt.plot(range(0, len(score_history)), score_history, '-o') ax.set_ylabel("Score") ax.set_xlabel('Moves') ax.set_title("Score History (from White's Viewpoint)") ax.grid(True) #fig = plt.gcf() # get current figure buf = io.BytesIO() fig.savefig(buf, format='png') buf.seek(0) string = base64.b64encode(buf.read()) base64_dict = {} base64_dict[ 'score_history'] = f"<img src=\"data:image/png;base64,{urllib.parse.quote(string)}\"/>" plt.close(fig) # output_html_str = f"{base64_dict['score_history']}" self.text_browser.setHtml(output_html_str) self.repaint()
class ResultsWindow(ChildToolWindow): def __init__(self, tool_instance, title, text="", **kwargs): super().__init__(tool_instance, title, statusbar=False, **kwargs) self._build_ui() self.results.setText(text) def _build_ui(self): layout = QVBoxLayout() self.results = QTextBrowser() font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.results.setFont(font) layout.insertWidget(0, self.results, 1) self.ui_area.setLayout(layout) self.manage(None)