Bread_Editor/utils.py

23 lines
621 B
Python
Raw Normal View History

#!/usr/bin/python3
from pathlib import Path
from PyQt6.QtWidgets import QFileDialog
class Utils:
def __init__(self, app):
self.app = app
self.home_path = str(Path.home())
def open_file(self):
dialog = QFileDialog(self.app.QTMainWindow)
dialog.setDirectory(self.home_path)
dialog.setFileMode(QFileDialog.FileMode.ExistingFiles)
dialog.setNameFilters(["Binary (*.bin)", "Any (*)"])
dialog.setViewMode(QFileDialog.ViewMode.List)
if dialog.exec():
for file_path in dialog.selectedFiles():
self.app.open_file(file_path)