pyside

How to save PySide tree view model structure

穿精又带淫゛_ 提交于 2019-11-27 07:33:17
问题 Here is the link on other SO question QTreeView with custom items where is QTreeView example. Please, can anyone explain me at this example, how to save tree structure from treeview. Is the QAbstractItemModel class from which I can extract label names, and structure which I could load again? If so, how could I access to nodes? Any other way except index? EDIT (from the link) : import sys from PySide import QtGui, QtCore #------------------------------------------------------------------------

PySide (or PyQt) signals and slots basics

别说谁变了你拦得住时间么 提交于 2019-11-27 07:15:53
问题 Consider a simple example like this which links two sliders using signals and slots: from PySide.QtCore import * from PySide.QtGui import * import sys class MyMainWindow(QWidget): def __init__(self): QWidget.__init__(self, None) vbox = QVBoxLayout() sone = QSlider(Qt.Horizontal) vbox.addWidget(sone) stwo = QSlider(Qt.Horizontal) vbox.addWidget(stwo) sone.valueChanged.connect(stwo.setValue) if __name__ == '__main__': app = QApplication(sys.argv) w = MyMainWindow() w.show() sys.exit(app.exec_()

How to drop a custom QStandardItem into a QListView

谁都会走 提交于 2019-11-27 07:07:17
问题 I am trying to get drag&drop to work between two QListViews using a custom QStandardItem. I can't find the info I need online other than this document which helped a little bit but now I'm stuck. Drag&drop from one QListView to another works fine when I use a QStandardItem to hold my data, but when I use a custom item I run into trouble, because the receiving model/view creates a QStandardItem when a custom item is dropped. Ideally I could tell the receiving model to use my custom item as the

pyside connection Error “RuntimeError: Failed to connect signal clicked()”

六月ゝ 毕业季﹏ 提交于 2019-11-27 06:25:19
问题 from PySide.QtCore import * from PySide.QtGui import * import sys import stackwid class Dialog(QDialog,stackwid.Ui_Dialog): def __init__(self,parent = None): super(Dialog,self).__init__(parent) self.setupUi(self) self.camButton.clicked.connect(self.set()) def set(self): self.stackedWidget.setCurrentIndex(1) app = QApplication(sys.argv) form = Dialog() form.show() app.exec_() I wanted to connect clicked() signal emitted by camButton(PushButton) to slot which is a function set().This just does

QWidget does not draw background color

邮差的信 提交于 2019-11-27 05:20:21
I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing three other items and another label. For the widget containing the button, radio button and checkbox I set the styleSheet property to background-color: #FFFFFF . In Qt Designer everything renders as desired: But in Pyside the widget does not draw the background color - but the items on it inherit the color correctly: Here's the ui-XML: <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class>

Python PySide and Progress Bar Threading

橙三吉。 提交于 2019-11-27 04:02:53
问题 I have this code: from PySide import QtCore, QtGui import time class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 133) self.progressBar = QtGui.QProgressBar(Dialog) self.progressBar.setGeometry(QtCore.QRect(20, 10, 361, 23)) self.progressBar.setProperty("value", 24) self.progressBar.setObjectName("progressBar") self.pushButton = QtGui.QPushButton(Dialog) self.pushButton.setGeometry(QtCore.QRect(20, 40, 361, 61)) self.pushButton.setObjectName(

How to set QWidget background color?

假如想象 提交于 2019-11-27 02:18:11
问题 The line w.setBackgroundRole(QPalette.Base) in the code below has no effect. Why? How do I fix that? import sys from PySide.QtCore import * from PySide.QtGui import * app = QApplication(sys.argv) w = QWidget() w.setBackgroundRole(QPalette.Base) w.show() app.exec_() 回答1: You need to call setAutoFillBackground(True) on the widget. By default, a QWidget doesn't fill its background. For more information, see the documentation for the setAutoFillBackground property. If you want to use an arbitrary

Setting Mac OSX Application Menu menu bar item to other than “Python” in my python Qt application

眉间皱痕 提交于 2019-11-27 01:52:59
问题 I am writing a GUI application using python and Qt. When I launch my application on Mac, the first menu item in the Mac menu bar at the top of the screen is "Python". I would prefer the application name there to be the name of my application. How can I get my program name up there? The following demo program creates a window with two menus: "Python", and "Foo". I don't like that, because it makes no difference to my users whether I wrote the app in python or COBOL. Instead I want menus "MyApp

Convert numpy array to PySide QPixmap

China☆狼群 提交于 2019-11-27 01:22:31
问题 I want to convert an image into a NumPy array to a PySide QPixmap, so I can display it (EDIT: in my PySide UI). I already found this tool: qimage2ndarray, but it only works for PyQt4. I tried to change it to get it working with PySide, but I would have to change the C part of the tool and I have no experience with C. How can I do this or are there any alternatives? 回答1: One alternative is to just use PIL library. >>> import numpy as np >>> import Image >>> im = Image.fromarray(np.random

Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox?

半世苍凉 提交于 2019-11-26 23:45:55
I'm using Virtualenv with profit on my development environment with web.py , simplejson and other web oriented packages. I'm going to develop a simple python client using Qt to reuse some Api developed with web.py. Does anybody here had succesfully installed PyQt4 with Virtualenv? Is it possible? I've downloaded all the binaries and have PyQt4 installed globally on my python2.6 directory. If I don't use --no-site--packages option, Virtualenv correctly includes PyQt4 in my new sandbox but, obviously, with all the global packages that I don't need. Is there a clean way to prepare a new sandbox