NavigationView Example
import sys
from DevMachines import __pyside2__, __pyside6__
from DevMachines import QtitanBase
from DevMachines.QtitanStyle import ColorizedStyle
from DevMachines.QtitanBase import Qtitan, SegoeMDL2Font, ColorPickerButton
from DevMachines.QtitanNavigationDesignUI import NavigationMainWindow, NavigationView
if __pyside2__:
from PySide2 import QtCore
from PySide2.QtCore import Qt, QFile, QTextStream
from PySide2.QtGui import QPalette
from PySide2.QtWidgets import (QApplication, QTableView, QCalendarWidget, QLabel)
if __pyside6__:
from PySide6 import QtCore
from PySide6.QtCore import Qt, QFile, QTextStream
from PySide6.QtGui import QPalette
from PySide6.QtWidgets import (QApplication, QTableView, QCalendarWidget, QLabel)
import NavigationView_rc
from settings import SettingsWidget
def load_html_file(fileName):
file = QFile(fileName)
if not file.exists() or not file.open(QFile.ReadOnly):
return ""
ret = QTextStream(file).readAll()
return ret
class Window(NavigationMainWindow):
def __init__(self):
NavigationMainWindow.__init__(self)
self.setWindowTitle(self.tr("NavigationView Application"))
self.setGeometry(100, 100, 1500, 800)
view = NavigationView(self)
label = QLabel()
label.setText(load_html_file(":/res/page1.html"))
view.addPageItem(SegoeMDL2Font.code(SegoeMDL2Font.World), "News", label)
label2 = QLabel()
label2.setText(load_html_file(":/res/page2.html"))
item = view.addPageItem(SegoeMDL2Font.code(SegoeMDL2Font.Walk), "Fantasy Surfer", label2)
calendarWidget = QCalendarWidget()
f = calendarWidget.font()
f.setPointSize(8)
calendarWidget.setFont(f)
p = calendarWidget.palette()
p.setColor(QPalette.Base, Qt.transparent)
calendarWidget.setPalette(p)
caledarView = calendarWidget.findChild(QTableView)
calendarWidget.setAutoFillBackground(False)
calendarWidget.setAttribute(Qt.WA_NoSystemBackground, True)
caledarView.setAutoFillBackground(False)
caledarView.setAttribute(Qt.WA_NoSystemBackground, True)
view.addWidgetItem(SegoeMDL2Font.code(SegoeMDL2Font.Calendar), calendarWidget)
label3 = QLabel()
label3.setText(load_html_file(":/res/page3.html"))
view.addPageItem(SegoeMDL2Font.code(SegoeMDL2Font.Color), "Surface Water", label3)
label4 = QLabel()
label4.setText(load_html_file(":/res/page4.html"))
view.addPageItem(SegoeMDL2Font.code(SegoeMDL2Font.FavoriteStar), "Best Surfing 2018", label4)
label5 = QLabel()
label5.setText(load_html_file(":/res/page5.html"))
view.addPageItem(SegoeMDL2Font.code(SegoeMDL2Font.Video), "Video and Forecasting", label5)
view.settingsItem().setPage(SettingsWidget(self))
view.settingsItem().setTransition(Qtitan.Entrance)
self.setCentralWidget(view)
#self.setContentsMargins(1, 1, 1, 1)
self.titleBar().setSysButtonKind(QtitanBase.WindowTitleBar.SysButtonHidden)
self.titleBar().setBlurBehindWindowEnabled(True)
self.titleBar().setExtendViewIntoTitleBar(True)
#titleBar().setStyledFrame(False)
self.titleBar().setVisible(True)
view.frame().navigateTo(view.settingsItem().page(), Qtitan.Suppress)
def create_link(self, link, text):
ret = "<a style=\"text-decoration:underline;\" href=\"" + link + "\">" + text + "</a>"
return ret
def createHelpWidget(self):
label = QLabel()
html = self.create_link("#", "Help Topics")
html += "<br><br>"
html += self.create_link("#", "Feedback")
html += "<br><br>"
html += self.create_link("#", "Community")
html += "<br><br>"
html += self.create_link("#", "Legal Information")
html += "<br><br>"
html += self.create_link("#", "Privacy and cookie")
html += "<br><br>"
label.setText(html)
return label
def paintEvent(self, event):
NavigationMainWindow.paintEvent(self, event)
if __name__ == "__main__":
app = QApplication(sys.argv)
style = ColorizedStyle()
app.setStyle(style)
w = Window()
w.show()
sys.exit(app.exec_())