Own TabWidget object

This commit is contained in:
Florian Bruhin 2013-12-15 00:39:28 +01:00
parent 06506e5e48
commit bc59d7697e
2 changed files with 30 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import sys import sys
from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout,
QTabWidget, QWidget) QTabWidget, QWidget)
from qutebrowser.widgets import StatusBar from qutebrowser.widgets import StatusBar, TabWidget
class TestWindow(QMainWindow): class TestWindow(QMainWindow):
def __init__(self): def __init__(self):
@ -17,11 +17,14 @@ class TestWindow(QMainWindow):
self.vbox.setContentsMargins(0, 0, 0, 0) self.vbox.setContentsMargins(0, 0, 0, 0)
self.vbox.setSpacing(0) self.vbox.setSpacing(0)
self.tabs = QTabWidget(self.cwidget) self.tabs = TabWidget(self.cwidget)
self.tabs.setObjectName("tabs") self.tabs.setObjectName("tabs")
self.tab = QWidget() self.tab = QWidget()
self.tab2 = QWidget()
self.tab.setObjectName("tab") self.tab.setObjectName("tab")
self.tab2.setObjectName("tab2")
self.tabs.addTab(self.tab, "test") self.tabs.addTab(self.tab, "test")
self.tabs.addTab(self.tab2, "test2")
self.vbox.addWidget(self.tabs) self.vbox.addWidget(self.tabs)
self.status = StatusBar(self.cwidget) self.status = StatusBar(self.cwidget)

View File

@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget, QTabWidget
class StatusBar(QWidget): class StatusBar(QWidget):
def __init__(self, parent): def __init__(self, parent):
@ -31,3 +31,27 @@ class StatusCommand(QLineEdit):
super().__init__(parent) super().__init__(parent)
self.setObjectName(self.__class__.__name__) self.setObjectName(self.__class__.__name__)
self.setStyleSheet("border: 0px; padding-left: 1px") self.setStyleSheet("border: 0px; padding-left: 1px")
class TabWidget(QTabWidget):
def __init__(self, parent):
super().__init__(parent)
self.setObjectName(self.__class__.__name__)
self.setStyleSheet("""
QTabWidget::pane {
position: absolute;
top: 0px;
}
QTabBar::tab {
background-color: grey;
color: white;
padding-left: 5px;
padding-right: 5px;
padding-top: 0px;
padding-bottom: 0px;
}
QTabBar::tab:selected {
background-color: black;
}
""")