converted main tabs to stacked widget
This commit is contained in:
@@ -14,7 +14,7 @@ import sys, os, shutil, tempfile
|
|||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import QCoreApplication, QUrl, pyqtSlot, QSettings
|
from PyQt5.QtCore import QCoreApplication, QUrl, pyqtSlot, QSettings
|
||||||
from PyQt5.QtGui import QIcon, QKeySequence, QFont, QSyntaxHighlighter
|
from PyQt5.QtGui import QIcon, QKeySequence, QFont, QSyntaxHighlighter
|
||||||
from PyQt5.QtWidgets import QMainWindow, QAction, QWidget, QApplication, QShortcut, QGridLayout, QLabel, QTabWidget, QHBoxLayout, QVBoxLayout, QSplitter, QSplitterHandle, QPlainTextEdit, QInputDialog, QLineEdit, QFileDialog, QMessageBox, QPushButton
|
from PyQt5.QtWidgets import QMainWindow, QAction, QWidget, QApplication, QShortcut, QGridLayout, QLabel, QTabWidget, QStackedWidget, QHBoxLayout, QVBoxLayout, QSplitter, QSplitterHandle, QPlainTextEdit, QInputDialog, QLineEdit, QFileDialog, QMessageBox, QPushButton
|
||||||
# from PyQt5.QtNetwork import QNetworkProxyFactory, QNetworkRequest
|
# from PyQt5.QtNetwork import QNetworkProxyFactory, QNetworkRequest
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
from PyQt5.QtWebKitWidgets import QWebPage, QWebView, QWebInspector
|
from PyQt5.QtWebKitWidgets import QWebPage, QWebView, QWebInspector
|
||||||
@@ -108,7 +108,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.initMenuBar()
|
self.initMenuBar()
|
||||||
|
|
||||||
self.initTabs()
|
self.initMainStack()
|
||||||
# self.shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
|
# self.shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
|
||||||
# self.shortcut.activated.connect(self.quit)
|
# self.shortcut.activated.connect(self.quit)
|
||||||
|
|
||||||
@@ -137,13 +137,33 @@ class MainWindow(QMainWindow):
|
|||||||
quit.setShortcut("Ctrl+q")
|
quit.setShortcut("Ctrl+q")
|
||||||
file.addAction(quit)
|
file.addAction(quit)
|
||||||
|
|
||||||
file.triggered[QAction].connect(self.processtrigger)
|
file.triggered[QAction].connect(self.onfilemenutrigger)
|
||||||
|
|
||||||
|
# edit menu
|
||||||
edit = bar.addMenu("Edit")
|
edit = bar.addMenu("Edit")
|
||||||
edit.addAction("copy")
|
edit.addAction("copy")
|
||||||
edit.addAction("paste")
|
edit.addAction("paste")
|
||||||
|
edit.addAction("preferences")
|
||||||
|
|
||||||
def processtrigger(self, q):
|
# view menu
|
||||||
|
view = bar.addMenu("&View")
|
||||||
|
|
||||||
|
designview = QAction("&Design",self)
|
||||||
|
designview.setShortcut("F1")
|
||||||
|
view.addAction(designview)
|
||||||
|
|
||||||
|
contentview = QAction("&Content",self)
|
||||||
|
contentview.setShortcut("F2")
|
||||||
|
view.addAction(contentview)
|
||||||
|
|
||||||
|
versionview = QAction("&Version",self)
|
||||||
|
versionview.setShortcut("F3")
|
||||||
|
view.addAction(versionview)
|
||||||
|
|
||||||
|
view.triggered[QAction].connect(self.onviewmenutrigger)
|
||||||
|
|
||||||
|
|
||||||
|
def onfilemenutrigger(self, q):
|
||||||
print(q.text()+" is triggered")
|
print(q.text()+" is triggered")
|
||||||
if q.text() == "&New Project":
|
if q.text() == "&New Project":
|
||||||
self.newprojectdialogue()
|
self.newprojectdialogue()
|
||||||
@@ -195,34 +215,44 @@ class MainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
self.core.quit()
|
self.core.quit()
|
||||||
|
|
||||||
def initTabs(self):
|
def onviewmenutrigger(self, q):
|
||||||
self.tabwidget = QTabWidget()
|
print(q.text()+" is triggered")
|
||||||
|
if q.text() == "&Design":
|
||||||
|
self.mainstack.setCurrentIndex(0)
|
||||||
|
elif q.text() == "&Content":
|
||||||
|
self.mainstack.setCurrentIndex(1)
|
||||||
|
elif q.text() == "&Version":
|
||||||
|
self.mainstack.setCurrentIndex(2)
|
||||||
|
|
||||||
|
|
||||||
|
def initMainStack(self):
|
||||||
|
self.mainstack = QStackedWidget()
|
||||||
# self.tabwidget.setContentsMargins(0,0,0,0)
|
# self.tabwidget.setContentsMargins(0,0,0,0)
|
||||||
self.tabwidget.setStyleSheet("""
|
# self.tabwidget.setStyleSheet("""
|
||||||
QTabWidget::pane {
|
# QTabWidget::pane {
|
||||||
border:0px solid inherted;
|
# border:0px solid inherted;
|
||||||
margin:0px;
|
# margin:0px;
|
||||||
padding:0px;
|
# padding:0px;
|
||||||
}
|
# }
|
||||||
QTabBar::tab {
|
# QTabBar::tab {
|
||||||
padding: 4px;
|
# padding: 4px;
|
||||||
font-size:12px;
|
# font-size:12px;
|
||||||
}
|
# }
|
||||||
QTabBar::tab:selected {
|
# QTabBar::tab:selected {
|
||||||
font-weight:bold;
|
# font-weight:bold;
|
||||||
}
|
# }
|
||||||
""")
|
# """)
|
||||||
|
|
||||||
self.viewtab = view.ViewTab(self.core)
|
self.viewstack = view.ViewStack(self.core)
|
||||||
self.contenttab = content.ContentTab(self.core)
|
self.contentstack = content.ContentStack(self.core)
|
||||||
self.versiontab = QLabel("Version (git).")
|
self.versionstack = QLabel("Version (git).")
|
||||||
|
|
||||||
|
|
||||||
self.tabwidget.addTab(self.viewtab, "View")
|
self.mainstack.addWidget(self.viewstack)
|
||||||
self.tabwidget.addTab(self.contenttab, "Content")
|
self.mainstack.addWidget(self.contentstack)
|
||||||
self.tabwidget.addTab(self.versiontab, "Version")
|
self.mainstack.addWidget(self.versionstack)
|
||||||
|
|
||||||
self.setCentralWidget(self.tabwidget)
|
self.setCentralWidget(self.mainstack)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
+2
-2
@@ -12,9 +12,9 @@ class Summary(QLabel):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ContentTab(QWidget):
|
class ContentStack(QWidget):
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
super(ContentTab, self).__init__()
|
super(ContentStack, self).__init__()
|
||||||
|
|
||||||
# self.grid = QGridLayout()
|
# self.grid = QGridLayout()
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
|
|||||||
+6
-6
@@ -37,9 +37,9 @@ class CodeEditor(QPlainTextEdit):
|
|||||||
# https://pypi.python.org/pypi/QScintilla/2.9.2
|
# https://pypi.python.org/pypi/QScintilla/2.9.2
|
||||||
|
|
||||||
|
|
||||||
class ViewTab(QWidget):
|
class ViewStack(QWidget):
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
super(ViewTab, self).__init__()
|
super(ViewStack, self).__init__()
|
||||||
|
|
||||||
# self.grid = QGridLayout()
|
# self.grid = QGridLayout()
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
@@ -65,7 +65,7 @@ class ViewTab(QWidget):
|
|||||||
hbox.addWidget(hsplitter)
|
hbox.addWidget(hsplitter)
|
||||||
|
|
||||||
|
|
||||||
def onChanged(self, text):
|
# def onChanged(self, text):
|
||||||
print("ViewTba Layout Changed")
|
# print("ViewTba Layout Changed")
|
||||||
self.lbl.setText(text)
|
# self.lbl.setText(text)
|
||||||
self.lbl.adjustSize()
|
# self.lbl.adjustSize()
|
||||||
|
|||||||
Reference in New Issue
Block a user