Compare commits
5 Commits
34176805d2
...
72d30b4688
Author | SHA1 | Date |
---|---|---|
BodgeMaster | 72d30b4688 | |
BodgeMaster | 964668467c | |
Milan Suman | 0f3e9b0689 | |
Milan Suman | b7018e1a73 | |
Milan Suman | 33e42e411c |
|
@ -1,14 +1,16 @@
|
|||
from PySide6 import QtWidgets
|
||||
from PySide6 import QtWidgets, QtCore, QtGui
|
||||
import util
|
||||
|
||||
app = QtWidgets.QApplication([])
|
||||
|
||||
#TODO: Implement separate editor, terminal and main_window classes using Window as a parent
|
||||
|
||||
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__()
|
||||
self.setWindowTitle(title)
|
||||
self.resize(size[0], size[1])
|
||||
self.show()
|
||||
self.__on_resize = on_resize
|
||||
|
||||
def __del__(self):
|
||||
#TODO: whatever needs to be done here
|
||||
|
@ -25,6 +27,9 @@ class Window(QtWidgets.QMainWindow):
|
|||
def set_size(self, 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):
|
||||
# if not a sub menu
|
||||
if menu == None:
|
||||
|
@ -51,6 +56,40 @@ class Window(QtWidgets.QMainWindow):
|
|||
menu_item = menu.addAction(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):
|
||||
def __init__(self, size=(640, 480)):
|
||||
super().__init__(size, "Editor")
|
||||
|
||||
#TODO: Figure out a way to do the fucking line numbers
|
||||
|
||||
#Text Editor
|
||||
self.text_edit = QtWidgets.QPlainTextEdit(self)
|
||||
self.text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
||||
|
||||
self.set_size(size[0], size[1])
|
||||
|
||||
#layout
|
||||
#FIXME: Somehow this places the editor behind the menu bar so that the
|
||||
# first couple lines are cut off
|
||||
layout = QtWidgets.QHBoxLayout()
|
||||
layout.addChildWidget(self.text_edit)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
super().on_resize(lambda event: self.set_size(event.size().width(), event.size().height()))
|
||||
|
||||
#FIXME: This function is inherently flawed because it doesn't take the
|
||||
# actual height of the usable area inside the window into account.
|
||||
# On a side note: This should be taken care of by the toolkit (Qt).
|
||||
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):
|
||||
def __init__(self, title, text):
|
||||
|
|
8
main.py
8
main.py
|
@ -26,11 +26,13 @@ configuration = Config(configuration_file_path, default_configuration)
|
|||
# PROGRAM MAIN WINDOW
|
||||
################################################################################
|
||||
|
||||
main_window = gui_handler.Window()
|
||||
main_window.set_title("Concorde IDE")
|
||||
main_window.set_size(configuration.get_configuration_value("window size")["x"], configuration.get_configuration_value("window size")["y"])
|
||||
#Commented out so that I can work on the dockable windows
|
||||
|
||||
|
||||
main_window = gui_handler.Editor((configuration.get_configuration_value("window size")["x"], configuration.get_configuration_value("window size")["y"]))
|
||||
main_window.set_title("Concorde IDE")
|
||||
main_window.update_menus(gui_helper.menu_structure)
|
||||
main_window.show()
|
||||
|
||||
|
||||
#TODO: get resolution of main window on exit and save it back to the configuration
|
||||
|
|
Reference in New Issue