2024-11-17 18:54:51 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from PyQt6 import QtWidgets
|
|
|
|
from gui.main_window import Ui_MainWindow
|
|
|
|
from utils import Utils
|
|
|
|
from connect_gui import connect_gui
|
|
|
|
|
|
|
|
|
|
|
|
class BreadEditor:
|
|
|
|
def __init__(self):
|
|
|
|
self.utils = Utils(self)
|
2024-11-18 17:20:49 +01:00
|
|
|
self.open_files = {}
|
2024-11-17 18:54:51 +01:00
|
|
|
|
|
|
|
self.qt_app = QtWidgets.QApplication(sys.argv)
|
|
|
|
|
|
|
|
self.QTMainWindow = QtWidgets.QMainWindow()
|
|
|
|
|
|
|
|
self.main_window = Ui_MainWindow()
|
|
|
|
self.main_window.setupUi(self.QTMainWindow)
|
|
|
|
|
|
|
|
connect_gui(self)
|
|
|
|
|
2024-11-18 17:20:49 +01:00
|
|
|
def open_file(self, file_path):
|
2024-11-18 18:00:35 +01:00
|
|
|
file = open(file_path, "r")
|
|
|
|
file_content = file.read()
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
self.open_files[file_path] = {
|
|
|
|
"name": file_path.split("/")[-1], # set name that shows in the tab list
|
|
|
|
"content": file_content
|
|
|
|
}
|
|
|
|
|
|
|
|
content_widget = QtWidgets.QWidget(self.main_window.openFileTabs)
|
|
|
|
content_label = QtWidgets.QLabel(content_widget)
|
|
|
|
content_label.setText(file_content)
|
|
|
|
|
2024-11-18 17:20:49 +01:00
|
|
|
self.main_window.openFileTabs.addTab(
|
2024-11-18 18:00:35 +01:00
|
|
|
content_widget,
|
|
|
|
self.open_files[file_path]["name"]
|
2024-11-18 17:20:49 +01:00
|
|
|
)
|
|
|
|
|
2024-11-17 18:54:51 +01:00
|
|
|
def run(self):
|
|
|
|
self.QTMainWindow.show()
|
|
|
|
sys.exit(self.qt_app.exec())
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
editor = BreadEditor()
|
|
|
|
editor.run()
|