This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlauncher.py
48 lines (41 loc) · 1.48 KB
/
launcher.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
#!/usr/bin/env python
import launcherui
import sys
import os
from subprocess import Popen
from ResourceHelpers import SettingsHelper
from PyQt5 import QtWidgets, QtGui
class MainWindow(QtWidgets.QWidget, launcherui.Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.btn_save.clicked.connect(self.write_settings)
self.btn_launch.clicked.connect(self.launch)
self.load_settings()
def load_settings(self):
settings = SettingsHelper()
detailed_water = settings.get('world_water_tiled', False)
resolution = (settings.get('screen_width', 800), settings.get('screen_height', 600))
if resolution == (1366, 768):
self.fs_cb.setChecked(True)
if detailed_water is True:
self.wat_cb.setChecked(True)
def write_settings(self):
settings = SettingsHelper()
settings.set('world_water_tiled', self.wat_cb.isChecked())
if self.fs_cb.isChecked():
settings.set('screen_width', 1366)
settings.set('screen_height', 768)
else:
settings.set('screen_width', 800)
settings.set('screen_height', 600)
def launch(self):
self.write_settings()
# os.system("python main.py")
proc = Popen(['python main.py'], shell=True,
stdin=None, stdout=None, stderr=None, close_fds=True)
self.close()
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()