Add about page

This commit is contained in:
Samuel Sloniker 2024-07-28 16:11:16 -07:00
parent 55c9722b27
commit d8964a7a0c
4 changed files with 53 additions and 2 deletions

View File

@ -6,7 +6,7 @@ distDir=navpoint-linux-$arch
rm -rf dist/$distDir rm -rf dist/$distDir
mkdir -p dist/$distDir mkdir -p dist/$distDir
pyinstaller -w -F --hidden-import tornado.web main.py pyinstaller -w -F --hidden-import tornado.web --add-data README.md:files --add-data GPL-3.0.txt:files --add-data CC-BY-SA-4.0.txt:files main.py
mv dist/main dist/$distDir/navpoint mv dist/main dist/$distDir/navpoint
cp icon.png dist/$distDir/navpoint.png cp icon.png dist/$distDir/navpoint.png

View File

@ -1,4 +1,4 @@
pyinstaller -i=icon.ico --windowed --onefile --hidden-import tornado.web --add-data icon.ico:files --name=navpoint.exe main.py pyinstaller -i=icon.ico --windowed --onefile --hidden-import tornado.web --add-data icon.ico:files --add-data README.md:files --add-data GPL-3.0.txt:files --add-data CC-BY-SA-4.0.txt:files --name=navpoint.exe main.py
"C:\Program Files (x86)\NSIS\makensis.exe" .\windows_installer.nsi "C:\Program Files (x86)\NSIS\makensis.exe" .\windows_installer.nsi
move "dist\navpoint.exe" "dist\navpoint-windows-%PROCESSOR_ARCHITECTURE%-portable.exe" move "dist\navpoint.exe" "dist\navpoint-windows-%PROCESSOR_ARCHITECTURE%-portable.exe"
move "dist\NavpointInstaller.exe" "dist\navpoint-windows-%PROCESSOR_ARCHITECTURE%-installer.exe" move "dist\NavpointInstaller.exe" "dist\navpoint-windows-%PROCESSOR_ARCHITECTURE%-installer.exe"

44
navpoint/about.py Normal file
View File

@ -0,0 +1,44 @@
import webbrowser
import tempfile
import time
import markdown
import navpoint.fix_path
def about():
with open(navpoint.fix_path.fix_path("README.md")) as f:
readme = markdown.markdown(
f.read()
.replace("https://www.gnu.org/licenses/gpl-3.0.en.html", "#gpl")
.replace("https://creativecommons.org/licenses/by-sa/4.0/", "#cc")
)
with open(navpoint.fix_path.fix_path("GPL-3.0.txt")) as f:
gpl = f.read()
with open(navpoint.fix_path.fix_path("CC-BY-SA-4.0.txt")) as f:
cc = f.read()
with tempfile.NamedTemporaryFile("w+") as f:
f.write(
f"""\
<!DOCTYPE html>
<html>
<head>
<title>Navpoint Desktop</title>
</head>
<body>
<a id="top"></a>{readme}
<h3 id="gpl">GNU General Public License v3.0</h3>
<pre>{gpl}</pre>
<p><a href="#top">Back to top</a></p>
<h3 id="cc">Creative Commons Attribution-ShareAlike 4.0 International</h3>
<pre>{cc}</pre>
<p><a href="#top">Back to top</a></p>
</body>
</html>
"""
)
f.flush()
webbrowser.open(f.name)
time.sleep(0.5) # Give the browser time to open the file

View File

@ -4,6 +4,7 @@ import navpoint.fix_path
import navpoint.local_server import navpoint.local_server
import navpoint.phone_server import navpoint.phone_server
import navpoint.usb import navpoint.usb
import navpoint.about
def run(): def run():
@ -33,6 +34,12 @@ def run():
window, text="Phone running Navpoint Mobile", command=_mobile_clicked window, text="Phone running Navpoint Mobile", command=_mobile_clicked
) )
mobile_button.pack() mobile_button.pack()
ttk.Separator(window, orient="horizontal").pack()
ttk.Label(window, text="Navpoint is free and open-source.").pack()
about_button = ttk.Button(
window, text="About Navpoint", command=navpoint.about.about
)
about_button.pack()
try: try:
window.iconbitmap(navpoint.fix_path.fix_path("icon.ico")) window.iconbitmap(navpoint.fix_path.fix_path("icon.ico"))