예제 #1
0
class ColorDialog(QDialog):
    def __init__(self):
        super(ColorDialog, self).__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle("ColorDialog")
        self.setGeometry(400, 400, 300, 260)

        self.colorButton = QPushButton("颜色对话框")
        self.colorFrame = QFrame()
        self.colorFrame.setFrameShape(QFrame.Box)
        self.colorFrame.setAutoFillBackground(True)
        self.colorButton.clicked.connect(self.openColor)

        self.mainLayout = QGridLayout()
        self.mainLayout.addWidget(self.colorButton, 0, 0)
        self.mainLayout.addWidget(self.colorFrame, 0, 1)

        self.setLayout(self.mainLayout)

    def openColor(self):
        color = QColorDialog.getColor(Qt.white, None, "Selectting Color")
        if color.isValid():
            self.colorFrame.setPalette(QPalette(color))
예제 #2
0
 def drawCharts(self, frame: QFrame):
     """вывод графика в рисунок и в frame"""
     # logger.debug(self.drawCharts.__doc__)
     pic = self.renderToImage(frame.size())
     palette = frame.palette()
     palette.setBrush(QPalette.Background, QBrush(pic))
     frame.setPalette(palette)
     frame.setAutoFillBackground(True)
예제 #3
0
 def create_separator(self) -> QFrame:
     separator = QFrame(self)
     separator.setProperty("TTSeparator", QtCore.QVariant(True))
     separator.setAutoFillBackground(False)
     separator.setFrameShadow(QFrame.Plain)
     separator.setLineWidth(1)
     separator.setMidLineWidth(0)
     separator.setFrameShape(QFrame.VLine)
     return separator
예제 #4
0
    def __init__(self, parent=None):
        super(Main_Ayuda, self).__init__(parent)
        self.setWindowTitle("EXADATA (AYUDA)")
        self.setFixedSize(800, 600)
        self.setWindowIcon(QIcon("icono.jpg"))

        # FRAME
        paleta = QPalette()
        paleta.setColor(QPalette.Background, QColor(51, 0, 102))

        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(paleta)
        frame.setFixedWidth(800)
        frame.setFixedHeight(100)
        frame.move(0, 0)

        labelIcono = QLabel(frame)
        labelIcono.setFixedWidth(65)
        labelIcono.setFixedHeight(65)
        labelIcono.setPixmap(
            QPixmap("icono.jpg").scaled(65, 65, Qt.KeepAspectRatio,
                                        Qt.SmoothTransformation))
        labelIcono.move(10, 28)

        fuenteTitulo = QFont()
        fuenteTitulo.setPointSize(25)
        fuenteTitulo.setBold(True)

        labelTitulo = QLabel("<font color='white'>EXADATA</font>", frame)
        labelTitulo.setFont(fuenteTitulo)
        labelTitulo.move(85, 30)

        fuenteSubtitulo = QFont()
        fuenteSubtitulo.setPointSize(13)

        labelSubtitulo = QLabel("<font color='white'>Análisis de Tweets ",
                                frame)
        labelSubtitulo.setFont(fuenteSubtitulo)
        labelSubtitulo.move(85, 68)

        # LOGO
        self.centralwidget = QtWidgets.QWidget(self)
        self.setCentralWidget(self.centralwidget)

        # CUADRO TEXTO
        self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
        self.textBrowser.setGeometry(QtCore.QRect(10, 110, 780, 480))
예제 #5
0
    def initUI(self):
        frame = QFrame(self)
        frame.setFrameShape(QFrame.Box)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setFixedSize(450, 500)
        frame.move(0, 0)

        label = QLabel(frame)
        label.setPixmap(QPixmap("Imagenes/siacle.jpg").scaled(447, 447, Qt.KeepAspectRatio,
                                                              Qt.SmoothTransformation))
        label.move(1, 1)

        botonConfigurar = QPushButton("Информация", frame)
        botonConfigurar.setFixedSize(430, 32)
        botonConfigurar.move(10, 457)

        botonConfigurar.clicked.connect(self.Configuracion)
예제 #6
0
class VlcPlayer:

    def __init__(self):
        try:
            os.remove('vlc.log')
        except:
            pass
        self.instance = vlc.Instance("--verbose=2 --network-caching=1000 --no-snapshot-preview --no-osd --file-logging --logfile=vlc.log")
        self.mediaplayer = self.instance.media_player_new()

    def setMedia(self, mediaFile):

        if sys.version < '3':
            filename = unicode(mediaFile)
        else:
            filename = mediaFile

        self.media = self.instance.media_new(filename)
        self.mediaplayer.set_media(self.media)
        self.media.parse()

    def createWidget(self, parent=None):
        self.videoframe = QFrame(parent)
        self.videoPalette = self.videoframe.palette()
        self.videoPalette.setColor(QPalette.Window,
                              QColor(0, 0, 0))
        self.videoframe.setAutoFillBackground(True)
        self.videoframe.setPalette(self.videoPalette)

        if sys.platform.startswith('linux'):
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))

        return self.videoframe
예제 #7
0
    def createBox(self):
        box = QFrame(self)
        #box.setMinimumSize(self.width(), self.height()/3)
        box.setMaximumSize(self.width(), self.height() / 3)
        box.setStyleSheet("background-color:yellow")
        box.setAutoFillBackground(True)
        box.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        box.setStyleSheet("background-color:#f5f5ef")
        box.setFrameShape(QFrame.Box)

        font = QFont("Times new roman", 15)

        layout = QVBoxLayout(box)
        layout.setContentsMargins(5, 0, 0, 5)

        date = QLabel('', box)
        date.setObjectName('date')
        date.setFont(font)
        date.setStyleSheet("font-weight: bold;")

        name = QLabel('', box)
        name.setObjectName('name')
        name.setFont(font)

        layout.addWidget(date)
        layout.addWidget(name)
        layout.setAlignment(date, Qt.AlignTop)
        layout.setAlignment(name, Qt.AlignBottom)

        box.setLayout(layout)

        self.layout.addWidget(box)
        #layout.setAlignment(box,Qt.AlignTop)
        box.hide()

        return box
예제 #8
0
파일: BD.py 프로젝트: RodrigooDS/Exadata
    def __init__(self, parent=None):
        super(Main_DB, self).__init__(parent)
        self.setWindowTitle("EXADATA")
        self.setFixedSize(800, 600)
        self.setWindowIcon(QIcon("icono.jpg"))
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        # FRAME
        paleta = QPalette()
        paleta.setColor(QPalette.Background, QColor(51, 0, 102))

        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(paleta)
        frame.setFixedWidth(800)
        frame.setFixedHeight(100)
        frame.move(0, 0)

        labelIcono = QLabel(frame)
        labelIcono.setFixedWidth(65)
        labelIcono.setFixedHeight(65)
        labelIcono.setPixmap(
            QPixmap("icono.jpg").scaled(65, 65, Qt.KeepAspectRatio,
                                        Qt.SmoothTransformation))
        labelIcono.move(10, 28)

        fuenteTitulo = QFont()
        fuenteTitulo.setPointSize(25)
        fuenteTitulo.setBold(True)

        labelTitulo = QLabel("<font color='white'>EXADATA</font>", frame)
        labelTitulo.setFont(fuenteTitulo)
        labelTitulo.move(85, 30)

        fuenteSubtitulo = QFont()
        fuenteSubtitulo.setPointSize(13)

        labelSubtitulo = QLabel("<font color='white'>Análisis de Tweets ",
                                frame)
        labelSubtitulo.setFont(fuenteSubtitulo)
        labelSubtitulo.move(85, 68)

        #BARRA
        self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
        self.progressBar.setGeometry(QtCore.QRect(10, 400, 375, 23))
        self.progressBar.setProperty("value", 24)
        self.progressBar.setTextVisible(False)
        self.progressBar.setObjectName("progressBar")

        #inicio tabla
        self.tabla = QtWidgets.QTableWidget(self.centralwidget)
        self.tabla.setGeometry(QtCore.QRect(10, 110, 500, 400))
        self.tabla.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.tabla.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.tabla.setColumnCount(3)
        self.tabla.setObjectName("tabla")
        self.tabla.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(2, item)
        self.tabla.horizontalHeader().setDefaultSectionSize(165)
        self.tabla.horizontalHeader().setStretchLastSection(True)
        self.tabla.verticalHeader().setStretchLastSection(False)
        self.tabla.cellClicked.connect(self.clic)

        #fin tabla

        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(510, 70, 151, 16))
        self.label.setObjectName("label")

        #qlineedit nombre base
        self.input_nombre_bd = QtWidgets.QLineEdit(self.centralwidget)
        self.input_nombre_bd.setGeometry(QtCore.QRect(550, 130, 170, 20))
        self.input_nombre_bd.setObjectName("input_nombre_bd")

        # label
        #label nombre_bd
        self.label_nombre_base = QtWidgets.QLabel(self.centralwidget)
        self.label_nombre_base.setGeometry(QtCore.QRect(550, 110, 180, 20))
        self.label_nombre_base.setObjectName("label_nombre_base")
        # label editar_bd
        self.label_editar_bd = QtWidgets.QLabel(self.centralwidget)
        self.label_editar_bd.setGeometry(QtCore.QRect(550, 230, 180, 16))
        self.label_editar_bd.setObjectName("label_editar_bd")

        # BOTONES
        #boton importar
        self.bt_importar = QtWidgets.QPushButton(self.centralwidget)
        self.bt_importar.setGeometry(QtCore.QRect(550, 160, 170, 21))
        self.bt_importar.setObjectName("bt_importar")
        # boton agregar_bd
        self.bt_agregar_bd = QtWidgets.QPushButton(self.centralwidget)
        self.bt_agregar_bd.setGeometry(QtCore.QRect(550, 260, 170, 21))
        self.bt_agregar_bd.setObjectName("bt_agregar_bd")
        self.bt_agregar_bd.clicked.connect(self.Anadir)
        # boton eliminar_bd
        self.bt_eliminar_bt = QtWidgets.QPushButton(self.centralwidget)
        self.bt_eliminar_bt.setGeometry(QtCore.QRect(550, 290, 170, 21))
        self.bt_eliminar_bt.setObjectName("bt_eliminar_bt")
        self.bt_eliminar_bt.clicked.connect(self.BorrarTabla)
        # boton exportar_bd
        self.bt_exportar_bd = QtWidgets.QPushButton(self.centralwidget)
        self.bt_exportar_bd.setGeometry(QtCore.QRect(550, 320, 170, 21))
        self.bt_exportar_bd.setObjectName("bt_exportar_bd")
        self.bt_exportar_bd.clicked.connect(self.ExportarBase)
        # boton recarga_bd
        self.bt_recarga_bd = QtWidgets.QPushButton(self.centralwidget)
        self.bt_recarga_bd.setGeometry(QtCore.QRect(10, 520, 500, 21))
        self.bt_recarga_bd.setObjectName("bt_recarga_bd")
        self.bt_recarga_bd.clicked.connect(self.CargarTabla)

        #=================================================================================
        self.setCentralWidget(self.centralwidget)

        # BARRA MENU
        self.menubar = QtWidgets.QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName("menubar")
        self.Programas = QtWidgets.QMenu(self.menubar)
        self.BaseDeDatos = QtWidgets.QAction(self)
        self.menubar.addAction(self.Programas.menuAction())
        self.Programas.addAction(self.BaseDeDatos)
        self.Ayuda = QtWidgets.QMenu(self.menubar)
        self.SobreQue = QtWidgets.QAction(self)
        self.menubar.addAction(self.Ayuda.menuAction())
        self.Ayuda.addAction(self.SobreQue)

        self.retranslateUi()
        self.tabla_master()
        self.CargarTabla()
        self.progressBar.hide()
예제 #9
0
class App(QMainWindow):
    def __init__(self, a):
        super().__init__()
        self.title = 'Shivsagar Hotel'
        self.left = 100
        self.top = 100
        self.width = 600
        self.height = 300
        self.a = a
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.setAutoFillBackground(True)
        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.green)
        self.setPalette(p)

        #head image
        self.lh = QLabel(self)
        self.lh.move(0, 0)
        self.lh.resize(600, 200)
        self.head = QPixmap('head.png')
        self.lh.setPixmap(self.head)
        self.lh.resize(self.head.width(), self.head.height())

        self.back = QPushButton("Back", self)
        self.back.move(550, 20)
        self.back.resize(40, 20)
        self.back.clicked.connect(self.backclick)

        #main page
        #h1
        self.frame1 = QFrame(self)
        self.frame1.setStyleSheet("color: rgb(0,0,255)")
        self.frame1.move(0, 75)
        self.frame1.resize(299, 110)
        self.frame1.setAutoFillBackground(True)
        self.frame1.setStyleSheet(
            "QWidget {background-color: Qcolor(0,0,255) } ")

        self.i1 = QLabel(self.frame1)
        self.i1.move(0, 0)
        self.i1.resize(299, 110)
        self.i1.setPixmap(QPixmap('thalli.jpg'))
        self.i1.resize(self.i1.width(), self.i1.height())

        self.h1 = QLabel("Special Talli    ₹150", self.frame1)
        self.h1.setFont(QFont('SansSerif', 20))
        self.h1.setStyleSheet(
            "QLabel {background-color: rgba(255, 255, 255, 10); color :yellow ;}"
        )
        self.h1.move(15, 65)
        self.h1.resize(300, 50)

        self.s1 = QPushButton("Select", self.frame1)
        self.s1.move(260, 5)
        self.s1.resize(38, 16)
        self.s1.setFont(QFont('SansSerif', 10))
        self.s1.setStyleSheet("border:1px solid lightblue; ")
        self.s1.clicked.connect(self.hotel1)

        #h2
        self.frame2 = QFrame(self)
        self.frame2.setStyleSheet("color: rgb(0,0,255)")
        self.frame2.move(300, 75)
        self.frame2.resize(300, 110)
        self.frame2.setAutoFillBackground(True)
        self.frame2.setStyleSheet(
            "QWidget {background-color: Qcolor(0,0,255)}")

        self.i2 = QLabel(self.frame2)
        self.i2.move(0, 0)
        self.i2.resize(300, 110)
        self.i2.setPixmap(QPixmap('manchu.jpg'))
        self.i2.resize(self.i1.width(), self.i1.height())

        self.h2 = QLabel("Dry Manchurian    ₹150", self.frame2)
        self.h2.setFont(QFont('SansSerif', 20))
        self.h2.setStyleSheet(
            "QLabel {background-color: rgba(255, 255, 255, 10); color :yellow ;}"
        )
        self.h2.move(15, 65)
        self.h2.resize(300, 50)

        self.s2 = QPushButton("Select", self.frame2)
        self.s2.move(260, 5)
        self.s2.resize(38, 16)
        self.s2.setFont(QFont('SansSerif', 10))
        self.s2.setStyleSheet("border:1px solid lightblue; ")
        self.s2.clicked.connect(self.hotel2)

        #h3
        self.frame3 = QFrame(self)
        self.frame3.setStyleSheet("color: rgb(0,0,255)")
        self.frame3.move(0, 186)
        self.frame3.resize(299, 110)
        self.frame3.setAutoFillBackground(True)
        self.frame3.setStyleSheet(
            "QWidget {background-color: Qcolor(0,0,255)}")

        self.i3 = QLabel(self.frame3)
        self.i3.move(0, 0)
        self.i3.resize(300, 110)
        self.i3.setPixmap(QPixmap('desert.jpg'))
        self.i3.resize(self.i1.width(), self.i1.height())

        self.h3 = QLabel("Dessert    ₹200", self.frame3)
        self.h3.setFont(QFont('SansSerif', 20))
        self.h3.setStyleSheet(
            "QLabel {background-color: rgba(255, 255, 255, 10); color :yellow ;}"
        )
        self.h3.move(15, 65)
        self.h3.resize(300, 50)

        self.s3 = QPushButton("Select", self.frame3)
        self.s3.move(260, 5)
        self.s3.resize(38, 16)
        self.s3.setFont(QFont('SansSerif', 10))
        self.s3.setStyleSheet("border:1px solid lightblue; ")
        self.s3.clicked.connect(self.hotel3)

        #h4
        self.frame4 = QFrame(self)
        self.frame4.setStyleSheet("color: rgb(0,0,255)")
        self.frame4.move(300, 186)
        self.frame4.resize(299, 110)
        self.frame4.setAutoFillBackground(True)
        self.frame4.setStyleSheet(
            "QWidget {background-color: Qcolor(0,0,255)}")

        self.i4 = QLabel(self.frame4)
        self.i4.move(0, 0)
        self.i4.resize(300, 110)
        self.i4.setPixmap(QPixmap('noodles.jpg'))
        self.i4.resize(self.i1.width(), self.i1.height())

        self.h4 = QLabel("Fry Noodles    ₹150", self.frame4)
        self.h4.setFont(QFont('SansSerif', 20))
        self.h4.setStyleSheet(
            "QLabel {background-color: rgba(255, 255, 255, 10); color :yellow ;}"
        )
        self.h4.move(15, 65)
        self.h4.resize(300, 50)

        self.s4 = QPushButton("Select", self.frame4)
        self.s4.move(260, 5)
        self.s4.resize(38, 16)
        self.s4.setFont(QFont('SansSerif', 10))
        self.s4.setStyleSheet("border:1px solid lightblue; ")
        self.s4.clicked.connect(self.hotel4)

        self.show()

    def hotel1(self):
        c = self.a
        que = "INSERT INTO " + c + " (food, hotel, rupees, date) VALUES (%s, %s, %s, %s)"
        now = QDate.currentDate().toPyDate()
        print(now)
        vala = ('Special thalli', 'Shivsagar hotel', '150', now)
        mycu.execute(que, vala)
        conn.commit()
        QMessageBox.question(self, 'Shivsagar hotel', "Food added to list")

    def hotel2(self):
        c = self.a
        que = "INSERT INTO " + c + " (food, hotel, rupees, date) VALUES (%s, %s, %s, %s)"
        now = QDate.currentDate().toPyDate()
        print(now)
        vala = ('Dry  Manchurian', 'Shivsagar hotel', '150', now)
        mycu.execute(que, vala)
        conn.commit()
        QMessageBox.question(self, 'Shivsagar hotel', "Food added to list")

    def hotel3(self):
        c = self.a
        que = "INSERT INTO " + c + " (food, hotel, rupees, date) VALUES (%s, %s, %s, %s)"
        now = QDate.currentDate().toPyDate()
        print(now)
        vala = ('Dessert', 'Shivsagar hotel', '200', now)
        mycu.execute(que, vala)
        conn.commit()
        QMessageBox.question(self, 'Shivsagar hotel', "Food added to list")

    def hotel4(self):
        c = self.a
        que = "INSERT INTO " + c + " (food, hotel, rupees, date) VALUES (%s, %s, %s, %s)"
        now = QDate.currentDate().toPyDate()
        print(now)
        vala = ('Fry Noodles', 'Shivsagar hotel', '150', now)
        mycu.execute(que, vala)
        conn.commit()
        QMessageBox.question(self, 'Shivsagar hotel', "Food added to list")

    def backclick(self):
        from main import App
        self.m = App(self.a)
        self.m.show()
        self.close()
예제 #10
0
class TassomaiUI(object):
    def __init__(self, main_window: QMainWindow):
        self.win = main_window

    def setupUi(self):
        self.win.setWindowTitle(f"Tassomai Automation v{__version__}")
        self.win.setWindowIcon(QIcon(path('images', 'logo.png')))
        self.win.resize(665, 580)

        self.centralwidget = QWidget(self.win)

        self.formLayout = QFormLayout(self.centralwidget)
        self.formLayout.setContentsMargins(5, 0, 5, -1)

        self.topFrame = QFrame(self.centralwidget)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.topFrame.sizePolicy().hasHeightForWidth())
        self.topFrame.setSizePolicy(sizePolicy)
        self.topFrame.setAutoFillBackground(True)
        self.topFrame.setFrameShape(QFrame.StyledPanel)
        self.topFrame.setFrameShadow(QFrame.Raised)

        self.gridLayout = QGridLayout(self.topFrame)

        self.tassomaiImage = QLabel(self.topFrame)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.tassomaiImage.sizePolicy().hasHeightForWidth())
        self.tassomaiImage.setSizePolicy(sizePolicy)
        self.tassomaiImage.setPixmap(QPixmap(path('images', 'banner.png')))
        self.gridLayout.addWidget(self.tassomaiImage, 0, 0, 1, 1)

        self.formLayout.setWidget(0, QFormLayout.SpanningRole, self.topFrame)

        self.tab = QTabWidget(self.centralwidget)

        self.main_tab = QWidget()
        self.automation_tab = QWidget()

        self.gridLayout_4 = QGridLayout(self.main_tab)
        self.gridLayout_4.setContentsMargins(0, 0, 0, 0)

        self.main_frame = QFrame(self.main_tab)
        self.main_frame.setAutoFillBackground(True)
        self.main_frame.setFrameShape(QFrame.StyledPanel)
        self.main_frame.setFrameShadow(QFrame.Raised)
        self.gridLayout_2 = QGridLayout(self.main_frame)
        self.gridLayout_2.setContentsMargins(5, 6, 2, -1)
        self.gridLayout_2.setVerticalSpacing(10)

        self.gridLayout_5 = QGridLayout(self.automation_tab)
        self.gridLayout_5.setContentsMargins(0, 0, 0, 0)

        self.automation_frame = QFrame(self.automation_tab)
        self.automation_frame.setAutoFillBackground(True)
        self.automation_frame.setFrameShape(QFrame.StyledPanel)
        self.automation_frame.setFrameShadow(QFrame.Raised)

        self.delayLayout = QHBoxLayout()
        self.delayLayout.setContentsMargins(0, 0, 0, 0)
        self.delayLayout.setSpacing(3)

        self.delay = QCheckBox(self.main_frame)
        font = QFont()
        font.setPointSize(10)
        self.delay.setFont(font)

        self.delayLayout.addWidget(self.delay)

        self.amountOfDelay = QDoubleSpinBox(self.main_frame)
        self.amountOfDelay.setMinimumWidth(70)
        self.amountOfDelay.setMaximum(25.00)

        self.delayLayout.addWidget(self.amountOfDelay)

        self.label03 = QLabel(self.main_frame)
        self.label03.setSizePolicy(sizePolicy)
        self.label03.setFont(font)

        self.delayLayout.addWidget(self.label03)

        self.amountOfDelay2 = QDoubleSpinBox(self.main_frame)
        self.amountOfDelay2.setMinimumWidth(70)
        self.amountOfDelay2.setMaximum(25.00)

        self.delayLayout.addWidget(self.amountOfDelay2)

        self.label3 = QLabel(self.main_frame)
        self.label3.setSizePolicy(sizePolicy)
        self.label3.setFont(font)

        self.delayLayout.addWidget(self.label3)

        self.whenDelay = QComboBox(self.main_frame)
        self.whenDelay.addItem("question")
        self.whenDelay.addItem("quiz")
        self.whenDelay.setMaximumWidth(100)

        self.delayLayout.addWidget(self.whenDelay)

        self.verticalSpacer1 = QSpacerItem(20, 40, QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.delayLayout.addItem(self.verticalSpacer1)

        self.gridLayout_2.addLayout(self.delayLayout, 2, 0, 1, 1)

        self.randomnessLayout = QHBoxLayout()
        self.randomnessLayout.setContentsMargins(0, 0, 0, 0)
        self.randomnessLayout.setSpacing(3)

        self.randomness = QCheckBox(self.main_frame)
        self.randomness.setFont(font)
        self.randomness.setMaximumWidth(338)

        self.randomnessLayout.addWidget(self.randomness)

        self.randomnessAmount = QSpinBox(self.main_frame)
        self.randomnessAmount.setMinimumWidth(70)
        self.randomnessAmount.setMaximum(600)

        self.randomnessLayout.addWidget(self.randomnessAmount)

        self.label4 = QLabel(self.main_frame)
        self.label4.setSizePolicy(sizePolicy)
        self.label4.setFont(font)

        self.randomnessLayout.addWidget(self.label4)

        self.gridLayout_2.addLayout(self.randomnessLayout, 3, 0, 1, 1)

        self.dailyGoal = QCheckBox(self.main_frame)
        font = QFont()
        font.setPointSize(10)
        self.dailyGoal.setFont(font)
        self.gridLayout_2.addWidget(self.dailyGoal, 4, 0, 1, 1)

        self.bonusGoal = QCheckBox(self.main_frame)
        self.bonusGoal.setFont(font)
        self.gridLayout_2.addWidget(self.bonusGoal, 5, 0, 1, 1)

        self.horizontalLayout = QHBoxLayout()

        self.label1 = QLabel(self.main_frame)
        sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label1.sizePolicy().hasHeightForWidth())
        self.label1.setSizePolicy(sizePolicy)
        font = QFont()
        font.setPointSize(10)
        self.label1.setFont(font)
        self.horizontalLayout.addWidget(self.label1)

        self.maxQuizes = QSpinBox(self.main_frame)
        self.maxQuizes.setMinimum(1)
        self.maxQuizes.setMaximum(1000000)
        self.maxQuizes.setProperty("value", 1000)
        self.horizontalLayout.addWidget(self.maxQuizes)

        self.label2 = QLabel(self.main_frame)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label2.sizePolicy().hasHeightForWidth())
        self.label2.setSizePolicy(sizePolicy)
        font = QFont()
        font.setPointSize(10)
        self.label2.setFont(font)
        self.horizontalLayout.addWidget(self.label2)
        self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)

        self.userBox = QGroupBox(self.main_frame)
        font = QFont()
        font.setPointSize(9)
        font.setBold(False)
        font.setWeight(50)
        self.userBox.setFont(font)
        self.gridLayout_3 = QGridLayout(self.userBox)

        self.emailTassomaiLabel = QLabel(self.userBox)
        self.gridLayout_3.addWidget(self.emailTassomaiLabel, 0, 0, 1, 1)
        self.emailTassomai = QLineEdit(self.userBox)
        self.gridLayout_3.addWidget(self.emailTassomai, 0, 1, 1, 1)

        self.passwordTassomaiLabel = QLabel(self.userBox)
        self.gridLayout_3.addWidget(self.passwordTassomaiLabel, 1, 0, 1, 1)
        self.passwordTassomai = QLineEdit(self.userBox)
        self.passwordTassomai.setEchoMode(QLineEdit.Password)
        self.gridLayout_3.addWidget(self.passwordTassomai, 1, 1, 1, 1)

        self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.gridLayout_3.addItem(self.verticalSpacer, 2, 0, 1, 1)

        self.gridLayout_4.addWidget(self.main_frame, 0, 0, 1, 1)
        self.gridLayout_5.addWidget(self.automation_frame, 0, 0, 1, 1)

        self.tab.addTab(self.main_tab, "")
        self.tab.addTab(self.automation_tab, "")

        self.formLayout.setWidget(1, QFormLayout.SpanningRole, self.tab)

        self.gridLayout_2.addWidget(self.userBox, 0, 0, 1, 1)

        self.buttonsLayout = QHBoxLayout()

        self.bottom_frame = QFrame(self.centralwidget)
        self.bottom_frame.setFrameShape(QFrame.StyledPanel)
        self.bottom_frame.setFrameShadow(QFrame.Raised)

        self.gridLayout_7 = QGridLayout(self.bottom_frame)
        self.gridLayout_7.setContentsMargins(0, 0, 0, 0)


        self.startButton = QPushButton(self.bottom_frame)
        self.buttonsLayout.addWidget(self.startButton)

        self.stopButton = QPushButton(self.bottom_frame)
        self.buttonsLayout.addWidget(self.stopButton)

        self.gridLayout_7.addLayout(self.buttonsLayout, 0, 0, 1, 1)

        self.output = QTextEdit(self.bottom_frame)
        self.gridLayout_7.addWidget(self.output, 1, 0, 1, 1)

        self.formLayout.setWidget(2, QFormLayout.SpanningRole, self.bottom_frame)

        self.win.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(self.win)
        self.menubar.setGeometry(QRect(0, 0, 665, 21))

        self.tools_menu = QMenu(self.menubar)

        self.uninstall_option = QAction()

        self.tools_menu.addAction(self.uninstall_option)

        self.menubar.addAction(self.tools_menu.menuAction())

        self.win.setMenuBar(self.menubar)

        self.createTable()
        self.retranslateUi()

        self.tab.setCurrentIndex(0)
        self.tab.currentChanged['int'].connect(lambda k: self.bottom_frame.hide() if k != 0 else self.bottom_frame.show())

        QMetaObject.connectSlotsByName(self.win)

    def retranslateUi(self):
        self.dailyGoal.setChecked(True)
        self.dailyGoal.setText("Finish when daily goal complete")
        self.bonusGoal.setText("Finish when bonus goal complete")
        self.delay.setText("Add a delay between")
        self.label03.setText("and")
        self.label3.setText("seconds between each")
        self.randomness.setText("Make it so that you answer a question incorrectly every")
        self.label4.setText("questions")
        self.label1.setText("Only do a maximum of ")
        self.label2.setText(" quiz(s)")
        self.userBox.setTitle("User Settings")
        self.passwordTassomaiLabel.setText("Password for Tassomai login")
        self.emailTassomaiLabel.setText("Email for Tassomai login")
        self.tab.setTabText(self.tab.indexOf(self.main_tab), "General")
        self.tab.setTabText(self.tab.indexOf(self.automation_tab), "Automation")
        self.startButton.setText("Start Automation")
        self.stopButton.setText("Stop Automation")
        self.tools_menu.setTitle("Tools")
        self.uninstall_option.setText("Uninstall (coming soon)")
        self.output.setReadOnly(True)
        self.startButton.setEnabled(True)
        self.stopButton.setEnabled(False)
        self.output.setHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
        "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
        "p, li { white-space: pre-wrap; }\n"
        "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
        "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">-------------------------------------------</p>\n"
        "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600; text-decoration: underline; color:#14860a;\">All output will go here<br /></span></p>\n"
        "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">-------------------------------------------</p>\n"
)

    def createTable(self):
        self.table = QTableWidget(self.automation_tab)
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table.setAlternatingRowColors(True)
        self.table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.table.setShowGrid(True)
        self.table.setGridStyle(Qt.DashLine)
        self.table.setRowCount(999999)
        self.table.setColumnCount(6)
        for i in range(6):
            self.table.setHorizontalHeaderItem(i, QTableWidgetItem())
            self.table.horizontalHeaderItem(i).setTextAlignment(Qt.AlignLeft)
        for i in range(6):
            self.table.setItem(0, i, QTableWidgetItem())
            self.table.setItem(1, i, QTableWidgetItem())
        self.table.horizontalHeader().setVisible(True)
        self.table.horizontalHeader().setHighlightSections(True)
        self.table.verticalHeader().setVisible(False)
        self.table.verticalHeader().setHighlightSections(True)
        self.gridLayout_5.addWidget(self.table, 0, 0, 1, 1)
        headers = ["Quiz", "Num", "Question", "Correct", "Time", "Answer"]
        for header in headers:
            item = self.table.horizontalHeaderItem(headers.index(header))
            item.setText(header)
            item.setSizeHint(QSize(25, 25))
        self.table.setColumnWidth(0, 40)
        self.table.setColumnWidth(1, 40)
        self.table.setColumnWidth(2, 175)
        self.table.setColumnWidth(3, 80)
        self.table.setColumnWidth(4, 80)
        self.table.setColumnWidth(5, 230)
class Player(QMainWindow):
    def __init__(self, f=" ", master=None):
        QMainWindow.__init__(self, master)
        self.setWindowTitle("Media Player")
        self.filename = f
        self.instance = vlc.Instance()
        self.mediaplayer = self.instance.media_player_new()
        self.createUI()
        self.isPaused = False

    def createUI(self):
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.videoframe = QMacCocoaViewContainer(0)
        else:
            self.videoframe = QFrame()
        self.palette = self.videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)

        self.positionslider = QSlider(Qt.Horizontal, self)
        self.positionslider.setToolTip("Position")
        self.positionslider.setMaximum(1000)
        self.positionslider.sliderMoved.connect(self.setPosition)

        self.hbuttonbox = QHBoxLayout()
        self.playbutton = QPushButton("Play")
        self.hbuttonbox.addWidget(self.playbutton)
        self.playbutton.clicked.connect(self.PlayPause)

        self.stopbutton = QPushButton("Stop")
        self.hbuttonbox.addWidget(self.stopbutton)
        self.stopbutton.clicked.connect(self.Stop)

        self.hbuttonbox.addStretch(1)
        self.volumeslider = QSlider(Qt.Horizontal, self)
        self.volumeslider.setMaximum(100)
        self.volumeslider.setValue(self.mediaplayer.audio_get_volume())
        self.volumeslider.setToolTip("Volume")
        self.hbuttonbox.addWidget(self.volumeslider)
        self.volumeslider.valueChanged.connect(self.setVolume)

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.addWidget(self.videoframe)
        self.vboxlayout.addWidget(self.positionslider)
        self.vboxlayout.addLayout(self.hbuttonbox)

        self.widget.setLayout(self.vboxlayout)

        open = QAction("&Open", self)
        open.triggered.connect(self.OpenFile)
        exit = QAction("&Exit", self)
        exit.triggered.connect(sys.exit)
        menubar = self.menuBar()
        filemenu = menubar.addMenu("&File")
        filemenu.addAction(open)
        filemenu.addSeparator()
        filemenu.addAction(exit)

        self.timer = QTimer(self)
        self.timer.setInterval(200)
        self.timer.timeout.connect(self.updateUI)

    def PlayPause(self):
        if self.mediaplayer.is_playing():
            self.mediaplayer.pause()
            self.playbutton.setText("Play")
            self.isPaused = True
        else:
            if self.mediaplayer.play() == -1:
                self.OpenFile()
                return
            self.mediaplayer.play()
            self.playbutton.setText("Pause")
            self.timer.start()
            self.isPaused = False

    def Stop(self):

        self.mediaplayer.stop()
        self.playbutton.setText("Play")

    def OpenFile(self, filename=None):
        self.media = self.instance.media_new(self.filename)
        # put the media in the media player
        self.mediaplayer.set_media(self.media)
        self.media.parse()
        self.setWindowTitle(self.media.get_meta(0))

        if sys.platform.startswith('linux'):  # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":  # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":  # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))
        self.PlayPause()

    def setVolume(self, Volume):
        self.mediaplayer.audio_set_volume(Volume)

    def setPosition(self, position):
        self.mediaplayer.set_position(position / 1000.0)

    def updateUI(self):
        self.positionslider.setValue(self.mediaplayer.get_position() * 1000)
        if not self.mediaplayer.is_playing():
            self.timer.stop()
            if not self.isPaused:
                self.Stop()
예제 #12
0
class MainUI(QMainWindow):
    def __init__(self):
        super().__init__()

    def initUI(self):
        rec = QApplication.desktop()
        rec = rec.screenGeometry()
        self.screenWidth, self.screenHeight = rec.width(), rec.height()
        
        top_field_width = 0.173 * self.screenWidth
        top_field_height = 0.037 * self.screenHeight
        
        if sys.platform == 'linux':
            font = QFont("Liberation Serif")
        elif sys.platform == 'darwin':
            font = QFont("Times")
        else:
            font = QFont("Calibri")
        
        
        self.framepal = QPalette()
        self.framepal.setColor(self.backgroundRole(), QColor(240, 240, 240)) 
 
        self.topframe = QFrame(self)
        self.topframe.setFrameShape(QFrame.StyledPanel)
        self.topframe.setPalette(self.framepal)
        self.topframe.setAutoFillBackground(True)
        self.topframe.resize(0.307 * self.screenWidth, 0.22 * self.screenHeight)
        self.topframe.move(0.01 * self.screenWidth, 0.037 * self.screenHeight)
        
        self.lbl1 = QLabel('Enter poject name : ', self.topframe)
        font.setPixelSize(28 / 1920 * self.screenWidth)
        self.lbl1.setFont(font)
        self.lbl1.move(10 / 1920 * self.screenWidth, 15 / 1080 * self.screenHeight)
        
        self.le = QLineEdit(self.topframe)
        self.le.resize(top_field_width, top_field_height)
        self.le.move(243 / 1920 * self.screenWidth, 16 / 1080 * self.screenHeight)
        font.setPixelSize(26 / 1920 * self.screenWidth)
        self.le.setFont(font)
        
        self.srclbl = QLabel('Source code file : ', self.topframe)
        font.setPixelSize(28 / 1920 * self.screenWidth)
        self.srclbl.setFont(font)
        self.srclbl.move(10 / 1920 * self.screenWidth, 75 / 1080 * self.screenHeight)
        
        self.lt = QListWidget(self.topframe)
        self.lt.resize(top_field_width, top_field_height)
        self.lt.move(243 / 1920 * self.screenWidth, 74 / 1080 * self.screenHeight)
        font.setPixelSize(24 / 1920 * self.screenWidth)
        self.lt.setFont(font)
        self.lt.setIconSize(QSize(25 / 1080 * self.screenHeight, 25 / 1080 * self.screenHeight))
        self.lt.setContextMenuPolicy(Qt.CustomContextMenu)
        
        self.lbln = QLabel('Build target folder : ', self.topframe)
        font.setPixelSize(28 / 1920 * self.screenWidth)
        self.lbln.setFont(font)
        self.lbln.move(10 / 1920 * self.screenWidth, 133 / 1080 * self.screenHeight)
        
        self.folle = QLineEdit(self.topframe)
        self.folle.resize(top_field_width, top_field_height)
        self.folle.move(243 / 1920 * self.screenWidth, 134 / 1080 * self.screenHeight)
        font.setPixelSize(25 / 1920 * self.screenWidth)
        self.folle.setFont(font)
        self.folle.setReadOnly(True)
        
        self.choosebtn = QPushButton('Choose file', self.topframe)
        self.choosebtn.move(10 / 1920 * self.screenWidth, 185 / 1080 * self.screenHeight)
        self.choosebtn.resize(0.07 * self.screenWidth, 0.036 * self.screenHeight)
        font.setPixelSize(22 / 1920 * self.screenWidth)
        self.choosebtn.setFont(font)
        
        self.choosefoldbtn = QPushButton('Choose folder', self.topframe)
        self.choosefoldbtn.move(155 / 1920 * self.screenWidth, 185 / 1080 * self.screenHeight)
        self.choosefoldbtn.resize(0.07 * self.screenWidth, 0.036 * self.screenHeight)
        font.setPixelSize(22 / 1920 * self.screenWidth)
        self.choosefoldbtn.setFont(font)
        self.choosefoldbtn.setToolTip("Where folder with compiled project will be placed")
        
        #self.warnlbl = QLabel('                                                                    ', self.topframe)
        #self.warnlbl.setFont(QFont('Calibri', 14))
        #self.warnlbl.move(294 / 1920 * self.screenWidth, 190 / 1080 * self.screenHeight)
        #self.warnlbl.setStyleSheet("QLabel { color : red; }")
        
        self.leftframe = QFrame(self)
        self.leftframe.setFrameShape(QFrame.StyledPanel)
        self.leftframe.setPalette(self.framepal)
        self.leftframe.setAutoFillBackground(True)
        self.leftframe.resize(0.106 * self.screenWidth, 0.351 * self.screenHeight)
        self.leftframe.move(20 / 1920 * self.screenWidth, 290 / 1080 * self.screenHeight)
        
        self.lbl2 = QLabel('Build tool : ', self.leftframe)
        font.setPixelSize(27 / 1920 * self.screenWidth)
        self.lbl2.setFont(font)
        self.lbl2.move(10 / 1920 * self.screenWidth, 15 / 1080 * self.screenHeight)
        
        self.toolle = QLineEdit(self.leftframe)
        self.toolle.resize(182 / 1920 * self.screenWidth, 37 / 1080 * self.screenHeight)
        self.toolle.move(10 / 1920 * self.screenWidth, 60 / 1080 * self.screenHeight)
        font.setPixelSize(26 / 1920 * self.screenWidth)
        self.toolle.setFont(font)
        self.toolle.setReadOnly(True)
        
        self.settingsbtn = QPushButton('Settings', self.leftframe)
        self.settingsbtn.move(30 / 1920 * self.screenWidth, 115 / 1080 * self.screenHeight)
        self.settingsbtn.resize(140 / 1920 * self.screenWidth, 45 / 1080 * self.screenHeight)
        font.setPixelSize(23 / 1920 * self.screenWidth)
        self.settingsbtn.setFont(font)
        
        self.buildbtn = QPushButton('Build', self.leftframe)
        self.buildbtn.move(17 / 1920 * self.screenWidth, 311 / 1080 * self.screenHeight)
        self.buildbtn.resize(170 / 1920 * self.screenWidth, 50 / 1080 * self.screenHeight)
        font.setPixelSize(25 / 1920 * self.screenWidth)
        self.buildbtn.setFont(font)
        
        self.rightframe = QFrame(self)
        self.rightframe.setFrameShape(QFrame.StyledPanel)
        self.rightframe.setPalette(self.framepal)
        self.rightframe.setAutoFillBackground(True)
        self.rightframe.resize(0.192 * self.screenWidth, 0.351 * self.screenHeight)
        self.rightframe.move(240 / 1920 * self.screenWidth, 290 / 1080 * self.screenHeight)
        
        self.list = QListWidget(self.rightframe)
        self.list.resize(350 / 1920 * self.screenWidth, 250 / 1080 * self.screenHeight)
        self.list.move(9 / 1920 * self.screenWidth, 46 / 1080 * self.screenHeight)
        self.list.setIconSize(QSize(27 / 1080 * self.screenHeight, 27 / 1080 * self.screenHeight))
        font.setPixelSize(23 / 1920 * self.screenWidth)
        self.list.setFont(font)
        self.list.setSelectionMode(QAbstractItemView.SingleSelection)
        #self.list.setDragDropMode(QAbstractItemView.NoDragDrop)
        self.list.setContextMenuPolicy(Qt.CustomContextMenu)
        self.list.setToolTip("Add resources and your modules/packages that program uses here")
        
        self.lbl4 = QLabel('Include files : ', self.rightframe)
        self.lbl4.move(10 / 1920 * self.screenWidth, 5 / 1080 * self.screenHeight)
        font.setPixelSize(26 / 1920 * self.screenWidth)
        self.lbl4.setFont(font)
        #self.lbl4.setToolTip("Add resources and YOUR modules/packages that program uses here")
        
        self.addbtn = QPushButton('Add', self.rightframe)
        self.addbtn.move(8 / 1920 * self.screenWidth, 315 / 1080 * self.screenHeight)
        self.addbtn.resize(130 / 1920 * self.screenWidth, 44 / 1080 * self.screenHeight)
        font.setPixelSize(23 / 1920 * self.screenWidth)
        self.addbtn.setFont(font)
        
        self.delbtn = QPushButton('Remove', self.rightframe)
        self.delbtn.move(230 / 1920 * self.screenWidth, 315 / 1080 * self.screenHeight)
        self.delbtn.resize(130  / 1920 * self.screenWidth, 44 / 1080 * self.screenHeight)
        font.setPixelSize(23 / 1920 * self.screenWidth)
        self.delbtn.setFont(font)
예제 #13
0
class Player(QMainWindow):
    """A simple Media Player using VLC and Qt
    """
    def __init__(self, master=None):
        QMainWindow.__init__(self, master)
        self.setWindowTitle("Media Player")

        self.isAudio = False

        # creating a basic vlc instance
        self.instance = vlc.Instance()
        # creating an empty vlc media player
        self.mediaplayer = self.instance.media_player_new()

        self.createUI()
        self.isPaused = False

    def createUI(self):
        """Set up the user interface, signals & slots
        """
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)

        # In this widget, the video will be drawn
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.videoframe = QMacCocoaViewContainer(0)
        else:
            self.videoframe = QFrame()

        self.palette = self.videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)

        self.positionslider = QSlider(Qt.Horizontal, self)
        self.positionslider.setToolTip("Position")
        self.positionslider.setMaximum(1000)
        self.positionslider.sliderMoved.connect(self.setPosition)

        self.hbuttonbox = QHBoxLayout()

        self.playbutton = QPushButton("►")
        self.hbuttonbox.addWidget(self.playbutton)
        self.playbutton.clicked.connect(self.PlayPause)

        self.stopbutton = QPushButton("⯀")
        self.hbuttonbox.addWidget(self.stopbutton)
        self.stopbutton.clicked.connect(self.Stop)

        self.audiobutton = QPushButton("𝅘𝅥")
        self.hbuttonbox.addWidget(self.audiobutton)
        self.audiobutton.setToolTip(
            "Switch to audio only mode\n(must search again)")
        self.audiobutton.clicked.connect(self.AudioVideo)

        self.hbuttonbox.addStretch(1)
        self.volumeslider = QSlider(Qt.Horizontal, self)
        self.volumeslider.setMaximum(100)
        self.volumeslider.setValue(self.mediaplayer.audio_get_volume())
        self.volumeslider.setToolTip("Volume")
        self.hbuttonbox.addWidget(self.volumeslider)
        self.volumeslider.valueChanged.connect(self.setVolume)

        self.hbuttonbox2 = QHBoxLayout()

        self.searchline = QLineEdit()
        self.hbuttonbox2.addWidget(self.searchline)
        self.searchline.setToolTip("Enter search term here")

        self.searchbutton = QPushButton("Search")
        self.hbuttonbox2.addWidget(self.searchbutton)
        self.searchbutton.setToolTip("Press to search")
        self.searchbutton.clicked.connect(self.searchYouTube)

        self.searchresult = QHBoxLayout()

        #adding QListWidget to the layout causes the video frame
        #to disappear and im not sure why
        #self.searchresults = QListWidget(self)
        #self.searchresult.addWidget(self.searchresults)
        #self.searchresults.addItem("testing1")
        #self.searchresults.addItem("testing2")

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.addWidget(self.videoframe)
        self.vboxlayout.addWidget(self.positionslider)
        self.vboxlayout.addLayout(self.hbuttonbox)
        self.vboxlayout.addLayout(self.hbuttonbox2)
        #self.vboxlayout.addLayout(self.searchresult)

        self.widget.setLayout(self.vboxlayout)

        open = QAction("&Open", self)
        open.triggered.connect(lambda: self.OpenFile())
        exit = QAction("&Exit", self)
        exit.triggered.connect(sys.exit)
        download = QAction("&Download", self)
        download.triggered.connect(self.downloadFile)
        menubar = self.menuBar()
        filemenu = menubar.addMenu("&File")
        filemenu.addAction(open)
        filemenu.addSeparator()
        filemenu.addAction(exit)
        filemenu.addSeparator()
        filemenu.addAction(download)

        self.timer = QTimer(self)
        self.timer.setInterval(200)
        self.timer.timeout.connect(self.updateUI)

    def AudioVideo(self):
        """Toggle whether a video is shown or just audio.
        requires another search to take effect"""
        if self.isAudio == False:
            self.isAudio = True
            self.audiobutton.setText("🎥")
            self.audiobutton.setToolTip(
                "Switch to video only mode\n(must search again)")
        else:
            self.isAudio = False
            self.audiobutton.setText("𝅘𝅥")
            self.audiobutton.setToolTip(
                "Switch to audio only mode\n(must search again)")

    def PlayPause(self):
        """Toggle play/pause status
        """
        if self.mediaplayer.is_playing():
            self.mediaplayer.pause()
            self.playbutton.setText("►")
            self.isPaused = True
        else:
            if self.mediaplayer.play() == -1:
                self.searchYouTube()
                return
            self.mediaplayer.play()
            self.playbutton.setText("❚❚")
            self.timer.start()
            self.isPaused = False

    def Stop(self):
        """Stop player
        """
        self.mediaplayer.stop()
        self.playbutton.setText("►")

    def OpenFile(self, filename=None):
        """Open a media file in a MediaPlayer
        """
        if filename is None:
            filename = QFileDialog.getOpenFileName(self, "Open File",
                                                   os.path.expanduser('~'))[0]
        if not filename:
            return

        # create the media
        if sys.version < '3':
            filename = unicode(filename)
        self.media = self.instance.media_new(filename)
        # put the media in the media player
        self.mediaplayer.set_media(self.media)

        # parse the metadata of the file
        self.media.parse()
        # set the title of the track as window title
        self.setWindowTitle(self.media.get_meta(0))

        # the media player has to be 'connected' to the QFrame
        # (otherwise a video would be displayed in it's own window)
        # this is platform specific!
        # you have to give the id of the QFrame (or similar object) to
        # vlc, different platforms have different functions for this
        if sys.platform.startswith('linux'):  # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":  # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":  # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))
        self.PlayPause()

    def searchYouTube(self):
        """Search YouTube with search term and play top video"""
        searchTerm = self.searchline.text()
        self.searchline.clear()

        searchTerm = searchTerm.replace(" ", "+")  #For formatting

        #request youtube search results and web scrape information
        r = requests.get("https://www.youtube.com/results?search_query=" +
                         searchTerm)
        page = r.text
        soup = bs(page, 'html.parser')
        vids = soup.findAll('a', attrs={'class': 'yt-uix-tile-link'})

        self.titlelist = []
        self.videolist = []
        #create a list with all the links and titles of youtube videos
        for v in vids:
            tmp = 'https://www.youtube.com' + v['href']
            self.videolist.append(tmp)
            self.titlelist.append(v['title'])

        #currently only the top video will play
        url_0 = self.videolist[0]

        #use pafy to convert into a VLC playable video
        self.video_0 = pafy.new(url_0)

        #chooses whether to get video or audio only
        if self.isAudio:
            self.best = self.video_0.getbestaudio()
        else:
            self.best = self.video_0.getbest()

        #play in VLC
        playurl = self.best.url
        self.media = self.instance.media_new(playurl)
        self.media.get_mrl()
        self.mediaplayer.set_media(self.media)

        if sys.platform.startswith('linux'):  # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":  # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":  # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))

        self.setWindowTitle(self.titlelist[0])
        self.PlayPause()

    def setVolume(self, Volume):
        """Set the volume
        """
        self.mediaplayer.audio_set_volume(Volume)

    def setPosition(self, position):
        """Set the position
        """
        # setting the position to where the slider was dragged
        self.mediaplayer.set_position(position / 1000.0)
        # the vlc MediaPlayer needs a float value between 0 and 1, Qt
        # uses integer variables, so you need a factor; the higher the
        # factor, the more precise are the results
        # (1000 should be enough)

    def downloadFile(self):
        """downloads the file currently playing, .mp4 for video or .webm for audio
        settings can be altered but are left default for now"""
        self.best.download()

    def updateUI(self):
        """updates the user interface"""
        # setting the slider to the desired position
        self.positionslider.setValue(self.mediaplayer.get_position() * 1000)

        if not self.mediaplayer.is_playing():
            # no need to call this function if nothing is played
            self.timer.stop()
            if not self.isPaused:
                # after the video finished, the play button stills shows
                # "Pause", not the desired behavior of a media player
                # this will fix it
                self.Stop()
예제 #14
0
def main():
    MAX_INTENSITY = 255

    app = QApplication([])

    # Create and lay out widgets.

    redLabel = QLabel('Red:')
    redLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
    redLabel.setAutoFillBackground(True)
    p = redLabel.palette()
    p.setColor(redLabel.backgroundRole(), Qt.red)
    redLabel.setPalette(p)

    greenLabel = QLabel('Green:')
    greenLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
    greenLabel.setAutoFillBackground(True)
    p = greenLabel.palette()
    p.setColor(greenLabel.backgroundRole(), Qt.green)
    greenLabel.setPalette(p)

    blueLabel = QLabel('Blue:')
    blueLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
    blueLabel.setAutoFillBackground(True)
    p = blueLabel.palette()
    p.setColor(blueLabel.backgroundRole(), Qt.blue)
    blueLabel.setPalette(p)

    redSlider = QSlider(Qt.Horizontal)
    redSlider.setMinimum(0)
    redSlider.setMaximum(MAX_INTENSITY)

    greenSlider = QSlider(Qt.Horizontal)
    greenSlider.setMinimum(0)
    greenSlider.setMaximum(MAX_INTENSITY)

    blueSlider = QSlider(Qt.Horizontal)
    blueSlider.setMinimum(0)
    blueSlider.setMaximum(MAX_INTENSITY)

    redLineEdit = QLineEdit('0')
    greenLineEdit = QLineEdit('0')
    blueLineEdit = QLineEdit('0')

    controlFrameLayout = QGridLayout()
    controlFrameLayout.setSpacing(0)
    controlFrameLayout.setContentsMargins(0, 0, 0, 0)
    controlFrameLayout.setRowStretch(0, 0)
    controlFrameLayout.setRowStretch(1, 0)
    controlFrameLayout.setRowStretch(2, 0)
    controlFrameLayout.setColumnStretch(0, 0)
    controlFrameLayout.setColumnStretch(1, 1)
    controlFrameLayout.setColumnStretch(2, 0)
    controlFrameLayout.addWidget(redLabel, 0, 0)
    controlFrameLayout.addWidget(greenLabel, 1, 0)
    controlFrameLayout.addWidget(blueLabel, 2, 0)
    controlFrameLayout.addWidget(redSlider, 0, 1)
    controlFrameLayout.addWidget(greenSlider, 1, 1)
    controlFrameLayout.addWidget(blueSlider, 2, 1)
    controlFrameLayout.addWidget(redLineEdit, 0, 2)
    controlFrameLayout.addWidget(greenLineEdit, 1, 2)
    controlFrameLayout.addWidget(blueLineEdit, 2, 2)
    controlFrame = QFrame()
    controlFrame.setLayout(controlFrameLayout)

    colorFrame = QFrame()
    colorFrame.setAutoFillBackground(True)
    p = colorFrame.palette()
    p.setColor(colorFrame.backgroundRole(), Qt.black)
    colorFrame.setPalette(p)

    centralFrameLayout = QGridLayout()
    centralFrameLayout.setSpacing(0)
    centralFrameLayout.setContentsMargins(0, 0, 0, 0)
    centralFrameLayout.setRowStretch(0, 1)
    centralFrameLayout.setRowStretch(1, 0)
    centralFrameLayout.setColumnStretch(0, 1)
    centralFrameLayout.addWidget(colorFrame, 0, 0)
    centralFrameLayout.addWidget(controlFrame, 1, 0)
    centralFrame = QFrame()
    centralFrame.setLayout(centralFrameLayout)

    window = QMainWindow()
    window.setWindowTitle('Color Displayer')
    window.setCentralWidget(centralFrame)
    screenSize = QDesktopWidget().screenGeometry()
    window.resize(screenSize.width() // 2, screenSize.height() // 2)

    # Handle events for the QSlider objects.

    def sliderSlot():
        r = redSlider.value()
        g = greenSlider.value()
        b = blueSlider.value()
        redLineEdit.setText(str(r))
        greenLineEdit.setText(str(g))
        blueLineEdit.setText(str(b))
        p = colorFrame.palette()
        p.setColor(colorFrame.backgroundRole(), QColor(r, g, b))
        colorFrame.setPalette(p)

    redSlider.valueChanged.connect(sliderSlot)
    greenSlider.valueChanged.connect(sliderSlot)
    blueSlider.valueChanged.connect(sliderSlot)

    # Handle events for the LineEdit objects.

    def lineEditSlot():
        try:
            r = int(redLineEdit.text())
            g = int(greenLineEdit.text())
            b = int(blueLineEdit.text())
            if (r < 0) or (r > MAX_INTENSITY): raise Exception()
            if (g < 0) or (g > MAX_INTENSITY): raise Exception()
            if (b < 0) or (b > MAX_INTENSITY): raise Exception()
            redSlider.setValue(r)
            greenSlider.setValue(g)
            blueSlider.setValue(b)
            p = colorFrame.palette()
            p.setColor(colorFrame.backgroundRole(), QColor(r, g, b))
            colorFrame.setPalette(p)
        except:
            # Use the Slider objects to restore the LineEdit objects.
            redLineEdit.setText(str(redSlider.value()))
            greenLineEdit.setText(str(greenSlider.value()))
            blueLineEdit.setText(str(blueSlider.value()))

    redLineEdit.returnPressed.connect(lineEditSlot)
    greenLineEdit.returnPressed.connect(lineEditSlot)
    blueLineEdit.returnPressed.connect(lineEditSlot)

    window.show()
    exit(app.exec_())
예제 #15
0
class FindInFilesWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        _ToolsDock.register_widget(translations.TR_FIND_IN_FILES, self)

    def install_widget(self):
        container = QHBoxLayout(self)
        container.setContentsMargins(3, 0, 3, 0)
        self._actions = FindInFilesActions(self)
        container.addWidget(self._actions)
        self.__count = 0

        top_widget = QFrame()
        top_layout = QVBoxLayout(top_widget)
        top_layout.setContentsMargins(0, 0, 0, 0)
        top_layout.setSpacing(0)
        self._message_frame = QFrame()
        self._message_frame.hide()
        self._message_frame.setAutoFillBackground(True)
        pal = QPalette()
        pal.setColor(QPalette.Window, QColor("#6a6ea9"))
        pal.setColor(QPalette.WindowText, pal.windowText().color())
        self._message_frame.setPalette(pal)
        self._message_label = QLabel("")
        message_layout = QHBoxLayout(self._message_frame)
        message_layout.addStretch(1)
        message_layout.setContentsMargins(2, 2, 2, 2)
        message_layout.addWidget(self._message_label)
        top_layout.addWidget(self._message_frame)

        self._tree_results = SearchResultTreeView(self)
        top_layout.addWidget(self._tree_results)
        container.addWidget(top_widget)

        self._main_container = IDE.get_service("main_container")
        # Search worker
        self._search_worker = FindInFilesWorker()
        search_thread = QThread()
        self._search_worker.moveToThread(search_thread)
        self._search_worker.resultAvailable.connect(self._on_worker_finished)
        search_thread.finished.connect(search_thread.deleteLater)

        self._actions.searchRequested.connect(self._on_search_requested)
        self._tree_results.activated.connect(self._go_to)

    def _clear_results(self):
        self.__count = 0
        self._tree_results.clear()

    def _go_to(self, index):
        result_item = self._tree_results.model().data(index, Qt.UserRole + 1)
        if result_item.lineno != -1:
            parent = result_item.parent
            file_name = parent.file_path
            lineno = result_item.lineno
            # Open the file and jump to line
            self._main_container.open_file(file_name, line=lineno)

    @pyqtSlot('PyQt_PyObject')
    def _on_worker_finished(self, lines):
        self.__count += len(lines[-1])
        self._message_frame.show()
        self._message_label.setText(
            translations.TR_MATCHES_FOUND.format(self.__count))
        self._tree_results.add_result(lines)

    @pyqtSlot('QString', bool, bool, bool)
    def _on_search_requested(self, to_find, cs, regex, wo):
        self._clear_results()
        type_ = QRegExp.FixedString
        if regex:
            type_ = QRegExp.RegExp
        if wo:
            type_ = QRegExp.RegExp
            to_find = "|".join(
                ["\\b" + word.strip() + "\\b" for word in to_find.split()])
        filters = re.split(",", "*.py")
        pattern = QRegExp(to_find, cs, type_)
        self._search_worker.find_in_files(self._actions.current_project_path,
                                          filters,
                                          pattern,
                                          recursive=True)

    def showEvent(self, event):
        self._actions._line_search.setFocus()
        super().showEvent(event)
예제 #16
0
class Player(QWidget):
    """A simple Media Player using VLC and Qt
    """
    def __init__(self, master=None):
        QWidget.__init__(self, master)
        #self.setWindowTitle("Media Player")

        # creating a basic vlc instance
        self.instance = vlc.Instance()
        # creating an empty vlc media player
        self.mediaplayer = self.instance.media_player_new()

        self.createUI()
        self.isPaused = False

    def createUI(self):
        """Set up the user interface, signals & slots
        """
        #self.widget = QWidget(self)
        #self.setCentralWidget(self.widget)

        # In this widget, the video will be drawn
        self.videoframe = QFrame()
        self.palette = self.videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)

        # self.positionslider = QSlider(Qt.Horizontal, self)
        # self.positionslider.setToolTip("Position")
        # self.positionslider.setMaximum(1000)
        # self.positionslider.sliderMoved.connect(self.setPosition)

        # self.hbuttonbox = QHBoxLayout()
        # self.playbutton = QPushButton("Play")
        # self.hbuttonbox.addWidget(self.playbutton)
        # self.playbutton.clicked.connect(self.PlayPause)

        # self.stopbutton = QPushButton("Stop")
        # self.hbuttonbox.addWidget(self.stopbutton)
        # self.stopbutton.clicked.connect(self.Stop)

        # self.hbuttonbox.addStretch(1)
        # self.volumeslider = QSlider(Qt.Horizontal, self)
        # self.volumeslider.setMaximum(100)
        # self.volumeslider.setValue(self.mediaplayer.audio_get_volume())
        # self.volumeslider.setToolTip("Volume")
        # self.hbuttonbox.addWidget(self.volumeslider)
        # self.volumeslider.valueChanged.connect(self.setVolume)

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.addWidget(self.videoframe)
        #self.vboxlayout.addWidget(self.positionslider)
        #self.vboxlayout.addLayout(self.hbuttonbox)

        self.setLayout(self.vboxlayout)

        # open = QAction("&Open", self)
        # open.triggered.connect(self.OpenFile)
        # exit = QAction("&Exit", self)
        # exit.triggered.connect(sys.exit)
        #menubar = self.menuBar()
        #filemenu = menubar.addMenu("&File")
        #filemenu.addAction(open)
        #filemenu.addSeparator()
        #filemenu.addAction(exit)

        self.timer = QTimer(self)
        self.timer.setInterval(200)
        self.timer.timeout.connect(self.updateUI)

    def PlayPause(self):
        """Toggle play/pause status
        """
        if self.mediaplayer.is_playing():
            self.mediaplayer.pause()
            #self.playbutton.setText("Play")
            self.isPaused = True
        else:
            if self.mediaplayer.play() == -1:
                self.OpenFile()
                return
            self.mediaplayer.play()
            #self.playbutton.setText("Pause")
            self.timer.start()
            self.isPaused = False

    def Stop(self):
        """Stop player
        """
        self.mediaplayer.stop()
        #self.playbutton.setText("Play")

    def OpenFile(self, filename=None):
        """Open a media file in a MediaPlayer
        """
        if filename is None:
            filename = QFileDialog.getOpenFileName(self, "Open File",
                                                   os.path.expanduser('~'))[0]
        if not filename:
            return

        # create the media
        if sys.version < '3':
            filename = unicode(filename)
        self.media = self.instance.media_new(filename)
        # put the media in the media player
        self.mediaplayer.set_media(self.media)

        # parse the metadata of the file
        self.media.parse()
        # set the title of the track as window title
        self.setWindowTitle(self.media.get_meta(0))

        # the media player has to be 'connected' to the QFrame
        # (otherwise a video would be displayed in it's own window)
        # this is platform specific!
        # you have to give the id of the QFrame (or similar object) to
        # vlc, different platforms have different functions for this
        if sys.platform.startswith('linux'):  # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":  # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":  # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))
        self.PlayPause()

    def setVolume(self, Volume):
        """Set the volume
        """
        self.mediaplayer.audio_set_volume(Volume)

    def setPosition(self, position):
        """Set the position
        """
        # setting the position to where the slider was dragged
        self.mediaplayer.set_position(position / 1000.0)
        # the vlc MediaPlayer needs a float value between 0 and 1, Qt
        # uses integer variables, so you need a factor; the higher the
        # factor, the more precise are the results
        # (1000 should be enough)

    def updateUI(self):
        """updates the user interface"""
        # setting the slider to the desired position
        #self.positionslider.setValue(self.mediaplayer.get_position() * 1000)

        if not self.mediaplayer.is_playing():
            # no need to call this function if nothing is played
            self.timer.stop()
            if not self.isPaused:
                # after the video finished, the play button stills shows
                # "Pause", not the desired behavior of a media player
                # this will fix it
                self.Stop()
예제 #17
0
    def initUI(self):

      # ======================== WIDGETS ===========================

        framePrincipal = QFrame(self)
        framePrincipal.setFrameShape(QFrame.Box)
        framePrincipal.setFrameShadow(QFrame.Sunken)
        framePrincipal.setAutoFillBackground(True)
        framePrincipal.setBackgroundRole(QPalette.Light)
        framePrincipal.setFixedSize(640,480)
        framePrincipal.move(10, 10)
        frame = QFrame(framePrincipal)
        frame.setFixedSize(2000, 2000)
        frame.move(10, 10)

        self.labelImagen = QLabel(frame)
        self.labelImagen.setAlignment(Qt.AlignCenter)
        self.labelImagen.setGeometry(0, 0, 640, 480)        
        self.labelImagenUno = QLabel(frame)
        self.labelImagenUno.setAlignment(Qt.AlignCenter)
        self.labelImagenUno.setGeometry(-650, 0, 640, 480)

      # =================== BOTONES (QPUSHBUTTON) ==================

        self.buttonCargar = QPushButton("Cargar imagen", self)
        self.buttonCargar.setCursor(Qt.PointingHandCursor)
        self.buttonCargar.setFixedSize(100, 30)
        self.buttonCargar.move(10, 519)
        self.buttonEliminar = QPushButton("Eliminar imagen", self)
        self.buttonEliminar.setCursor(Qt.PointingHandCursor)
        self.buttonEliminar.setFixedSize(100, 30)
        self.buttonEliminar.move(120, 519)
        self.buttonAnterior = QPushButton("<", self)
        self.buttonAnterior.setObjectName("Anterior")
        self.buttonAnterior.setToolTip("Imagen anterior")
        self.buttonAnterior.setCursor(Qt.PointingHandCursor)
        self.buttonAnterior.setFixedSize(30, 30)
        self.buttonAnterior.move(230, 519)        
        self.buttonSiguiente = QPushButton(">", self)
        self.buttonSiguiente.setObjectName("Siguiente")
        self.buttonSiguiente.setToolTip("Imagen siguiente")
        self.buttonSiguiente.setCursor(Qt.PointingHandCursor)
        self.buttonSiguiente.setFixedSize(30, 30)
        self.buttonSiguiente.move(265, 519)

        self.buttonCarpeta1= QPushButton("Carpeta 1", self)
        self.buttonCarpeta1.setObjectName("Carpeta1")
        self.buttonCarpeta1.setToolTip("Guardar en Carpeta 1")
        self.buttonCarpeta1.setCursor(Qt.PointingHandCursor)
        self.buttonCarpeta1.setFixedSize(160,30)
        self.buttonCarpeta1.move(300,519)

        self.buttonCarpeta2= QPushButton("Carpeta 2", self)
        self.buttonCarpeta2.setObjectName("Carpeta2")
        self.buttonCarpeta2.setToolTip("Guardar en Carpeta 2")
        self.buttonCarpeta2.setCursor(Qt.PointingHandCursor)
        self.buttonCarpeta2.setFixedSize(160,30)
        self.buttonCarpeta2.move(465,519)

      # ===================== CONECTAR SEÑALES =====================

        self.buttonCargar.clicked.connect(self.Cargar)
        self.buttonEliminar.clicked.connect(self.Eliminar)
        self.buttonAnterior.clicked.connect(self.anteriorSiguiente)
        self.buttonSiguiente.clicked.connect(self.anteriorSiguiente)
        self.buttonCarpeta1.clicked.connect(self.GuardarCarpeta1)
        self.buttonCarpeta2.clicked.connect(self.GuardarCarpeta2)
    

        # Establecer los valores predeterminados

        self.posicion = int
        self.estadoAnterior, self.estadoSiguiente = False, False
        self.carpetaActual = QDir()
        self.imagenesCarpeta = []
예제 #18
0
class Player(QMainWindow):
    """
    Modification of the simple Media Player using VLC and Qt
    to show the mambo stream

    The window part of this example was modified from the QT example cited below.
    VLC requires windows to create and show the video and this was a cross-platform solution.
    VLC will automatically create the windows in linux but not on the mac.
    Amy McGovern, [email protected]

    Qt example for VLC Python bindings
    https://github.com/devos50/vlc-pyqt5-example
    Copyright (C) 2009-2010 the VideoLAN team

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
    """
    def __init__(self, vlc_player, drone_gui):
        """
        Create a UI window for the VLC player
        :param vlc_player: the VLC player (created outside the function)
        """
        QMainWindow.__init__(self)
        self.setWindowTitle("VLC Tello Video Player")

        # save the media player
        self.mediaplayer = vlc_player

        # need a reference to the main drone vision class
        self.drone_vision = drone_gui

        # create the GUI
        self.createUI()

    def createUI(self):
        """
        Set up the window for the VLC viewer
        """
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)

        # In this widget, the video will be drawn
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.videoframe = QMacCocoaViewContainer(0)
        else:
            self.videoframe = QFrame()
        self.palette = self.videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)

        self.hbuttonbox = QHBoxLayout()
        self.playbutton = QPushButton("Run my program")
        self.hbuttonbox.addWidget(self.playbutton)
        self.playbutton.clicked.connect(
            partial(self.drone_vision.run_user_code, self.playbutton))

        self.landbutton = QPushButton("Land NOW")
        self.hbuttonbox.addWidget(self.landbutton)
        self.landbutton.clicked.connect(self.drone_vision.land)

        self.stopbutton = QPushButton("Quit")
        self.hbuttonbox.addWidget(self.stopbutton)
        self.stopbutton.clicked.connect(self.drone_vision.close_exit)

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.addWidget(self.videoframe)
        self.vboxlayout.addLayout(self.hbuttonbox)

        self.widget.setLayout(self.vboxlayout)

        # the media player has to be 'connected' to the QFrame
        # (otherwise a video would be displayed in it's own window)
        # this is platform specific!
        # you have to give the id of the QFrame (or similar object) to
        # vlc, different platforms have different functions for this
        if sys.platform.startswith('linux'):  # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":  # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":  # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))
예제 #19
0
파일: game.py 프로젝트: trawl/gamelog
class GameRoundsDetail(QGroupBox):

    edited = QtCore.pyqtSignal()

    def __init__(self, engine, parent=None):
        super(GameRoundsDetail, self).__init__(parent)
        self.engine = engine
        self.initUI()

    def initUI(self):
        self.setStyleSheet("QGroupBox { font-size: 18px; font-weight: bold; }")
        self.widgetLayout = QVBoxLayout(self)
#        self.container = QToolBox(self)
        self.container = QTabWidget(self)
        self.widgetLayout.addWidget(self.container)

        self.tableContainer = QFrame(self)
        self.tableContainerLayout = QVBoxLayout(self.tableContainer)
        self.tableContainer.setAutoFillBackground(True)
        self.container.addTab(self.tableContainer, '')

        self.table = self.createRoundTable(self.engine, self)
        self.tableContainerLayout.addWidget(self.table, stretch=1)
        self.table.edited.connect(self.updateRound)
        self.table.edited.connect(self.edited.emit)

        self.plot = self.createRoundPlot(self.engine, self)
        self.plot.setAutoFillBackground(True)
#        self.container.addItem(self.plot,'')
        self.container.addTab(self.plot, '')

        self.statsFrame = QWidget(self)
        self.statsFrame.setAutoFillBackground(True)
        self.container.addTab(self.statsFrame, '')

        self.statsLayout = QVBoxLayout(self.statsFrame)
        self.gamestats = self.createQSBox(self.statsFrame)
        self.statsLayout.addWidget(self.gamestats)

    def retranslateUI(self):
        # self.setTitle(i18n("GameRoundsDetail",'Details'))
        self.container.setTabText(
            0, i18n("GameRoundsDetail", "Table"))
        self.container.setTabText(
            1, i18n("GameRoundsDetail", "Plot"))
        self.container.setTabText(2, i18n(
            "GameRoundsDetail", "Statistics"))
#        self.container.setItemText(0,i18n(
        #       "CarcassonneEntriesDetail","Table"))
#        self.container.setItemText(1,i18n(
        #       "CarcassonneEntriesDetail","Plot"))
#        self.container.setItemText(2,i18n(
        #       "CarcassonneEntriesDetail","Statistics"))
        self.gamestats.retranslateUI()
        self.plot.retranslateUI()
        self.updateRound()

    def updatePlot(self):
        self.plot.updatePlot()

    def updateRound(self):
        self.table.resetClear()
        for r in self.engine.getRounds():
            self.table.insertRound(r)
        self.updatePlot()

    def updateStats(self):
        try:
            self.gamestats.update(self.engine.getGame(),
                                  self.engine.getListPlayers())
        except Exception:
            self.gamestats.update()

    def deleteRound(self, nround):
        self.plot.updatePlot()

    # Implement in subclasses if necessary
    def createRoundTable(
        self, engine, parent=None): return GameRoundTable(self)

    def createRoundPlot(self, engine, parent=None): return GameRoundPlot(self)

    def createQSBox(self, parent=None): return QuickStatsTW(
        self.engine.getGame(), self.engine.getListPlayers(), self)

    def updatePlayerOrder(self):
        self.updateRound()
예제 #20
0
    def initUI(self):

        fuenteSiacle = self.font()
        fuenteSiacle.setBold(True)
        fuenteSiacle.setPointSize(12)

        paletaBotones = self.palette()
        paletaBotones.setColor(QPalette.Background, QColor("#2EFEC8"))

        frameBotones = QFrame()
        frameBotones.setFrameStyle(QFrame.NoFrame)
        frameBotones.setAutoFillBackground(True)
        frameBotones.setPalette(paletaBotones)
        frameBotones.setFixedWidth(220)

        paletaPanel = self.palette()
        paletaPanel.setBrush(QPalette.Background, QBrush(QColor(255, 90, 0), Qt.SolidPattern))
        paletaPanel.setColor(QPalette.Foreground, Qt.white)

        labelSiacle = QLabel("ПАНЕЛЬ УПРАВЛЕНИЯ", frameBotones)
        labelSiacle.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        labelSiacle.setFont(fuenteSiacle)
        labelSiacle.setAutoFillBackground(True)
        labelSiacle.setPalette(paletaPanel)
        labelSiacle.setFixedSize(220, 46)
        labelSiacle.move(0, 0)

        # ============================================================

        tamanioIcono = QSize(30, 30)

        botonNuevo = Boton(frameBotones)
        botonNuevo.setText(" Новый")
        botonNuevo.setToolTip("Новый клиент")
        botonNuevo.setCursor(Qt.PointingHandCursor)
        botonNuevo.move(-2, 45)

        botonActualizar = Boton(frameBotones)
        botonActualizar.setText(" Обновление")
        botonActualizar.setToolTip("Обновление клиента ")
        botonActualizar.setCursor(Qt.PointingHandCursor)
        botonActualizar.move(-2, 82)

        botonEliminar = Boton(frameBotones)
        botonEliminar.setText(" Удалить")
        botonEliminar.setToolTip("Удалить клиента")
        botonEliminar.setCursor(Qt.PointingHandCursor)
        botonEliminar.move(-2, 119)

        botonLimpiar = Boton(frameBotones)
        botonLimpiar.setText(" Закрыть")
        botonLimpiar.setToolTip("Закрыть бд")
        botonLimpiar.setCursor(Qt.PointingHandCursor)
        botonLimpiar.move(-2, 156)

        # ============================================================

        paletaSuscribete = self.palette()
        paletaSuscribete.setBrush(QPalette.Background, QBrush(QColor(135, 206, 250),
                                                              Qt.SolidPattern))

        fuenteSuscribete = self.font()
        fuenteSuscribete.setBold(True)
        fuenteSuscribete.setFamily("Arial")
        fuenteSuscribete.setPointSize(11)

        labelSuscribete = QLabel("<a href='https://t.me/yarosla_0v'>АВТОР</a>", frameBotones)

        labelSuscribete.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        labelSuscribete.setOpenExternalLinks(True)
        labelSuscribete.setFont(fuenteSuscribete)
        labelSuscribete.setAutoFillBackground(True)
        labelSuscribete.setPalette(paletaSuscribete)
        labelSuscribete.setFixedSize(220, 46)
        labelSuscribete.move(0, 210)

        paletaFrame = self.palette()
        paletaFrame.setColor(QPalette.Background, QColor("blue"))

        frameBienvenido = QFrame()
        frameBienvenido.setFrameStyle(QFrame.NoFrame)
        frameBienvenido.setAutoFillBackground(True)
        frameBienvenido.setPalette(paletaFrame)
        frameBienvenido.setFixedHeight(46)

        # ============================================================

        paletaTitulo = self.palette()
        paletaTitulo.setColor(QPalette.Foreground, Qt.yellow)

        labelBienvenido = QLabel("Клиенты")
        labelBienvenido.setAlignment(Qt.AlignCenter)
        labelBienvenido.setFont(fuenteSiacle)
        labelBienvenido.setPalette(paletaTitulo)

        botonConfiguracion = QPushButton()
        botonConfiguracion.setIcon(QIcon("Imagenes/configuracion.png"))
        botonConfiguracion.setIconSize(QSize(24, 24))
        botonConfiguracion.setToolTip("Конфигурация")
        botonConfiguracion.setCursor(Qt.PointingHandCursor)
        botonConfiguracion.setFixedWidth(36)

        disenioFrame = QHBoxLayout()
        disenioFrame.addWidget(labelBienvenido, Qt.AlignCenter)
        disenioFrame.addStretch()
        disenioFrame.addWidget(botonConfiguracion)
        disenioFrame.setContentsMargins(0, 0, 5, 0)
        frameBienvenido.setLayout(disenioFrame)

        # ============================================================

        self.buscarLineEdit = QLineEdit()
        self.buscarLineEdit.setObjectName("Enter")
        self.buscarLineEdit.setPlaceholderText("Имя клента")
        self.buscarLineEdit.setMinimumSize(200, 26)

        botonBuscar = QPushButton("Поиск")
        botonBuscar.setObjectName("Поиск")
        botonBuscar.setCursor(Qt.PointingHandCursor)
        botonBuscar.setMinimumSize(60, 26)

        separadorTodos = QFrame()
        separadorTodos.setFrameShape(QFrame.VLine)
        separadorTodos.setFrameShadow(QFrame.Raised)
        separadorTodos.setFixedSize(1, 26)

        botonTodos = QPushButton("Все записи")
        botonTodos.setObjectName("Все записи")
        botonTodos.setCursor(Qt.PointingHandCursor)
        botonTodos.setMinimumSize(60, 26)

        nombreColumnas = ("Id", "Имя", "Фамилия", "Пол", "Дата рождения", "Страна",
                          "Телефон")

        menuMostrarOcultar = QMenu()
        for indice, columna in enumerate(nombreColumnas, start=0):
            accion = QAction(columna, menuMostrarOcultar)
            accion.setCheckable(True)
            accion.setChecked(True)
            accion.setData(indice)

            menuMostrarOcultar.addAction(accion)

        botonMostrarOcultar = QPushButton("Скрыть столбцы")
        botonMostrarOcultar.setCursor(Qt.PointingHandCursor)
        botonMostrarOcultar.setMenu(menuMostrarOcultar)
        botonMostrarOcultar.setMinimumSize(180, 26)

        disenioBuscar = QHBoxLayout()
        disenioBuscar.setSpacing(10)
        disenioBuscar.addWidget(self.buscarLineEdit)
        disenioBuscar.addWidget(botonBuscar)
        disenioBuscar.addWidget(separadorTodos)
        disenioBuscar.addWidget(botonTodos)
        disenioBuscar.addWidget(botonMostrarOcultar)

        self.tabla = QTableWidget()

        self.tabla.setEditTriggers(QAbstractItemView.NoEditTriggers)

        self.tabla.setDragDropOverwriteMode(False)

        self.tabla.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.tabla.setSelectionMode(QAbstractItemView.SingleSelection)

        self.tabla.setTextElideMode(Qt.ElideRight)  # Qt.ElideNone

        self.tabla.setWordWrap(False)

        self.tabla.setSortingEnabled(False)

        self.tabla.setColumnCount(7)

        self.tabla.setRowCount(0)

        self.tabla.horizontalHeader().setDefaultAlignment(Qt.AlignHCenter | Qt.AlignVCenter |
                                                          Qt.AlignCenter)

        self.tabla.horizontalHeader().setHighlightSections(False)

        self.tabla.horizontalHeader().setStretchLastSection(True)

        self.tabla.verticalHeader().setVisible(False)

        self.tabla.setAlternatingRowColors(True)

        self.tabla.verticalHeader().setDefaultSectionSize(20)

        # self.tabla.verticalHeader().setHighlightSections(True)

        self.tabla.setHorizontalHeaderLabels(nombreColumnas)

        self.tabla.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tabla.customContextMenuRequested.connect(self.menuContextual)

        for indice, ancho in enumerate((80, 240, 240, 140, 150, 130), start=0):
            self.tabla.setColumnWidth(indice, ancho)

        # ============================================================

        disenioBuscarTabla = QVBoxLayout()
        disenioBuscarTabla.addLayout(disenioBuscar)
        disenioBuscarTabla.addWidget(self.tabla)
        disenioBuscarTabla.setSpacing(8)
        disenioBuscarTabla.setContentsMargins(10, 10, 10, 0)

        disenioDerecho = QVBoxLayout()
        disenioDerecho.addWidget(frameBienvenido)
        disenioDerecho.addLayout(disenioBuscarTabla)
        disenioDerecho.setContentsMargins(0, 0, 0, 0)

        disenioFinal = QGridLayout()
        disenioFinal.addWidget(frameBotones, 0, 0)
        disenioFinal.addLayout(disenioDerecho, 0, 1)
        disenioFinal.setSpacing(0)
        disenioFinal.setContentsMargins(0, 0, 0, 0)

        self.setLayout(disenioFinal)

        self.copiarInformacion = QApplication.clipboard()

        botonNuevo.clicked.connect(self.Nuevo)
        botonActualizar.clicked.connect(self.Actualizar)
        botonEliminar.clicked.connect(self.Eliminar)
        botonLimpiar.clicked.connect(self.limpiarTabla)

        self.buscarLineEdit.returnPressed.connect(self.Buscar)
        botonBuscar.clicked.connect(self.Buscar)
        botonTodos.clicked.connect(self.Buscar)

        botonConfiguracion.clicked.connect(lambda: Configuracion(self).exec_())

        self.tabla.itemDoubleClicked.connect(self.Suscribete)

        menuMostrarOcultar.triggered.connect(self.mostrarOcultar)
예제 #21
0
class Player(QMainWindow):
    """
    Modification of the simple Media Player using VLC and Qt
    to show the mambo stream

    The window part of this example was modified from the QT example cited below.
    VLC requires windows to create and show the video and this was a cross-platform solution.
    VLC will automatically create the windows in linux but not on the mac.
    Amy McGovern, [email protected]

    Qt example for VLC Python bindings
    https://github.com/devos50/vlc-pyqt5-example
    Copyright (C) 2009-2010 the VideoLAN team

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
    """
    def __init__(self, vlc_player, drone_gui, move, process):
        """
        Create a UI window for the VLC player
        :param vlc_player: the VLC player (created outside the function)
        """
        self.process = process
        QMainWindow.__init__(self)
        self.move = move
        self.setWindowTitle("VLC Drone Video Player")

        # save the media player
        self.mediaplayer = vlc_player

        # need a reference to the main drone vision class
        self.drone_vision = drone_gui

        # create the GUI
        self.createUI()

    def set_values(self, yaw, pitch):
        pass
        # self.yaw_bar.setValue(yaw)
        # self.pitch_bar.setValue(pitch)

    # here the GUI and all it's buttons are created
    def createUI(self):
        """
        Set up the window for the VLC viewer
        """
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)

        # In this widget, the video will be drawn
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.videoframe = QMacCocoaViewContainer(0)
        else:
            self.videoframe = QFrame()
        self.palette = self.videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)

        self.hbuttonbox = QHBoxLayout()
        self.raise_lower_box = QHBoxLayout()
        self.forward_box = QHBoxLayout()
        self.left_right_box = QHBoxLayout()
        self.backward_box = QHBoxLayout()
        self.toggle_box = QHBoxLayout()

        self.playbutton = QPushButton("Start")
        self.hbuttonbox.addWidget(self.playbutton)
        self.playbutton.clicked.connect(partial(self.move.restart))

        self.landbutton = QPushButton("Land NOW")
        self.hbuttonbox.addWidget(self.landbutton)
        self.landbutton.clicked.connect(self.drone_vision.land)

        self.landsafebutton = QPushButton("Land safe")
        self.hbuttonbox.addWidget(self.landsafebutton)
        self.landsafebutton.clicked.connect(self.move.kill)

        self.stopbutton = QPushButton("Quit")
        self.hbuttonbox.addWidget(self.stopbutton)
        self.stopbutton.clicked.connect(self.drone_vision.close_exit)

        self.raise_button = QPushButton("Raise Drone")
        self.raise_lower_box.addWidget(self.raise_button)
        self.raise_button.clicked.connect(self.move.raise_drone)

        self.lower_button = QPushButton("Lower Drone")
        self.raise_lower_box.addWidget(self.lower_button)
        self.lower_button.clicked.connect(self.move.lower_drone)

        self.forward_button = QPushButton("^")
        self.forward_box.addWidget(self.forward_button)
        self.forward_button.clicked.connect(self.move.drone_forward)

        self.left_button = QPushButton("<")
        self.hover_button = QPushButton("o")
        self.right_button = QPushButton(">")

        self.left_right_box.addWidget(self.left_button)
        self.left_right_box.addWidget(self.hover_button)
        self.left_right_box.addWidget(self.right_button)

        self.left_button.clicked.connect(self.move.drone_left)
        self.hover_button.clicked.connect(self.move.drone_hover)
        self.right_button.clicked.connect(self.move.drone_right)

        self.backward_button = QPushButton("v")
        self.backward_box.addWidget(self.backward_button)
        self.backward_button.clicked.connect(self.move.drone_right)

        self.rotation_button = QPushButton("Rotation Track")
        self.toggle_box.addWidget(self.rotation_button)
        self.rotation_button.clicked.connect(self.move.rotate_true)

        self.fixed_button = QPushButton("Fixed Track")
        self.toggle_box.addWidget(self.fixed_button)
        self.fixed_button.clicked.connect(self.move.rotate_false)

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.addWidget(self.videoframe)
        self.vboxlayout.addLayout(self.hbuttonbox)
        self.vboxlayout.addLayout(self.raise_lower_box)
        self.vboxlayout.addLayout(self.forward_box)
        self.vboxlayout.addLayout(self.left_right_box)
        self.vboxlayout.addLayout(self.backward_box)
        self.vboxlayout.addLayout(self.toggle_box)

        # determined how far away from the tracked object the drone should be
        sld = QSlider(Qt.Horizontal, self)
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setGeometry(30, 40, 100, 30)
        sld.setValue(60)
        sld.valueChanged[int].connect(self.change_box_size_max)

        sld1 = QSlider(Qt.Horizontal, self)
        sld1.setFocusPolicy(Qt.NoFocus)
        sld1.setGeometry(30, 40, 100, 30)
        sld1.setValue(40)
        sld1.valueChanged[int].connect(self.change_box_size_min)
        sld1.move(30, 60)

        # shows how much the drone 'wants' to rotate to the left/right
        # (this corresponds to where on the x-axis the tracked object is)
        # self.yaw_bar = QProgressBar(self)
        # self.yaw_bar.setGeometry(30, 40, 200, 25)
        # self.yaw_bar.move(0, 100)
        #
        # # shows how much the drone 'wants' to go forwards/backwards
        # # (corresponds to how far away the tracked object is)
        # self.pitch_bar = QProgressBar(self)
        # self.pitch_bar.setGeometry(30, 40, 200, 25)
        # self.pitch_bar.move(0, 200)
        # self.pitch_bar.setValue(60)

        self.label = QLabel(self)

        self.setGeometry(300, 300, 280, 170)
        self.setWindowTitle('QSlider')
        self.show()

        self.widget.setLayout(self.vboxlayout)

        # the media player has to be 'connected' to the QFrame
        # (otherwise a video would be displayed in it's own window)
        # this is platform specific!
        # you have to give the id of the QFrame (or similar object) to
        # vlc, different platforms have different functions for this
        if sys.platform.startswith('linux'):  # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32":  # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin":  # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))

    def change_box_size_max(self, value):
        # convert the slider input to 0 to 1 and feed it to the movement function
        self.process.set_max_box_size(value / (100))

    def change_box_size_min(self, value):
        # convert the slider input to 0 to 1 and feed it to the movement function
        self.process.set_min_box_size(value / (100))
예제 #22
0
class Player(QMainWindow):
    """A simple Media Player using VLC and Qt
    """
    def __init__(self, master=None):
        QMainWindow.__init__(self, master)
        self.setWindowTitle("Media Player")

        # creating a basic vlc instance
        self.instance = vlc.Instance()
        # creating an empty vlc media player
        self.mediaplayer = self.instance.media_player_new()

        self.createUI()
        self.isPaused = False

    def createUI(self):
        """Set up the user interface, signals & slots
        """
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)

        # In this widget, the video will be drawn
        if sys.platform == "darwin": # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer	
            self.videoframe = QMacCocoaViewContainer(0)
        else:
            self.videoframe = QFrame()
        self.palette = self.videoframe.palette()
        self.palette.setColor (QPalette.Window,
                               QColor(0,0,0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)

        self.positionslider = QSlider(Qt.Horizontal, self)
        self.positionslider.setToolTip("Position")
        self.positionslider.setMaximum(1000)
        self.positionslider.sliderMoved.connect(self.setPosition)

        self.hbuttonbox = QHBoxLayout()
        self.playbutton = QPushButton("Play")
        self.hbuttonbox.addWidget(self.playbutton)
        self.playbutton.clicked.connect(self.PlayPause)

        self.stopbutton = QPushButton("Stop")
        self.hbuttonbox.addWidget(self.stopbutton)
        self.stopbutton.clicked.connect(self.Stop)

        self.hbuttonbox.addStretch(1)
        self.volumeslider = QSlider(Qt.Horizontal, self)
        self.volumeslider.setMaximum(100)
        self.volumeslider.setValue(self.mediaplayer.audio_get_volume())
        self.volumeslider.setToolTip("Volume")
        self.hbuttonbox.addWidget(self.volumeslider)
        self.volumeslider.valueChanged.connect(self.setVolume)

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.addWidget(self.videoframe)
        self.vboxlayout.addWidget(self.positionslider)
        self.vboxlayout.addLayout(self.hbuttonbox)

        self.widget.setLayout(self.vboxlayout)

        open = QAction("&Open", self)
        open.triggered.connect(self.OpenFile)
        exit = QAction("&Exit", self)
        exit.triggered.connect(sys.exit)
        menubar = self.menuBar()
        filemenu = menubar.addMenu("&File")
        filemenu.addAction(open)
        filemenu.addSeparator()
        filemenu.addAction(exit)

        self.timer = QTimer(self)
        self.timer.setInterval(200)
        self.timer.timeout.connect(self.updateUI)

    def PlayPause(self):
        """Toggle play/pause status
        """
        if self.mediaplayer.is_playing():
            self.mediaplayer.pause()
            self.playbutton.setText("Play")
            self.isPaused = True
        else:
            if self.mediaplayer.play() == -1:
                self.OpenFile()
                return
            self.mediaplayer.play()
            self.playbutton.setText("Pause")
            self.timer.start()
            self.isPaused = False

    def Stop(self):
        """Stop player
        """
        self.mediaplayer.stop()
        self.playbutton.setText("Play")

    def OpenFile(self, filename=None):
        """Open a media file in a MediaPlayer
        """
        if filename is None:
            filename = QFileDialog.getOpenFileName(self, "Open File", os.path.expanduser('~'))[0]
        if not filename:
            return

        # create the media
        if sys.version < '3':
            filename = unicode(filename)
        self.media = self.instance.media_new(filename)
        # put the media in the media player
        self.mediaplayer.set_media(self.media)

        # parse the metadata of the file
        self.media.parse()
        # set the title of the track as window title
        self.setWindowTitle(self.media.get_meta(0))

        # the media player has to be 'connected' to the QFrame
        # (otherwise a video would be displayed in it's own window)
        # this is platform specific!
        # you have to give the id of the QFrame (or similar object) to
        # vlc, different platforms have different functions for this
        if sys.platform.startswith('linux'): # for Linux using the X Server
            self.mediaplayer.set_xwindow(self.videoframe.winId())
        elif sys.platform == "win32": # for Windows
            self.mediaplayer.set_hwnd(self.videoframe.winId())
        elif sys.platform == "darwin": # for MacOS
            self.mediaplayer.set_nsobject(int(self.videoframe.winId()))
        self.PlayPause()

    def setVolume(self, Volume):
        """Set the volume
        """
        self.mediaplayer.audio_set_volume(Volume)

    def setPosition(self, position):
        """Set the position
        """
        # setting the position to where the slider was dragged
        self.mediaplayer.set_position(position / 1000.0)
        # the vlc MediaPlayer needs a float value between 0 and 1, Qt
        # uses integer variables, so you need a factor; the higher the
        # factor, the more precise are the results
        # (1000 should be enough)

    def updateUI(self):
        """updates the user interface"""
        # setting the slider to the desired position
        self.positionslider.setValue(self.mediaplayer.get_position() * 1000)

        if not self.mediaplayer.is_playing():
            # no need to call this function if nothing is played
            self.timer.stop()
            if not self.isPaused:
                # after the video finished, the play button stills shows
                # "Pause", not the desired behavior of a media player
                # this will fix it
                self.Stop()
예제 #23
0
    def initui(self):

        palette = QPalette()
        palette.setColor(QPalette.Background, QColor(100, 100, 100))

        # ************ Header ************
        # ------------ Frame ----------
        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(palette)
        frame.setFixedWidth(800)
        frame.setFixedHeight(84)
        frame.move(0, 0)

        # ------------ Icon ----------

        label_icon = QLabel(frame)
        label_icon.setFixedWidth(40)
        label_icon.setFixedHeight(40)
        label_icon.setPixmap(
            QPixmap("./images/LoginIcon.png").scaled(40, 40,
                                                     Qt.KeepAspectRatio,
                                                     Qt.SmoothTransformation))
        label_icon.move(57, 22)

        # ------------ Tittle ----------

        tittle_font = QFont()
        tittle_font.setPixelSize(16)
        tittle_font.setBold(True)

        tittle_label = QLabel("<font color='white'> Ariadna </rfont>", frame)
        tittle_label.setFont(tittle_font)
        tittle_label.move(103, 20)

        # ------------ Sub Tittle ----------

        sub_tittle_font = QFont()
        sub_tittle_font.setPointSize(9)

        sub_tittle_label = QLabel(
            "<font color='white'> Labyrinth Solver </font>", frame)
        sub_tittle_label.setFont(sub_tittle_font)
        sub_tittle_label.move(111, 46)

        # ************ Body ************

        # ------------ Labyrinth Frame ----------
        labyrinth_frame = QFrame(self)
        labyrinth_frame.setFrameShape(QFrame.NoFrame)
        labyrinth_frame.setFrameShadow(QFrame.Sunken)
        labyrinth_frame.setAutoFillBackground(False)
        labyrinth_frame.setPalette(palette)
        labyrinth_frame.setFixedWidth(800)
        labyrinth_frame.setFixedHeight(500)
        labyrinth_frame.move(0, 150)

        # ------------ Labyrinth ----------

        self.labyrinth_label = QLabel("", labyrinth_frame)
        self.labyrinth_label.setPixmap(QPixmap("./images/AriadnaFile.jpg"))
        self.labyrinth_label.setFixedWidth(420)
        self.labyrinth_label.setFixedHeight(280)
        self.labyrinth_label.setScaledContents(True)
        self.labyrinth_label.move(200, 100)

        # ---------- Buttons ----------

        load_labyrinth_button = QPushButton("Cargar Laberinto", self)
        load_labyrinth_button.setFixedWidth(175)
        load_labyrinth_button.setFixedHeight(28)
        load_labyrinth_button.move(60, 90)

        solve_labyrinth_button = QPushButton("Solucionar Laberinto", self)
        solve_labyrinth_button.setFixedWidth(175)
        solve_labyrinth_button.setFixedHeight(28)
        solve_labyrinth_button.move(315, 90)

        save_labyrinth_button = QPushButton("Guardar Laberinto", self)
        save_labyrinth_button.setFixedWidth(175)
        save_labyrinth_button.setFixedHeight(28)
        save_labyrinth_button.move(565, 90)

        back_main_menu_button = QPushButton("Menu Principal", self)
        back_main_menu_button.setFixedWidth(175)
        back_main_menu_button.setFixedHeight(28)
        back_main_menu_button.move(320, 680)

        # ---------- Button's Events ----------

        load_labyrinth_button.clicked.connect(self.load_labyrinth)
        solve_labyrinth_button.clicked.connect(self.solve_labyrinth)
        save_labyrinth_button.clicked.connect(self.save_labyrinth)
        back_main_menu_button.clicked.connect(self.back_main_menu)
예제 #24
0
    def __init__(self, parent=None):
        super(Main_MUESTRA, self).__init__(parent)
        self.setWindowTitle("EXADATA")
        self.setFixedSize(900, 600)
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")

        # FRAME
        paleta = QPalette()
        paleta.setColor(QPalette.Background, QColor(51, 0, 102))

        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(paleta)
        frame.setFixedWidth(950)
        frame.setFixedHeight(100)
        frame.move(0, 0)

        labelIcono = QLabel(frame)
        labelIcono.setFixedWidth(65)
        labelIcono.setFixedHeight(65)
        labelIcono.setPixmap(QPixmap("icono.jpg").scaled(65, 65, Qt.KeepAspectRatio,
                                                         Qt.SmoothTransformation))
        labelIcono.move(10, 28)

        fuenteTitulo = QFont()
        fuenteTitulo.setPointSize(25)
        fuenteTitulo.setBold(True)

        labelTitulo = QLabel("<font color='white'>EXADATA</font>", frame)
        labelTitulo.setFont(fuenteTitulo)
        labelTitulo.move(85, 30)

        fuenteSubtitulo = QFont()
        fuenteSubtitulo.setPointSize(13)

        labelSubtitulo = QLabel("<font color='white'>Análisis de Tweets "
                                , frame)
        labelSubtitulo.setFont(fuenteSubtitulo)
        labelSubtitulo.move(85, 68)

        # BARRA
        self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
        self.progressBar.setGeometry(QtCore.QRect(10, 480, 510, 23))
        self.progressBar.setProperty("value", 24)
        self.progressBar.setTextVisible(False)
        self.progressBar.setObjectName("progressBar")

        #inicio tabla
        self.tabla = QtWidgets.QTableWidget(self.centralwidget)
        # formato tabla posx,posy,tamx,tamy
        self.tabla.setGeometry(QtCore.QRect(10, 120, 510, 400))
        self.tabla.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.tabla.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.tabla.setColumnCount(4)
        self.tabla.setObjectName("tabla")
        self.tabla.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        self.tabla.setHorizontalHeaderItem(3, item)
        self.tabla.horizontalHeader().setDefaultSectionSize(120)
        self.tabla.horizontalHeader().setStretchLastSection(True)
        self.tabla.verticalHeader().setStretchLastSection(False)
        self.tabla.cellClicked.connect(self.ConsultarFecha)
        #fin tabla

        # BOTONES
        # boton exportar_bd
        self.bt_exportar_bd = QtWidgets.QPushButton(self.centralwidget)
        self.bt_exportar_bd.setGeometry(QtCore.QRect(550, 400, 100, 20))
        self.bt_exportar_bd.setObjectName("bt_exportar_bd")
        self.bt_exportar_bd.clicked.connect(self.Exportar_Fecha)

        # boton exportar_bd2
        self.bt_exportar_bd2 = QtWidgets.QPushButton(self.centralwidget)
        self.bt_exportar_bd2.setGeometry(QtCore.QRect(635, 460, 100, 20))
        self.bt_exportar_bd2.setObjectName("bt_exportar_bd2")
        self.bt_exportar_bd2.clicked.connect(self.Exportar_Cantidad)

        # CUADRO TEXTO
        self.muestra_cantidad = QtWidgets.QLineEdit(self.centralwidget)
        self.muestra_cantidad.setGeometry(QtCore.QRect(550, 460, 50, 20))
        self.muestra_cantidad.setObjectName("muestra_cantidad")

        #=================================================================================
        self.setCentralWidget(self.centralwidget)

        #CALENDARIO
        # formato tabla posx,posy,tamx,tamy
        self.calendario = QtWidgets.QCalendarWidget(self.centralwidget)
        self.calendario.setGeometry(QtCore.QRect(550, 120, 312, 183))
        self.calendario.setStyleSheet("")
        self.calendario.setStyleSheet("alternate-background-color: rgb(118, 148, 255);")
        self.calendario.setObjectName("calendario")

        #LABEL MUESTRA POR FECHA
        self.label_muestraFecha = QtWidgets.QLabel(self.centralwidget)
        self.label_muestraFecha.setGeometry(QtCore.QRect(550, 330, 121, 16))
        self.label_muestraFecha.setObjectName("label_muestraFecha")

        #LABEL MUESTRA DE TODA LA BASE
        self.label_muestraToda = QtWidgets.QLabel(self.centralwidget)
        self.label_muestraToda.setGeometry(QtCore.QRect(550, 440, 200, 16))
        self.label_muestraToda.setObjectName("label_muestraToda")

        self.fechaInicio = QtWidgets.QDateEdit(self.centralwidget)
        self.fechaInicio.setGeometry(QtCore.QRect(550, 370, 110, 22))
        self.fechaInicio.setObjectName("fechaInicio")
        self.fechaInicio.setCalendarPopup(True)
        self.fechaTermino = QtWidgets.QDateEdit(self.centralwidget)
        self.fechaTermino.setGeometry(QtCore.QRect(720, 370, 110, 22))
        self.fechaTermino.setObjectName("fechaTermino")
        self.fechaTermino.setCalendarPopup(True)
        self.fechaInicio.setDate(QtCore.QDate.currentDate())
        self.fechaTermino.setDate(QtCore.QDate.currentDate())

        self.incioLetra = QtWidgets.QLabel(self.centralwidget)
        self.incioLetra.setGeometry(QtCore.QRect(550, 350, 111, 16))
        self.incioLetra.setObjectName("incioLetra")
        self.terminoLetra = QtWidgets.QLabel(self.centralwidget)
        self.terminoLetra.setGeometry(QtCore.QRect(720, 350, 111, 16))
        self.terminoLetra.setObjectName("terminoLetra")

        #BARRA MENU
        self.menubar = QtWidgets.QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 21))
        self.menubar.setObjectName("menubar")

        self.Programas = QtWidgets.QMenu(self.menubar)
        self.BaseDeDatos = QtWidgets.QAction(self)
        self.menubar.addAction(self.Programas.menuAction())
        self.Programas.addAction(self.BaseDeDatos)
        self.BaseDeDatos.triggered.connect(self.close)

        self.Ayuda = QtWidgets.QMenu(self.menubar)
        self.SobreQue = QtWidgets.QAction(self)
        self.menubar.addAction(self.Ayuda.menuAction())
        self.Ayuda.addAction(self.SobreQue)
        self.SobreQue.triggered.connect(self.AYUDA)

        # boton recarga_bd
        self.bt_recarga_bd = QtWidgets.QPushButton(self.centralwidget)
        self.bt_recarga_bd.setGeometry(QtCore.QRect(10, 530, 510, 20))
        self.bt_recarga_bd.setObjectName("bt_recarga_bd")
        self.bt_recarga_bd.clicked.connect(self.CargarTabla)

        self.retranslateUi(self)
        QtCore.QMetaObject.connectSlotsByName(self)

        #new table
        self.tabla_master()
        self.CargarTabla()
        self.progressBar.hide()
예제 #25
0
    def initui(self):

        palette = QPalette()
        palette.setColor(QPalette.Background, QColor(100, 100, 100))

        # ************ Header ************
        # ------------ Frame ----------
        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(palette)
        frame.setFixedWidth(500)
        frame.setFixedHeight(84)
        frame.move(0, 0)

        # ------------ Icon ----------

        label_icon = QLabel(frame)
        label_icon.setFixedWidth(40)
        label_icon.setFixedHeight(40)
        label_icon.setPixmap(
            QPixmap("./images/LoginIcon.png").scaled(40, 40,
                                                     Qt.KeepAspectRatio,
                                                     Qt.SmoothTransformation))
        label_icon.move(57, 22)

        # ------------ Tittle ----------

        tittle_font = QFont()
        tittle_font.setPixelSize(16)
        tittle_font.setBold(True)

        tittle_label = QLabel("<font color='white'> Ariadna Sign In </rfont>",
                              frame)
        tittle_label.setFont(tittle_font)
        tittle_label.move(103, 20)

        # ------------ Sub Tittle ----------

        sub_tittle_font = QFont()
        sub_tittle_font.setPointSize(9)

        sub_tittle_label = QLabel(
            "<font color='white'> Labyrinth Solver </font>", frame)
        sub_tittle_label.setFont(sub_tittle_font)
        sub_tittle_label.move(111, 46)

        # ************ Login ************

        # ---------- User ----------

        user_label = QLabel('Usuario', self)
        user_label.move(90, 110)

        user_frame = QFrame(self)
        user_frame.setFrameShape(QFrame.StyledPanel)
        user_frame.setFixedWidth(338)
        user_frame.setFixedHeight(28)
        user_frame.move(90, 136)

        user_icon = QLabel(user_frame)
        user_icon.setPixmap(
            QPixmap("./images/UserIcon.png").scaled(20, 20, Qt.KeepAspectRatio,
                                                    Qt.SmoothTransformation))
        user_icon.move(10, 4)

        self.line_edit_user = QLineEdit(user_frame)
        self.line_edit_user.setFrame(False)
        self.line_edit_user.setTextMargins(8, 0, 4, 1)
        self.line_edit_user.setFixedWidth(297)
        self.line_edit_user.setFixedHeight(26)
        self.line_edit_user.move(40, 1)

        # ---------- Password ----------

        password_label = QLabel("Contraseña", self)
        password_label.move(90, 170)

        password_frame = QFrame(self)
        password_frame.setFrameShape(QFrame.StyledPanel)
        password_frame.setFixedWidth(338)
        password_frame.setFixedHeight(28)
        password_frame.move(90, 196)

        password_icon = QLabel(password_frame)
        password_icon.setPixmap(
            QPixmap("./images/PasswordIcon.png").scaled(
                20, 20, Qt.KeepAspectRatio, Qt.SmoothTransformation))
        password_icon.move(10, 4)

        self.line_edit_password = QLineEdit(password_frame)
        self.line_edit_password.setFrame(False)
        self.line_edit_password.setEchoMode(QLineEdit.Password)
        self.line_edit_password.setTextMargins(8, 0, 4, 1)
        self.line_edit_password.setFixedWidth(297)
        self.line_edit_password.setFixedHeight(26)
        self.line_edit_password.move(40, 1)

        # ---------- Confirm Password ----------

        confirm_password_label = QLabel("Confirmar Contraseña", self)
        confirm_password_label.move(90, 224)

        confirm_password_frame = QFrame(self)
        confirm_password_frame.setFrameShape(QFrame.StyledPanel)
        confirm_password_frame.setFixedWidth(338)
        confirm_password_frame.setFixedHeight(28)
        confirm_password_frame.move(90, 250)

        confirm_password_icon = QLabel(confirm_password_frame)
        confirm_password_icon.setPixmap(
            QPixmap("./images/PasswordIcon.png").scaled(
                20, 20, Qt.KeepAspectRatio, Qt.SmoothTransformation))
        confirm_password_icon.move(10, 4)

        self.line_edit_confirm_password = QLineEdit(confirm_password_frame)
        self.line_edit_confirm_password.setFrame(False)
        self.line_edit_confirm_password.setEchoMode(QLineEdit.Password)
        self.line_edit_confirm_password.setTextMargins(8, 0, 4, 1)
        self.line_edit_confirm_password.setFixedWidth(297)
        self.line_edit_confirm_password.setFixedHeight(26)
        self.line_edit_confirm_password.move(40, 1)

        # ---------- Buttons ----------

        sign_in_button = QPushButton("Registrarse", self)
        sign_in_button.setFixedWidth(175)
        sign_in_button.setFixedHeight(28)
        sign_in_button.move(170, 300)

        login_button = QPushButton("Volver a Login", self)
        login_button.setFixedWidth(175)
        login_button.setFixedHeight(28)
        login_button.move(170, 334)

        cancel_button = QPushButton("Cancelar", self)
        cancel_button.setFixedWidth(135)
        cancel_button.setFixedHeight(28)
        cancel_button.move(192, 368)

        # ---------- Button's Events ----------

        sign_in_button.clicked.connect(self.sign_in)
        login_button.clicked.connect(self.login)
        cancel_button.clicked.connect(self.close)
예제 #26
0
    def initUI(self):

        # ==================== FRAME ENCABEZADO ====================

        paleta = QPalette()
        paleta.setColor(QPalette.Background, QColor(51, 0, 102))

        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(paleta)
        frame.setFixedWidth(400)
        frame.setFixedHeight(84)
        frame.move(0, 0)

        labelIcono = QLabel(frame)
        labelIcono.setFixedWidth(40)
        labelIcono.setFixedHeight(40)
        labelIcono.setPixmap(
            QPixmap("icono.png").scaled(40, 40, Qt.KeepAspectRatio,
                                        Qt.SmoothTransformation))
        labelIcono.move(37, 22)

        fuenteTitulo = QFont()
        fuenteTitulo.setPointSize(16)
        fuenteTitulo.setBold(True)

        labelTitulo = QLabel("<font color='white'>Login</font>", frame)
        labelTitulo.setFont(fuenteTitulo)
        labelTitulo.move(83, 20)

        # ===================== WIDGETS LOGIN ======================

        # ========================================================

        labelUsuario = QLabel("Usuario", self)
        labelUsuario.move(60, 120)

        frameUsuario = QFrame(self)
        frameUsuario.setFrameShape(QFrame.StyledPanel)
        frameUsuario.setFixedWidth(280)
        frameUsuario.setFixedHeight(28)
        frameUsuario.move(60, 146)

        self.lineEditUsuario = QLineEdit(frameUsuario)
        self.lineEditUsuario.setFrame(False)
        self.lineEditUsuario.setTextMargins(8, 0, 4, 1)
        self.lineEditUsuario.setFixedWidth(238)
        self.lineEditUsuario.setFixedHeight(26)
        self.lineEditUsuario.move(40, 1)

        # ========================================================

        labelContrasenia = QLabel("Contraseña", self)
        labelContrasenia.move(60, 174)

        frameContrasenia = QFrame(self)
        frameContrasenia.setFrameShape(QFrame.StyledPanel)
        frameContrasenia.setFixedWidth(280)
        frameContrasenia.setFixedHeight(28)
        frameContrasenia.move(60, 200)

        self.lineEditContrasenia = QLineEdit(frameContrasenia)
        self.lineEditContrasenia.setFrame(False)
        self.lineEditContrasenia.setEchoMode(QLineEdit.Password)
        self.lineEditContrasenia.setTextMargins(8, 0, 4, 1)
        self.lineEditContrasenia.setFixedWidth(238)
        self.lineEditContrasenia.setFixedHeight(26)
        self.lineEditContrasenia.move(40, 1)

        labelToken = QLabel("Token", self)
        labelToken.move(60, 224)

        frameToken = QFrame(self)
        frameToken.setFrameShape(QFrame.StyledPanel)
        frameToken.setFixedWidth(280)
        frameToken.setFixedHeight(28)
        frameToken.move(60, 250)

        self.lineEditToken = QLineEdit(frameToken)
        self.lineEditToken.setFrame(False)
        self.lineEditToken.setEchoMode(QLineEdit.Password)
        self.lineEditToken.setTextMargins(8, 0, 4, 1)
        self.lineEditToken.setFixedWidth(238)
        self.lineEditToken.setFixedHeight(26)
        self.lineEditToken.move(40, 1)

        # ================== WIDGETS QPUSHBUTTON ===================

        buttonLogin = QPushButton("Iniciar sesión", self)
        buttonLogin.setFixedWidth(135)
        buttonLogin.setFixedHeight(28)
        buttonLogin.move(60, 286)

        buttonCancelar = QPushButton("Cancelar", self)
        buttonCancelar.setFixedWidth(135)
        buttonCancelar.setFixedHeight(28)
        buttonCancelar.move(205, 286)

        # ==================== MÁS INFORMACIÓN =====================

        # ==================== SEÑALES BOTONES =====================

        buttonLogin.clicked.connect(self.Login)
        buttonCancelar.clicked.connect(self.close)
예제 #27
0
    def initui(self):

        palette = QPalette()
        palette.setColor(QPalette.Background, QColor(100, 100, 100))

        # ************ Header ************
        # ------------ Frame ----------
        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(palette)
        frame.setFixedWidth(800)
        frame.setFixedHeight(84)
        frame.move(0, 0)

        # ------------ Icon ----------

        label_icon = QLabel(frame)
        label_icon.setFixedWidth(40)
        label_icon.setFixedHeight(40)
        label_icon.setPixmap(
            QPixmap("./images/LoginIcon.png").scaled(40, 40,
                                                     Qt.KeepAspectRatio,
                                                     Qt.SmoothTransformation))
        label_icon.move(57, 22)

        # ------------ Tittle ----------

        tittle_font = QFont()
        tittle_font.setPixelSize(16)
        tittle_font.setBold(True)

        tittle_label = QLabel("<font color='white'> Ariadna </rfont>", frame)
        tittle_label.setFont(tittle_font)
        tittle_label.move(103, 20)

        # ------------ Sub Tittle ----------

        sub_tittle_font = QFont()
        sub_tittle_font.setPointSize(9)

        sub_tittle_label = QLabel(
            "<font color='white'> Labyrinth Solver </font>", frame)
        sub_tittle_label.setFont(sub_tittle_font)
        sub_tittle_label.move(111, 46)

        # ************ Body ************
        # ------------ Frame ----------
        instructions_frame = QFrame(self)
        instructions_frame.setFrameShape(QFrame.NoFrame)
        instructions_frame.setFrameShadow(QFrame.Sunken)
        instructions_frame.setAutoFillBackground(False)
        instructions_frame.setFixedWidth(300)
        instructions_frame.setFixedHeight(500)
        instructions_frame.move(0, 84)

        # ---------- Instructions ----------

        instructions_font = QFont()
        instructions_font.setPointSize(9)

        instructions_label = QLabel(
            "<font style='font-family:times new roman;font-size:15px;' color='white'><b> "
            "<br/>Pre-resquisitos:"
            "<br/><br/>Para que la imagen pueda ser "
            "<br/>reconocida por el sistema, el "
            "<br/>laberinto debe ser dibujado en "
            "<br/>una hoja blanca con un marcador o"
            "<br/>esfero de color negro y debe tener"
            "<br/>una forma rectangular."
            "<br/><br/>Pasos:"
            "<br/><br/>1. Seleccionar la opcion "
            "<br/>'Nuevo Laberinto'."
            "<br/><br/>2. Seleccionar la opcion "
            "<br/>'Cargar laberinto', en esta opcion se."
            "<br/>soluciona el laberinto de manera "
            "<br/>automatica."
            "</b></font>", instructions_frame)
        instructions_label.setFont(instructions_font)
        instructions_label.move(20, 20)

        # ---------- Buttons ----------

        back_main_menu_button = QPushButton("Volver al Menu Principal", self)
        back_main_menu_button.setFixedWidth(200)
        back_main_menu_button.setFixedHeight(28)
        back_main_menu_button.move(300, 660)

        # ---------- Button's Events ----------

        back_main_menu_button.clicked.connect(self.back_main_menu)
예제 #28
0
class MainWindow(QMainWindow):
    def reset_canvas_action(self):

        self.item_cnt = 0
        self.canvas_widget.reset_canvas()
        #self.list_widget.clear()
        self.list_widget.currentTextChanged.disconnect(
            self.canvas_widget.selection_changed)
        self.list_widget.clear()
        self.list_widget.currentTextChanged.connect(
            self.canvas_widget.selection_changed)

        self.scene = QGraphicsScene(self)
        self.scene.setSceneRect(1, 1, 601, 601)  #挪一个像素,不然会有边框线
        self.item_cnt = 0
        self.statusBar().showMessage('重置画布')

        self.canvas_widget.setScene(self.scene)
        #self.canvas_widget = MyCanvas(self.scene, self.Image_window)

        #解决了一个bug参考 https://blog.csdn.net/yaowangII/article/details/80929261
    def save_canvas_action(self):
        # pixMap = view->grab(view->sceneRect().toRect());
        # QString
        # fileName = QFileDialog::getSaveFileName(this, "Save image",
        #                                         QCoreApplication::applicationDirPath(), "BMP Files (*.bmp);;JPEG (*.JPEG);;PNG (*.png)" );
        # filename=QFileDialog.getSaveFileName("Save image",QCoreApplication.applicationDirPath(),"BMP Files (*.bmp);;JPEG (*.JPEG);;PNG (*.png)")
        filename, ok2 = QFileDialog.getSaveFileName(
            self, "Save Image", QDir.currentPath(),
            "BMP Files (*.bmp);;JPEG (*.JPEG);;PNG (*.png)")

        #
        pixmap = QPixmap()
        pixmap = self.canvas_widget.grab(
            self.canvas_widget.sceneRect().toRect())
        pixmap.save(filename)

    def theme1_action(self):
        self.setStyleSheet(css1)

    def theme2_action(self):
        self.setStyleSheet(css2)

    def Menu_init(self):
        menubar = self.menuBar()
        # 菜单栏
        mfile = menubar.addMenu("文件")
        themefile = menubar.addMenu("主题")
        # 重置
        reset_canvas_act = QAction(QIcon("./icon/file.png"), "重置画布", self)

        reset_canvas_act.triggered.connect(
            self.reset_canvas_action)  # To be done

        # 保存
        save_canvas_act = QAction(QIcon("./icon/save.png"), "保存画布", self)
        save_canvas_act.triggered.connect(self.save_canvas_action)

        #默认主题:
        theme1_act = QAction("Blue theme", self)
        theme1_act.triggered.connect(self.theme1_action)
        theme2_act = QAction("Coffee theme", self)
        theme2_act.triggered.connect(self.theme2_action)
        # 将action添加到file上面
        mfile.addAction(reset_canvas_act)
        mfile.addAction(save_canvas_act)
        #将action添加到theme上面
        themefile.addAction(theme1_act)
        themefile.addAction(theme2_act)
        # 工具栏
        toolbar = QToolBar()
        toolbar.setMovable(False)
        self.addToolBar(toolbar)
        toolbar.addAction(reset_canvas_act)
        toolbar.addAction(save_canvas_act)

    def pen_width(self):
        w = self.spinbox_penwidth.text()
        w = int(w)
        # print("w:" + w)
        self.canvas_widget.setpenWidth(w)
        self.statusBar().showMessage('宽度为%d' % (w))

    def pen_color(self):
        c = QColorDialog.getColor()
        self.frame_color.setPalette(QPalette(c))
        # assert(0)
        self.frame_color.setStyleSheet("QWidget { background-color: %s }" %
                                       c.name())
        # self.frame_color.setStyleSheet("QFrame{background-color: rgba("+c.red()+","+c.green()+","+c.blue()+",1);border:none}")
        # print(c.red())
        # 参考了https://www.cnblogs.com/icat-510/p/10166882.html
        self.canvas_widget.setpenColor(c)

    def Color_init(self):
        colorbar = QToolBar("画笔属性栏")
        self.addToolBar(colorbar)
        colorbar.setMovable(True)

        label_penwidth = QLabel("画笔宽度")
        self.spinbox_penwidth = QSpinBox()
        self.spinbox_penwidth.setRange(1, 50)
        self.spinbox_penwidth.setValue(2)

        self.color_botton = QPushButton("画笔颜色")
        self.frame_color = QFrame(self)
        self.frame_color.setObjectName("colorframe")
        self.frame_color.setFrameShape(QFrame.Box)
        self.frame_color.setPalette(QPalette(Qt.black))
        self.frame_color.setAutoFillBackground(True)
        self.frame_color.setFixedSize(30, 30)
        self.frame_color.setStyleSheet(
            "QFrame{background-color: rgba(0,0,0,1);border:none}")

        # 槽函数
        self.spinbox_penwidth.valueChanged[int].connect(self.pen_width)
        self.color_botton.clicked.connect(self.pen_color)

        # 布局
        color_layout = QHBoxLayout()
        color_layout.setAlignment(Qt.AlignLeft)

        color_layout.addWidget(label_penwidth)
        color_layout.addWidget(self.spinbox_penwidth)
        color_layout.addWidget(self.color_botton)
        color_layout.addWidget(self.frame_color)

        color_widget = QWidget()
        color_widget.setLayout(color_layout)
        colorbar.addWidget(color_widget)

    def layout_init(self):
        # p=self.takeCentralWidget()
        self.setDockNestingEnabled(True)  # 允许嵌套

        self.Tool_window = QDockWidget("工具栏")

        self.setCentralWidget(self.Image_window)
        self.addDockWidget(Qt.TopDockWidgetArea, self.Tool_window)
        self.addDockWidget(Qt.RightDockWidgetArea, self.List_window)

    def line_action(self, algorithm):
        self.canvas_widget.start_draw_line(algorithm, self.get_id())
        self.statusBar().showMessage(algorithm + '算法绘制线段:左键点击绘制,松开结束')
        self.list_widget.clearSelection()
        self.canvas_widget.clear_selection()

    def DDA_line_draw_action(self):
        self.line_action('DDA')

    def Bresenham_line_draw_action(self):
        self.line_action('Bresenham')

    def polygon_action(self, algorithm):
        self.canvas_widget.start_draw_polygon(algorithm, self.get_id())
        self.statusBar().showMessage(algorithm +
                                     '算法绘制多边形:左键点击设置控制点,右键或者切换其他工具栏图标结束')
        self.list_widget.clearSelection()
        self.canvas_widget.clear_selection()

    def DDA_polygon_draw_action(self):
        self.polygon_action('DDA')

    def Bresenham_polygon_draw_action(self):
        self.polygon_action('Bresenham')

    def ellipse_draw_action(self):
        self.canvas_widget.start_draw_ellipse(self.get_id())
        self.statusBar().showMessage('中心圆算法绘制椭圆:左键点击设置控制点1,拖动松开后设置控制点2,完成绘制')
        self.list_widget.clearSelection()
        self.canvas_widget.clear_selection()

    def curve_draw_action(self, algorithm):
        self.canvas_widget.start_draw_curve(algorithm, self.get_id())
        self.statusBar().showMessage(algorithm +
                                     '算法绘制曲线:左键点击设置控制点,右键或者点击其他工具栏图标结束绘制')
        self.list_widget.clearSelection()
        self.canvas_widget.clear_selection()

    def Bezier_curve_draw_action(self):
        self.curve_draw_action('Bezier')

    def B_spline_curve_draw_action(self):
        self.curve_draw_action('B-spline')

    def translate_draw_action(self):
        self.canvas_widget.start_draw_translate()
        self.statusBar().showMessage('平移图元:选择图元之后任意拖动,松开结束')
        # self.list_widget.clearSelection()
        # self.canvas_widget.clear_selection()

    def rotate_draw_action(self):
        self.canvas_widget.start_draw_rotate()
        self.statusBar().showMessage('旋转图元:选择图元之后任意旋转,松开结束')

    def scale_draw_action(self):

        self.canvas_widget.start_draw_scale()
        self.statusBar().showMessage('缩放图元:选择图元之后任意移动,松开结束')

    def clip_draw_action(self, algorithm):
        self.canvas_widget.start_draw_clip(algorithm)
        self.statusBar().showMessage(algorithm +
                                     '裁剪线段:选择线段图元之后,左键点击拖动得到红色的裁剪框,松开结束')

    def Cohen_Sutherland_clip_draw_action(self):
        self.clip_draw_action("Cohen-Sutherland")

    def Liang_Barsky_clip_draw_action(self):
        self.clip_draw_action("Liang-Barsky")

    def cursor_draw_action(self):
        self.canvas_widget.start_cursor_selection()
        self.statusBar().showMessage('鼠标选择:左键点击任意图元进行选择')

    def fill_draw_action(self):
        self.canvas_widget.start_fill_polygon()
        self.statusBar().showMessage('多边形填充:选择多边形图元之后根据颜色框颜色填充')

    def polygon_clip_draw_action(self):
        self.canvas_widget.start_cut_polygon()
        self.statusBar().showMessage('多边形裁剪:选择多边形图元之后左键点击拖动得到绿色裁剪框进行裁剪')

    def x_mirror_draw_action(self):
        self.canvas_widget.start_x_mirror_draw()
        self.statusBar().showMessage('水平方向镜像:选择图元之后点击按钮')

    def y_mirror_draw_action(self):
        self.canvas_widget.start_y_mirror_draw()
        self.statusBar().showMessage('竖直方向镜像:选择图元之后点击按钮')

    def copy_draw_action(self):
        self.canvas_widget.start_copy_draw(self.get_id())
        self.statusBar().showMessage('复制粘贴:选择图元之后点击按钮,在原位置复制')

    def delete_draw_action(self):
        self.canvas_widget.start_delete_draw()
        self.statusBar().showMessage('删除图元:选择图元之后点击按钮删除')

    def tool_init(self):
        # line相关,使用的https://www.walletfox.com/course/customqtoolbutton.php做的可选算法button
        self.line_action_1 = QAction("DDA line")
        self.line_action_2 = QAction("Bresenham line")
        self.line_action_1.setIcon(QIcon("./icon/line.png"))
        self.line_action_2.setIcon(QIcon("./icon/line.png"))
        self.line_action_1.triggered.connect(self.DDA_line_draw_action)
        self.line_action_2.triggered.connect(self.Bresenham_line_draw_action)
        self.line_menu = QMenu()
        self.line_menu.addAction(self.line_action_1)
        self.line_menu.addAction(self.line_action_2)
        self.line_tool_button = CusToolButton()
        self.line_tool_button.setMenu(self.line_menu)
        self.line_tool_button.setDefaultAction(self.line_action_1)
        self.line_tool_bar = QToolBar(self)
        self.line_tool_bar.addWidget(self.line_tool_button)

        # polygon相关
        self.polygon_action_1 = QAction("DDA polygon")
        self.polygon_action_2 = QAction("Bresenham polygon")
        self.polygon_action_1.setIcon(QIcon("./icon/polygon.png"))
        self.polygon_action_2.setIcon(QIcon("./icon/polygon.png"))
        self.polygon_action_1.triggered.connect(self.DDA_polygon_draw_action)
        self.polygon_action_2.triggered.connect(
            self.Bresenham_polygon_draw_action)
        self.polygon_menu = QMenu()
        self.polygon_menu.addAction(self.polygon_action_1)
        self.polygon_menu.addAction(self.polygon_action_2)
        self.polygon_tool_button = CusToolButton()
        self.polygon_tool_button.setMenu(self.polygon_menu)
        self.polygon_tool_button.setDefaultAction(self.polygon_action_1)
        self.polygon_tool_bar = QToolBar(self)
        self.polygon_tool_bar.addWidget(self.polygon_tool_button)

        # ellipse相关
        self.ellipse_action = QAction("Ellipse")
        self.ellipse_action.setIcon(QIcon("./icon/ellipse.png"))
        self.ellipse_action.triggered.connect(self.ellipse_draw_action)

        self.ellipse_tool_bar = QToolBar(self)
        self.ellipse_tool_bar.addAction(self.ellipse_action)

        # curve相关
        self.curve_action_1 = QAction("Bezier Curve")
        self.curve_action_1.setIcon(QIcon("./icon/curve.png"))
        self.curve_action_2 = QAction("B-spline Curve")
        self.curve_action_2.setIcon(QIcon("./icon/curve.png"))
        self.curve_action_1.triggered.connect(self.Bezier_curve_draw_action)
        self.curve_action_2.triggered.connect(self.B_spline_curve_draw_action)
        self.curve_menu = QMenu()
        self.curve_menu.addAction(self.curve_action_1)
        self.curve_menu.addAction(self.curve_action_2)
        self.curve_tool_button = CusToolButton()
        self.curve_tool_button.setMenu(self.curve_menu)
        self.curve_tool_button.setDefaultAction(self.curve_action_1)

        self.curve_tool_bar = QToolBar(self)
        self.curve_tool_bar.addWidget(self.curve_tool_button)

        # translate相关(平移)
        self.translate_action = QAction("Translate")
        self.translate_action.setIcon(QIcon("./icon/move.png"))
        self.translate_action.triggered.connect(self.translate_draw_action)

        self.translate_tool_bar = QToolBar(self)
        self.translate_tool_bar.addAction(self.translate_action)

        # rotate相关 旋转
        self.rotate_action = QAction("Rotate")
        self.rotate_action.setIcon(QIcon("./icon/rotate.png"))
        self.rotate_action.triggered.connect(self.rotate_draw_action)

        self.rotate_tool_bar = QToolBar(self)
        self.rotate_tool_bar.addAction(self.rotate_action)
        # scale相关,缩放;
        self.scale_action = QAction("Scale")
        self.scale_action.setIcon(QIcon("./icon/scale.png"))
        self.scale_action.triggered.connect(self.scale_draw_action)

        self.scale_tool_bar = QToolBar(self)
        self.scale_tool_bar.addAction(self.scale_action)
        # clip 裁剪
        self.clip_action_1 = QAction("Cohen-Sutherland Clip")
        self.clip_action_2 = QAction("Liang-Barsky Clip")

        self.clip_action_1.setIcon(QIcon("./icon/crop.png"))
        self.clip_action_2.setIcon(QIcon("./icon/crop.png"))
        self.clip_action_1.triggered.connect(
            self.Cohen_Sutherland_clip_draw_action)
        self.clip_action_2.triggered.connect(
            self.Liang_Barsky_clip_draw_action)

        self.clip_menu = QMenu()
        self.clip_menu.addAction(self.clip_action_1)
        self.clip_menu.addAction(self.clip_action_2)
        self.clip_tool_button = CusToolButton()
        self.clip_tool_button.setMenu(self.clip_menu)
        self.clip_tool_button.setDefaultAction(self.clip_action_1)

        self.clip_tool_bar = QToolBar(self)
        self.clip_tool_bar.addWidget(self.clip_tool_button)

        #鼠标选择相关;
        self.cursor_action = QAction("Cursor")
        self.cursor_action.setIcon(QIcon("./icon/cursor.png"))
        self.cursor_action.triggered.connect(self.cursor_draw_action)

        self.cursor_tool_bar = QToolBar(self)
        self.cursor_tool_bar.addAction(self.cursor_action)
        #多边形填充相关:
        self.fill_action = QAction("Fill")
        self.fill_action.setIcon(QIcon("./icon/fill.png"))

        self.fill_action.triggered.connect(self.fill_draw_action)
        self.fill_tool_bar = QToolBar(self)
        self.fill_tool_bar.addAction(self.fill_action)
        #多边形裁剪相关:
        self.polygon_clip_action = QAction("Polygon Clip")
        self.polygon_clip_action.setIcon(QIcon("./icon/cut_polygon.png"))

        self.polygon_clip_action.triggered.connect(
            self.polygon_clip_draw_action)
        self.polygon_clip_tool_bar = QToolBar(self)
        self.polygon_clip_tool_bar.addAction(self.polygon_clip_action)

        #x轴镜像相关:
        self.x_mirror_action = QAction("X Axis Mirror")
        self.x_mirror_action.setIcon(QIcon("./icon/flip_horizontal.png"))

        self.x_mirror_action.triggered.connect(self.x_mirror_draw_action)
        self.x_mirror_tool_bar = QToolBar(self)
        self.x_mirror_tool_bar.addAction(self.x_mirror_action)
        #y轴镜像相关:
        self.y_mirror_action = QAction("Y Axis Mirror")
        self.y_mirror_action.setIcon(QIcon("./icon/flip_vertical.png"))

        self.y_mirror_action.triggered.connect(self.y_mirror_draw_action)
        self.y_mirror_tool_bar = QToolBar(self)
        self.y_mirror_tool_bar.addAction(self.y_mirror_action)
        #复制粘贴相关:
        self.copy_action = QAction("Copy paste")
        self.copy_action.setIcon(QIcon("./icon/copy.png"))

        self.copy_action.triggered.connect(self.copy_draw_action)
        self.copy_tool_bar = QToolBar(self)
        self.copy_tool_bar.addAction(self.copy_action)
        #删除图元相关:
        self.delete_action = QAction("Delete")
        self.delete_action.setIcon(QIcon("./icon/trash.png"))

        self.delete_action.triggered.connect(self.delete_draw_action)
        self.delete_tool_bar = QToolBar(self)
        self.delete_tool_bar.addAction(self.delete_action)

        #     #布局
        tools_layout = QGridLayout()
        tools_layout.setAlignment(Qt.AlignLeft)
        tools_layout.addWidget(self.line_tool_bar, 0, 0)
        tools_layout.addWidget(self.polygon_tool_bar, 0, 1)
        tools_layout.addWidget(self.ellipse_tool_bar, 0, 2)
        tools_layout.addWidget(self.curve_tool_bar, 0, 3)
        tools_layout.addWidget(self.translate_tool_bar, 0, 4)
        tools_layout.addWidget(self.rotate_tool_bar, 0, 5)
        tools_layout.addWidget(self.scale_tool_bar, 0, 6)
        tools_layout.addWidget(self.clip_tool_bar, 0, 7)
        tools_layout.addWidget(self.cursor_tool_bar, 0, 8)
        tools_layout.addWidget(self.fill_tool_bar, 0, 9)
        tools_layout.addWidget(self.polygon_clip_tool_bar, 0, 10)
        tools_layout.addWidget(self.x_mirror_tool_bar, 0, 11)
        tools_layout.addWidget(self.y_mirror_tool_bar, 0, 12)
        tools_layout.addWidget(self.copy_tool_bar, 0, 13)
        tools_layout.addWidget(self.delete_tool_bar, 0, 14)
        # 加入tool_window
        tools_widget = QWidget(self.Tool_window)
        tools_widget.setLayout(tools_layout)
        self.Tool_window.setWidget(tools_widget)
        self.Tool_window.setFeatures(QDockWidget.DockWidgetMovable
                                     | QDockWidget.DockWidgetFloatable)

    #
    #
    #     #按钮组 通过按钮组的值连接槽函数确定状态
    #     toolbuttons=QButtonGroup()
    #     toolbuttons.addButton(line_button_1,1)
    #
    #
    #     toolbuttons.buttonClicked[int].connect(self.tool_clicked)
    # def tool_clicked(self,type:int):
    #     a=type

    def __init__(self):
        super().__init__()
        self.item_cnt = 0

        ## 主窗口布局
        # 图片与标题
        QMainWindow.setWindowIcon(self, QIcon("./picture/icon.png"))
        QMainWindow.setWindowTitle(self, "Image Editor By ytr")

        # self.setWindowTitle('CG Demo')

        # 界面大小位置
        # QMainWindow.resize(self,QApplication.desktop().width()*0.9,QApplication.desktop().height()*0.9)
        # QMainWindow.move(self,QApplication.desktop().width()*0.05,QApplication.desktop().height()*0.05)

        self.Menu_init()
        self.Color_init()

        self.Image_window = QDockWidget("图像编辑框")
        self.Image_window.setFeatures(QDockWidget.DockWidgetMovable
                                      | QDockWidget.DockWidgetFloatable)
        self.Image_window.setAllowedAreas(Qt.LeftDockWidgetArea
                                          | Qt.RightDockWidgetArea)
        self.Image_window.setMinimumSize(620, 620)  #大一点点 不然会有边框线

        self.List_window = QDockWidget("图元列表")
        self.List_window.setFeatures(QDockWidget.DockWidgetMovable)
        self.list_widget = QListWidget(self.List_window)
        self.list_widget.setMinimumWidth(200)
        self.scene = QGraphicsScene(self)
        self.scene.setSceneRect(1, 1, 601, 601)  #挪一个像素,不然会有边框线

        self.canvas_widget = MyCanvas(self.scene, self.Image_window)

        self.canvas_widget.setFixedSize(610, 610)  #这样就没有滑动条了
        self.canvas_widget.main_window = self
        self.canvas_widget.list_widget = self.list_widget

        self.List_window.setWidget(self.list_widget)
        self.Image_window.setWidget(self.canvas_widget)
        self.setCentralWidget(self.Image_window)
        height = self.Image_window.height()
        width = self.Image_window.width()
        center_y = (self.canvas_widget.geometry().height() - height) / 2
        center_x = (self.canvas_widget.geometry().width() - width) / 2
        self.canvas_widget.setGeometry(center_x, center_y,
                                       self.canvas_widget.geometry().width(),
                                       self.canvas_widget.geometry().height())
        self.canvas_widget.setAlignment(Qt.AlignCenter)

        # 槽函数
        self.list_widget.currentTextChanged.connect(
            self.canvas_widget.selection_changed)

        self.layout_init()
        self.tool_init()

        self.setStyleSheet(css)

        # self.hbox_layout = QHBoxLayout()
        # self.hbox_layout.addWidget(self.canvas_widget)
        # self.hbox_layout.addWidget(self.list_widget, stretch=1)
        # self.central_widget = QWidget(self.Image_window)
        # self.central_widget.setLayout(self.hbox_layout)

        # self.setCentralWidget(self.central_widget)
        self.statusBar().showMessage('空闲')
        self.resize(600, 600)

    def get_id(self):
        _id = str(self.item_cnt)
        self.item_cnt += 1
        return _id
예제 #29
0
class FindInFilesWidget(QWidget):

    def __init__(self, parent=None):
        super().__init__(parent)
        _ToolsDock.register_widget(translations.TR_FIND_IN_FILES, self)

    def install_widget(self):
        container = QHBoxLayout(self)
        container.setContentsMargins(3, 0, 3, 0)
        self._actions = FindInFilesActions(self)
        container.addWidget(self._actions)
        self.__count = 0

        top_widget = QFrame()
        top_layout = QVBoxLayout(top_widget)
        top_layout.setContentsMargins(0, 0, 0, 0)
        top_layout.setSpacing(0)
        self._message_frame = QFrame()
        self._message_frame.hide()
        self._message_frame.setAutoFillBackground(True)
        pal = QPalette()
        pal.setColor(QPalette.Window, QColor("#6a6ea9"))
        pal.setColor(QPalette.WindowText, pal.windowText().color())
        self._message_frame.setPalette(pal)
        self._message_label = QLabel("")
        message_layout = QHBoxLayout(self._message_frame)
        message_layout.addStretch(1)
        message_layout.setContentsMargins(2, 2, 2, 2)
        message_layout.addWidget(self._message_label)
        top_layout.addWidget(self._message_frame)

        self._tree_results = SearchResultTreeView(self)
        top_layout.addWidget(self._tree_results)
        container.addWidget(top_widget)

        self._main_container = IDE.get_service("main_container")
        # Search worker
        self._search_worker = FindInFilesWorker()
        search_thread = QThread()
        self._search_worker.moveToThread(search_thread)
        self._search_worker.resultAvailable.connect(self._on_worker_finished)
        search_thread.finished.connect(search_thread.deleteLater)

        self._actions.searchRequested.connect(self._on_search_requested)
        self._tree_results.activated.connect(self._go_to)

    def _clear_results(self):
        self.__count = 0
        self._tree_results.clear()

    def _go_to(self, index):
        result_item = self._tree_results.model().data(index, Qt.UserRole + 1)
        if result_item.lineno != -1:
            parent = result_item.parent
            file_name = parent.file_path
            lineno = result_item.lineno
            # Open the file and jump to line
            self._main_container.open_file(file_name, line=lineno)

    @pyqtSlot('PyQt_PyObject')
    def _on_worker_finished(self, lines):
        self.__count += len(lines[-1])
        self._message_frame.show()
        self._message_label.setText(
            translations.TR_MATCHES_FOUND.format(self.__count))
        self._tree_results.add_result(lines)

    @pyqtSlot('QString', bool, bool, bool)
    def _on_search_requested(self, to_find, cs, regex, wo):
        self._clear_results()
        type_ = QRegExp.FixedString
        if regex:
            type_ = QRegExp.RegExp
        if wo:
            type_ = QRegExp.RegExp
            to_find = "|".join(["\\b" + word.strip() + "\\b"
                                for word in to_find.split()])
        filters = re.split(",", "*.py")
        pattern = QRegExp(to_find, cs, type_)
        self._search_worker.find_in_files(
            self._actions.current_project_path,
            filters,
            pattern,
            recursive=True
        )

    def showEvent(self, event):
        self._actions._line_search.setFocus()
        super().showEvent(event)
예제 #30
0
class GraphicalInterface(QMainWindow, Interface):
    def __init__(self, video_player, debug=False):
        self.__app = QApplication(sys.argv)
        super().__init__()
        self.__video_player = video_player
        #TODO get in .config the value of the volume by default
        self.__video_player.set_volume(100)
        # Property of the main window
        self.__width = 0
        self.__height = 0
        # List of all derivated object from the following QWidgets
        self.__palette = None
        self.__logo_image = None
        self.__previousbtn_image = None
        self.__skipbtn_image = None
        self.__playbtn_image = None
        self.__pausebtn_image = None
        # List of all the QWidget present in the main window
        self.__videotitle = None
        self.__searchbtn = None
        self.__searchbar = None
        self.__mainbox = None
        self.__modebox = None
        self.__logo = None
        self.__video_reader = None
        self.__previousbtn_audio = None
        self.__playbtn_audio = None
        self.__skipbtn_audio = None
        self.__previousbtn_video = None
        self.__playbtn_video = None
        self.__skipbtn_video = None
        self.__buttonbar_video = None
        # List of all the GraphicalObject in the main window
        self.__header = None
        self.__footer = None
        self.__body = None
        self.__gr_videotitle = None
        self.__gr_searchbar = None
        self.__gr_searchbtn = None
        self.__gr_modebox = None
        self.__gr_logo = None
        self.__gr_video_reader = None
        self.__gr_buttonbar_video = None

        self.__gr_previousbtn_audio = None
        self.__gr_playbtn_audio = None
        self.__gr_skipbtn_audio = None
        self.__gr_previousbtn_video = None
        self.__gr_playbtn_video = None
        self.__gr_skipbtn_video = None

        self.__object_list = []

        self.__debug = debug

    def main(self):
        """ 
        Main loop of the graphic interface
        """
        self.resize(640, 480)
        self.move(0, 0)
        self.setWindowTitle('Youtube Reader')
        self.setWindowIcon(QIcon('resources/icon.svg'))
        content = read_css("./css/main.css")
        self.setStyleSheet(content)
        self.__mainbox = GraphicalObject(self,
                                         width=640,
                                         height=480,
                                         pos_x=0,
                                         pos_y=0)

        self.__header = GraphicalObject(None,
                                        width=100,
                                        height=10,
                                        pos_x=0,
                                        pos_y=0,
                                        parent=self.__mainbox)

        self.__searchbar = QLineEdit(self)
        self.__searchbar.returnPressed.connect(self.handle_research)
        self.__gr_searchbar = GraphicalObject(self.__searchbar,
                                              width=70,
                                              height=60,
                                              pos_x=15,
                                              pos_y=20,
                                              parent=self.__header)

        self.__searchbtn = QPushButton('Search', self)
        self.__searchbtn.clicked.connect(self.handle_research)
        self.__gr_searchbtn = GraphicalObject(self.__searchbtn,
                                              width=10,
                                              height=60,
                                              pos_x=87,
                                              pos_y=20,
                                              parent=self.__header)

        self.__logo_image = QPixmap('resources/logo.png')
        self.__logo = QLabel(self)
        self.__logo.setScaledContents(True)
        self.__logo.setPixmap(self.__logo_image)
        self.__gr_logo = GraphicalObject(self.__logo,
                                         width=15,
                                         height=60,
                                         pos_x=0,
                                         pos_y=20,
                                         parent=self.__header)

        self.__body = GraphicalObject(None,
                                      width=100,
                                      height=80,
                                      pos_x=0,
                                      pos_y=10,
                                      parent=self.__mainbox)

        self.create_reader()
        self.set_player_mode(self.__video_player.get_mode())

        self.__footer = GraphicalObject(None,
                                        width=100,
                                        height=10,
                                        pos_x=0,
                                        pos_y=90,
                                        parent=self.__mainbox)

        self.__modebox = ComboDemo(self, self)
        self.__modebox.init_combo_box(self.__video_player.get_mode())
        self.__gr_modebox = GraphicalObject(self.__modebox,
                                            width=20,
                                            height=100,
                                            pos_x=80,
                                            pos_y=20,
                                            parent=self.__footer)

        self.show()
        self.__app.exec_()
        self.__video_player.stop_stream()

    def handle_research(self):
        my_string = self.__searchbar.text()
        self.__searchbar.clear()
        if "www.youtube.com/" in my_string:
            self.__video_player.add_url(my_string)
        else:
            print("Search functionnality not implemented yet. Put url please!")

    def create_reader(self):
        # code from github.com/devos50/vlc-pyqt5-example.git
        # Video UI
        if sys.platform == "darwin":
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.__video_reader = QMacCocoaViewContainer(0)
        else:
            self.__video_reader = QFrame(self)
        self.__palette = self.__video_reader.palette()
        self.__palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.__video_reader.setPalette(self.__palette)
        self.__video_reader.setAutoFillBackground(True)

        self.__gr_video_reader = GraphicalObject(self.__video_reader,
                                                 width=80,
                                                 height=80,
                                                 pos_x=10,
                                                 pos_y=10,
                                                 parent=self.__body)

        self.__videotitle = QLabel("No Video!", self)
        self.__videotitle.setWordWrap(True)
        self.__gr_videotitle = GraphicalObject(self.__videotitle,
                                               width=80,
                                               height=10,
                                               pos_x=10,
                                               pos_y=90,
                                               parent=self.__body)

        number_of_button = 3
        btn_height = 7
        btn_width = 7
        ui_origin_x = 0
        ui_origin_y = 100 - btn_height
        self.__buttonbar_video = QLabel(self)
        self.__buttonbar_video.setStyleSheet(
            "QLabel { background-color : white; color : blue; }")
        self.__gr_buttonbar_video = GraphicalObject(
            self.__buttonbar_video,
            width=100,
            height=btn_height,
            pos_x=0,
            pos_y=ui_origin_y,
            parent=self.__gr_video_reader)

        self.__previousbtn_video = TranslucidButton(self)
        self.__previousbtn_image = QPixmap('resources/back.svg')
        self.__previousbtn_video.setScaledContents(True)
        self.__previousbtn_video.setPixmap(self.__previousbtn_image)
        self.__gr_previousbtn_video = GraphicalObject(
            self.__previousbtn_video,
            width=btn_width,
            height=btn_height,
            pos_x=ui_origin_x + 0 * btn_width,
            pos_y=ui_origin_y,
            parent=self.__gr_video_reader)

        self.__skipbtn_video = TranslucidButton(self)
        self.__skipbtn_image = QPixmap('resources/skip.svg')
        self.__skipbtn_video.setScaledContents(True)
        self.__skipbtn_video.setPixmap(self.__skipbtn_image)
        self.__gr_skipbtn_video = GraphicalObject(
            self.__skipbtn_video,
            width=btn_width,
            height=btn_height,
            pos_x=ui_origin_x + 2 * btn_width,
            pos_y=ui_origin_y,
            parent=self.__gr_video_reader)

        self.__playbtn_video = TranslucidButton(self)
        self.__playbtn_video.clicked.connect(self.video_play_pause)
        self.__playbtn_image = QPixmap('resources/play.svg')
        self.__playbtn_video.setScaledContents(True)
        self.__playbtn_video.setPixmap(self.__playbtn_image)
        self.__gr_playbtn_video = GraphicalObject(
            self.__playbtn_video,
            width=btn_width,
            height=btn_height,
            pos_x=ui_origin_x + 1 * btn_width,
            pos_y=ui_origin_y,
            parent=self.__gr_video_reader)

        # Audio UI
        number_of_button = 3
        btn_height = 5
        btn_width = 10
        ui_origin_x = 30
        ui_origin_y = 50 - (btn_height / 2)

        self.__previousbtn_audio = QPushButton('Previous', self)
        #clicked.connect(self.handle_research)
        self.__gr_previousbtn_audio = GraphicalObject(
            self.__previousbtn_audio,
            width=btn_width,
            height=btn_height,
            pos_x=ui_origin_x + (0 *
                                 (100 - 2 * ui_origin_x)) / number_of_button,
            pos_y=ui_origin_y,
            parent=self.__body)

        self.__playbtn_audio = QPushButton('Play', self)
        self.__playbtn_audio.clicked.connect(self.audio_play_pause)
        self.__gr_playbtn_audio = GraphicalObject(
            self.__playbtn_audio,
            width=btn_width,
            height=btn_height,
            pos_x=ui_origin_x + (1 *
                                 (100 - 2 * ui_origin_x)) / number_of_button,
            pos_y=ui_origin_y,
            parent=self.__body)

        self.__skipbtn_audio = QPushButton('Skip', self)
        self.__skipbtn_audio.clicked.connect(self.__video_player.skip)
        self.__gr_skipbtn_audio = GraphicalObject(
            self.__skipbtn_audio,
            width=btn_width,
            height=btn_height,
            pos_x=ui_origin_x + (2 *
                                 (100 - 2 * ui_origin_x)) / number_of_button,
            pos_y=ui_origin_y,
            parent=self.__body)

    def set_player_mode(self, value):
        self.__video_player.set_mode(value)
        if value == 'Video':
            self.__video_reader.show()
            self.__previousbtn_audio.hide()
            self.__playbtn_audio.hide()
            self.__skipbtn_audio.hide()
        else:
            self.__video_reader.hide()
            self.__previousbtn_audio.show()
            self.__playbtn_audio.show()
            self.__skipbtn_audio.show()

    def end_of_play_list(self):
        print("End of stream")
        self.__palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.__video_reader.setPalette(self.__palette)

    def update_title(self, title):
        self.__videotitle.setText(title)

    def audio_play_pause(self):
        if self.__video_player.is_running():
            self.pause_start()
        else:
            self.__playbtn_audio.setText('Pause')
            self.__video_player.play_stream()

    def video_play_pause(self):
        print("Play pause")
        if self.__video_player.is_running():
            self.pause_start()
        else:
            print("Launching the stream")
            if sys.platform.startswith(
                    'linux'):  # for Linux using the X Server
                self.__video_player.get_player().set_xwindow(
                    self.__video_reader.winId())
            elif sys.platform == "win32":  # for Windows
                self.__video_player.get_player().set_hwnd(
                    self.__video_reader.winId())
            elif sys.platform == "darwin":  # for MacOS
                self.__video_player.get_player().set_nsobject(
                    int(self.__video_reader.winId()))
#TODO LAPALETTE
            self.__video_player.play_stream()
            if self.__video_player.is_playing():
                self.__palette.setColor(QPalette.Window, QColor(255, 255, 255))
                self.__video_reader.setPalette(self.__palette)
                self.__video_reader.setAutoFillBackground(True)

    def pause_start(self):
        if self.__video_player.is_paused():
            print("Unpausing the player")
            self.__playbtn_audio.setText('Pause')
            self.__video_player.resume_stream()
        elif self.__video_player.is_playing():
            print("Pausing the player")
            self.__playbtn_audio.setText('Play')
            self.__video_player.pause_stream()
        else:
            print("Restarting the stream")
            self.__playbtn_audio.setText('Pause')
            self.__video_player.play_stream()

# Redefinition of the QMainWindow built-in methods

    def mousePressEvent(self, event):
        # Left click
        if event.button() == 1:
            if ((event.x() <= (self.__gr_video_reader.getRealWidth() +
                               self.__gr_video_reader.getRealPosX()))
                    and (event.x() >= self.__gr_video_reader.getRealPosX())
                    and (event.y() <= (self.__gr_video_reader.getRealHeight() +
                                       self.__gr_video_reader.getRealPosY()))
                    and (event.y() >= self.__gr_video_reader.getRealPosY())
                    and self.__video_player.get_mode() == 'Video'):

                print("True")
                if self.__video_player.is_running():
                    self.pause_start()
                else:
                    print("Launching the stream")
                    if sys.platform.startswith(
                            'linux'):  # for Linux using the X Server
                        self.__video_player.get_player().set_xwindow(
                            self.__video_reader.winId())
                    elif sys.platform == "win32":  # for Windows
                        self.__video_player.get_player().set_hwnd(
                            self.__video_reader.winId())
                    elif sys.platform == "darwin":  # for MacOS
                        self.__video_player.get_player().set_nsobject(
                            int(self.__video_reader.winId()))


#TODO LAPALETTE
                    self.__video_player.play_stream()
                    if self.__video_player.is_playing():
                        self.__palette.setColor(QPalette.Window,
                                                QColor(255, 255, 255))
                        self.__video_reader.setPalette(self.__palette)
                        self.__video_reader.setAutoFillBackground(True)

        print("Plop X " + str(event.x()) + " Plop Y " + str(event.y()))
        print("Glob X " + str(event.globalX()) + " Glob Y " +
              str(event.globalY()))

    def resizeEvent(self, event):
        print("OLD height: " + str(event.oldSize().height()) + " width: " +
              str(event.oldSize().width()))
        print("NEW height: " + str(event.size().height()) + " width: " +
              str(event.oldSize().width()))
        self.__width = event.size().width()
        self.__height = event.size().height()
        self.__mainbox.resize(event.size().width(), event.size().height())
예제 #31
0
    def initUI(self):

        # ==================== FRAME ENCABEZADO ====================

        paleta = QPalette()
        paleta.setColor(QPalette.Background, QColor(51, 0, 102))

        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(paleta)
        frame.setFixedWidth(400)
        frame.setFixedHeight(84)
        frame.move(0, 0)

        labelIcono = QLabel(frame)
        labelIcono.setFixedWidth(40)
        labelIcono.setFixedHeight(40)
        labelIcono.setPixmap(
            QPixmap("./assets/icono.png").scaled(40, 40, Qt.KeepAspectRatio,
                                                 Qt.SmoothTransformation))
        labelIcono.move(37, 22)

        fuenteTitulo = QFont()
        fuenteTitulo.setPointSize(20)
        fuenteTitulo.setBold(True)

        labelTitulo = QLabel("<font color='white'>Proyección</font>", frame)
        labelTitulo.setFont(fuenteTitulo)
        labelTitulo.move(90, 20)

        fuenteSubtitulo = QFont()
        fuenteSubtitulo.setPointSize(12)

        labelSubtitulo = QLabel(
            "<font color='white'>Pronósticos de ventas"
            ".</font>", frame)
        labelSubtitulo.setFont(fuenteSubtitulo)
        labelSubtitulo.move(115, 50)

        # ========================================================

        labelUsuario = QLabel("Usuario", self)
        labelUsuario.move(60, 170)

        frameUsuario = QFrame(self)
        frameUsuario.setFrameShape(QFrame.StyledPanel)
        frameUsuario.setFixedWidth(280)
        frameUsuario.setFixedHeight(28)
        frameUsuario.move(60, 196)

        imagenUsuario = QLabel(frameUsuario)
        imagenUsuario.setPixmap(
            QPixmap("./assets/usuario.png").scaled(20, 20, Qt.KeepAspectRatio,
                                                   Qt.SmoothTransformation))
        imagenUsuario.move(10, 4)

        self.lineEditUsuario = QLineEdit(frameUsuario)
        self.lineEditUsuario.setFrame(False)
        self.lineEditUsuario.setTextMargins(8, 0, 4, 1)
        self.lineEditUsuario.setFixedWidth(238)
        self.lineEditUsuario.setFixedHeight(26)
        self.lineEditUsuario.move(40, 1)

        # ========================================================

        labelContrasenia = QLabel("Contraseña", self)
        labelContrasenia.move(60, 224)

        frameContrasenia = QFrame(self)
        frameContrasenia.setFrameShape(QFrame.StyledPanel)
        frameContrasenia.setFixedWidth(280)
        frameContrasenia.setFixedHeight(28)
        frameContrasenia.move(60, 250)

        imagenContrasenia = QLabel(frameContrasenia)
        imagenContrasenia.setPixmap(
            QPixmap("./assets/contrasena.png").scaled(20, 20,
                                                      Qt.KeepAspectRatio,
                                                      Qt.SmoothTransformation))
        imagenContrasenia.move(10, 4)

        self.lineEditContrasenia = QLineEdit(frameContrasenia)
        self.lineEditContrasenia.setFrame(False)
        self.lineEditContrasenia.setEchoMode(QLineEdit.Password)
        self.lineEditContrasenia.setTextMargins(8, 0, 4, 1)
        self.lineEditContrasenia.setFixedWidth(238)
        self.lineEditContrasenia.setFixedHeight(26)
        self.lineEditContrasenia.move(40, 1)

        # ================== WIDGETS QPUSHBUTTON ===================

        buttonLogin = QPushButton("Iniciar sesión", self)
        buttonLogin.setFixedWidth(135)
        buttonLogin.setFixedHeight(28)
        buttonLogin.move(60, 286)

        buttonCancelar = QPushButton("Cancelar", self)
        buttonCancelar.setFixedWidth(135)
        buttonCancelar.setFixedHeight(28)
        buttonCancelar.move(205, 286)

        # ==================== MÁS INFORMACIÓN =====================

        labelInformacion = QLabel(
            "<a href='https://github.com/liluisjose1'>Más información</a>.",
            self)
        labelInformacion.setOpenExternalLinks(True)
        labelInformacion.setToolTip("Help")
        labelInformacion.move(15, 344)

        # ==================== SEÑALES BOTONES =====================

        buttonLogin.clicked.connect(self.Login)
        buttonCancelar.clicked.connect(self.close)
예제 #32
0
    def setupUI(self, animarBotones):

        paleta = QPalette()
        paleta.setColor(QPalette.Background, QColor(0, 0, 93))

        frame = QFrame(self)
        frame.setFrameShape(QFrame.NoFrame)
        frame.setFrameShadow(QFrame.Sunken)
        frame.setAutoFillBackground(True)
        frame.setPalette(paleta)
        frame.setFixedWidth(400)
        frame.setFixedHeight(84)
        frame.move(0, 0)

        labelIcono = QLabel(frame)
        labelIcono.setFixedWidth(40)
        labelIcono.setFixedHeight(40)
        labelIcono.setPixmap(
            QPixmap("mundo.png").scaled(40, 40, Qt.KeepAspectRatio,
                                        Qt.SmoothTransformation))
        labelIcono.move(37, 22)

        fuenteTitulo = QFont()
        fuenteTitulo.setPointSize(16)
        fuenteTitulo.setBold(True)

        labelTitulo = QLabel("<font color='white'>BIENVENIDO</font>", frame)
        labelTitulo.setFont(fuenteTitulo)
        labelTitulo.move(83, 20)

        frameUsuario = QFrame(self)
        frameUsuario.setFrameShape(QFrame.StyledPanel)
        frameUsuario.setFixedWidth(100)
        frameUsuario.setFixedHeight(28)
        frameUsuario.move(90, 50)

        self.lineEditUsuario1 = QLineEdit(frameUsuario)

        self.lineEditUsuario1.setReadOnly(True)
        self.lineEditUsuario1.setFrame(False)
        self.lineEditUsuario1.setTextMargins(8, 0, 4, 1)
        self.lineEditUsuario1.setFixedWidth(100)
        self.lineEditUsuario1.setFixedHeight(26)
        self.lineEditUsuario1.move(0, 1)

        fuenteSubtitulo = QFont()
        fuenteSubtitulo.setPointSize(9)

        labelSubtitulo = QLabel("<font color='white'"
                                "(Python).</font>", frame)
        labelSubtitulo.setFont(fuenteSubtitulo)
        labelSubtitulo.move(111, 46)

        self.button = ui_menu(self)
        self.button.setText("MIS CURSOS")
        self.button.setCursor(Qt.PointingHandCursor)
        self.button.setAutoDefault(False)
        self.button.setGeometry(40, 150, 160, 60)
        self.button.clicked.connect(self.abrirmenuuser)

        self.buttonDos = ui_menu(self)
        self.buttonDos.setText("UNIRSE A \nUN CURSO")
        self.buttonDos.setCursor(Qt.PointingHandCursor)
        self.buttonDos.setAutoDefault(False)
        self.buttonDos.setGeometry(220, 150, 160, 60)
        self.buttonDos.clicked.connect(self.openanadirclase)
예제 #33
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setFixedSize(800, 500)
        self.file = None
        but = QPushButton("Choose a directory with images", self)
        but.move(300, 20)
        but.setFixedSize(200, 25)
        but.clicked.connect(lambda x: self.get_data_path())
        but.setFocusPolicy(Qt.NoFocus)

        self.left = QFrame(self)
        self.left.setFixedSize(200, 200)
        self.left.move(50, 150)
        self.left.setAutoFillBackground(False)
        self.left.setStyleSheet(
            "QFrame { background-color: transparent; background: url('green_ar.png') no-repeat left; background-size: 50px 50px;}"
        )

        self.right = QFrame(self)
        self.right.setFixedSize(200, 200)
        self.right.move(550, 150)
        self.right.setAutoFillBackground(False)
        self.right.setStyleSheet(
            "QFrame { background-color: transparent; background: url('red_ar.png') no-repeat right; background-size: 50px 50px;}"
        )

        self.img = QFrame(self)
        self.img.setFixedSize(200, 400)
        self.img.setFrameShadow(QFrame.Sunken)
        self.img.setFrameShape(QFrame.Panel)
        self.img.move(300, 50)
        self.img.setAutoFillBackground(False)

        self.show()

    def get_data_path(self):
        local_path = str(
            QFileDialog.getExistingDirectory(self, "Select Directory"))
        if len(local_path) == 0: return
        self.local_path = local_path
        true_path = path.join(self.local_path, 'true')
        false_path = path.join(self.local_path, 'false')
        os.makedirs(true_path) if not os.path.exists(true_path) else None
        os.makedirs(false_path) if not os.path.exists(false_path) else None

        self.change_file()

    def change_file(self):
        self.first = os.listdir(self.local_path)[0]
        self.file = path.join(self.local_path, self.first).replace("\\", "/")
        self.img.setStyleSheet(
            "QFrame { background-color: transparent; background: url('" +
            self.file + "') no-repeat center; background-size: 100px 100px;}")

    def move_car(self, is_car):
        try:
            os.rename(
                self.file,
                path.join(self.local_path, "true" if is_car else "false",
                          self.first))
            self.change_file()
        except:
            pass

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Left:
            self.move_car(True)
        elif event.key() == Qt.Key_Right:
            self.move_car(False)