mediaInfoSama/main_window.py
cuissedemouche 03c0ad0635 Update name convention to PEP8
Variable name where not following PEP8 convention
2022-12-15 16:07:45 +00:00

58 lines
1.8 KiB
Python

from PySide6.QtWidgets import QWidget
from ui_main_window import Ui_MainWindow
from file_cmds import FileCmds
from PySide6.QtCore import QSize
class MainWindow(QWidget, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.window_title = "mediaInfoSama"
self.setWindowTitle(self.window_title)
self.setAcceptDrops(True)
self.setupConnections()
self.splitter.setStretchFactor(0, False)
self.splitter.setStretchFactor(1, True)
def setupConnections(self):
self.tracks_list_widget.itemSelectionChanged.connect(self.popuplate_content)
def dragEnterEvent(self, event):
event.accept()
def dragMoveEvent(self, event):
event.accept()
def dropEvent(self, event):
self.file_path = event.mimeData().urls()[0].toLocalFile()
self.file_cmds = FileCmds(self.file_path)
if self.file_cmds.file_exist() == False:
return
self.setWindowTitle(f"{self.file_path} - {self.window_title}")
self.populate_tabs()
self.tracks_list_widget.item(0).setSelected(True)
def populate_tabs(self):
self.tracks_list_widget.clear()
self.tracks_list_widget.addItems(self.file_cmds.tabs_list)
for i in range(self.tracks_list_widget.count()):
item = self.tracks_list_widget.item(i)
height = self.tracks_list_widget.sizeHintForRow(0)
item.setSizeHint(QSize(0, height+5))
def popuplate_content(self):
item_selected = self.tracks_list_widget.selectedItems()
if item_selected:
text = self.file_cmds.tabs_content[item_selected[0].text()]
self.detail_plain_text_edit.setPlainText(text)