Implemented closing tabs.
This commit is contained in:
parent
5bc3dab10c
commit
56e16dfb8b
3 changed files with 13 additions and 0 deletions
|
@ -3,3 +3,4 @@
|
||||||
def connect_gui(app):
|
def connect_gui(app):
|
||||||
app.main_window.openFile.triggered.connect(app.file_actions.open_files)
|
app.main_window.openFile.triggered.connect(app.file_actions.open_files)
|
||||||
app.main_window.saveFile.triggered.connect(app.file_actions.save_current_file)
|
app.main_window.saveFile.triggered.connect(app.file_actions.save_current_file)
|
||||||
|
app.main_window.openFileTabs.tabCloseRequested.connect(app.file_actions.close_current_file)
|
||||||
|
|
6
file.py
6
file.py
|
@ -33,6 +33,12 @@ class FileActions:
|
||||||
|
|
||||||
self.save_file(current_file_path)
|
self.save_file(current_file_path)
|
||||||
|
|
||||||
|
def close_current_file(self):
|
||||||
|
tab_index = self.app.main_window.openFileTabs.currentIndex()
|
||||||
|
self.app.main_window.openFileTabs.removeTab(tab_index)
|
||||||
|
current_file_path = self.app.main_window.openFileTabs.currentWidget().objectName()
|
||||||
|
del self.app.open_files[current_file_path]
|
||||||
|
|
||||||
|
|
||||||
class File:
|
class File:
|
||||||
def __init__(self, app, path, name):
|
def __init__(self, app, path, name):
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>-1</number>
|
<number>-1</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tabsClosable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="movable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in a new issue