class MyClass(QMainWindow, srv.Ui_MainWindow): def __init__(self, parent=None): super(MyClass, self).__init__(parent) self.setupUi(self) self.server = "s1" self.conn = None self.connect(self.pushButton, SIGNAL("clicked()"), self.execute) self.connect(self.pushButton_2, SIGNAL("clicked()"), self.turn_connect) self.connect(self.radioButton_isp, SIGNAL("clicked()"), self.select_isp) self.connect(self.radioButton_scp, SIGNAL("clicked()"), self.select_scp) self.connect(self.radioButton_spl, SIGNAL("clicked()"), self.select_spl) self.connect(self.comboBox_isp, SIGNAL("activated(int)"), self.select_isp) self.connect(self.comboBox_scp, SIGNAL("activated(int)"), self.select_scp) self.connect(self.comboBox_spl, SIGNAL("activated(int)"), self.select_spl) self.textEdit.setReadOnly(True) self.textEdit_2.setReadOnly(True) def turn_connect(self): if not self.conn: self.conn = Server(str(self.server), "imir") print "\033[1;32mConnect pressed\033[1;m: server=" + self.server + " login=imir" self.lineEdit_2.setText("Online") self.pushButton_2.setText("Disconnect") else: self.conn.kill() self.conn = None print "\033[1;32mDisconnect pressed\033[1;m: conn=" + str(self.conn) self.lineEdit_2.setText("No connection") self.pushButton_2.setText("Connect") def execute(self): if self.conn: try: self.textEdit_2.append(self.conn.cmd(self.lineEdit.text())) except: self.textEdit_2.append("Error: Can not execute command.") print "\033[1;31mError: Can not execute command.\033[1;m" def select_isp(self): self.server = "s" + self.comboBox_isp.currentText() print "\033[1;32mSelect\033[1;m: server=" + self.server def select_scp(self): self.server = "scp" + self.comboBox_scp.currentText() print "\033[1;32mSelect\033[1;m: server=" + self.server def select_spl(self): self.server = "spl" + self.comboBox_spl.currentText() print "\033[1;32mSelect\033[1;m: server=" + self.server
def turn_connect(self): if not self.conn: self.conn = Server(str(self.server), "imir") print "\033[1;32mConnect pressed\033[1;m: server=" + self.server + " login=imir" self.lineEdit_2.setText("Online") self.pushButton_2.setText("Disconnect") else: self.conn.kill() self.conn = None print "\033[1;32mDisconnect pressed\033[1;m: conn=" + str(self.conn) self.lineEdit_2.setText("No connection") self.pushButton_2.setText("Connect")