File opening is now really working.
(Shows a tab menu with the opened files.)
This commit is contained in:
parent
2797c3ca44
commit
8f8c11772e
4 changed files with 26 additions and 7 deletions
|
@ -6,20 +6,30 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>861</width>
|
||||||
<height>600</height>
|
<height>548</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>Bread Editor</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTabWidget" name="openFileTabs">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>861</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
9
main.py
9
main.py
|
@ -10,7 +10,7 @@ from connect_gui import connect_gui
|
||||||
class BreadEditor:
|
class BreadEditor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.utils = Utils(self)
|
self.utils = Utils(self)
|
||||||
self.open_files = []
|
self.open_files = {}
|
||||||
|
|
||||||
self.qt_app = QtWidgets.QApplication(sys.argv)
|
self.qt_app = QtWidgets.QApplication(sys.argv)
|
||||||
|
|
||||||
|
@ -21,6 +21,13 @@ class BreadEditor:
|
||||||
|
|
||||||
connect_gui(self)
|
connect_gui(self)
|
||||||
|
|
||||||
|
def open_file(self, file_path):
|
||||||
|
self.open_files[file_path] = file_path.split("/")[-1] # set name that shows in the tab list
|
||||||
|
self.main_window.openFileTabs.addTab(
|
||||||
|
QtWidgets.QWidget(self.main_window.openFileTabs),
|
||||||
|
self.open_files[file_path]
|
||||||
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.QTMainWindow.show()
|
self.QTMainWindow.show()
|
||||||
sys.exit(self.qt_app.exec())
|
sys.exit(self.qt_app.exec())
|
||||||
|
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
PyQt6>=6.4.2
|
3
utils.py
3
utils.py
|
@ -18,4 +18,5 @@ class Utils:
|
||||||
dialog.setViewMode(QFileDialog.ViewMode.List)
|
dialog.setViewMode(QFileDialog.ViewMode.List)
|
||||||
|
|
||||||
if dialog.exec():
|
if dialog.exec():
|
||||||
self.app.open_files += dialog.selectedFiles()
|
for file_path in dialog.selectedFiles():
|
||||||
|
self.app.open_file(file_path)
|
||||||
|
|
Loading…
Reference in a new issue