Oct-31-2024, 10:59 PM
I'm trying to show markdown within a Qt app which I've got working (it's a bit average with the externally referenced markdown script link...), but I want to show images as well within it that are locally stored, and this isn't working as is.
This is my code:
Also, how would I use a local md-block reference instead of external? I've tried copying the md-block.js from that external source into a local file and using that as the source, but no worky... I'm canoeing with a broken paddle I feel.
This is my code:
from PyQt6.QtWidgets import (QMainWindow, QApplication, QVBoxLayout, QWidget, QPushButton) from PyQt6.QtWebEngineWidgets import QWebEngineView from PyQt6.QtCore import Qt class mainWin(QMainWindow): def __init__(self, parent=None): super(mainWin, self).__init__(parent) self.setupUI() def setupUI(self): self.setGeometry(0, 0, 300, 200) central_widget = QWidget() vbox = QVBoxLayout() vbox.setAlignment(Qt.AlignmentFlag.AlignCenter) central_widget.setLayout(vbox) markdown_html = r'''<!DOCTYPE html> <html> <head> <title></title> <style> :root { font-family: "Roboto"; font-size: 10pt; } </style> <script type="module" src="https://md-block.verou.me/md-block.js"></script> </head> <body> <md-block>**Click** on a function's info icon to see a description and usage examples. </md-block> </body> </html> ''' help_md = QWebEngineView() help_md.setHtml(markdown_html) vbox.addWidget(help_md) self.setCentralWidget(central_widget) def on_btn_clicked(self): print("button clicked") if __name__ == '__main__': import sys app = QApplication(sys.argv) win = mainWin() win.setWindowTitle("Main Window") win.show() sys.exit(app.exec())How can I show images?
Also, how would I use a local md-block reference instead of external? I've tried copying the md-block.js from that external source into a local file and using that as the source, but no worky... I'm canoeing with a broken paddle I feel.