SHARE
TWEET

Untitled

a guest Oct 24th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. from PyQt5.QtWidgets import (QApplication, QWidget, QGridLayout, QVBoxLayout, QLabel, QToolBox, QPushButton, QTextEdit, QLineEdit)
  3. from PyQt5.QtGui import QColor
  4.  
  5. class AppDemo(QWidget):
  6.     def __init__(self):
  7.         super().__init__()
  8.         self.resize(600, 400)
  9.         layout = QGridLayout()
  10.  
  11.         styleSheet = """
  12.                         QToolBox::tab {
  13.                             border: 1px solid #C4C4C3;
  14.                             border-bottom-color: RGB(0, 0, 255);                            
  15.                         }
  16.  
  17.                         QToolBox::tab:selected {
  18.                             background-color: #f14040;
  19.                             border-bottom-style: none;
  20.                         }
  21.                      """
  22.  
  23.         toolbox = QToolBox()
  24.         layout.addWidget(toolbox, 0, 0)
  25.  
  26.         # tab X
  27.         w1 = QWidget()
  28.         layout1 = QVBoxLayout()
  29.  
  30.         self.lineEdit = QLineEdit()
  31.         layout1.addWidget(QLabel('Enter something'))
  32.         layout1.addWidget(self.lineEdit)
  33.         w1.setLayout(layout1)
  34.  
  35.         toolbox.addItem(w1, 'Tab X')
  36.  
  37.         # tab Y
  38.         btn = QPushButton('My Button')
  39.         btn.clicked.connect(self.printText)
  40.         toolbox.addItem(btn, 'Tab Y')
  41.  
  42.         # tab Z
  43.         self.textEditor = QTextEdit()
  44.         toolbox.addItem(self.textEditor, 'Tab Z')
  45.  
  46.         toolbox.setCurrentIndex(1)
  47.         toolbox.setStyleSheet(styleSheet)
  48.         toolbox.setItemToolTip(1, 'This is tab Y')
  49.         self.setLayout(layout)
  50.  
  51.     def printText(self):
  52.         self.textEditor.setPlainText(self.lineEdit.text())
  53.  
  54. if __name__ == '__main__':
  55.     app = QApplication(sys.argv)
  56.  
  57.     demo = AppDemo()
  58.     demo.show()
  59.  
  60.     sys.exit(app.exec_())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top