cmd_supertux_textedit.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/python3
  2. # Flexlay - A Generic 2D Game Editor
  3. # Copyright (C) 2015 Karkus476 <karkus476@yahoo.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. from typing import IO, Optional
  18. import sys
  19. from PyQt5.QtWidgets import (QMainWindow, QApplication, QVBoxLayout,
  20. QWidget)
  21. from supertux.text_editor.supertux_text_edit import SupertuxTextEdit
  22. from supertux.text_editor.highlighters.lisp_highlighter import SuperTuxLispHighlighter
  23. class SupertuxTextEditMainWindow(QMainWindow):
  24. def __init__(self, text_file: Optional[IO[str]] = None) -> None:
  25. super().__init__()
  26. self.setWindowTitle("Supertux Text Editor")
  27. self.central_widget = QWidget()
  28. self.setCentralWidget(self.central_widget)
  29. layout = QVBoxLayout()
  30. self.ide_widget = SupertuxTextEdit(self)
  31. layout.addWidget(self.ide_widget)
  32. self.central_widget.setLayout(layout)
  33. assert text_file is not None
  34. highlighter = SuperTuxLispHighlighter(self.ide_widget, text_file)
  35. highlighter.rehighlight()
  36. def main() -> None:
  37. sys.path.append(".")
  38. # file_path = input("Type the path to the file you'd like to open:")
  39. text_file = open("example.stl") # open(file_path, "r")
  40. app = QApplication(sys.argv)
  41. window = SupertuxTextEditMainWindow(text_file)
  42. window.show()
  43. app.exec_()
  44. # text_file.close()
  45. # EOF #