pyqt

PyQt5: QPushButton double click?

╄→尐↘猪︶ㄣ 提交于 2021-02-04 21:22:14
问题 I can't find a good answer for this: is there a way for double click to execute a certain function, and single click one other function?? For example: def func1(self): print('First function') def func2(self): print('Second function') self.ui.button.clicked.connect(self.func1) self.ui.button.doubleClicked.connect(self.func2) I've seen double clicking is possible for the QTreeview but not a QPushButton . Thanks! 回答1: You can add the functionality easily yourself by extending QPushButton class:

How to kill the QRunnable in PyQt5?

与世无争的帅哥 提交于 2021-02-04 21:05:36
问题 I have an app with two buttons start and end . The start button will start a thread, which runs the audio recording function. This function is written using sounddevice and soundfile libraries. The audio recording can take place for an arbitary duration and the user can stop anytime by pressing ctrl+c . So, now I want to implement a function for the end button to stop the thread which started by pressing start button or the function can send ctrl+c signal to the thread. So, that the current

PyQt frameless window at specified coordinates

自古美人都是妖i 提交于 2021-02-04 20:10:36
问题 After much googling I'm aware that I need to use self.setWindowFlags(QtCore.Qt.FramelessWindowHint) to generate a frameless window, and some variation of the co-ordinates (0,0) to place it in the upper left corner of the screen. The problem I'm having is that everywhere that I've tried using this code, it generates errors, even in my sparse existing code: from PyQt4 import QtCore, QtGui from ui.mainwindow import MainWindow if __name__ == "__main__": import sys app = QtGui.QApplication(sys

PyQt frameless window at specified coordinates

白昼怎懂夜的黑 提交于 2021-02-04 20:09:23
问题 After much googling I'm aware that I need to use self.setWindowFlags(QtCore.Qt.FramelessWindowHint) to generate a frameless window, and some variation of the co-ordinates (0,0) to place it in the upper left corner of the screen. The problem I'm having is that everywhere that I've tried using this code, it generates errors, even in my sparse existing code: from PyQt4 import QtCore, QtGui from ui.mainwindow import MainWindow if __name__ == "__main__": import sys app = QtGui.QApplication(sys

PyQt frameless window at specified coordinates

∥☆過路亽.° 提交于 2021-02-04 20:07:52
问题 After much googling I'm aware that I need to use self.setWindowFlags(QtCore.Qt.FramelessWindowHint) to generate a frameless window, and some variation of the co-ordinates (0,0) to place it in the upper left corner of the screen. The problem I'm having is that everywhere that I've tried using this code, it generates errors, even in my sparse existing code: from PyQt4 import QtCore, QtGui from ui.mainwindow import MainWindow if __name__ == "__main__": import sys app = QtGui.QApplication(sys

PyQt frameless window at specified coordinates

為{幸葍}努か 提交于 2021-02-04 20:05:07
问题 After much googling I'm aware that I need to use self.setWindowFlags(QtCore.Qt.FramelessWindowHint) to generate a frameless window, and some variation of the co-ordinates (0,0) to place it in the upper left corner of the screen. The problem I'm having is that everywhere that I've tried using this code, it generates errors, even in my sparse existing code: from PyQt4 import QtCore, QtGui from ui.mainwindow import MainWindow if __name__ == "__main__": import sys app = QtGui.QApplication(sys

Class to position a window on the screen

爷,独闯天下 提交于 2021-02-04 17:38:55
问题 I am new to Python and this is my fist Python class. I am using PyQt4 framework on Windows 7. I don't know whether the few lines of code below is correctly written or not. I want to modify it further as: In the arguments, I want to pass the name of another opened Window (.py) on the screen. I will be passing the x-coord., y-coord. and the name of the window to position on the screen. How to modify the code to fulfill these requirements? Edited Further class PositionWindow: def __init__(self,

Displaying other language characters in PyQt

可紊 提交于 2021-02-04 16:47:43
问题 Is there a way to display other language characters in PyQt4? and if there is, what's the approach/direction that I should take? Thanks in advance. 回答1: Qt uses Unicode and should be able to display (Unicode) text in any language you have a suitable font for. For example, Roberto Alesina's simple "Hello World" program on the PyQt Wiki -- which I transcribe for readability (and w/o the comments for brevity) since it's pretty unreadable in the wiki -- should let you use as the button's text any

Displaying other language characters in PyQt

自古美人都是妖i 提交于 2021-02-04 16:47:19
问题 Is there a way to display other language characters in PyQt4? and if there is, what's the approach/direction that I should take? Thanks in advance. 回答1: Qt uses Unicode and should be able to display (Unicode) text in any language you have a suitable font for. For example, Roberto Alesina's simple "Hello World" program on the PyQt Wiki -- which I transcribe for readability (and w/o the comments for brevity) since it's pretty unreadable in the wiki -- should let you use as the button's text any

How to capture button click from customized QMessageBox?

穿精又带淫゛_ 提交于 2021-02-04 16:01:06
问题 How can I modify the code for the customized QMessageBox below in order to know whether the user clicked 'yes' or 'no'? from PySide import QtGui, QtCore # Create a somewhat regular QMessageBox msgBox = QtGui.QMessageBox( QtGui.QMessageBox.Question, "My title", "My text.", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No ) # Get the layout question_layout = msgBox.layout() # Additional widgets to add to the QMessageBox qlabel_workspace_project = QtGui.QLabel('Some random data window:') qtextedit