|
|
@ -6,10 +6,11 @@ app = QtWidgets.QApplication([])
|
|
|
|
#TODO: Implement separate editor, terminal and main_window classes using Window as a parent
|
|
|
|
#TODO: Implement separate editor, terminal and main_window classes using Window as a parent
|
|
|
|
|
|
|
|
|
|
|
|
class Window(QtWidgets.QMainWindow):
|
|
|
|
class Window(QtWidgets.QMainWindow):
|
|
|
|
def __init__(self, size=(640, 480), title="Concorde"):
|
|
|
|
def __init__(self, size=(640, 480), title="Concorde", on_resize=lambda event: None):
|
|
|
|
super().__init__()
|
|
|
|
super().__init__()
|
|
|
|
self.setWindowTitle(title)
|
|
|
|
self.setWindowTitle(title)
|
|
|
|
self.resize(size[0], size[1])
|
|
|
|
self.resize(size[0], size[1])
|
|
|
|
|
|
|
|
self.__on_resize = on_resize
|
|
|
|
|
|
|
|
|
|
|
|
def __del__(self):
|
|
|
|
def __del__(self):
|
|
|
|
#TODO: whatever needs to be done here
|
|
|
|
#TODO: whatever needs to be done here
|
|
|
@ -26,6 +27,9 @@ class Window(QtWidgets.QMainWindow):
|
|
|
|
def set_size(self, size_x, size_y):
|
|
|
|
def set_size(self, size_x, size_y):
|
|
|
|
self.resize(size_x, size_y)
|
|
|
|
self.resize(size_x, size_y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_resize(self, function):
|
|
|
|
|
|
|
|
self.__on_resize = function
|
|
|
|
|
|
|
|
|
|
|
|
def update_menus(self, menu_dict, menu=None):
|
|
|
|
def update_menus(self, menu_dict, menu=None):
|
|
|
|
# if not a sub menu
|
|
|
|
# if not a sub menu
|
|
|
|
if menu == None:
|
|
|
|
if menu == None:
|
|
|
@ -52,6 +56,11 @@ class Window(QtWidgets.QMainWindow):
|
|
|
|
menu_item = menu.addAction(entry)
|
|
|
|
menu_item = menu.addAction(entry)
|
|
|
|
menu_item.triggered.connect(menu_dict[entry])
|
|
|
|
menu_item.triggered.connect(menu_dict[entry])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Toolkit specific! Do not use outside gui_handler.
|
|
|
|
|
|
|
|
def resizeEvent(self, event):
|
|
|
|
|
|
|
|
self.__on_resize(event)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Editor(Window):
|
|
|
|
class Editor(Window):
|
|
|
|
def __init__(self, size=(640, 480)):
|
|
|
|
def __init__(self, size=(640, 480)):
|
|
|
|
super().__init__(size, "Editor")
|
|
|
|
super().__init__(size, "Editor")
|
|
|
@ -59,24 +68,13 @@ class Editor(Window):
|
|
|
|
#TODO: Figure out a way to do the fucking line numbers
|
|
|
|
#TODO: Figure out a way to do the fucking line numbers
|
|
|
|
|
|
|
|
|
|
|
|
#Text Editor
|
|
|
|
#Text Editor
|
|
|
|
self.text_edit = QtWidgets.QPlainTextEdit(self)
|
|
|
|
self.text_edit = QtWidgets.QPlainTextEdit()
|
|
|
|
self.text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
|
|
|
self.text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
|
|
|
|
|
|
|
self.text_edit.setWordWrapMode(QtGui.QTextOption.NoWrap)
|
|
|
|
self.set_size(size[0], size[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#layout
|
|
|
|
|
|
|
|
layout = QtWidgets.QHBoxLayout()
|
|
|
|
|
|
|
|
layout.addChildWidget(self.text_edit)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def resizeEvent(self, event):
|
|
|
|
self.tabs = QtWidgets.QTabWidget()
|
|
|
|
self.set_size(event.size().width(), event.size().height())
|
|
|
|
self.tabs.addTab(self.text_edit, "untitled")
|
|
|
|
|
|
|
|
self.setCentralWidget(self.tabs)
|
|
|
|
def set_size(self, size_x, size_y):
|
|
|
|
|
|
|
|
self.text_edit.resize(size_x, size_y)
|
|
|
|
|
|
|
|
self.resize(size_x, size_y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Message(QtWidgets.QMessageBox):
|
|
|
|
class Message(QtWidgets.QMessageBox):
|
|
|
|
def __init__(self, title, text):
|
|
|
|
def __init__(self, title, text):
|
|
|
|