pyqt

QObject: Cannot create children for a parent that is in a different thread. PyQt5

那年仲夏 提交于 2020-07-23 06:38:22
问题 When I try to change the text of a text browser which is inside a scroll area I get this PyQt5 threading error: QObject: Cannot create children for a parent that is in a different thread. (Parent is QTextDocument(0x212e3bb1f50), parent's thread is QThread(0x212e171e220), current thread is QThread(0x212e41dc7e0) I assume it is because of the scroll area and that I don't have access to it from the thread I am trying to change this from and it works if I put the same bit of code... filepath = ".

QObject: Cannot create children for a parent that is in a different thread. PyQt5

倾然丶 夕夏残阳落幕 提交于 2020-07-23 06:35:44
问题 When I try to change the text of a text browser which is inside a scroll area I get this PyQt5 threading error: QObject: Cannot create children for a parent that is in a different thread. (Parent is QTextDocument(0x212e3bb1f50), parent's thread is QThread(0x212e171e220), current thread is QThread(0x212e41dc7e0) I assume it is because of the scroll area and that I don't have access to it from the thread I am trying to change this from and it works if I put the same bit of code... filepath = ".

Make button execute a script

拟墨画扇 提交于 2020-07-22 21:34:54
问题 I've a script that is organizing folders. I want to improve it so I'm trying to make GUI. I've spend more than a week on It and I can't find a solution... How do you mix link properly the second and third script to integrate them in the main script ? And then, how do you compile three file in one executable ? Here is the main script #Introduction of the code """The aim of this script is to organize your download folder by placing files in a sub-folder regarding of their extension""" import os

Move Cursor Line Position QTextEdit

纵饮孤独 提交于 2020-07-22 09:29:04
问题 Text editor: Sublime Text 3 Python Version: 3.6 UTF-8 PyQt5 I am making a notepad in PyQt5 and I am making an option to be able to navigate between the lines and, of course, I need to move the text editor cursor so that it is in the line that the user wants, and the problem is that, nose how to move the cursor of a TextEdit. I have used several methods and none works. Simply or does not move the cursor or an error jumps. This is the full code: https://github.com/MasPot4/Bloc-de-Notas This is

Can't add extension to file in QFileDialog

给你一囗甜甜゛ 提交于 2020-07-21 11:23:05
问题 I've got a problem with saving file with extension (get path to file and append extension) in PyQt4 with QFileDialog. My Python code looks like that: dialog = QtGui.QFileDialog() dialog.setDefaultSuffix(".json") file = dialog.getSaveFileName(None, "Title", "", "JSON (.json)") It works, path is correct, dialog title and filter are in dialog window, but second line was ignored. File doesn't have any extension. How to add extension by default? What am I doing wrong? 回答1: Calling setDefaultSuffix

Can't add extension to file in QFileDialog

[亡魂溺海] 提交于 2020-07-21 11:20:46
问题 I've got a problem with saving file with extension (get path to file and append extension) in PyQt4 with QFileDialog. My Python code looks like that: dialog = QtGui.QFileDialog() dialog.setDefaultSuffix(".json") file = dialog.getSaveFileName(None, "Title", "", "JSON (.json)") It works, path is correct, dialog title and filter are in dialog window, but second line was ignored. File doesn't have any extension. How to add extension by default? What am I doing wrong? 回答1: Calling setDefaultSuffix

How to properly set parent of a widget in Pyqt?

旧巷老猫 提交于 2020-07-21 04:22:06
问题 I have the following code from PyQt5 import QtCore, QtGui, QtWidgets from mw import Ui_MainWindow as mwin from wd import Ui_Form as wdg class widget(QtWidgets.QWidget): def __init__(self,parent = None): super(widget,self).__init__(parent) self.ui = wdg() self.ui.setupUi(self) self.show() class Main(QtWidgets.QMainWindow): def __init__(self,parent = None): super(Main,self).__init__(parent) self.ui = mwin() self.ui.setupUi(self) self.show() w = widget(self) import sys if __name__ == '__main__':

Get printable name of any QKeyEvent key value

瘦欲@ 提交于 2020-07-19 04:42:25
问题 I'm using PyQt5. When I write a keyPressEvent handler, I would like to be able to print, for debugging purposes, a human-readable description of what keys were pressed. I want to be able to print such a thing no matter what, regardless of how many keys were pressed in the event, or whether they were modifiers or "regular" keys. I have seen this previous question in which the accepted answer (using C++) suggests creating a QKeySequence and using its .toString method. I can do this like this:

pyqt: A correct way to connect multiple signals to the same function in pyqt (QSignalMapper not applicable)

雨燕双飞 提交于 2020-07-17 12:41:39
问题 I've ready many posts on how to connect multiple signals to the same event handler in python and pyqt. For example, connecting several buttons or comboboxes to the same function. Many examples show how to do this with QSignalMapper, but it is not applicable when the signal carries a parameter, as with combobox.currentIndexChanged Many people suggest it can be made with lambda. It is a clean and pretty solution, I agree, but nobody mentions that lambda creates a closure, which holds a

pyqt: A correct way to connect multiple signals to the same function in pyqt (QSignalMapper not applicable)

筅森魡賤 提交于 2020-07-17 12:40:25
问题 I've ready many posts on how to connect multiple signals to the same event handler in python and pyqt. For example, connecting several buttons or comboboxes to the same function. Many examples show how to do this with QSignalMapper, but it is not applicable when the signal carries a parameter, as with combobox.currentIndexChanged Many people suggest it can be made with lambda. It is a clean and pretty solution, I agree, but nobody mentions that lambda creates a closure, which holds a