Garbage
This commit is contained in:
91
__main__.py
91
__main__.py
@@ -26,8 +26,11 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
super(self.__class__, self).__init__()
|
super(self.__class__, self).__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
# Set up a dictionary to keep track of new tabs
|
# New tabs and their contents
|
||||||
self.tabs = {}
|
self.tabs = {}
|
||||||
|
self.current_tab = None
|
||||||
|
self.current_textEdit = None
|
||||||
|
self.current_textEdit_parent = None
|
||||||
|
|
||||||
# Toolbar setup
|
# Toolbar setup
|
||||||
self.BookToolBar.hide()
|
self.BookToolBar.hide()
|
||||||
@@ -47,15 +50,29 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.LibraryToolBar.addSeparator()
|
self.LibraryToolBar.addSeparator()
|
||||||
self.LibraryToolBar.addAction(settingsButton)
|
self.LibraryToolBar.addAction(settingsButton)
|
||||||
|
|
||||||
self.exit_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Escape'), self)
|
self.exit_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Escape'), self.textEdit)
|
||||||
self.exit_shortcut.activated.connect(self.set_normalsize)
|
self.exit_shortcut.activated.connect(self.testfsoff)
|
||||||
|
|
||||||
# Toolbar switching
|
# Toolbar switching
|
||||||
self.tabWidget.currentChanged.connect(self.toolbar_switch)
|
self.tabWidget.currentChanged.connect(self.toolbar_switch)
|
||||||
|
|
||||||
|
# Tab closing
|
||||||
|
self.tabWidget.tabCloseRequested.connect(self.close_tab_class)
|
||||||
|
|
||||||
|
self.pushButton.clicked.connect(self.testfs)
|
||||||
|
|
||||||
def create_tab_class(self):
|
def create_tab_class(self):
|
||||||
a = Tabber(self, 'Title text')
|
# TODO
|
||||||
print(dir(a))
|
# Shift focus to tab if it's already open instead of creating
|
||||||
|
# a new one
|
||||||
|
self.tabs['TitleText'] = {
|
||||||
|
'information about': 'This tab'}
|
||||||
|
this_tab = Tabs(self, 'TitleText')
|
||||||
|
this_tab.create_tab()
|
||||||
|
|
||||||
|
def close_tab_class(self, tab_index):
|
||||||
|
this_tab = Tabs(self, None)
|
||||||
|
this_tab.close_tab(tab_index)
|
||||||
|
|
||||||
def toolbar_switch(self):
|
def toolbar_switch(self):
|
||||||
if self.tabWidget.currentIndex() == 0:
|
if self.tabWidget.currentIndex() == 0:
|
||||||
@@ -66,41 +83,71 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.LibraryToolBar.hide()
|
self.LibraryToolBar.hide()
|
||||||
|
|
||||||
def set_fullscreen(self):
|
def set_fullscreen(self):
|
||||||
|
self.current_tab = self.tabWidget.currentIndex()
|
||||||
|
self.current_textEdit = self.tabWidget.widget(self.current_tab)
|
||||||
|
self.current_textEdit_parent = self.current_textEdit.parent()
|
||||||
|
print(self.current_textEdit_parent)
|
||||||
|
|
||||||
scr = QtGui.QGuiApplication.primaryScreen()
|
scr = QtGui.QGuiApplication.primaryScreen()
|
||||||
agm = QtGui.QScreen.availableGeometry(scr)
|
agm = QtGui.QScreen.availableGeometry(scr)
|
||||||
self.textEdit.setParent(self)
|
|
||||||
self.textEdit.setGeometry(agm)
|
self.current_textEdit.setParent(self)
|
||||||
self.textEdit.showFullScreen()
|
self.current_textEdit.setGeometry(agm)
|
||||||
|
self.current_textEdit.showFullScreen()
|
||||||
self.showFullScreen()
|
self.showFullScreen()
|
||||||
|
|
||||||
def set_normalsize(self):
|
def set_normalsize(self):
|
||||||
self.textEdit.setParent(self.tab_2)
|
# TODO
|
||||||
self.textEdit.showNormal()
|
# Figure out how to restore the textEdit to its original parent
|
||||||
|
# self.current_textEdit.setParent(self.current_textEdit_parent)
|
||||||
|
# self.current_textEdit_parent.show()
|
||||||
|
print(self.current_textEdit_parent)
|
||||||
|
self.current_textEdit.setParent(self.current_textEdit_parent)
|
||||||
|
self.current_textEdit.showNormal()
|
||||||
self.showNormal()
|
self.showNormal()
|
||||||
|
|
||||||
class Tabber:
|
|
||||||
|
def testfs(self):
|
||||||
|
self.textEdit.setWindowFlags(QtCore.Qt.Window)
|
||||||
|
self.textEdit.setWindowState(QtCore.Qt.WindowFullScreen)
|
||||||
|
self.textEdit.show()
|
||||||
|
|
||||||
|
def testfsoff(self):
|
||||||
|
self.textEdit.setWindowState(QtCore.Qt.WindowNoState)
|
||||||
|
self.textEdit.setWindowFlags(QtCore.Qt.Widget)
|
||||||
|
self.textEdit.show()
|
||||||
|
|
||||||
|
|
||||||
|
# def set_fullscreen_te(self):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Tabs:
|
||||||
def __init__(self, parent, book_title):
|
def __init__(self, parent, book_title):
|
||||||
self.myparent = parent
|
self.parent_window = parent
|
||||||
self.book_title = book_title
|
self.book_title = book_title
|
||||||
self.create_tab()
|
|
||||||
|
|
||||||
def create_tab(self):
|
def create_tab(self):
|
||||||
self.tab = QtWidgets.QWidget()
|
self.tab = QtWidgets.QWidget()
|
||||||
self.tab.setObjectName("tab")
|
self.tab.setObjectName("newtab")
|
||||||
self.gridLayout = QtWidgets.QGridLayout(self.tab)
|
self.gridLayout = QtWidgets.QGridLayout(self.tab)
|
||||||
self.gridLayout.setObjectName("gridLayout")
|
self.gridLayout.setObjectName("gridLayout")
|
||||||
self.textEdit = QtWidgets.QTextEdit(self.tab)
|
self.textEdit = QtWidgets.QTextEdit(self.tab)
|
||||||
self.textEdit.setObjectName("textEdit")
|
self.textEdit.setObjectName("textEdit")
|
||||||
self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1)
|
self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1)
|
||||||
self.myparent.tabWidget.addTab(self.tab, "")
|
self.parent_window.tabWidget.addTab(self.tab, "")
|
||||||
self.myparent.tabWidget.setTabText(
|
self.parent_window.tabWidget.setTabText(
|
||||||
self.myparent.tabWidget.indexOf(self.tab), self.book_title)
|
self.parent_window.tabWidget.indexOf(self.tab), self.book_title)
|
||||||
self.textEdit.setText(','.join(dir(self.myparent)))
|
self.textEdit.setText(','.join(dir(self.parent_window)))
|
||||||
|
|
||||||
|
def close_tab(self, tab_index):
|
||||||
|
tab_title = self.parent_window.tabWidget.tabText(tab_index).replace('&', '')
|
||||||
def wutface():
|
print(self.parent_window.tabs[tab_title])
|
||||||
print('huh?')
|
# self.parent_window.tabWidget.removeTab(tab_index)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@@ -27,6 +27,12 @@ class Ui_MainWindow(object):
|
|||||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
|
self.pushButton = QtWidgets.QPushButton(self.tab)
|
||||||
|
self.pushButton.setObjectName("pushButton")
|
||||||
|
self.verticalLayout.addWidget(self.pushButton)
|
||||||
|
self.textEdit = QtWidgets.QTextEdit(self.tab)
|
||||||
|
self.textEdit.setObjectName("textEdit")
|
||||||
|
self.verticalLayout.addWidget(self.textEdit)
|
||||||
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
|
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
|
||||||
self.tabWidget.addTab(self.tab, "")
|
self.tabWidget.addTab(self.tab, "")
|
||||||
self.horizontalLayout.addWidget(self.tabWidget)
|
self.horizontalLayout.addWidget(self.tabWidget)
|
||||||
@@ -51,6 +57,7 @@ class Ui_MainWindow(object):
|
|||||||
def retranslateUi(self, MainWindow):
|
def retranslateUi(self, MainWindow):
|
||||||
_translate = QtCore.QCoreApplication.translate
|
_translate = QtCore.QCoreApplication.translate
|
||||||
MainWindow.setWindowTitle(_translate("MainWindow", "Lector"))
|
MainWindow.setWindowTitle(_translate("MainWindow", "Lector"))
|
||||||
|
self.pushButton.setText(_translate("MainWindow", "PushButton"))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Library"))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Library"))
|
||||||
self.LibraryToolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
|
self.LibraryToolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
|
||||||
self.BookToolBar.setWindowTitle(_translate("MainWindow", "toolBar_2"))
|
self.BookToolBar.setWindowTitle(_translate("MainWindow", "toolBar_2"))
|
||||||
|
@@ -31,7 +31,18 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="textEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Reference in New Issue
Block a user