Calc3D_by_Risen/update.py

91 lines
3.2 KiB
Python
Raw Normal View History

2023-04-08 07:08:13 +03:00
import requests
import webbrowser
import json
import PySimpleGUI as Sgi
import gettext
2023-04-08 07:08:13 +03:00
from texts import ver
from setts import language
lang = gettext.translation('locale', localedir='locale', languages=[language()])
lang.install()
_ = lang.gettext
2023-04-08 07:08:13 +03:00
def upd_check():
with open('setts.json') as json_file:
2023-04-08 07:08:13 +03:00
data = json.load(json_file)
set_theme = data["settings"]["theme"]
version_new = requests.get('https://risenhome.xyz/feed/Risen.json').json()["version"]["ver"]
version_old = ver
if version_new > version_old:
Sgi.theme(set_theme)
layout = [
[Sgi.Text(_("Обновление"))],
[Sgi.Text(_("Вышла новая версия программы\nНужно обновиться"))],
[Sgi.Button(_(' Скачать ')), Sgi.Push(), Sgi.Button(_(' Отмена '))]
2023-04-08 07:08:13 +03:00
]
window = Sgi.Window(_("Проверка обновления"), layout, modal=True)
2023-04-08 07:08:13 +03:00
while True:
event, button = window.read()
if event == _(' Скачать '):
2023-04-08 07:08:13 +03:00
webbrowser.open('https://risenhome.xyz/calc.html', new=2, autoraise=True)
window.close()
elif event == _(' Отмена '):
2023-04-08 07:08:13 +03:00
window.close()
elif event == "Exit" or event == Sgi.WIN_CLOSED:
break
else:
Sgi.theme(set_theme)
layout = [
2024-03-31 13:42:28 +03:00
[Sgi.Text(_('Последняя версия: ')+f'{version_new}'+_('\nВаша версия: ')+f'{version_old}'+_('\n\n'
'Обновление не'
' требуется'))],
[Sgi.Button(_(' Закрыть '))]
2023-04-08 07:08:13 +03:00
]
window = Sgi.Window(_("Проверка обновления"), layout, modal=True)
2023-04-08 07:08:13 +03:00
while True:
event, button = window.read()
if event == _(' Закрыть '):
2023-04-08 07:08:13 +03:00
window.close()
elif event == "Exit" or event == Sgi.WIN_CLOSED:
break
2024-03-31 13:42:28 +03:00
# def upd_start():
# with open('setts.json') as json_file:
# data = json.load(json_file)
# set_theme = data["settings"]["theme"]
#
# version_new = requests.get('https://risenhome.xyz/feed/Risen.json').json()["version"]["ver"]
# version_old = ver
#
# if version_new > version_old:
#
# Sgi.theme(set_theme)
# layout = [
# [Sgi.Text(_("Обновление"))],
# [Sgi.Text(_("Вышла новая версия программы\nНужно обновиться"))],
# [Sgi.Button(_(' Скачать ')), Sgi.Push(), Sgi.Button(' Отмена ')]
# ]
#
# window = Sgi.Window(_("Вышла новая версия!"), layout, modal=True)
#
# while True:
# event, button = window.read()
# if event == _(' Скачать '):
# webbrowser.open('https://risenhome.xyz', new=2, autoraise=True)
# window.close()
# elif event == _(' Отмена '):
# window.close()
# elif event == "Exit" or event == Sgi.WIN_CLOSED:
# break