interface.py 1.59 KB
import sys
import configuracion as config
import archivos
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtGui import QIcon


class App(QWidget):

    def __init__(self):
        super().__init__()
        self.title = 'PyQt5 button - pythonspot.com'
        self.left = 10
        self.top = 10
        self.width = 120
        self.height = 200
        self.ordenV = 0
        self.initUI()
    
    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.show()
        self.GenerarBotones()


    def GenerarBotones(self):
        n = 0
        for conf in config.nabegadores:
            self.constructor(conf["nombre"], n)
            n += 1

    def button_pushed(self, id):
        nab = config.nabegadores[id]
        try:
            comando = "bash Proxy.sh {} {} {} {} {}".format(nab["SSHpass"],
            nab["SSHuser"], nab["SSHport"], nab["SSHprox"], nab["SSHdom"])
        except:
            comando = "google-chrome"
        comando = "{} --user-data-dir={}".format(comando, nab["CARPETA"])
        try:
            comando = "{} {}".format(comando, nab["HOME"])
        except:
            pass
        print(comando)
        archivos.ejecutar(self, comando)

    def constructor(self, name, id):
        self.ordenV += 25
        button1 = QPushButton(str(name), self)
        button1.move(10, self.ordenV)
        button1.clicked.connect(lambda x:self.button_pushed(id))
        button1.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()
    sys.exit(app.exec_())