Start work on editor
This commit is contained in:
53
tools/editor.py
Executable file
53
tools/editor.py
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QVBoxLayout, QPushButton,
|
||||
QDialog
|
||||
)
|
||||
from OpenGL.GL import *
|
||||
from OpenGL.GLU import *
|
||||
from editortool.maptool import MapWindow
|
||||
from editortool.langtool import LangToolWindow
|
||||
|
||||
DEFAULT_TOOL = None # Set to "map" or "language" to auto-select for testing
|
||||
|
||||
TOOLS = [
|
||||
("Map Editor", "map", MapWindow),
|
||||
("Language Editor", "language", LangToolWindow)
|
||||
]
|
||||
|
||||
class EditorChoiceDialog(QDialog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("Choose Tool")
|
||||
layout = QVBoxLayout(self)
|
||||
self.selected = None
|
||||
for label, key, win_cls in TOOLS:
|
||||
btn = QPushButton(label)
|
||||
btn.clicked.connect(lambda checked, w=win_cls: self.choose_tool(w))
|
||||
layout.addWidget(btn)
|
||||
|
||||
def choose_tool(self, win_cls):
|
||||
self.selected = win_cls
|
||||
self.accept()
|
||||
|
||||
def get_choice(self):
|
||||
return self.selected
|
||||
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
tool_map = { key: win_cls for _, key, win_cls in TOOLS }
|
||||
if DEFAULT_TOOL in tool_map:
|
||||
win_cls = tool_map[DEFAULT_TOOL]
|
||||
else:
|
||||
choice_dialog = EditorChoiceDialog()
|
||||
if choice_dialog.exec_() == QDialog.Accepted:
|
||||
win_cls = choice_dialog.get_choice()
|
||||
else:
|
||||
sys.exit(0)
|
||||
win = win_cls()
|
||||
win.show()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user