Python
- 39 ответов
- 0 вопросов
42
Вклад в тег
from PyQt5 import Qt
class Widget(Qt.QWidget):
def __init__(self):
super().__init__()
layout = Qt.QVBoxLayout(self)
button1 = Qt.QPushButton("Button 1")
button2 = Qt.QPushButton("Button 2")
layout.addWidget(button1)
layout.addWidget(button2)
button1.setStyleSheet("""
QPushButton {
background-color: green;
border-style: outset;
border-width: 2px;
border-radius: 10px;
border-color: beige;
font: bold 14px;
min-width: 10em;
padding: 6px;
}
QPushButton:pressed{
background-color: #4CAF50;
color: white;
border-color: black;
border-style: inset;
}
""")
if __name__ == '__main__':
app = Qt.QApplication([])
w = Widget()
w.show()
app.exec()
class ORGH_widget(Qt.QWidget):
def __init__(self, parent=None):
super(ORGH_widget, self).__init__(parent)
self.maindialog = ORGH_app(None)
self.layout = Qt.QVBoxLayout(self)
self.layout.addWidget(self.maindialog)
self.maindialog.show()
# self.exec_loop()
def keyPressEvent(self, e):
if e.key() == Qt.Qt.Key_Escape:
self.close()
class ORGH_app(Qt.QMainWindow):
def __init__(self, parent):
super(ORGH_app, self).__init__()
self.form = Ui_Form()
self.form.setupUi(self)
self._connectSlots()
def _connectSlots(self):
self.form.pushButton.clicked.connect(self._slotAddClicked)
def _slotAddClicked(self):
text = self.form.lineEdit.text()
if len(text):
# tvi = Qt.QTableViewItem(self.form.tableView)
# tvi.setText(0, text)
self.form.lineEdit.clear()
if __name__ == "__main__":
app = Qt.QApplication(sys.argv)
main = ORGH_app(None)
main.show()
sys.exit(app.exec())