Statusbar styling

This commit is contained in:
Florian Bruhin 2013-12-15 00:01:05 +01:00
parent 2461d74647
commit 06506e5e48
2 changed files with 21 additions and 10 deletions

View File

@ -10,10 +10,12 @@ class TestWindow(QMainWindow):
self.cwidget = QWidget(self)
self.cwidget.setObjectName("cwidget")
self.setCentralWidget(self.cwidget)
self.vbox = QVBoxLayout(self.cwidget)
self.vbox.setObjectName("vbox")
self.setCentralWidget(self.cwidget)
self.vbox.setContentsMargins(0, 0, 0, 0)
self.vbox.setSpacing(0)
self.tabs = QTabWidget(self.cwidget)
self.tabs.setObjectName("tabs")
@ -24,7 +26,7 @@ class TestWindow(QMainWindow):
self.status = StatusBar(self.cwidget)
self.status.lbl.setText("Hello World")
self.vbox.addLayout(self.status)
self.vbox.addWidget(self.status)
#self.retranslateUi(MainWindow)
#self.tabWidget.setCurrentIndex(0)

View File

@ -1,24 +1,33 @@
from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel
from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget
class StatusBar(QHBoxLayout):
class StatusBar(QWidget):
def __init__(self, parent):
super().__init__(parent)
self.setObjectName(self.__class__.__name__)
self.bg_color("black")
self.hbox = QHBoxLayout(self)
self.hbox.setObjectName("status_hbox")
self.hbox.setContentsMargins(0, 0, 0, 0)
self.hbox.setSpacing(0)
self.cmd = StatusCommand(parent)
self.addWidget(self.cmd)
self.cmd = StatusCommand(self)
self.hbox.addWidget(self.cmd)
self.lbl = StatusText(parent)
self.addWidget(self.lbl)
self.lbl = StatusText(self)
self.hbox.addWidget(self.lbl)
def bg_color(self, color):
self.setStyleSheet("""* {{ background: {}; color: white; font-family:
Monospace; }}""".format(color))
class StatusText(QLabel):
def __init__(self, parent):
super().__init__(parent)
self.setObjectName(self.__class__.__name__)
self.setStyleSheet('QLabel { background: yellow }')
self.setStyleSheet("padding-right: 1px")
class StatusCommand(QLineEdit):
def __init__(self, parent):
super().__init__(parent)
self.setObjectName(self.__class__.__name__)
self.setStyleSheet('QLineEdit { background: yellow }')
self.setStyleSheet("border: 0px; padding-left: 1px")