-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathAboutBoxQT.py
75 lines (65 loc) · 3.09 KB
/
AboutBoxQT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
# generated by wxGlade 0.3.5.1 on Thu Apr 21 12:10:56 2005
# Papagayo-NG, a lip-sync tool for use with several different animation suites
# Original Copyright (C) 2005 Mike Clifton
# Contact information at http://www.lostmarble.com
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import PySide2.QtCore as QtCore
import PySide2.QtGui as QtGui
import yaml
from PySide2.QtGui import QDesktopServices
import PySide2.QtWidgets as QtWidgets
# from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
from PySide2.QtUiTools import QUiLoader as uic
from PySide2.QtCore import QFile
import utilities
from utilities import *
class AboutBox:
def __init__(self):
self.loader = None
self.ui = None
self.ui_file = None
print(os.path.join(get_main_dir(), "rsrc", "about_box.ui"))
self.main_window = self.load_ui_widget(os.path.join(get_main_dir(), "rsrc", "about_box.ui"))
self.main_window.setWindowIcon(QtGui.QIcon(os.path.join(get_main_dir(), "rsrc", "window_icon.bmp")))
self.main_window.about_ok_button.clicked.connect(self.close)
self.main_window.license.anchorClicked.connect(self.open_license)
self.main_window.license_version.setText("Version: {}".format(self.get_version_from_yaml()))
self.markdown_url = QtCore.QUrl("file:///{}".format(os.path.join(utilities.get_main_dir(),
"about_markdown.html")))
self.main_window.license.setAlignment(QtCore.Qt.AlignCenter)
self.main_window.license.setSource(self.markdown_url)
def get_version_from_yaml(self):
version_file = open(os.path.join(utilities.get_main_dir(), "version_information.txt"))
version_data = yaml.safe_load(version_file)
return version_data["Version"]
def open_license(self, event):
if event.toString() == "gpl.html":
license_path = QtCore.QUrl("file:///{}".format(os.path.join(get_main_dir(), "rsrc", "gpl.html")))
QtGui.QDesktopServices.openUrl(license_path)
else:
QtGui.QDesktopServices.openUrl(event)
def load_ui_widget(self, ui_filename, parent=None):
loader = uic()
file = QFile(ui_filename)
file.open(QFile.ReadOnly)
self.ui = loader.load(file, parent)
file.close()
return self.ui
def close(self):
self.main_window.close()
# end of class AboutBox