PyQT_Group
2016/6/27 10:15:52 PyQT_Group
fromPyQt5.QtCoreimport* fromPyQt5.QtGuiimport* fromPyQt5.QtWidgetsimport* import sys classWindow(QWidget): def __init__(self): super(Window, self).__init__() self.echoGroup =QGroupBox('Echo') self.echoLabel =QLabel('Mode:') self.echoComboBox =QComboBox() self.echoComboBox.addItem('Normal') self.echoComboBox.addItem('Password') self.echoComboBox.addItem('PasswordEchoOnEdit') self.echoComboBox.addItem('No Echo') self.echoLineEdit =QLineEdit() self.echoLineEdit.setPlaceholderText('Placeholder Text') self.echoLineEdit.setFocus() self.echoLayout =QGridLayout() self.echoLayout.addWidget(self.echoLabel,0,0) self.echoLayout.addWidget(self.echoComboBox,0,1) self.echoLayout.addWidget(self.echoLineEdit,1,0,1,2) self.echoGroup.setLayout(self.echoLayout) self.Layout=QGridLayout() self.Layout.addWidget(self.echoGroup,0,0) self.setLayout(self.Layout) self.setWindowTitle('Qt_Group') def echoChanged(self, index): if index ==0: self.echoLineEdit.setEchoMode(QLineEdit.Normal) elif index ==1: self.echoLineEdit.setEchoMode(QLineEdit.Password) elif index ==2: self.echoLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit) elif index ==3: self.echoLineEdit.setEchoMode(QLineEdit.NoEcho) app =QApplication(sys.argv) win =Window() win.show() app.exec_()