pyside

Only move QGraphicsItem when mouse in specific region

扶醉桌前 提交于 2019-12-06 08:43:44
I'm trying to create something similar to terragens node network view in python using PySide. I subclassed QGraphicsRectItem using this code. class Node(QGraphicsRectItem): def __init__(self,pos): QGraphicsRectItem.__init__(self,pos.x()-100,pos.y()-30,200,60) self.setFlag(QGraphicsItem.ItemIsMovable,True) (...) Which gives this (with some fancy painting): I'd like to implent connecting nodes by dragging the mouse from one small rectangle to another, but this results in moving the whole node. So I don't want the QGraphicsRectItem getting moved when the mouse is pressed inside a small rectangle.

Qthread locking up Gui PySide

扶醉桌前 提交于 2019-12-06 08:29:21
I am trying to run a process in a separate thread but it is freezing my Gui and I cant understand why. I am initialising the thread in the init function of my class: self.cipher = Cipher() self.cipher_thread = QThread() self.cipher.moveToThread(self.cipher_thread) self.cipher_thread.started.connect(lambda: self.cipher.encrypt(self.plaintext_file_path, self.ciphertext_file_path, self.init_vector, self.key)) self.cipher_thread.start() The encrypt method of the cipher class is: def encrypt(self): # check that both the key and the initialisation vector are 16 bytes long if len(self.k) == self.key

Unable to change __class__ of PySide.QtGui objects

痞子三分冷 提交于 2019-12-06 08:13:14
问题 I've used PyQt4 quite a lot - sometimes I like to overload some of the objects to allow me to add some functionality. This works fine in PyQt4, eg: from PyQt4 import QtGui button = QtGui.QPushButton() class MyPushButton(QtGui.QPushButton): pass button.__class__ = MyPushButton However, I'm trying to adapt some of my code so that it uses PySide instead of PyQt4. My understanding is that they should have the same functionality. PySide will not allow me to do the same thing. from PySide import

canFetchMore() and fetchMore() are not working as expected

最后都变了- 提交于 2019-12-06 07:41:57
I have problems implementing Qt tree model with lazy loading using canFetchMore() and fetchMore() . I have this code: from PySide.QtCore import Qt, QAbstractItemModel, QModelIndex from PySide.QtWidgets import QTreeView, QApplication BATCH_SIZE = 100 class ObjectItem(object): def __init__(self, parent, name, data, row): self.parent = parent self.name = name self.data = data self.row = row self.hasChildren = False self.canFetchMore = False # ints have no children if isinstance(data, int): return self.childCount = 0 self.childItems = [] if len(data) > 0: self.canFetchMore = True self.hasChildren

How to style (rich text) in QListWidgetItem and QCombobox items? (PyQt/PySide)

你说的曾经没有我的故事 提交于 2019-12-06 07:02:10
问题 I have found similar questions being asked, but without answers or where the answer is an alternative solution. I need to create a breadcrumb trail in both QComboBoxes and QListWidgets (in PySide), and I'm thinking making these items' text bold. However, I have a hard time finding information on how to achieve this. This is what I have: # QComboBox for server in servers: if optionValue == 'top secret': optionValue = server else: optionValue = '<b>' + server + '</b>' self.comboBox_servers

Set Vertical Alignment of QFormLayout QLabel

南笙酒味 提交于 2019-12-06 06:22:46
I'm using PySide/PyQt, but this is a general Qt question. Is there a way to set up a QFormLayout so that labels are centered vertically without having to explicitly create the QLabel's and set their vertical size policy to expanding first? When the widget in column 2 is taller than my label, I want my label to be centered vertically with the widget, rather than aligned with it's top... Here's an example script that demonstrates the problem. I've colored the labels red to better demonstrate their size behavior. from PySide import QtCore, QtGui app = QtGui.QApplication([]) widget = QtGui.QWidget

Wrapping C++ Qt widget for using in Python with PySide

对着背影说爱祢 提交于 2019-12-06 05:57:31
What is the best approach for wrapping a custom C++ library with custom Qt display widgets in Python for using in a PySide based QApplication? Does the C++ library need special treatment for wrapping with SWIG? Will wrapped Qt widgets integrate properly with PySide? I would appreciate any comments on the appropriate nomenclature needed to refine my unsuccessful searches on this subject. The Shiboken bindings tool used to generate the PySide bindings for Qt turns out to be the right tool for the job. The basic procedure for generating the bindings for a custom C++ library is outlined here: http

Error loading ipython qtconsole

萝らか妹 提交于 2019-12-06 05:33:08
问题 I need some advise here. I've installed ipython (sudo pip install ipython[all]) I've python 2.7, mac osx 10.9 64bits. I'm trying to lunch qtconsole camilo-mbp:mvc cami$ ipython qtconsole Traceback (most recent call last): File "/usr/local/bin/ipython", line 8, in <module> load_entry_point('ipython==2.2.0', 'console_scripts', 'ipython')() File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/Library

How do I emit a PySide signal with a custom python type argument?

一世执手 提交于 2019-12-06 05:31:31
问题 I am having trouble correctly using signals in my PySide python Qt program. I want to emit a signal that takes a single argument of a custom python type. The documentation says Signals can be defined using the QtCore.signal() class. Python types and C types can be passed as parameters to it. So I tried the following: from PySide import QtCore from PySide.QtCore import QObject class Foo: pass class Bar(QObject): sig = QtCore.Signal(Foo) def baz(self): foo = Foo() self.sig.emit(foo) bar = Bar()

Loading an image using QPixmap

若如初见. 提交于 2019-12-06 05:07:47
问题 I have an image file , as C:/44637landscapes-2007.jpg I want to load this file using QPixmap using PySide I tried as following . pixmap = QPixmap('C:/44637landscapes-2007.jpg') But documentation says like QPixmap(':/xxxxxx.jpeg') . What does ':' means ? How do I load an image at 'C:\' ? EDIT : The problem was with trying to load "JPEG" . It was able to load "PNG" , with no issues. So what else , I need to do to load "JPEG" ? Thanks Jijoy 回答1: If you're trying to build your Python code to an