pyside

Using QtHostinfo.lookupHost in PySide

旧巷老猫 提交于 2019-12-05 08:24:18
I am working on a project where I want to confirm the existence of a host on a local network. In the QtNetwork package in Qt, the QHostInfo::lookupHost method is a convenient way of searching for a host without needing to implement any kind of pinging or being dependent on a ping system call. Its asynchronous call makes it convenient to create a dialog waiting for the call to return with a slot in either the dialog or the main program to handle the return. From Qt's Documentation for QHostInfo: To look up a host's IP addresses asynchronously, call lookupHost(), which takes the host name or IP

Python Import Error for modules installed with Homebrew

眉间皱痕 提交于 2019-12-05 08:00:18
问题 I've already installed PySide using homebrew, but I get an error when my scripts run things such as from PySide import QtWebKit When I try brew install pyside I get an error that pyside-1.2.0 already installed When I try pip install pyside I get the following error: In file included from /Users/fitvalet/wgwt/env/build/pyside/sources/pyside/plugins/customwidgets.cpp:23: /Users/fitvalet/wgwt/env/build/pyside/sources/pyside/plugins/customwidget.h:27:10: fatal error: 'QtDesigner/QtDesigner' file

Elegant command line argument parsing for PyQt

我的梦境 提交于 2019-12-05 02:32:31
I'm writing a new PyQt app. I'm trying to do everything related to the program and ui using as much of the PyQt APIs as possible as a means to improve my knowledge of PyQt and Qt in general. The question I have is, is there an API within PyQt/Qt to handle command line argument parsing elegantly? My research so far has turned up: an example of how to make it play nice with python's opt_parser module, except it doesn't handle QApplication's built in arg parsing. PyKDE's KCmdLineArgs (which introduces an unwanted KDE dependency) it looks like KCmdLineArgs is being ported upstream for Qt5.1 as

PySide : How to get the clicked QPushButton object in the QPushButton clicked slot?

…衆ロ難τιáo~ 提交于 2019-12-04 22:04:42
问题 I am new to PySide. I want to get the QPushButton obj (such as use it to get its text) in its clicked slot. button = QtGui.QPushButton("start go") button.clicked.connect(self.buttonClick) def buttonClick(self): ... # How can I get the button object? # print button.text() how to get the text : 'start go' ? Thanks! 回答1: Here is what I did to solve the problem: button = QtGui.QPushButton("start go") button.clicked.connect(lambda: self.buttonClick(button)) def buttonClick(self, button): print

Replace CentralWidget in MainWindow

心已入冬 提交于 2019-12-04 21:22:12
问题 I'm kinda new to PySide.I have a main window object which shows one widget at a time. I've been trying to change the central widget of the QMainWindow class in order to replace the visible Widget in the window when pressing a button. The problem is that the button pressed is in the Widget class, not in the main window class. say... class App(QtGui.QMainWindow): def __init__(self): super(App, self).__init__() self.initUI() def initUI(self): self.statusBar().showMessage('Listo.') #Status Bar

PyQT Listen for SystemWide Key and mouse events

断了今生、忘了曾经 提交于 2019-12-04 20:39:03
I'm trying to write an application that listens for systemwide key and mouse events matching certain patterns and responds to them. I plan on making the application run in the background. No it is not a keylogger, it is a legit application with a good intent. I'm planning to user PyQT or more likely PySide for this application. It's fairly simple to listen to events when an application window is focused, but how would I do it when there is no window at all? I'm specifically working on OS X, but I would prefer a cross platform solution. I think you'll almost certainly need a third party library

get the exact height of QTextDocument in pixels

淺唱寂寞╮ 提交于 2019-12-04 19:42:49
I need to get the actual height of QTextDocument in order to be able to set the containing QPlainTextEdit to a minimum height (while keeping its width constant) so that it shows the whole content without the vertical scrollbar. I tried to follow this question (closed with with accepted answer) How do I determine the height of a QTextDocument? but it does not do what it promises. A piece of code: from PyQt5.QtWidgets import QApplication, QPlainTextEdit app = QApplication([]) w = QPlainTextEdit() w.setPlainText("Hello!") print(w.document().size()) w.setPlainText("Hello!\nHello again!") print(w

Python PyQT/PySide QThread limiting

此生再无相见时 提交于 2019-12-04 18:18:48
I have problem with thread limiting. I want to do it using QThread. So SpiderThread is QThread object crawling some urls. But I want to limit working threads to X threads at once. I have done it earlier with threadpool and QRunnable but it's buggy in pyside when numbers of urls are big. So I have this simple code: self.threads = [] for url in self.urls: th = SpiderThread(url) th.updateresultsSignal.connect(self.update_results) self.threads.append(th) th.start() Anyone have working example of limiting threads using QThread ? So you want to have at most X threads running at any given time? So

What is the parent of createEditor in a QStyledItemDelegate (PySide/PyQt/Qt)?

柔情痞子 提交于 2019-12-04 15:25:18
I have a QTreeView of a QStandardItemModel . I am painting/editing the data using a custom delegate. Within createEditor method, I use parent.window() to access the main window of the entire application (see below to link to some code from another question). Question: what is the parent of createEditor in the delegate? It is defined with the following parameters: def createEditor(self, parent, option, index) What is confusing is when QStyledItemDelegate is initialized, and I print type(parent) for that , I get the tree back (the tree that I have made this delegate to display). This is what I

How to use QTimer inside QThread which uses QWaitCondition? (pyside)

和自甴很熟 提交于 2019-12-04 15:11:21
I'm using pyside but (I think) is a generic Qt question. I know that QThread implementation calls ._exec() method so we should have an event loop on a started QThread. This way we can use QTimer on that thread (I've done this and it works perfectly). My problem is when QWaitCondition is also used, I'd like to have a "consumer" thread with a infinite loop waiting to be notify (from producers) on the QWaitCondition. The problem I have is that with this design I cannot use QTimer inside the consumer Thread. This is a snippet of the scenario I'm trying to explain: from PySide import QtGui from