コード例 #1
0
 def mousePressEvent(self, event):
     x = event.x()
     y = event.y()
     if event.buttons() == QtCore.Qt.LeftButton and 0 < y < 60:
         self.currentPos = event.pos()
         self.setCursor(Qt.QCursor(Qt.Qt.OpenHandCursor))
         self.flag = True
     elif event.buttons() == QtCore.Qt.LeftButton and event.pos() in self._bottom_rect:
         self.resizing = True
         self.setCursor(Qt.QCursor(Qt.Qt.SizeVerCursor))
コード例 #2
0
def wait_cursor(value, **kwargs):
    """
    Set / clear "wait" override cursor for the application.

    The function can be called recursively: each request to set "wait"
    cursor must eventually be followed by a corresponding request to
    restore cursor.

    To unconditionally remove "wait" cursor, specify *True* value as the
    *force* keyword argument.

    Arguments:
        value (bool): *True* to set "wait" cursor; *False* to clear it.
        **kwargs: Keyword arguments.

    The following named parameters can be passed via `**kwargs`:

    - *force* (bool): Forces complete clearing of "wait" cursor;
      applicable only when *value* is *False*.
    """
    if value:
        Q.QApplication.setOverrideCursor(Q.QCursor(Q.Qt.WaitCursor))
    else:
        if Q.QApplication.overrideCursor() is not None:
            Q.QApplication.restoreOverrideCursor()
        if kwargs.get("force", False):
            while Q.QApplication.overrideCursor() is not None:
                Q.QApplication.restoreOverrideCursor()
コード例 #3
0
 def mousePressEvent(self, event):
     x = event.x()
     y = event.y()
     if event.buttons() == QtCore.Qt.LeftButton and 0 < y < 30:
         self.currentPos = event.pos()
         self.setCursor(Qt.QCursor(Qt.Qt.SizeAllCursor))
         self.flag = True
コード例 #4
0
ファイル: generic.py プロジェクト: nekomona/ManaLEDCaster
 def mousePressEvent(self, event):
     if self.isEnabled():
         self.mouseDown = True
         self.xpress = event.globalX()
         self.ypress = event.globalY()
         self.setCursor(Qt.QCursor(QtCore.Qt.BlankCursor))  # Hide cursor
         self.move = 0
         if self.pairedLine:
             self.baseValue = str2float(self.pairedLine.text())
コード例 #5
0
ファイル: generic.py プロジェクト: nekomona/ManaLEDCaster
    def __init__(self, *args, **kwargs):
        self.mouseScale = 0.1
        self.pairedLine = None
        self.intValue = False

        self.mouseDown = False
        retval = super().__init__(*args, **kwargs)
        self.setCursor(Qt.QCursor(QtCore.Qt.SizeHorCursor))
        return retval
コード例 #6
0
    def __init__(self, topwidget, bottomwidget, toptext='', bottomtext=''):
        """Constructs the widget
        
        Parameters
        ----------
        topwidget : QWidget
            Widget to display on top
        bottomwidget : QWidget
            Widget to display on bottom
        toptext : str, optional
            Text to display when top is collapsed, by default ''
        bottomtext : str, optional
            Text to display when bottom is collapsed, by default ''
        """
        # Create child class
        QtWidgets.QSplitter.__init__(self, QtCore.Qt.Vertical)

        self.addWidget(topwidget)
        self.addWidget(bottomwidget)

        self.toptext = toptext
        self.bottomtext = bottomtext

        self.splitterMoved.connect(self.on_moved)

        handle_layout = QtWidgets.QVBoxLayout()
        handle_layout.setContentsMargins(0, 0, 0, 0)
        self.setHandleWidth(5)

        self.button = QtWidgets.QToolButton()
        self.button.setStyleSheet('background-color: rgba(255, 255, 255, 0)')

        uplogo = self.style().standardIcon(
            QtWidgets.QStyle.SP_TitleBarShadeButton)
        downlogo = self.style().standardIcon(
            QtWidgets.QStyle.SP_TitleBarUnshadeButton)
        self.upicon = QtGui.QIcon(uplogo)
        self.downicon = QtGui.QIcon(downlogo)
        self.noicon = QtGui.QIcon()
        self.icon = self.noicon

        self.button.setIcon(self.icon)
        self.button.clicked.connect(self.handleSplitterButton)
        self.button.setCursor(Qt.QCursor(QtCore.Qt.PointingHandCursor))

        self.label = QtWidgets.QLabel('')

        handle_layout.addLayout(HLayout([self.button, self.label]))
        handle_layout.addItem(
            QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Maximum,
                                  QtWidgets.QSizePolicy.Expanding))

        handle = self.handle(1)
        handle.setLayout(handle_layout)
コード例 #7
0
ファイル: simlty_GUI.py プロジェクト: jnettels/lpagg
    def perform_time_shift(self):
        """Perform the time shift simulataneity calculation.

        Callback for the button that starts the simultaneity calculation.

        To prevent the GUI from becoming unresponsive, an extra object for
        the task is created and moved to a thread of its own. Several
        connections for starting and finishing the tasks need to be made.
        """
        load_dir = './'
        # if getattr(sys, 'frozen', False):  # If frozen with cx_Freeze
        #     logger.debug(os.getcwd())
        #     load_dir = os.path.expanduser('~user')

        self.file = QtWidgets.QFileDialog.getOpenFileName(
            self, 'Bitte Exceldatei mit Zeitreihe auswählen', load_dir,
            'Excel Datei (*.xlsx)')[0]

        if self.file == '' or self.file is None:
            return

        self.start_button.setEnabled(False)
        self.statusBar().showMessage('Bitte warten...')
        Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor))

        try:  # Thread magic to prevent unresponsive GUI
            self.objThread = QtCore.QThread()
            self.obj = self.simultaneity_obj(self.settings, self.file,
                                             self.set_hist)
            self.obj.moveToThread(self.objThread)
            self.objThread.started.connect(self.obj.run)
            self.obj.failed.connect(self.fail)
            self.obj.failed.connect(self.objThread.quit)
            self.obj.finished.connect(self.done)
            self.obj.finished.connect(self.objThread.quit)
            self.objThread.start()

        except Exception as e:
            logger.exception(e)
            Qt.QApplication.restoreOverrideCursor()
            self.statusBar().showMessage('')
            self.start_button.setEnabled(True)
            QtWidgets.QMessageBox.critical(self, 'Fehler', str(e),
                                           QtWidgets.QMessageBox.Ok)
        else:
            logger.debug('Waiting for return of results...')
            pass
コード例 #8
0
ファイル: generic.py プロジェクト: nekomona/ManaLEDCaster
 def setEnabled(self, val):
     if val:
         self.setCursor(Qt.QCursor(QtCore.Qt.SizeHorCursor))
     else:
         self.setCursor(Qt.QCursor(QtCore.Qt.ArrowCursor))
     super().setEnabled(val)
コード例 #9
0
 def mouseReleaseEvent(self, event):
     self.setCursor(Qt.QCursor(Qt.Qt.ArrowCursor))
     self.flag = False
コード例 #10
0
 def mouseMoveEvent(self, event):
     if self.flag == True:
         self.move(Qt.QPoint(self.pos() + event.pos() - self.currentPos))
         self.setCursor(Qt.QCursor(Qt.Qt.SizeAllCursor))
コード例 #11
0
 def mouseReleaseEvent(self, QMouseEvent):  # 鼠标释放操作
     self.flag = False
     self.setCursor(Qt.QCursor(Qt.Qt.ArrowCursor))  # 设置光标为箭头
コード例 #12
0
 def mousePressEvent(self, QMouseEvent):  # 鼠标按下操作
     if QMouseEvent.button() == Qt.Qt.LeftButton:
         self.flag = True
         self.m_Position = QMouseEvent.globalPos() - self.pos()
         QMouseEvent.accept()
         self.setCursor(Qt.QCursor(Qt.Qt.OpenHandCursor))  # 设置光标为手型
コード例 #13
0
    def __init__(self,parent = None):
        super(QtWidgets.QMainWindow,self).__init__(parent)

        self.setupUi(self)
        self._padding = 3
        self._bottom_rect = [QtCore.QPoint(x, y) for x in range(1, self.width() - self._padding)
                             for y in range(self.height() - self._padding-12, self.height() -11)]
        self.flag = False
        self.LM = True
        self.resizing = False

        self.setWindowFlags(Qt.Qt.FramelessWindowHint)
        self.setAttribute(Qt.Qt.WA_TranslucentBackground)
        self.currentIndex = None
        self.currentListMusicIndex = None
        self.user = ""
        self.isConfigEdited = False
        self.listShowing = False
        self.musiclistShowing = True
        self.localShowing = True

        self.playing = False
        self.MyList = ListOperation.loadList()
        self.musicStorage = "."
        self.MyMusic = []
        self.ConfigInfo = {}
        self.customInfo = {}
        self.initConfigs()

        self.eTimeLabel.move(self.eTimeLabel.x()+40, self.eTimeLabel.y())
        self.adD = addToListDialog.ListDialog(self.MyList)
        self.adD.hide()
        self.config = configDialog.configWidget(self)
        self.config.hide()
        self.scroll = QtWidgets.QScrollBar()
        self.scroll.setStyleSheet("""QScrollBar:vertical {     
                           border-radius:4px;         
                           border: none;
                           background:transparent;
                           width:10px;
                           height:410px;

                       }
                       QScrollBar::down-arrow{height:0px}
                       QScrollBar::handle:vertical {
                       border-radius:4px;
                       border:none;
                       background:rgba(112,112,112,0.5);

                       }
                       QScrollBar::down-arrow{width:0px}
               """)
        self.sure_3 = sureDialog.sureDialog(self)
        self.sure_3.hide()
        self.sure_2 = sureDialog.sureDialog(self)
        self.sure_2.hide()
        self.sure = sureDialog.sureDialog(self)
        self.sure.hide()
        self.scroll.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
        self.listMusicWidget.setVerticalScrollBar(self.scroll)
        self.pl = playListDialog.PlayListWidget(self)
        self.pl.resize(550,self.pl.height())
        self.pl.hide()
        self.pSlider = playListDialog.MyPSlider(Qt.Qt.Horizontal, self.LowerNav)
        self.pSlider.move(105, 43)
        self.pSlider.setWindowFlags(Qt.Qt.WindowStaysOnTopHint)
        self.vSlider = playListDialog.MySlider(Qt.Qt.Horizontal, self.LowerNav)
        self.vSlider.move(830, 34)

        self.MusicWidget = musicWidget.MusicWidget(self.Leftnav,self)
        self.MusicWidget.move(0, 333)
        self.MusicWidget.resize(200, 300)
        self.line_12.setCursor(Qt.QCursor(Qt.Qt.SizeVerCursor))

        self.listMusicWidget.setHorizontalHeaderItem(0, QtWidgets.QTableWidgetItem("  音乐标题"))
        self.listMusicWidget.horizontalHeaderItem(0).setTextAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter)
        self.listMusicWidget.setHorizontalHeaderItem(1, QtWidgets.QTableWidgetItem("  歌手"))
        self.listMusicWidget.horizontalHeaderItem(1).setTextAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter)
        self.listMusicWidget.setHorizontalHeaderItem(2, QtWidgets.QTableWidgetItem("  专辑"))
        self.listMusicWidget.horizontalHeaderItem(2).setTextAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter)
        self.listMusicWidget.setHorizontalHeaderItem(3, QtWidgets.QTableWidgetItem("  时长"))
        self.listMusicWidget.horizontalHeaderItem(3).setTextAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter)
        self.listMusicWidget.horizontalHeader().setDisabled(True)
        self.listMusicWidget.setColumnWidth(0, 330)
        self.listMusicWidget.setColumnWidth(1, 260)
        self.listMusicWidget.setColumnWidth(2, 290)
        self.listMusicWidget.setColumnWidth(3, 110)

        self.picLabel = MyLabel(self)
        self.popMenu = QtWidgets.QMenu()
        self.popMenu.addAction(self.P)
        self.popMenu.addAction(self.D)
        self.popMenu.setStyleSheet("QMenu{background-color:rgb(252, 239, 232);"
                                   "font-size:16px;padding:3px 10px;"
                                   "font-family:\"微软雅黑\";"
                                   "color:rgb(112,112,112);"
                                   "border:1px solid #DBDBDB}"
                                   "QMenu::item{height:18px;"
                                   "background:transparent;"
                                   " border-bottom:1px solid #DBDBDB;"
                                   "padding:6px}"
                                   "QMenu::item:selected{background:rgba(245, 231, 236, 220);"
                                   "color:black }")
        self.listMusicWidget.customContextMenuRequested[QtCore.QPoint].connect(self.show_content_menu)
        self.listMusicWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.D.triggered.connect(self.delete_from_list)
        self.P.triggered.connect(self.play_to_list)

        # connect slot with signal
        self.picLabel.setStyleSheet('border: 1px groove #e4c6d0;')
        self.picLabel.setScaledContents(True)
        self.editListButton.hide()
        self.PlayAllButton.hide()
        # Initialize some information
        self.initMusicList()
        self.initInterfaceInfo()
        self.timesLabel.setText("播放次数:0")
        self.picLabel.setPixmap(QtGui.QPixmap("./Head/unKnown.png"))

        self.config.config_edited[dict].connect(self.edit_restart)
        self.orderChangedSignal.connect(self.pl.changeOrder)
        self.StopSearchingSingal.connect(self.MusicWidget.stop_searching)
        self.playListSignal[list, str].connect(self.pl.addListToList)
        self.PlayButton.clicked.connect(self.pl.play_it)
        self.exitButton.clicked.connect(self.myclose)
        self.hideButton.clicked.connect(self.showMinimized)
        self.vSlider.volumeChanged[float].connect(self.pl.change_volume)
        self.pSlider.valueChange[int].connect(self.updateLabel)
        self.pSlider.processChanged[float].connect(self.pl.change_progress)
        self.newListButton.clicked.connect(self.createNewList)
        self.PlaylistWidget.currentItemChanged.connect(self.updateInterface)
        self.delListButton.clicked.connect(self.deleteList)
        self.editListButton.clicked.connect(self.desChange)
        self.moveUpButton.clicked.connect(self.moveUp)
        self.configButton.clicked.connect(self.editConfig)
        self.descriptionEidt.installEventFilter(self)
        self.showListButton.clicked.connect(self.showList)
        self.NextButton.clicked.connect(self.pl.play_next)
        self.FormerButton.clicked.connect(self.pl.play_former)
        self.pl.playStarted[int,str].connect(self.pSlider.updateMax)
        self.pl.playCrushed[str].connect(self.crushed)
        self.pl.musicOutted.connect(self.music_out_of_play)
        self.MusicWidget.deleteSingal[MusicList.singleMusic].connect(self.pl.deleteMusic)
        self.MusicWidget.addToPlaySignal[MusicList.singleMusic].connect(self.pl.addToPlay)
        self.MusicWidget.addToListSignal[MusicList.singleMusic].connect(self.pl.addToList)
        self.MusicWidget.addToMusicListSignal[MusicList.singleMusic].connect(self.add_to_music_list)
        self.PlayAllButton.clicked.connect(self.playList)
        self.playOrderButton.clicked.connect(self.change_order)
        self.SoundButton.clicked.connect(self.volumeZero)
        self.PlaylistWidget.itemDoubleClicked.connect(self.playList)
        self.refreshButton.clicked.connect(self.MusicWidget.updateLocalMusic)
        self.toListButton.clicked.connect(self.list_hide)
        self.toListButton_2.clicked.connect(self.local_hide)
        self.picLabel.picChange.connect(self.change_head)
        self.searchDiskButton.clicked.connect(self.search_all)
コード例 #14
0
ファイル: generic.py プロジェクト: nekomona/ManaLEDCaster
 def mouseReleaseEvent(self, event):
     self.mouseDown = False
     self.setCursor(Qt.QCursor(QtCore.Qt.SizeHorCursor))  # Unhide cursor
     self.editFinished.emit()
コード例 #15
0
 def __init__(self,parent=None):
     super(MyLabel, self).__init__(parent)
     self.parent = parent
     self.setGeometry(227, 90, 190, 190)
     self.setCursor(Qt.QCursor(Qt.Qt.PointingHandCursor))
     self.setToolTip("修改头像")
コード例 #16
0
 def setCursorWait(self):
     """
     Changes cursor to waiting cursor.
     """
     Qt.QApplication.setOverrideCursor(Qt.QCursor(QtCore.Qt.WaitCursor))
     Qt.QApplication.processEvents()
コード例 #17
0
 def mouseMoveEvent(self, event):
     if self.flag:
         self.move(Qt.QPoint(self.pos() + event.pos() - self.currentPos))
         self.setCursor(Qt.QCursor(Qt.Qt.ClosedHandCursor))
     if self.resizing:
         self.resize(self.width(), event.pos().y())
コード例 #18
0
 def __init__(self,
              friends_info,
              my_id,
              aim_id,
              nick_name,
              age,
              gender,
              pic_byte,
              send_sockfd,
              server_addr,
              parent=None):
     super().__init__(parent)
     self.send_sockfd = send_sockfd
     self.server_addr = server_addr
     self.setStyleSheet("border:0.5px solid grey;")
     self.friends_info = friends_info
     self.my_id = my_id
     self.aim_id = aim_id
     self.resize(200, 100)
     self.head_pic_label = QLabel(self)
     filename = aim_id + '.jpg'
     f = open('temp_info/head_pic/' + filename, 'wb')
     f.write(pic_byte)
     f.close()
     path = 'temp_info/head_pic/%s' % filename
     self.head_pic_label.setPixmap(QtGui.QPixmap(path))
     self.head_pic_label.resize(80, 80)
     self.setStyleSheet('border:0px;')
     self.head_pic_label.setScaledContents(True)
     self.head_pic_label.move(5, 10)
     self.nick_name_label = QLabel(self)
     self.nick_name_label.setText(nick_name)
     self.nick_name_label.setStyleSheet("border:0px;")
     self.nick_name_label.resize(100, 20)
     self.nick_name_label.move(90, 20)
     self.id_label = QLabel(self)
     self.id_label.setText(self.aim_id)
     self.id_label.setStyleSheet('border:0px;')
     self.id_label.hide()
     self.age_label = QLabel(self)
     self.age_label.setText(age)
     self.age_label.setStyleSheet("border:0px;")
     self.age_label.resize(25, 25)
     self.age_label.move(90, 55)
     self.gender_label = QLabel(self)
     if gender == '男':
         self.gender_label.setPixmap(QtGui.QPixmap('images/08-01.png'))
     elif gender == '女':
         self.gender_label.setPixmap(QtGui.QPixmap('images/08-02.png'))
     self.gender_label.resize(20, 20)
     self.gender_label.setStyleSheet("border:0px;")
     self.gender_label.setScaledContents(True)
     self.gender_label.move(115, 60)
     self.add_btn = QPushButton(self)
     self.add_btn.setStyleSheet(
         "border-radius:3px;background-color:#009BDB;color:white;")
     self.add_btn.setText('加好友')
     self.add_btn.resize(50, 20)
     self.add_btn.setCursor(Qt.QCursor(Qt.Qt.PointingHandCursor))
     self.add_btn.move(150, 60)
     #触发事件
     self.add_btn.clicked.connect(self.request_add_friend)
コード例 #19
0
ファイル: main.py プロジェクト: kkpdata/HB-Havens
 def setCursorWait(self):
     Qt.QApplication.setOverrideCursor(Qt.QCursor(QtCore.Qt.WaitCursor))
     Qt.QApplication.processEvents()