limit the choices in argparse to the enum values
This commit is contained in:
@ -5,6 +5,7 @@ from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from . import ctrl_c, theme
|
||||
from .mainwin import MainWindow
|
||||
from .mdi import MDIWindowMode
|
||||
|
||||
|
||||
def main():
|
||||
@ -26,7 +27,7 @@ def handle_clargs():
|
||||
|
||||
parser.add_argument("-e", "--examples", dest="add_examples", action="store_true", help="Add example data")
|
||||
|
||||
parser.add_argument("-w", "--window-mode", default="multi", help='Set the window mode to either "single", "multi" or "tabs"')
|
||||
parser.add_argument("-w", "--window-mode", default="multi", choices=MDIWindowMode.values(), help="Set the initial window mode")
|
||||
|
||||
return parser.parse_args().__dict__
|
||||
|
||||
|
@ -8,9 +8,14 @@ from ..menus import BarMenu
|
||||
|
||||
|
||||
class MDIWindowMode(str, enum.Enum):
|
||||
MULTI = "multi"
|
||||
SINGLE = "single"
|
||||
MULTI = "multi"
|
||||
TABS = "tabs"
|
||||
TABS = "tabs"
|
||||
|
||||
@classmethod
|
||||
def values(cls):
|
||||
return tuple(i.value for i in cls)
|
||||
|
||||
|
||||
|
||||
class MDIArea(QMdiArea):
|
||||
@ -37,7 +42,7 @@ class MDIArea(QMdiArea):
|
||||
menu.addAction("Close inactive", self.closeInactiveSubWindows)
|
||||
|
||||
|
||||
def set_window_mode(self, mode:MDIWindowMode) -> None:
|
||||
def set_window_mode(self, mode: MDIWindowMode) -> None:
|
||||
mode_enablers = {
|
||||
MDIWindowMode.SINGLE: self.enable_single_window_mode,
|
||||
MDIWindowMode.MULTI: self.enable_multiple_windows_mode,
|
||||
|
Reference in New Issue
Block a user