Ejemplo n.º 1
0
 def button_1(self):
     chooseb = QPushButton("выбрать xml директорию с файлами")
     chooseb.addAction(QAction(QIcon('open.png'), 'Open', self))
     chooseb.setStatusTip(
         'Выбрать директорию с файлами выписок в формате xml ')
     chooseb.clicked.connect(self.choose_xml_file_dialog)
     self.vbox.addWidget(chooseb)
    def initUI(self):
        
        layout1 = QHBoxLayout()
        layout2 = QVBoxLayout()
        layout3 = QVBoxLayout()

        #label dell'immagine .jpg
        self.labelImage = QLabel(self)

        #label disegnabile 
        self.QLabelDraw = QLabel()
        self.QLabelDraw.setFixedSize(400, 400)
        h, w = 28, 28

        self.labelImage.setStyleSheet("border: 1px solid black;") 
        blackimage='none.jpg'
        self.pixmap = QPixmap(blackimage)


        im = np.random.randint(0, 255, [h, w], np.uint8)
        im = QImage(im.data, im.shape[1], im.shape[0], QImage.Format_Grayscale8)
        pix = QPixmap(im).scaled(self.QLabelDraw.width(), self.QLabelDraw.height())
        self.QLabelDraw.setPixmap(pix)
        

        self.labelImage.setPixmap(self.pixmap)
        self.labelImage.setFixedSize(400, 400)

        layout2.addWidget(self.QLabelDraw)
        layout3.addWidget(self.labelImage)
        
        saveButton = QPushButton('Next prediction', self)
        cancelButton = QPushButton('Exit', self)
        saveAction = QAction(QIcon("icons/save.jpg"), "Save",self)
        saveAction.setShortcut("Ctrl+S")
        saveButton.addAction(saveAction)
        saveButton.clicked.connect(self.save)
      

        cancelAction = QAction(QIcon("icons/clear.png"), "Clear", self)
        cancelAction.setShortcut("Ctrl+C")
        cancelButton.addAction(cancelAction)
        cancelButton.clicked.connect(self.cancel)

        layout2.addWidget(saveButton)
        layout3.addWidget(cancelButton)
        
        layout1.addLayout(layout2)
        layout1.addLayout(layout3)
        
        widget = QWidget(self)
        widget.setLayout(layout1)
        self.setGeometry(0, 0, 825, 450)
        self.setWindowTitle('Number Recognition')
        self.show()
    def initUI(self):
        
        layout1 = QHBoxLayout()
        layout2 = QVBoxLayout()
        layout3 = QVBoxLayout()

        #label dell'immagine .jpg
        self.labelImage = QLabel(self)

        #label disegnabile 
        self.QLabelDraw = QLabelDraw()
        self.labelImage.setStyleSheet("border: 1px solid black;") 
        blackimage='none.jpg'
        self.pixmap = QPixmap(blackimage)
        self.QLabelDraw.setFixedSize(400, 400)
        self.QLabelDraw.setStyleSheet("border: 100px solid black;") 
        self.labelImage.setPixmap(self.pixmap)
        self.labelImage.setFixedSize(400, 400)

        layout2.addWidget(self.QLabelDraw)
        layout3.addWidget(self.labelImage)
        
        saveButton = QPushButton('Save', self)
        cancelButton = QPushButton('Cancel', self)
        saveAction = QAction(QIcon("icons/save.jpg"), "Save",self)
        saveAction.setShortcut("Ctrl+S")
        saveButton.addAction(saveAction)
        saveButton.clicked.connect(self.save)
      

        cancelAction = QAction(QIcon("icons/clear.png"), "Clear", self)
        cancelAction.setShortcut("Ctrl+C")
        cancelButton.addAction(cancelAction)
        cancelButton.clicked.connect(self.cancel)

        layout2.addWidget(saveButton)
        layout3.addWidget(cancelButton)
        
        layout1.addLayout(layout2)
        layout1.addLayout(layout3)
        
        widget = QWidget(self)
        widget.setLayout(layout1)
        self.setGeometry(0, 0, 825, 450)
        self.setWindowTitle('Number Recognition')
        self.show()
Ejemplo n.º 4
0
    def initUI(self):
        choose_in_b = QPushButton("выбрать директорию xml")
        choose_out_b = QPushButton("выбрать директорию вывода")
        runb = QPushButton("добавить надпись")

        choose_in_b.addAction(QAction(QIcon('open.png'), 'Open', self))
        choose_in_b.setStatusTip('Выберите директорию с xml файлами')
        choose_in_b.clicked.connect(self.chooseInDialog)

        choose_out_b.addAction(QAction(QIcon('open.png'), 'Open', self))
        choose_out_b.setStatusTip(
            'Выберите директорию с для сохранение excel файла с выгрузкой данных'
        )
        choose_out_b.clicked.connect(self.chooseOutDialog)

        runb.addAction(QAction(QIcon('run.png'), 'Run', self))
        runb.setStatusTip('Запустить программу')
        runb.clicked.connect(self.runProgram)

        vbox = QVBoxLayout()
        vbox.addWidget(choose_in_b)
        vbox.addWidget(choose_out_b)
        vbox.addWidget(runb)

        self.setLayout(vbox)
        self.setFixedSize(280, 180)

        self.setWindowTitle('Добавить надпись')
        self.show()
Ejemplo n.º 5
0
    def initUI(self):
        chooseb = QPushButton("выбрать csv")
        runb = QPushButton("добавить надпись")

        chooseb.addAction(QAction(QIcon('open.png'), 'Open', self))
        chooseb.setStatusTip('Выбрать csv файл со списком скриншотов')
        chooseb.clicked.connect(self.showDialog)

        runb.addAction(QAction(QIcon('run.png'), 'Run', self))
        runb.setStatusTip('Запустить программу')
        runb.clicked.connect(self.runProgram)

        vbox = QVBoxLayout()
        vbox.addWidget(chooseb)
        vbox.addWidget(runb)


        self.setLayout(vbox)
        self.setFixedSize(280, 180)

        self.setWindowTitle('Добавить надпись')
        self.show()
Ejemplo n.º 6
0
 def button_3(self):
     runb = QPushButton("Конвертировать")
     runb.addAction(QAction(QIcon('run.png'), 'Run', self))
     runb.setStatusTip('Запустить программу')
     runb.clicked.connect(self.run_program)
     self.vbox.addWidget(runb)
Ejemplo n.º 7
0
 def button_2(self):
     savef = QPushButton("выбрать папку сохранения")
     savef.addAction(QAction(QIcon('save_folder.png'), 'save_folder', self))
     savef.setStatusTip('Выберите папку для сохранения excel файла')
     savef.clicked.connect(self.save_folder_dialog)
     self.vbox.addWidget(savef)
Ejemplo n.º 8
0
class TutorialDialog(QWidget):
    """ A customized QWidget used to instruct a user how to use a certain feature """
    def paintEvent(self, event, *args):
        """ Custom paint event """
        # Paint custom frame image on QWidget
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        frameColor = QColor("#53a0ed")

        painter.setPen(QPen(frameColor, 2))
        painter.setBrush(self.palette().color(QPalette.Window))
        painter.drawRoundedRect(
            QRectF(31, 0,
                   self.width() - 31, self.height()), 10, 10)

        # Paint blue triangle (if needed)
        if self.arrow:
            arrow_height = 20
            path = QPainterPath()
            path.moveTo(0, 35)
            path.lineTo(31, 35 - arrow_height)
            path.lineTo(31, (35 - arrow_height) + (arrow_height * 2))
            path.lineTo(0, 35)
            painter.fillPath(path, frameColor)

    def checkbox_metrics_callback(self, state):
        """ Callback for error and anonymous usage checkbox"""
        s = get_app().get_settings()
        if state == Qt.Checked:
            # Enabling metrics sending
            s.set("send_metrics", True)
            sentry.init_tracing()

            # Opt-in for metrics tracking
            track_metric_screen("metrics-opt-in")
        else:
            # Opt-out for metrics tracking
            track_metric_screen("metrics-opt-out")
            sentry.disable_tracing()

            # Disable metric sending
            s.set("send_metrics", False)

    def mouseReleaseEvent(self, event):
        """Process click events on tutorial. Especially useful when tutorial messages are partially
        obscured or offscreen (i.e. on small screens). Just click any part of the tutorial, and it will
        move on to the next one."""
        self.manager.next_tip(self.widget_id)

    def __init__(self, widget_id, text, arrow, manager, *args):
        # Invoke parent init
        QWidget.__init__(self, *args)

        # get translations
        app = get_app()
        _ = app._tr

        # Keep track of widget to position next to
        self.widget_id = widget_id
        self.arrow = arrow
        self.manager = manager

        # Create vertical box
        vbox = QVBoxLayout()
        vbox.setContentsMargins(32, 10, 10, 10)

        # Add label
        self.label = QLabel(self)
        self.label.setText(text)
        self.label.setTextFormat(Qt.RichText)
        self.label.setWordWrap(True)
        self.label.setStyleSheet("margin-left: 20px;")
        self.label.setAttribute(Qt.WA_TransparentForMouseEvents)
        vbox.addWidget(self.label)

        # Add error and anonymous metrics checkbox (for ID=0) tooltip
        # This is a bit of a hack, but since it's the only exception, it's
        # probably okay for now.
        if self.widget_id == "0":
            # Get settings
            s = get_app().get_settings()

            # create spinner
            checkbox_metrics = QCheckBox()
            checkbox_metrics.setText(
                _("Yes, I would like to improve OpenShot!"))
            checkbox_metrics.setStyleSheet(
                "margin-left: 25px; margin-bottom: 5px;")
            if s.get("send_metrics"):
                checkbox_metrics.setCheckState(Qt.Checked)
            else:
                checkbox_metrics.setCheckState(Qt.Unchecked)
            checkbox_metrics.stateChanged.connect(
                functools.partial(self.checkbox_metrics_callback))
            vbox.addWidget(checkbox_metrics)

        # Add button box
        hbox = QHBoxLayout()
        hbox.setContentsMargins(20, 10, 0, 0)

        # Close action
        self.close_action = QAction(_("Hide Tutorial"), self)
        self.close_action.setShortcut(QKeySequence(Qt.Key_Escape))
        self.close_action.setShortcutContext(Qt.ApplicationShortcut)

        # Create buttons
        self.btn_close_tips = QPushButton(self)
        self.btn_close_tips.setText(_("Hide Tutorial"))
        self.btn_close_tips.addAction(self.close_action)

        self.btn_next_tip = QPushButton(self)
        self.btn_next_tip.setText(_("Next"))
        self.btn_next_tip.setStyleSheet("font-weight:bold;")

        hbox.addWidget(self.btn_close_tips)
        hbox.addWidget(self.btn_next_tip)
        vbox.addLayout(hbox)

        # Set layout, cursor, and size
        self.setLayout(vbox)
        self.setCursor(Qt.ArrowCursor)
        self.setMinimumWidth(350)
        self.setMinimumHeight(100)
        self.setFocusPolicy(Qt.ClickFocus)

        # Make transparent
        self.setAttribute(Qt.WA_NoSystemBackground, True)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.setAttribute(Qt.WA_DeleteOnClose, True)

        # Connect close action signal
        self.close_action.triggered.connect(
            functools.partial(self.manager.hide_tips, self.widget_id, True))