Skip to content

Commit 7ebfa70

Browse files
Added first GUI version
1 parent 2f97cf4 commit 7ebfa70

17 files changed

Lines changed: 907 additions & 22 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ config.yml
139139

140140
# packaged releases
141141
*.zip
142+
143+
venv3/
144+
build/
145+
dist/

GUI/Styling.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
from PySide2.QtWidgets import QMainWindow
2+
3+
from util import Config
4+
5+
6+
def set_style(window: QMainWindow) -> None:
7+
"""
8+
Sets the style of the given window to the correct color scheme.
9+
:param window: The window to set the style for
10+
:return: None
11+
"""
12+
13+
dark_mode_enabled = Config.load_config_key(Config.ConfigKeys.DARK_MODE.value)
14+
if dark_mode_enabled is None:
15+
dark_mode_enabled = True
16+
17+
print(f"Dark mode is {dark_mode_enabled}")
18+
19+
# set some colors based on the darkmode variable
20+
if dark_mode_enabled:
21+
col_background = "#161618"
22+
col_background_accent = "#252529"
23+
col_btn_enabled = "#050507"
24+
col_text = "#FFF"
25+
col_accent = "#404045"
26+
col_btn_disabled = "#101012"
27+
28+
else:
29+
col_background = "#FFF"
30+
col_background_accent = "#AAA"
31+
col_btn_enabled = "#EEE"
32+
col_text = "#000"
33+
col_accent = "#252529"
34+
col_btn_disabled = "#666"
35+
36+
window.setStyleSheet(f"""
37+
QMainWindow, QWidget {{
38+
background-color: {col_background};
39+
}}
40+
41+
QMenu {{
42+
color: {col_text};
43+
}}
44+
45+
QLineEdit {{
46+
text-color: {col_text};
47+
font-size: 12pt;
48+
background-color: {col_background_accent};
49+
}}
50+
51+
QListWidget {{
52+
text-color: {col_text};
53+
font-size: 12pt;
54+
background-color: {col_background_accent};
55+
}}
56+
57+
QPushButton {{
58+
background-color: {col_btn_enabled};
59+
border: 0px;
60+
font-size: 10pt;
61+
text-transform: uppercase;
62+
font-weight: bold;
63+
color: {col_text};
64+
padding: 10px;
65+
}}
66+
67+
QPushButton:disabled {{
68+
background: {col_btn_disabled};
69+
color: {col_accent};
70+
border: 0px;
71+
}}
72+
73+
QPushButton:checked {{
74+
background: {col_accent};
75+
border: 0px;
76+
}}
77+
78+
QPushButton:hover {{
79+
background: {col_accent};
80+
border: 0px;
81+
}}
82+
83+
QLabel {{
84+
color: {col_text};
85+
}}
86+
""")

GUI/__init__.py

Whitespace-only changes.

GUI/config_creator.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import os
2+
3+
from PySide2.QtCore import Qt
4+
from PySide2.QtGui import QPalette
5+
from PySide2.QtWidgets import QWidget, QMainWindow
6+
7+
from GUI import Styling
8+
from GUI.ui_config_create import Ui_ConfigCreator
9+
from util import Config
10+
11+
12+
class ConfigCreator(QWidget):
13+
main_window = None
14+
15+
def __init__(self):
16+
super().__init__()
17+
18+
self.ui = Ui_ConfigCreator()
19+
self.ui.setupUi(self)
20+
21+
Styling.set_style(self)
22+
23+
self.setWindowTitle("Enter your Token")
24+
25+
cookie_explanation = ""
26+
with open(os.path.join(os.path.realpath(__file__), "../../files/cookie_explanation.txt"), 'r', encoding='utf8') as f:
27+
for line in f.read().splitlines():
28+
cookie_explanation += line + "\n"
29+
30+
self.ui.label_sids.setText("SIDS Token: ")
31+
self.ui.label_explanation.setText(cookie_explanation)
32+
33+
self.ui.btn_ok.setText("CONFIRM")
34+
self.ui.btn_ok.pressed.connect(self.ok_pressed)
35+
36+
# dark mode options
37+
dark_mode_enabled = Config.load_config_key(Config.ConfigKeys.DARK_MODE.value)
38+
if dark_mode_enabled is None:
39+
dark_mode_enabled = True
40+
41+
if dark_mode_enabled:
42+
# style items
43+
palette = QPalette()
44+
palette.setColor(QPalette.Text, Qt.white)
45+
46+
self.ui.text_sids.setPalette(palette)
47+
48+
def set_main_window(self, window: QMainWindow):
49+
self.main_window = window
50+
51+
def ok_pressed(self):
52+
Config.save_config(self.ui.text_sids.text())
53+
54+
self.main_window.refresh_theme_list()
55+
self.main_window.show()
56+
57+
self.close()

GUI/icon.ico

58.2 KB
Binary file not shown.

GUI/ui_config_create.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
3+
################################################################################
4+
## Form generated from reading UI file 'config_create.ui'
5+
##
6+
## Created by: Qt User Interface Compiler version 5.15.2
7+
##
8+
## WARNING! All changes made in this file will be lost when recompiling UI file!
9+
################################################################################
10+
11+
from PySide2.QtCore import *
12+
from PySide2.QtGui import *
13+
from PySide2.QtWidgets import *
14+
15+
16+
class Ui_ConfigCreator(object):
17+
def setupUi(self, ConfigCreator):
18+
if not ConfigCreator.objectName():
19+
ConfigCreator.setObjectName(u"ConfigCreator")
20+
ConfigCreator.resize(700, 300)
21+
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
22+
sizePolicy.setHorizontalStretch(0)
23+
sizePolicy.setVerticalStretch(0)
24+
sizePolicy.setHeightForWidth(ConfigCreator.sizePolicy().hasHeightForWidth())
25+
ConfigCreator.setSizePolicy(sizePolicy)
26+
ConfigCreator.setMinimumSize(QSize(700, 300))
27+
ConfigCreator.setMaximumSize(QSize(700, 300))
28+
self.verticalLayout = QVBoxLayout(ConfigCreator)
29+
self.verticalLayout.setObjectName(u"verticalLayout")
30+
self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
31+
32+
self.verticalLayout.addItem(self.verticalSpacer_2)
33+
34+
self.label_explanation = QLabel(ConfigCreator)
35+
self.label_explanation.setObjectName(u"label_explanation")
36+
37+
self.verticalLayout.addWidget(self.label_explanation, 0, Qt.AlignLeft | Qt.AlignTop)
38+
39+
self.verticalSpacer_3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Minimum)
40+
41+
self.verticalLayout.addItem(self.verticalSpacer_3)
42+
43+
self.horizontalLayout = QHBoxLayout()
44+
self.horizontalLayout.setObjectName(u"horizontalLayout")
45+
self.label_sids = QLabel(ConfigCreator)
46+
self.label_sids.setObjectName(u"label_sids")
47+
48+
self.horizontalLayout.addWidget(self.label_sids)
49+
50+
self.text_sids = QLineEdit(ConfigCreator)
51+
self.text_sids.setObjectName(u"text_sids")
52+
53+
self.horizontalLayout.addWidget(self.text_sids)
54+
55+
self.verticalLayout.addLayout(self.horizontalLayout)
56+
57+
self.btn_ok = QPushButton(ConfigCreator)
58+
self.btn_ok.setObjectName(u"btn_ok")
59+
60+
self.verticalLayout.addWidget(self.btn_ok)
61+
62+
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
63+
64+
self.verticalLayout.addItem(self.verticalSpacer)
65+
66+
self.retranslateUi(ConfigCreator)
67+
68+
QMetaObject.connectSlotsByName(ConfigCreator)
69+
70+
# setupUi
71+
72+
def retranslateUi(self, ConfigCreator):
73+
ConfigCreator.setWindowTitle(QCoreApplication.translate("ConfigCreator", u"Form", None))
74+
self.label_explanation.setText(QCoreApplication.translate("ConfigCreator", u"TextLabel", None))
75+
self.label_sids.setText(QCoreApplication.translate("ConfigCreator", u"TextLabel", None))
76+
self.btn_ok.setText(QCoreApplication.translate("ConfigCreator", u"PushButton", None))
77+
# retranslateUi

GUI/ui_voting.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# -*- coding: utf-8 -*-
2+
3+
################################################################################
4+
## Form generated from reading UI file 'voting.ui'
5+
##
6+
## Created by: Qt User Interface Compiler version 5.15.2
7+
##
8+
## WARNING! All changes made in this file will be lost when recompiling UI file!
9+
################################################################################
10+
11+
from PySide2.QtCore import *
12+
from PySide2.QtWidgets import *
13+
14+
15+
class Ui_VotingWindow(object):
16+
def setupUi(self, VotingWindow):
17+
if not VotingWindow.objectName():
18+
VotingWindow.setObjectName(u"VotingWindow")
19+
VotingWindow.resize(1000, 700)
20+
VotingWindow.setMinimumSize(QSize(1000, 700))
21+
VotingWindow.setMaximumSize(QSize(16777214, 16777215))
22+
self.actionAbout_pyJAMa = QAction(VotingWindow)
23+
self.actionAbout_pyJAMa.setObjectName(u"actionAbout_pyJAMa")
24+
self.actionCheck_for_Updates = QAction(VotingWindow)
25+
self.actionCheck_for_Updates.setObjectName(u"actionCheck_for_Updates")
26+
self.actionInput_token = QAction(VotingWindow)
27+
self.actionInput_token.setObjectName(u"actionInput_token")
28+
self.actionTest_Connection = QAction(VotingWindow)
29+
self.actionTest_Connection.setObjectName(u"actionTest_Connection")
30+
self.actionReload_all_Data = QAction(VotingWindow)
31+
self.actionReload_all_Data.setObjectName(u"actionReload_all_Data")
32+
self.actionQuit = QAction(VotingWindow)
33+
self.actionQuit.setObjectName(u"actionQuit")
34+
self.centralwidget = QWidget(VotingWindow)
35+
self.centralwidget.setObjectName(u"centralwidget")
36+
self.verticalLayout = QVBoxLayout(self.centralwidget)
37+
self.verticalLayout.setObjectName(u"verticalLayout")
38+
self.label_status = QLabel(self.centralwidget)
39+
self.label_status.setObjectName(u"label_status")
40+
41+
self.verticalLayout.addWidget(self.label_status)
42+
43+
self.text_theme_search = QLineEdit(self.centralwidget)
44+
self.text_theme_search.setObjectName(u"text_theme_search")
45+
46+
self.verticalLayout.addWidget(self.text_theme_search)
47+
48+
self.list_themes = QListWidget(self.centralwidget)
49+
self.list_themes.setObjectName(u"list_themes")
50+
51+
self.verticalLayout.addWidget(self.list_themes)
52+
53+
self.horizontalLayout = QHBoxLayout()
54+
self.horizontalLayout.setObjectName(u"horizontalLayout")
55+
self.btn_vote_yes = QPushButton(self.centralwidget)
56+
self.btn_vote_yes.setObjectName(u"btn_vote_yes")
57+
58+
self.horizontalLayout.addWidget(self.btn_vote_yes)
59+
60+
self.btn_vote_no = QPushButton(self.centralwidget)
61+
self.btn_vote_no.setObjectName(u"btn_vote_no")
62+
63+
self.horizontalLayout.addWidget(self.btn_vote_no)
64+
65+
self.btn_flag = QPushButton(self.centralwidget)
66+
self.btn_flag.setObjectName(u"btn_flag")
67+
68+
self.horizontalLayout.addWidget(self.btn_flag)
69+
70+
self.verticalLayout.addLayout(self.horizontalLayout)
71+
72+
VotingWindow.setCentralWidget(self.centralwidget)
73+
self.menubar = QMenuBar(VotingWindow)
74+
self.menubar.setObjectName(u"menubar")
75+
self.menubar.setGeometry(QRect(0, 0, 1000, 21))
76+
VotingWindow.setMenuBar(self.menubar)
77+
self.statusbar = QStatusBar(VotingWindow)
78+
self.statusbar.setObjectName(u"statusbar")
79+
VotingWindow.setStatusBar(self.statusbar)
80+
81+
self.retranslateUi(VotingWindow)
82+
83+
QMetaObject.connectSlotsByName(VotingWindow)
84+
85+
# setupUi
86+
87+
def retranslateUi(self, VotingWindow):
88+
VotingWindow.setWindowTitle(QCoreApplication.translate("VotingWindow", u"MainWindow", None))
89+
self.actionAbout_pyJAMa.setText(QCoreApplication.translate("VotingWindow", u"About pyJAMa", None))
90+
self.actionCheck_for_Updates.setText(QCoreApplication.translate("VotingWindow", u"Check for Updates", None))
91+
self.actionInput_token.setText(QCoreApplication.translate("VotingWindow", u"Input Token", None))
92+
self.actionTest_Connection.setText(QCoreApplication.translate("VotingWindow", u"Test Connection", None))
93+
self.actionReload_all_Data.setText(QCoreApplication.translate("VotingWindow", u"Reload all Data", None))
94+
self.actionQuit.setText(QCoreApplication.translate("VotingWindow", u"Quit", None))
95+
self.label_status.setText(QCoreApplication.translate("VotingWindow", u"TextLabel", None))
96+
self.text_theme_search.setPlaceholderText(
97+
QCoreApplication.translate("VotingWindow", u"Search for Themes", None))
98+
self.btn_vote_yes.setText(QCoreApplication.translate("VotingWindow", u"Vote YES", None))
99+
self.btn_vote_no.setText(QCoreApplication.translate("VotingWindow", u"Vote NO", None))
100+
self.btn_flag.setText(QCoreApplication.translate("VotingWindow", u"FLAG", None))
101+
# retranslateUi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ The program needs your session cookie from ldjam.com to communicate with the web
3333

3434
Entering tokens manually is not the most elegant solution. There might be a way to detect the browser used on the machine and to extract the cookies automatically.
3535

36-
- [ ] GUI
36+
- [X] GUI
3737

3838
A GUI would be nice to have to make the program more accessable to people who don't like using the command line or that don't want to deal with pip requirements.

files/cookie_explanation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Welcome to pyJAMa! To use this program, it needs your LDJAM login token to vote on behalf of your LDJAM account.
22
The token will NEVER be sent anywhere except to the official LDJAM API.
33

4-
If you don't know how to find your token, click here: https://github.com/InitialPosition/pyJAMa#cookie-data
4+
If you don't know how to find your token, go to https://github.com/InitialPosition/pyJAMa#cookie-data

0 commit comments

Comments
 (0)