示例#1
0
    def createCardHolder(self):
        scrollArea = QScrollArea()
        self.cardList = QFrame()

        self.listLayout = layoutUtil.createLayout(LayoutType.VERTICAL,
                                                  self.cardList)
        self.cardList.setObjectName("SequenceHolder")

        scrollArea.setWidget(self.cardList)
        scrollArea.setWidgetResizable(True)
        scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scrollArea.verticalScrollBar().setSingleStep(10)
        QScroller.grabGesture(scrollArea.viewport(),
                              QScroller.LeftMouseButtonGesture)
        return scrollArea
示例#2
0
文件: plugin.py 项目: hazedic/r2dwarf
    def __init__(self, *__args):
        super().__init__(*__args)

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setFrameStyle(QFrame.NoFrame)
        self.setFrameShadow(QFrame.Plain)
        self.viewport().setAttribute(Qt.WA_AcceptTouchEvents)
        QScroller.grabGesture(self.viewport(), QScroller.LeftMouseButtonGesture)
        self.setWidgetResizable(True)

        self.label = QLabel()
        self.label.setTextFormat(Qt.RichText)
        self.label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        self.setWidget(self.label)
示例#3
0
    def createLogPanel(self):
        self.scrollArea = QScrollArea()
        self.logList = QFrame()
        self.listLayout = layoutUtil.createLayout(LayoutType.VERTICAL,
                                                  self.logList)
        self.listLayout.setAlignment(Qt.AlignTop)
        self.logList.setObjectName("LogHolder")

        self.scrollArea.setWidget(self.logList)
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scrollArea.verticalScrollBar().setSingleStep(10)
        QScroller.grabGesture(self.scrollArea.viewport(),
                              QScroller.LeftMouseButtonGesture)

        self.layout.addWidget(self.scrollArea)
示例#4
0
    def __init__(self, 社員: 社員, 予約画面: 食事予約):
        super(Window, self).__init__()
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.load_ui()
        self.予約画面 = 予約画面
        self.社員 = 社員
        self.ui.btnGoBack.clicked.connect(lambda: self.quit(withParent=False))
        self.ui.btnOpenReserve.clicked.connect(
            lambda: self.quit(withParent=True))
        self.ui.tableWidget.itemClicked.connect(self.reserve)
        self.plot_data()

        # タッチスクロール設定
        QScroller.grabGesture(self.ui.tableWidget,
                              QScroller.LeftMouseButtonGesture)
        scroller = QScroller.scroller(self.ui.tableWidget)
        props = scroller.scrollerProperties()
        props.setScrollMetric(QScrollerProperties.MaximumVelocity, 0.5)
        scroller.setScrollerProperties(props)
示例#5
0
    def __init__(self, parent=None):
        super().__init__(parent)
        scroll_area = QScrollArea()
        layout = QGridLayout(self)
        layout.addWidget(scroll_area)

        scroll_widget = QWidget()
        scroll_layout = QFormLayout(scroll_widget)

        for i in range(30):
            scroll_layout.addRow(QLabel('Label #{}'.format(i)), QPushButton('{}'.format(i)))
            # scroll_layout.addRow(QLabel('Label #{}'.format(i)), QLineEdit()).clicked.connect(print(scroll_layout.addRow(QLabel('Label #{}'.format(i)), QLineEdit())))




        scroll_area.setWidget(scroll_widget)

        QScroller.grabGesture(
            scroll_area.viewport(), QScroller.LeftMouseButtonGesture
        )
示例#6
0
	def __init__(self, parent=None):
		super().__init__(parent)
		self._customStyleSheet = ''
		self._useInlineSelectMode = False
		self.setStyle(QStyleFactory.create('Fusion')) #Fix bug where scrollbar background is stippled.
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		#Set up scroll on jogwheel.
		self.setMouseTracking(False) #Something do do with the scroller?
		self.setUniformItemSizes(True) #This enables the view to do some optimizations for performance purposes.
		self.setHorizontalScrollMode(self.ScrollPerPixel) #Make grab gesture work, otherwise moves dropdown 1 entry per pixel dragged.
		self.setVerticalScrollMode(self.ScrollPerPixel)
		self.setAttribute(Qt.WA_AcceptTouchEvents, True) #Enable touch gestures according to http://doc.qt.io/qt-5/qtouchevent.html#enabling-touch-events, which appears to be lieing.
		self.setDragDropMode(self.NoDragDrop)
		self.setMovement(self.Static)
		
		#Only works in Qt ≥ v5.10.
		#self.jogWheelClick.connect(lambda: self.injectKeystrokes(Qt.Key_Enter))
		
		self.jogWheelClick.connect(self.onJogWheelClick)
		self.jogWheelLowResolutionRotation.connect(self.onJogWheelRotate)
		
		#Add drag-to-scroll to dropdown menus.
		QScroller.grabGesture(self.viewport(), QScroller.LeftMouseButtonGesture) #DDR 2019-01-15: Defaults to TouchGesture - which should work, according to WA_AcceptTouchEvents, but doesn't.
		scroller = QScroller.scroller(self.viewport())
		properties = scroller.scrollerProperties()
		properties.setScrollMetric(properties.AxisLockThreshold, 0.0)
		properties.setScrollMetric(properties.DragStartDistance, 0.010) #default: 0.005 - Set to 0.010, since if the scroll starts horizontally it goes into a weird selection mode. Initially tweaked for "feel" to 0.003, before knowledge of this issue.
		properties.setScrollMetric(properties.OvershootDragDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollTime, 0.5) #default: 0.7
		scroller.setScrollerProperties(properties)
示例#7
0
    def init_ui(self):
        self.ui = uic.loadUi(os.path.abspath("_gui/main.ui"), self)
        self.search = Search()
        self.load_form_pers(self)
        self.signal = MySignal()

        self.ui.btnSearch.clicked.connect(self.search_word)

        # Read Font-Size from Settings and apply to Result
        self.font = QtGui.QFont()
        self.font.setPointSize(int(self.db.get_property(2)))
        self.ui.txtResult.setFont(self.font)

        # MenuBar
        self.ui.menubar.setNativeMenuBar(False)
        self.txtSearch.textEdited.connect(self.txt_search_changed)

        exitAct = self.ui.actionQuit
        exitAct.setShortcut('Ctrl+Q')
        exitAct.triggered.connect(self.exit)

        zoominAct = self.ui.actionZoomIn
        zoominAct.setShortcut('Ctrl++')
        zoominAct.triggered.connect(self.zoom_in)

        zoomoutAct = self.ui.actionZoomOut
        zoomoutAct.setShortcut('Ctrl+-')
        zoomoutAct.triggered.connect(self.zoom_out)

        HistoryAct = self.ui.actionHistory
        HistoryAct.triggered.connect(self.history)

        AboutAct = self.ui.actionAbout
        AboutAct.triggered.connect(self.about)

        SettingsAct = self.ui.actionSettings
        SettingsAct.triggered.connect(self.settings_)

        self.signal.startLoading.connect(self.loading)
        self.signal.stopLoading.connect(self.stop_loading)

        self.threadpool = QThreadPool()
        self.open_thread()

        self.completer = QCompleter([])
        self.completer.setFilterMode(Qt.MatchContains)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.completer.setCompletionMode(QCompleter.PopupCompletion)
        self.completer.activated.connect(self.search_word)
        model = QStringListModel()
        self.completer.setModel(model)
        delegate = CompleterDelegate(self.ui.txtSearch)
        self.completer.popup().setItemDelegate(delegate)
        self.completer.popup().setFont(self.font)
        self.txtSearch.setCompleter(self.completer)

        self.ui.txtResult.setContextMenuPolicy(Qt.ActionsContextMenu)

        lookup = QAction("look-up", self)
        lookup.triggered.connect(self.look_up)
        self.ui.txtResult.addAction(lookup)

        self.spinner = QtWaitingSpinner(self, True, True, Qt.ApplicationModal)
        self.spinner.setInnerRadius(150)
        self.spinner.setNumberOfLines(50)
        self.spinner.setColor(QColor(230, 126, 34))

        self.ui.txtSearch.setFocus()

        self.ui.txtResult.installEventFilter(self)
        self.ui.txtResult.grabGesture(Qt.PinchGesture)
        self.ui.txtResult.grabGesture(Qt.TapAndHoldGesture)

        QScroller.grabGesture(self.txtResult.viewport(),
                              QScroller.LeftMouseButtonGesture)

        clipboard_enabled = self.db.get_property(5)
        if clipboard_enabled == '1':
            self.clip = QApplication.clipboard()
            # on Mac unfortunately this event will only be fired when the application
            # is active, i.e. not in background. On Windows it works fine. It might
            # have to come back to a timer with an endless for loop which checks with
            # paste whether something has changed. But how then to count Ctrl-C presses?
            self.clip.changed.connect(self.clipboard_changed)

            self.timer = QTimer()
            self.timer.timeout.connect(self.watch_clipboard)
            seconds = int(self.db.get_property(6))
            self.timer.start(seconds * 1000)
示例#8
0
    def initUI(self):

        self.scroll = QScrollArea(
            self
        )  # Scroll Area which contains the widgets, set as the centralWidget
        self.widget1 = QWidget(self)
        self.widget1.setStyleSheet('background-color:#FAF6F5;')
        self.widget1.resize(1024, 1800)
        # self.widget2=QWidget(self)
        # self.widget2.setStyleSheet('background-color:black;')
        # self.widget2.resize(1024,800)
        # self.widget2.move(0,500)
        self.setGeometry(100, 100, 1024, 768)
        #self.vbox = QVBoxLayout()
        #self.widget1.setLayout(self.vbox)                # Widget that contains the collection of Vertical Box
        self.epf = QLabel("", self.widget1)
        effect = QGraphicsDropShadowEffect(self.epf)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.epf.setGraphicsEffect(effect)
        self.epf.setStyleSheet((
            "QLabel{background-color:white; color: white;padding-left:8px;border-style: ridge;border-width:0px;border-radius: 10px;border-color: #008CBA;}"
        ))
        #self.epf.setStyleSheet('background-color:#4299ff;padding-left:10px;')
        self.epf.setGeometry(4, 3, 1000, 60)

        self.epf1 = QLabel("", self.widget1)
        #self.epf.setFont(QFont('Arial', 18))
        effect = QGraphicsDropShadowEffect(self.epf1)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.epf1.setGraphicsEffect(effect)
        self.epf1.setStyleSheet((
            "QLabel{background-color:#FCFCFE; color: white;padding-left:8px;border-style: ridge;border-width:0px;border-radius: 10px;border-color: #008CBA;}"
        ))
        #self.epf.setStyleSheet('background-color:#4299ff;padding-left:10px;')
        self.epf1.setGeometry(20, 93, 970, 1680)
        source_label = QLabel("Face Swap Using Youtube Videos", self.widget1)
        source_label.setStyleSheet('background-color:#FCFCFE;')
        source_label.setFont(QFont('Arial', 22))
        source_label.setGeometry(250, 113, 600, 35)

        qq = u'\u2190'
        bb = QPushButton(qq + ' Back', self.widget1)
        bb.setGeometry(20, 3, 85, 58)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(18)
        bb.setFont(font)
        bb.setStyleSheet((
            "QPushButton{background-color:white; color: black;border-style: ridge;border-width:0px;border-radius: 0px;border-color: white;}"
        ))
        #bb.clicked.connect(self.bb_onClick)
        self.epf = QLabel("", self.widget1)
        #self.epf.setFont(QFont('Arial', 18))
        effect = QGraphicsDropShadowEffect(self.epf)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.epf.setGraphicsEffect(effect)
        self.epf.setStyleSheet((
            "QLabel{background-color:white; color: white;padding-left:8px;border-style: ridge;border-width:0px;border-radius: 10px;border-color: #008CBA;}"
        ))
        #self.epf.setStyleSheet('background-color:#4299ff;padding-left:10px;')
        self.epf.setGeometry(50, 163, 900, 420)
        source_label = QLabel("Add Source Videos", self.widget1)
        source_label.setStyleSheet('background-color:white;')
        source_label.setFont(QFont('Arial', 21))
        source_label.setGeometry(100, 175, 600, 30)
        self.lineEdit1 = QLineEdit(self.widget1)
        self.lineEdit1.setEnabled(True)
        self.lineEdit1.setFont(QFont('Arial', 11))
        self.lineEdit1.setGeometry(100, 213, 650, 40)
        self.lineEdit1.setStyleSheet("background-color:white;color:black;")
        self.lineEdit1.setPlaceholderText("Enter Youtube Video Url")
        self.lineEdit1.setObjectName("lineEdit1")
        self.add_svideo = QPushButton('+', self.widget1)
        self.add_svideo.setGeometry(850, 213, 40, 40)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(18)
        self.add_svideo.setFont(font)
        self.add_svideo.setStyleSheet((
            "QPushButton{background-color:red; color: black;border-style: ridge;border-width:0px;border-radius: 20px;border-color: white;}"
        ))
        self.add_svideo.clicked.connect(self.add_svideo_onClick)

        self.del_svideo = QPushButton('-', self.widget1)
        self.del_svideo.setGeometry(800, 213, 40, 40)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(28)
        self.del_svideo.setFont(font)
        self.del_svideo.setStyleSheet((
            "QPushButton{background-color:blue; color: black;border-style: ridge;border-width:0px;border-radius: 20px;border-color: white;}"
        ))
        self.del_svideo.clicked.connect(self.del_svideo_onClick)

        self.dataView = QTreeWidget(self.widget1)
        self.dataView.setRootIsDecorated(False)
        self.dataView.setHeaderLabels(['Ref No', 'Source Videos'])
        self.dataView.header().setStyleSheet(
            'padding-top:-2px;background-color:white;font-size:21pt; font-family: Arial;border-width:1px;border-style:outset;border-color:black; '
        )
        self.dataView.setColumnCount(2)
        self.dataView.setColumnWidth(0, 100)
        self.dataView.setColumnWidth(1, 100)

        self.dataView.setStyleSheet('background-color:white;color: black;')
        self.dataView.setFont(QFont('Times New Roman', 22))

        self.dataView.setGeometry(100, 260, 800, 265)
        #self.dataView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

        QScroller.grabGesture(self.dataView.viewport(), QScroller.TouchGesture)
        #self.dataView.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        #self.dataView.itemClicked.connect(self.onItemClicked)

        self.epf = QLabel("", self.widget1)
        #self.epf.setFont(QFont('Arial', 18))
        effect = QGraphicsDropShadowEffect(self.epf)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.epf.setGraphicsEffect(effect)
        self.epf.setStyleSheet((
            "QLabel{background-color:white; color: white;padding-left:8px;border-style: ridge;border-width:0px;border-radius: 10px;border-color: #008CBA;}"
        ))
        #self.epf.setStyleSheet('background-color:#4299ff;padding-left:10px;')
        self.epf.setGeometry(50, 603, 900, 420)
        source_label = QLabel("Add Destination Videos", self.widget1)
        source_label.setStyleSheet('background-color:white;')
        source_label.setFont(QFont('Arial', 22))
        source_label.setGeometry(100, 613, 600, 30)
        self.lineEdit2 = QLineEdit(self.widget1)
        self.lineEdit2.setEnabled(True)
        self.lineEdit2.setFont(QFont('Arial', 11))
        self.lineEdit2.setGeometry(100, 653, 650, 40)
        self.lineEdit2.setStyleSheet("background-color:white;color:black;")
        self.lineEdit2.setPlaceholderText("Enter Youtube Video Url")
        self.lineEdit2.setObjectName("lineEdit2")
        self.add_dvideo = QPushButton('+', self.widget1)
        self.add_dvideo.setGeometry(850, 653, 40, 40)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(18)
        self.add_dvideo.setFont(font)
        self.add_dvideo.setStyleSheet((
            "QPushButton{background-color:red; color: black;border-style: ridge;border-width:0px;border-radius: 20px;border-color: white;}"
        ))
        self.add_dvideo.clicked.connect(self.add_dvideo_onClick)

        self.del_dvideo = QPushButton('-', self.widget1)
        self.del_dvideo.setGeometry(800, 653, 40, 40)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(28)
        self.del_dvideo.setFont(font)
        self.del_dvideo.setStyleSheet((
            "QPushButton{background-color:blue; color: black;border-style: ridge;border-width:0px;border-radius: 20px;border-color: white;}"
        ))
        self.del_dvideo.clicked.connect(self.del_dvideo_onClick)

        self.dataView1 = QTreeWidget(self.widget1)
        self.dataView1.setRootIsDecorated(False)
        self.dataView1.setHeaderLabels(['Ref No', 'Destination Videos'])
        self.dataView1.header().setStyleSheet(
            'padding-top:-2px;background-color:white;font-size:21pt; font-family: Arial;border-width:1px;border-style:outset;border-color:black; '
        )
        self.dataView1.setColumnCount(2)
        self.dataView1.setColumnWidth(0, 100)
        self.dataView1.setColumnWidth(1, 100)

        self.dataView1.setStyleSheet('background-color:white;color: black;')
        self.dataView1.setFont(QFont('Times New Roman', 22))

        self.dataView1.setGeometry(100, 700, 800, 265)

        source_label = QLabel("Picture of Person In Source Video",
                              self.widget1)
        source_label.setFont(QFont('Arial', 22))
        source_label.setStyleSheet('background-color:#FCFCFE;')
        source_label.setGeometry(100, 1113, 600, 30)
        self.lineEdit3 = QLineEdit(self.widget1)
        self.lineEdit3.setEnabled(False)
        self.lineEdit3.setFont(QFont('Arial', 11))
        self.lineEdit3.setGeometry(100, 1160, 650, 40)
        self.lineEdit3.setStyleSheet("background-color:white;color:black;")
        self.lineEdit3.setObjectName("lineEdit3")

        self.srcvideo_b = QPushButton('Select File', self.widget1)
        self.srcvideo_b.setGeometry(790, 1155, 120, 50)
        effect = QGraphicsDropShadowEffect(self.srcvideo_b)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.srcvideo_b.setGraphicsEffect(effect)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(13)
        self.srcvideo_b.setFont(font)
        self.srcvideo_b.setStyleSheet((
            "QPushButton{background-color:#333335; color: white;border-style: ridge;border-width:0px;border-radius: 3px;border-color: #008CBA;}"
        ))
        self.srcvideo_b.clicked.connect(self.srcvideo_b_onClick)

        source_label = QLabel("Picture of Person In Destination Video",
                              self.widget1)
        source_label.setFont(QFont('Arial', 22))
        source_label.setStyleSheet('background-color:#FCFCFE;')
        source_label.setGeometry(100, 1213, 600, 30)
        self.lineEdit4 = QLineEdit(self.widget1)
        self.lineEdit4.setEnabled(False)
        self.lineEdit4.setFont(QFont('Arial', 11))
        self.lineEdit4.setGeometry(100, 1260, 650, 40)
        self.lineEdit4.setStyleSheet("background-color:white;color:black;")
        self.lineEdit4.setObjectName("lineEdit4")

        self.dstvideo_b = QPushButton('Select File', self.widget1)
        self.dstvideo_b.setGeometry(790, 1255, 120, 50)
        effect = QGraphicsDropShadowEffect(self.dstvideo_b)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.dstvideo_b.setGraphicsEffect(effect)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(13)
        self.dstvideo_b.setFont(font)
        self.dstvideo_b.setStyleSheet((
            "QPushButton{background-color:#333335; color: white;border-style: ridge;border-width:0px;border-radius: 3px;border-color: #008CBA;}"
        ))
        self.dstvideo_b.clicked.connect(self.dstvideo_b_onClick)

        source_label = QLabel("Output Video in which face is to be replaced",
                              self.widget1)
        source_label.setStyleSheet('background-color:#FCFCFE;')
        source_label.setFont(QFont('Arial', 22))
        source_label.setGeometry(100, 1313, 600, 30)
        self.lineEdit5 = QLineEdit(self.widget1)
        self.lineEdit5.setEnabled(False)
        self.lineEdit5.setFont(QFont('Arial', 11))
        self.lineEdit5.setGeometry(100, 1360, 650, 40)
        self.lineEdit5.setStyleSheet("background-color:white;color:black;")
        self.lineEdit5.setObjectName("lineEdit5")

        self.output_v = QPushButton('Select File', self.widget1)
        self.output_v.setGeometry(790, 1355, 120, 50)
        effect = QGraphicsDropShadowEffect(self.output_v)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.output_v.setGraphicsEffect(effect)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(13)
        self.output_v.setFont(font)
        self.output_v.setStyleSheet((
            "QPushButton{background-color:#333335; color: white;border-style: ridge;border-width:0px;border-radius: 3px;border-color: #008CBA;}"
        ))
        self.output_v.clicked.connect(self.output_v_onClick)

        source_label = QLabel("Output Directory", self.widget1)
        source_label.setStyleSheet('background-color:#FCFCFE;')
        source_label.setFont(QFont('Arial', 22))
        source_label.setGeometry(100, 1413, 600, 30)
        self.lineEdit6 = QLineEdit(self.widget1)
        self.lineEdit6.setEnabled(False)
        self.lineEdit6.setFont(QFont('Arial', 11))
        self.lineEdit6.setGeometry(100, 1460, 650, 40)
        self.lineEdit6.setStyleSheet("background-color:white;color:black;")
        self.lineEdit6.setObjectName("lineEdit6")

        self.output_d = QPushButton('Select Folder', self.widget1)
        self.output_d.setGeometry(790, 1455, 120, 50)
        effect = QGraphicsDropShadowEffect(self.output_d)
        effect.setOffset(0, 0)
        effect.setBlurRadius(20)
        self.output_d.setGraphicsEffect(effect)
        font = QFont()
        font.setFamily("Arial")
        font.setBold(True)
        font.setWeight(50)
        font.setPointSize(13)
        self.output_d.setFont(font)
        self.output_d.setStyleSheet((
            "QPushButton{background-color:#333335; color: white;border-style: ridge;border-width:0px;border-radius: 3px;border-color: #008CBA;}"
        ))
        self.output_d.clicked.connect(self.output_d_onClick)

        self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        #self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.widget1)
        #self.scroll.setWidget(self.widget2)
        # self.scroll.setGeometry(0,0,1024,768)

        self.buttonWindow4 = QPushButton('Start', self.widget1)
        self.buttonWindow4.setGeometry(440, 1570, 215, 85)
        self.effect = QGraphicsDropShadowEffect(self.buttonWindow4)
        self.effect.setOffset(0, 0)
        self.effect.setBlurRadius(20)
        self.buttonWindow4.setGraphicsEffect(self.effect)
        self.font = QFont()
        self.font.setFamily("Arial")
        self.font.setBold(True)
        self.font.setWeight(50)
        self.font.setPointSize(18)
        self.buttonWindow4.setFont(self.font)
        self.buttonWindow4.setStyleSheet((
            "QPushButton{background-color:#3C81F8; color: black;border-style: ridge;border-width:1px;border-radius: 10px;border-color: black;}"
        ))

        #self.buttonWindow4.clicked.connect(self.buttonWindow4_onClick)

        self.setCentralWidget(self.scroll)
        self.setWindowTitle('Face Swap')

        self.dataView.itemClicked.connect(self.onItemClicked)
        self.dataView1.itemClicked.connect(self.onItemClicked1)
        self.show()
示例#9
0
    def __init__(self):
        #super(Music_Player, self).__init__()
        super().__init__()
        #set up the user interface from Designer
        self.setupUi(self)

        # this gets the inforation needed for the table
        lib = []
        directory = os.path.join(Music_Player.home_dir, "Music")

        walk = os.walk(directory)
        for root, dirs, files in walk:
            for file in files:
                path = os.path.join(root, file)
                if file.endswith(
                        '.mp3'):  # then we should add file to library\
                    song = os.path.splitext(file)[0]
                    song = song.replace('_', ' ')

                    # using eyed3 to get song info
                    audiofile = eyed3.load(path)
                    artist = audiofile.tag.artist
                    album = audiofile.tag.album
                    length_secs = audiofile.info.time_secs  # seconds
                    length_formatted = seconds_to_minutes(length_secs)

                    # list of lists with information
                    lib.append([
                        song, artist, album, length_formatted, path,
                        str(length_secs)
                    ])  # length shows seconds

        # usedfor the functions
        self.library = lib

        self.songTableWidget_tab3.setRowCount(len(lib))
        self.songTableWidget_2.setRowCount(len(lib))
        self.songTableWidget.setRowCount(len(lib))
        self.songTableWidget.setColumnHidden(4, True)  #hide path column
        self.songTableWidget.setColumnHidden(
            5, True)  #hide length column that shows seconds
        self.songTableWidget_2.setColumnHidden(4, True)  #hide path column
        self.songTableWidget_2.setColumnHidden(
            5, True)  #hide length column that shows seconds
        self.songTableWidget_tab3.setColumnHidden(4, True)  #hide path column
        self.songTableWidget_tab3.setColumnHidden(
            5, True)  #hide length column that shows seconds
        self.songTableWidget.setEditTriggers(
            QAbstractItemView.NoEditTriggers)  # no way to edit items
        self.songTableWidget_tab3.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        # setting the column widths
        self.songTableWidget.setColumnWidth(0, 220)
        self.songTableWidget.setColumnWidth(1, 160)
        self.songTableWidget.setColumnWidth(2, 165)
        self.songTableWidget.setColumnWidth(3, 60)

        # setting up touch scrolling for the songTableWidget
        scroller = QScroller.scroller(self.songTableWidget)
        QScroller.grabGesture(self.songTableWidget,
                              QScroller.LeftMouseButtonGesture)

        # setting up touch scrolling for the playlistTableWidget_2
        scroller_playlist_2 = QScroller.scroller(self.playlistTableWidget_2)
        QScroller.grabGesture(self.playlistTableWidget_2,
                              QScroller.LeftMouseButtonGesture)

        # setting up touch scrolling for the songTableWidget_2
        scroller_2 = QScroller.scroller(self.songTableWidget_2)
        QScroller.grabGesture(self.songTableWidget_2,
                              QScroller.LeftMouseButtonGesture)

        # setting up touch scrolling for the songTableWidget_tab3
        scroller_3 = QScroller.scroller(self.songTableWidget_tab3)
        QScroller.grabGesture(self.songTableWidget_tab3,
                              QScroller.LeftMouseButtonGesture)

        # populating the table
        for i in range(len(lib)):  #number of rows
            for k in range(6):  # there are 6 columns
                item = QTableWidgetItem(lib[i][k])
                item2 = QTableWidgetItem(lib[i][k])
                item3 = QTableWidgetItem(lib[i][k])
                self.songTableWidget.setItem(i, k, item)
                self.songTableWidget_tab3.setItem(i, k, item2)  # for tab3
                self.songTableWidget_2.setItem(i, k, item3)

        self.songTableWidget.sortItems(0, Qt.AscendingOrder)
        self.songTableWidget_tab3.sortItems(0, Qt.AscendingOrder)  # tab 3

        # add the check mark boxes so they don't only appear when the song is played for the first time
        for i in range(self.songTableWidget.rowCount()):
            self.songTableWidget.item(i, 0).setCheckState(Qt.Unchecked)
            self.songTableWidget_2.item(i, 0).setCheckState(Qt.Unchecked)

        # setting up media Player
        self.player = QMediaPlayer(None)

        if not os.path.exists("log.txt"):
            with open("log.txt", 'w') as f:
                pass
        # the time doesn't work but the row does
        # this will load the last song played into the media player, though time will start from 0
        with open("log.txt", 'r') as f:
            info = f.read()

        if info:
            row = int(info.split(',')[0])
            self.time = int(
                info.split(',')[1]
            )  # used in mediaStatusChanged to allow for the startup time
            song_path = self.songTableWidget.item(row, 4).text()
            self.player.setMedia(QMediaContent(QUrl.fromLocalFile(song_path)))
            #self.player.play()

            # used by mediaStatusChanged to load in the correct place the player left off from
            #self.startup = 1

        else:
            row = 0
            default_song_path = self.songTableWidget.item(0, 4).text()
            self.player.setMedia(
                QMediaContent(QUrl.fromLocalFile(default_song_path)))

        # make adjustments
        self.volumeSlider.setMaximum(100)
        self.volumeSlider.setSliderPosition(100)
        self.volumeLabel.setText(str(100))

        self.songSlider.setMinimum(0)
        self.songSlider.setMaximum(
            int(self.songTableWidget.item(row, 5).text()))

        self.endLabel.setText(self.songTableWidget.item(row, 3).text())
        self.songPlayingLabel.setText(self.songTableWidget.item(row, 0).text())

        # tab 3 signals and slots
        self.saveButton_tab3.clicked.connect(self.save_click)
        self.searchEdit_tab3.textChanged.connect(self.search_edit)

        #conncect buttons
        self.volumeSlider.valueChanged.connect(self.volume_change)
        self.playButton.clicked.connect(self.play_click)
        self.songTableWidget.cellDoubleClicked.connect(self.double_click)
        self.player.stateChanged.connect(
            self.state_changed)  # playing, paused, no media
        self.player.positionChanged.connect(self.position_changed)
        self.player.mediaStatusChanged.connect(
            self.media_status)  # #loading media, end of media, etc.
        self.player.currentMediaChanged.connect(
            self.song_changed)  # when the song changes
        self.songSlider.sliderMoved.connect(self.slider_moved)
        self.songSlider.sliderReleased.connect(self.slider_released)
        self.nextButton.clicked.connect(self.next)
        self.prevButton.clicked.connect(self.prev)

        ##################################################################
        ###########################################################
        #################### tab 2 #############################\

        self.finaldeleteButton_2.setVisible(False)

        self.player_2 = QMediaPlayer(None)
        self.player_2.setVolume(100)

        # make adjustments
        self.volumeSlider_2.setMaximum(100)
        self.volumeSlider_2.setSliderPosition(100)
        self.volumeLabel_2.setText(str(100))

        self.endLabel_2.setText(self.songTableWidget_2.item(0, 3).text())
        self.songPlayingLabel_2.setText(
            self.songTableWidget_2.item(0, 0).text())

        self.playlistTableWidget_2.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.songTableWidget_2.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        #conncect buttons
        self.volumeSlider_2.valueChanged.connect(self.volume_change_2)
        self.playButton_2.clicked.connect(self.play_click_2)
        self.songTableWidget_2.cellDoubleClicked.connect(self.double_click_2)
        self.player_2.stateChanged.connect(
            self.state_changed_2)  # playing, paused, no media
        self.player_2.positionChanged.connect(self.position_changed_2)
        self.player_2.mediaStatusChanged.connect(
            self.media_status_2)  # #loading media, end of media, etc.
        self.player_2.currentMediaChanged.connect(
            self.song_changed_2)  # when the song changes
        self.songSlider_2.sliderMoved.connect(self.slider_moved_2)
        self.songSlider_2.sliderReleased.connect(self.slider_released_2)
        self.nextButton_2.clicked.connect(self.next_2)
        self.prevButton_2.clicked.connect(self.prev_2)

        # if there are playlists present on the system we want to list them
        files = os.listdir(Music_Player.home_dir +
                           "/Desktop/music_player/playlists")
        if files:
            self.playlistTableWidget_2.setRowCount(len(files))
            playlist_names = [os.path.splitext(file)[0] for file in files]

            x = 0
            for file in files:
                with open(
                        Music_Player.home_dir +
                        '/Desktop/music_player/playlists/{}'.format(file),
                        'r') as f:
                    lines = f.readlines()
                    amount_of_songs = lines[-2]
                    date_added = lines[-1]
                playlist_name = os.path.splitext(file)[0]
                item_1 = QTableWidgetItem(playlist_name)
                item_2 = QTableWidgetItem(amount_of_songs)
                item_3 = QTableWidgetItem(date_added)
                self.playlistTableWidget_2.setItem(x, 0, item_1)
                self.playlistTableWidget_2.setItem(x, 1, item_2)
                self.playlistTableWidget_2.setItem(x, 2, item_3)
                x = x + 1

        self.playlistTableWidget_2.cellDoubleClicked.connect(
            self.choose_playlist)
        self.playlist_button_2.clicked.connect(self.back_to_playlists)
        self.deleteButton_2.clicked.connect(self.delete_button_2)
        self.finaldeleteButton_2.clicked.connect(self.finaldelete_clicked_2)
示例#10
0
文件: about.py 项目: rewisch/ReDict
 def init_ui(self):
     self.ui = uic.loadUi(os.path.abspath('_gui/about.ui'), self)
     QScroller.grabGesture(self.textBrowser.viewport(),
                           QScroller.LeftMouseButtonGesture)
     self.ui.show()
示例#11
0
文件: utils.py 项目: skylning/Roam
def install_touch_scroll(widget) -> None:
    """
    Install the touch events on a widget so it can scroll with touch events
    :param widget: The widget to install the touch events on.
    """
    QScroller.grabGesture(widget, QScroller.TouchGesture)
示例#12
0
    def __init__(self, cam: Camera, shutter: img_viewer.Shutter):
        super().__init__()
        self._init_camera(cam)
        self._shutter = shutter
        self._shutter.captured.connect(
            lambda img: self._display_image(img, CAPTURE_PREVIEW_TIMEOUT))

        self.previewing = False

        # Setup UI
        self.setupUi(self)

        self.widgetImgViewer.set_camera(cam)

        self._hide_image_timer = QTimer(self)
        self._hide_image_timer.timeout.connect(self._hide_image)

        self.btnShutter.clicked.connect(self.pressed_shutter)
        self.btnTogglePreview.clicked.connect(self.toggle_preview)

        # Tabs:
        # (0) Image settings
        self.comboboxIso.currentTextChanged.connect(
            lambda val: self.cam.set_iso(int(val)))
        self.sliderAwbGain.valueChanged.connect(
            lambda v: self.cam.set_awb_gain(float(v) / 10))
        self.comboboxAwbMode.currentTextChanged.connect(self._set_awb_mode)
        self.sliderBrightness.valueChanged.connect(
            lambda val: self.cam.set_brightness(int(val)))
        self.comboboxExposure.currentTextChanged.connect(
            lambda v: self.cam.set_exposure(v.lower()))
        self.comboboxShutterSpeed.currentTextChanged.connect(
            lambda val: self.cam.set_shutter_speed(val))
        self.comboboxDelay.currentTextChanged.connect(
            lambda val: self._shutter.set_delay(int(val)))
        # (1) Timelapse
        self.spinboxTimelapseDelay.valueChanged.connect(lambda val: print(val))
        self.spinboxTimelapseDelay.setEnabled(False)
        self.spinboxTimelapseCount.valueChanged.connect(lambda val: print(val))
        self.spinboxTimelapseCount.setEnabled(False)
        # (2) Other
        self.checkboxLed.stateChanged.connect(self._set_led)
        self.checkboxDenoise.stateChanged.connect(lambda val: print(val))
        self.checkboxDenoise.setEnabled(False)
        self.buttonMaxFps.clicked.connect(self.cam.maximize_fps)
        self.comboboxImageFormat.currentTextChanged.connect(
            self._set_extension)
        self._set_extension(self.comboboxImageFormat.currentText())

        self.sliderSharpness.valueChanged.connect(lambda val: print(val))
        self.sliderSharpness.setEnabled(False)
        self.sliderSaturation.valueChanged.connect(lambda val: print(val))
        self.sliderSaturation.setEnabled(False)
        self.comboboxMetermode.currentTextChanged.connect(
            lambda val: print(val))
        self.comboboxMetermode.setEnabled(False)
        self.sliderContrast.valueChanged.connect(
            lambda val: self.cam.set_contrast(int(val)))
        self.comboboxDrc.currentTextChanged.connect(lambda val: print(val))
        self.comboboxDrc.setEnabled(False)
        # enable scroll on the last tab
        QScroller.grabGesture(self.scrollAreaOtherSettings.viewport(),
                              QScroller.LeftMouseButtonGesture)
        # (3) Info
        self.update_info()  # TODO call this periodically?