]> Softwares of Agnibho - medscript.git/blob - viewbox.py
Bugfix: Windows uninstall package permission error
[medscript.git] / viewbox.py
1 # MedScript
2 # Copyright (C) 2023 Dr. Agnibho Mondal
3 # This file is part of MedScript.
4 # MedScript is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5 # MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6 # You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
7
8 import os
9 from PyQt6.QtWidgets import QMainWindow
10 from PyQt6.QtWebEngineWidgets import QWebEngineView
11 from PyQt6.QtCore import QUrl
12 from PyQt6.QtGui import QIcon
13 from markdown import markdown
14
15 class ViewBox(QMainWindow):
16 def __init__(self, *args, **kwargs):
17 super().__init__(*args, **kwargs)
18
19 self.setWindowTitle("MedScript")
20 self.setGeometry(100, 100, 400, 400)
21
22 self.webview=QWebEngineView()
23
24 self.setCentralWidget(self.webview)
25 self.setWindowIcon(QIcon(os.path.join("resource", "icon_medscript.ico")))
26
27
28 def open(self, file):
29 self.webview.load(QUrl("file:///"+os.path.abspath(file).replace(os.sep, "/")))
30
31 def md(self, file):
32 with open(file) as f:
33 html=markdown(f.read())
34 self.webview.setHtml(html)