2023-04-08 07:08:13 +03:00
|
|
|
import requests
|
|
|
|
import webbrowser
|
|
|
|
import json
|
|
|
|
import PySimpleGUI as Sgi
|
2023-05-28 15:59:32 +03:00
|
|
|
import gettext
|
2023-04-08 07:08:13 +03:00
|
|
|
|
2023-05-28 15:59:32 +03:00
|
|
|
from texts import ver
|
2023-06-09 22:16:49 +03:00
|
|
|
from setts import language
|
2023-05-28 15:59:32 +03:00
|
|
|
|
|
|
|
|
2023-06-09 22:16:49 +03:00
|
|
|
lang = gettext.translation('locale', localedir='locale', languages=[language()])
|
2023-05-28 15:59:32 +03:00
|
|
|
lang.install()
|
|
|
|
_ = lang.gettext
|
2023-04-08 07:08:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
def upd_check():
|
2023-07-13 16:31:12 +03:00
|
|
|
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 = [
|
2023-05-28 15:59:32 +03:00
|
|
|
[Sgi.Text(_("Обновление"))],
|
|
|
|
[Sgi.Text(_("Вышла новая версия программы\nНужно обновиться"))],
|
|
|
|
[Sgi.Button(_(' Скачать ')), Sgi.Push(), Sgi.Button(_(' Отмена '))]
|
2023-04-08 07:08:13 +03:00
|
|
|
]
|
|
|
|
|
2023-05-28 15:59:32 +03:00
|
|
|
window = Sgi.Window(_("Проверка обновления"), layout, modal=True)
|
2023-04-08 07:08:13 +03:00
|
|
|
|
|
|
|
while True:
|
|
|
|
event, button = window.read()
|
2023-05-28 15:59:32 +03:00
|
|
|
if event == _(' Скачать '):
|
2023-04-08 07:08:13 +03:00
|
|
|
webbrowser.open('https://risenhome.xyz/calc.html', new=2, autoraise=True)
|
|
|
|
window.close()
|
2023-05-28 15:59:32 +03:00
|
|
|
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 = [
|
2023-06-09 22:16:49 +03:00
|
|
|
[Sgi.Text(_('Последняя версия: ')+f'{version_new}'+_('\nВаша версия: ')+f'{version_old}'+_('\n\nОбновление не требуется'))],
|
2023-05-28 15:59:32 +03:00
|
|
|
[Sgi.Button(_(' Закрыть '))]
|
2023-04-08 07:08:13 +03:00
|
|
|
]
|
|
|
|
|
2023-05-28 15:59:32 +03:00
|
|
|
window = Sgi.Window(_("Проверка обновления"), layout, modal=True)
|
2023-04-08 07:08:13 +03:00
|
|
|
|
|
|
|
while True:
|
|
|
|
event, button = window.read()
|
2023-05-28 15:59:32 +03:00
|
|
|
if event == _(' Закрыть '):
|
2023-04-08 07:08:13 +03:00
|
|
|
window.close()
|
|
|
|
elif event == "Exit" or event == Sgi.WIN_CLOSED:
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
def upd_start():
|
2023-07-13 16:31:12 +03:00
|
|
|
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 = [
|
2023-05-28 15:59:32 +03:00
|
|
|
[Sgi.Text(_("Обновление"))],
|
|
|
|
[Sgi.Text(_("Вышла новая версия программы\nНужно обновиться"))],
|
|
|
|
[Sgi.Button(_(' Скачать ')), Sgi.Push(), Sgi.Button(' Отмена ')]
|
2023-04-08 07:08:13 +03:00
|
|
|
]
|
|
|
|
|
2023-05-28 15:59:32 +03:00
|
|
|
window = Sgi.Window(_("Вышла новая версия!"), layout, modal=True)
|
2023-04-08 07:08:13 +03:00
|
|
|
|
|
|
|
while True:
|
|
|
|
event, button = window.read()
|
2023-05-28 15:59:32 +03:00
|
|
|
if event == _(' Скачать '):
|
2023-04-08 07:08:13 +03:00
|
|
|
webbrowser.open('https://risenhome.xyz', new=2, autoraise=True)
|
|
|
|
window.close()
|
2023-05-28 15:59:32 +03:00
|
|
|
elif event == _(' Отмена '):
|
2023-04-08 07:08:13 +03:00
|
|
|
window.close()
|
|
|
|
elif event == "Exit" or event == Sgi.WIN_CLOSED:
|
|
|
|
break
|