Skip to content

Commit

Permalink
set checked state when checkboxes are created
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsumoto-ren committed Apr 15, 2024
1 parent b1eda70 commit 4fcb751
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from aqt.qt import *
from aqt.utils import restoreGeom, saveGeom, disable_help_button

from .ajt_common.utils import ui_translate
from .ajt_common.about_menu import tweak_window
from .common import ADDON_NAME, DEBUG_LOG_FILE_PATH
from .config import config
Expand All @@ -12,7 +13,14 @@


def make_checkboxes() -> dict[str, QCheckBox]:
return {key: QCheckBox(key.replace("_", " ").capitalize()) for key in config.bool_keys()}
"""
Create checkboxes and set initial checked states to the values in the config.
"""
d = {}
for key in config.bool_keys():
d[key] = QCheckBox(ui_translate(key))
d[key].setChecked(config[key])
return d


BUT_OK = QDialogButtonBox.StandardButton.Ok
Expand Down Expand Up @@ -59,7 +67,6 @@ def _make_form(self) -> QLayout:

for key, checkbox in self.checkboxes.items():
layout.addRow(checkbox)
checkbox.setChecked(config[key])
return layout

def connect_widgets(self):
Expand Down

0 comments on commit 4fcb751

Please sign in to comment.