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__()
|
||||
self.setupUi(self)
|
||||
|
||||
# Set up a dictionary to keep track of new tabs
|
||||
# New tabs and their contents
|
||||
self.tabs = {}
|
||||
self.current_tab = None
|
||||
self.current_textEdit = None
|
||||
self.current_textEdit_parent = None
|
||||
|
||||
# Toolbar setup
|
||||
self.BookToolBar.hide()
|
||||
@@ -47,15 +50,29 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
self.LibraryToolBar.addSeparator()
|
||||
self.LibraryToolBar.addAction(settingsButton)
|
||||
|
||||
self.exit_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Escape'), self)
|
||||
self.exit_shortcut.activated.connect(self.set_normalsize)
|
||||
self.exit_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Escape'), self.textEdit)
|
||||
self.exit_shortcut.activated.connect(self.testfsoff)
|
||||
|
||||
# Toolbar switching
|
||||
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):
|
||||
a = Tabber(self, 'Title text')
|
||||
print(dir(a))
|
||||
# TODO
|
||||
# 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):
|
||||
if self.tabWidget.currentIndex() == 0:
|
||||
@@ -66,41 +83,71 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
self.LibraryToolBar.hide()
|
||||
|
||||
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()
|
||||
agm = QtGui.QScreen.availableGeometry(scr)
|
||||
self.textEdit.setParent(self)
|
||||
self.textEdit.setGeometry(agm)
|
||||
self.textEdit.showFullScreen()
|
||||
|
||||
self.current_textEdit.setParent(self)
|
||||
self.current_textEdit.setGeometry(agm)
|
||||
self.current_textEdit.showFullScreen()
|
||||
self.showFullScreen()
|
||||
|
||||
def set_normalsize(self):
|
||||
self.textEdit.setParent(self.tab_2)
|
||||
self.textEdit.showNormal()
|
||||
# TODO
|
||||
# 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()
|
||||
|
||||
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):
|
||||
self.myparent = parent
|
||||
self.parent_window = parent
|
||||
self.book_title = book_title
|
||||
self.create_tab()
|
||||
|
||||
def create_tab(self):
|
||||
self.tab = QtWidgets.QWidget()
|
||||
self.tab.setObjectName("tab")
|
||||
self.tab.setObjectName("newtab")
|
||||
self.gridLayout = QtWidgets.QGridLayout(self.tab)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.textEdit = QtWidgets.QTextEdit(self.tab)
|
||||
self.textEdit.setObjectName("textEdit")
|
||||
self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1)
|
||||
self.myparent.tabWidget.addTab(self.tab, "")
|
||||
self.myparent.tabWidget.setTabText(
|
||||
self.myparent.tabWidget.indexOf(self.tab), self.book_title)
|
||||
self.textEdit.setText(','.join(dir(self.myparent)))
|
||||
self.parent_window.tabWidget.addTab(self.tab, "")
|
||||
self.parent_window.tabWidget.setTabText(
|
||||
self.parent_window.tabWidget.indexOf(self.tab), self.book_title)
|
||||
self.textEdit.setText(','.join(dir(self.parent_window)))
|
||||
|
||||
|
||||
|
||||
def wutface():
|
||||
print('huh?')
|
||||
def close_tab(self, tab_index):
|
||||
tab_title = self.parent_window.tabWidget.tabText(tab_index).replace('&', '')
|
||||
print(self.parent_window.tabs[tab_title])
|
||||
# self.parent_window.tabWidget.removeTab(tab_index)
|
||||
|
||||
|
||||
def main():
|
||||
|
@@ -27,6 +27,12 @@ class Ui_MainWindow(object):
|
||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||
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.tabWidget.addTab(self.tab, "")
|
||||
self.horizontalLayout.addWidget(self.tabWidget)
|
||||
@@ -51,6 +57,7 @@ class Ui_MainWindow(object):
|
||||
def retranslateUi(self, MainWindow):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "Lector"))
|
||||
self.pushButton.setText(_translate("MainWindow", "PushButton"))
|
||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Library"))
|
||||
self.LibraryToolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
|
||||
self.BookToolBar.setWindowTitle(_translate("MainWindow", "toolBar_2"))
|
||||
|
@@ -31,7 +31,18 @@
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
|
Reference in New Issue
Block a user