Files
krowlog/main.py
2021-10-25 20:21:39 +02:00

91 lines
2.4 KiB
Python

import re
from PyQt6.QtWidgets import *
from PyQt6.QtCore import *
from PyQt6.QtGui import *
import sys
from bigtext import BigText
from logFileModel import LogFileModel
from settings import Settings
MAX_LINE_LENGTH = 4096
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.settings = Settings()
self.setWindowTitle("RavenLog")
self.setGeometry(0, 0, 640, 480)
self.setDockNestingEnabled(True)
self.tabs = self.create_tabs()
self.setCentralWidget(self.tabs)
self.main_tool_bar = self.create_main_tool_bar()
self.addToolBar(self.main_tool_bar)
self.setStatusBar(QStatusBar(self))
self.setMenuBar(self.create_menu_bar())
def create_main_tool_bar(self):
result = QToolBar("main toolbar")
result.addWidget(QLabel("Font Size:"))
font_size = QComboBox(result)
for s in range(3,30):
font_size.addItem(str(s))
font_size.setCurrentText(str(self.settings.get_font_size()))
font_size.currentTextChanged.connect(self.update_font_size)
result.addWidget(font_size)
return result
def update_font_size(self, font_size):
self.settings.font_size(int(font_size))
self.tabs.update()
def on_follow_file_changed(self, e):
print(e)
def create_tabs(self) -> QTabWidget:
tabs = QTabWidget()
tabs.setTabsClosable(True)
tabs.tabCloseRequested.connect(lambda index: tabs.removeTab(index) )
model = LogFileModel("/home/andi/ws/ravenlog/example.log")
big_text = BigText(model, self.settings)
tabs.addTab(big_text, model.get_tab_name())
model = LogFileModel("/home/andi/ws/performanceDb/data/production/logs_2018-09-06_2018-09-06.csv")
big_text = BigText(model, self.settings)
tabs.addTab(big_text, model.get_tab_name())
return tabs
def create_menu_bar(self) -> QMenuBar:
menu_bar = QMenuBar()
file_menu = QMenu("File", self)
close_action = QAction("Close", self)
close_action.triggered.connect(self.close)
file_menu.addAction(close_action)
menu_bar.addMenu(file_menu)
return menu_bar
def onMyToolBarButtonClick(self, s) -> None:
print("click", s)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()