Skip to content

Commit ae9b9b3

Browse files
committed
gui for easier setup, changes in config
1 parent d2f3df8 commit ae9b9b3

12 files changed

+209
-348
lines changed

config.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[Settings]
2-
monitor_name = DELL U2422H
3-
multimonitortool_executable = C:\\App_Install\\multimonitortool-x64\\MultiMonitorTool.exe
4-
start_with_windows = yes
2+
monitor_name = ROG PG279Q
3+
monitor_serial = #ASNImfyQBwHd
4+
multimonitortool_executable = C:/App_Install/multimonitortool-x64/MultiMonitorTool.exe
5+
start_with_windows = no
56
first_start = no
67

main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from smct_pkg import config, tray
22

3-
# TODO add selection of monitor at startup
4-
53

64
def main():
75
config.read_config()

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
win10toast
22
pystray
3+
pandas
4+
customtkinter
5+
python-tkdnd

smct_pkg/config.py

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import configparser
22
import os
33

4-
from smct_pkg import multimonitortool, notification, paths, registry, ui_strings
4+
from smct_pkg import (
5+
multimonitortool,
6+
notification,
7+
paths,
8+
registry,
9+
setup_gui,
10+
ui_strings,
11+
)
512

613
ENCODING = "utf-8"
714

815
# keys
916
SETTINGS_SECTION = "Settings"
1017
MONITOR_NAME_KEY = "monitor_name"
11-
MULTIMONITORTOOL_EXECUTABLE_KEY = "multimonitortool_executable"
18+
MONITOR_SERIAL_KEY = "monitor_serial"
19+
MMT_PATH_KEY = "multimonitortool_executable"
1220
START_WITH_WINDOWS_KEY = "start_with_windows"
1321
FIRT_START_KEY = "first_start"
1422

1523
# values
1624
MMT_PATH_VALUE = ""
1725
MONITOR_NAME_VALUE = ""
18-
AUTOSTART_VALUE = False
26+
MONITOR_SERIAL_VALUE = ""
27+
START_WITH_WINDOWS_VALUE = False
1928
FIRST_START_VALUE = True
2029

2130
_configparser = configparser.ConfigParser()
22-
_configparser.read(paths.CONFIG_PATH, encoding=ENCODING)
2331

2432

2533
def check_for_missing_files():
@@ -52,35 +60,46 @@ def check_for_missing_files():
5260
def read_config():
5361
# Check if config.ini file is present
5462
if not os.path.exists(paths.CONFIG_PATH):
55-
notification.send_error(paths.CONFIG_PATH + ui_strings.FILE_NOT_FOUND)
63+
_create_default_config_file()
64+
65+
_configparser.read(paths.CONFIG_PATH, encoding=ENCODING)
5666

5767
# * pylint: disable=global-statement
58-
global AUTOSTART_VALUE, MMT_PATH_VALUE, MONITOR_NAME_VALUE, FIRST_START_VALUE
68+
global START_WITH_WINDOWS_VALUE, MMT_PATH_VALUE, MONITOR_NAME_VALUE, MONITOR_SERIAL_VALUE, FIRST_START_VALUE
5969

60-
MMT_PATH_VALUE = _configparser.get(
61-
SETTINGS_SECTION, MULTIMONITORTOOL_EXECUTABLE_KEY
62-
)
70+
MMT_PATH_VALUE = _configparser.get(SETTINGS_SECTION, MMT_PATH_KEY)
6371
MONITOR_NAME_VALUE = _configparser.get(SETTINGS_SECTION, MONITOR_NAME_KEY)
64-
AUTOSTART_VALUE = _configparser.getboolean(SETTINGS_SECTION, START_WITH_WINDOWS_KEY)
72+
MONITOR_SERIAL_VALUE = _configparser.get(SETTINGS_SECTION, MONITOR_SERIAL_KEY)
73+
START_WITH_WINDOWS_VALUE = _configparser.getboolean(
74+
SETTINGS_SECTION, START_WITH_WINDOWS_KEY
75+
)
6576
FIRST_START_VALUE = _configparser.getboolean(SETTINGS_SECTION, FIRT_START_KEY)
6677

67-
if AUTOSTART_VALUE:
78+
if START_WITH_WINDOWS_VALUE:
6879
registry.add_to_autostart()
6980
else:
7081
registry.remove_from_autostart()
7182

7283
if FIRST_START_VALUE:
73-
# TODO: Do something else here
74-
notification.send_notification(
75-
"placeholder",
76-
30,
77-
)
84+
setup_gui.init_mmt_selection_frame()
7885
FIRST_START_VALUE = False
7986
set_config_value(SETTINGS_SECTION, FIRT_START_KEY, FIRST_START_VALUE)
8087

8188
check_for_missing_files()
8289

8390

91+
def _create_default_config_file():
92+
_configparser["Settings"] = {
93+
MONITOR_NAME_KEY: "Example Monitor",
94+
MONITOR_SERIAL_KEY: "12345",
95+
MMT_PATH_KEY: "C:/MultiMonitorTool.exe",
96+
START_WITH_WINDOWS_KEY: "no",
97+
FIRT_START_KEY: "yes",
98+
}
99+
with open(paths.CONFIG_PATH, "w", encoding=ENCODING) as _file_object:
100+
_configparser.write(_file_object)
101+
102+
84103
def set_config_value(section, key, value):
85104
if isinstance(value, bool):
86105
value_str = "yes" if value else "no"

smct_pkg/customtkinter_example.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

smct_pkg/customtkintertest.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

smct_pkg/gui.py

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)