pyside

How to make a custom QStyledItemDelegate selectable in a QListView in PySide/PyQt?

人走茶凉 提交于 2019-12-13 04:36:50
问题 As a follow-up to my previous question, which was solved, I now want to make the items selectable . As mentioned earlier, I activated all kinds of selection-related parameters in the view and I also return core.Qt.ItemIsSelectable in the flags -method of the model. But still option.state & gui.QStyle.State_Selected is never fullfilled. Any help is highly appreciated. Please also note the minimal example in the linked question. 回答1: I solved it myself. The problem was, that the custom

Win7 Taskbar Icon Incorrect for PySide py2exe App

主宰稳场 提交于 2019-12-13 03:24:44
问题 I have a PySide app that I'm converting to an exe to be run on Windows 7 without any dependencies using py2exe. Here's setup from setup.py setup(windows=[{ "script" : "src/main.py", "dest_base" : "xxx-setup-" + configuration.version, "icon_resources": [(1, "images/xxx_icon.ico")], "other_resources": [(24,1, manifest)] }], name='xxx', data_files=[('imageformats',[r'C:\Python27\Lib\site-packages\PySide\plugins\imageformats\qico4.dll'])], options={"py2exe" : { "includes" : ["simplejson", "sip",

Getting the bounding box of QTextEdit selection

為{幸葍}努か 提交于 2019-12-13 03:10:54
问题 I'm trying to get the bounding box of a series of text selections stored in a list. The bounding box is the smallest rectangle that can contain the whole selection. Each item in the list has a start and end point measured in characters from the beginning of the QTextEdit window and also a letter identifier. QTextEdit.cursorRect(cursor) should do this, but is producing nonsensical box dimensions: id: A -- PySide.QtCore.QRect(0, 0, 1, 10) id: B -- PySide.QtCore.QRect(0, 0, 1, 10) id: C --

PySide: How to snap a button into a place when I drag it?

微笑、不失礼 提交于 2019-12-13 03:09:43
问题 I have an application where I am able to drag buttons around freely in a window. I want to have a section of the window with slots in which I can drop the button into. If I drop it in the vicinity of one slot, I want the button to lock in place in that slot. I only want to move the buttons in the Y direction. How would I go about implementing the slots? I am picturing something simple like a bookshelf. Edit: I've added code that implements 5 movable labels. What I am trying to do is to be

PySide QPropertyAnimation Not Starting

放肆的年华 提交于 2019-12-13 02:59:26
问题 The problem is that when I call QPropertyAnimation.start() , nothing happens. Color is the property I'm animating and button is the class. class Button(QPushButton): def __init__(self,text="",parent=None): super(Button,self).__init__(text,parent) # ... self.innercolor = QColor(200,0,20) def setcolor(self,value): self.innercolor = value def getcolor(self): return self.innercolor color = Property(QColor,getcolor,setcolor) def paintEvent(self, event): p = QPainter(self) p.fillRect(self.rect()

PySide Signal “duplicating” behavior

不羁的心 提交于 2019-12-13 02:56:08
问题 from PySide.QtCore import * class Eggs(QObject): evt_spam = Signal() print "Loaded" a = Eggs() b = Eggs() print a.evt_spam print b.evt_spam print a.evt_spam is b.evt_spam outputs: Loaded <PySide.QtCore.Signal object at 0xa2ff1a0> <PySide.QtCore.Signal object at 0xa2ff1b0> False "Loaded" only printing once (as expected; it is a class variable), but why are 2 instances of the signal being created (if it is also a class variable)? 回答1: It's not being printed when you create a class instance, but

QTableView sorting fails after setHorizontalHeader()

早过忘川 提交于 2019-12-13 02:55:50
问题 I am encountering a strange problem with PySide QTableView s after I have set a new QHeaderView instance via setHorizontalHeader() . Specifically it seems that the sorting ability of the view is broken/cannot be invoked anymore. Questions Why is the sorting broken after a new header view is set? Why does monkeypatching methods on the header view instance only work after a setting a new header via setHorizontalHeader() ? (See wrap_size_hint() in the demo code.) When logging the children of the

Why is QWidget with border and background image styling behaving different to QLabel, QDialog, …?

倖福魔咒の 提交于 2019-12-13 02:53:10
问题 I use the Qt4.8 Python binding PySide (version 1.2.2 on Python 3.3 on Windows) and I see that QWidget behaves different from QWidget derived widgets like QDialog , QLabel or QMainWindow when styling with stylesheets. In particular I observe that the attribute WA_StyledBackground must be set to show a border or a background image while a background color is set independently. In contrast for the other widgets this attribute has no influence, a border or background image is always shown.

Create a pandas dataframe from a qrc resource file

我与影子孤独终老i 提交于 2019-12-13 02:21:57
问题 I would like to save a CSV file into a qrc file and than read it putting its contents in a pandas dataframe, but I have some problems. I created a qrc file called res.qrc : <!DOCTYPE RCC><RCC version="1.0"> <qresource> <file>dataset.csv</file> </qresource> </RCC> I compiled it obtaining the res_rc.py file. To read it I created a python script called resource.py : import pandas as pd import res_rc from PySide.QtCore import * file = QFile(":/dataset.csv") df = pd.read_csv(file.fileName()) print

Qt - Pyside - .saveGeom() .saveState() (again)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 02:15:04
问题 This is a follow on question to Qt - pyside - saveGeometry() saveState() I have a Qt program and currently I use Qsettings and the mainWindow.saveGeometry() and mainWindow.saveState() functions to allow the program to restore the layout that the user set in the previous session. This approach works well for the docked position of all the docked windows. It also works well for the floating position of the un-docked windows provided the windows are un-docked at exit. When a user tailors the