pyside

Drag and drop rows within QTableWidget

谁说胖子不能爱 提交于 2019-11-30 08:50:12
Goal My goal is to have a QTableWidget in which the user can drag/drop rows internally. That is, the user can drag and drop one entire row, moving it up or down in the table to a different location in between two other rows. The goal is illustrated in this figure: What I tried, and what happens Once I have populated a QTableWidget with data, I set its properties as follows: table.setDragDropMode(QtGui.QAbstractItemView.InternalMove) #select one row at a time table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) Similar

PyQt/PySide - icon display

家住魔仙堡 提交于 2019-11-30 07:11:49
I have a PySide app which has an icon for the MainWindow (a QMainWindow instance). When I run the file normally, the icon is visible and everything is fine but when I create an exe with py2exe , the icon does not appear. This happens with cx_freeze also( so I don't think the problem's with py2exe ). The app was designed using QtDesigner and converted to python with pyside-uic . I tried both using icons as a file and as a resource(qrc file) and both don't seem to work. Any help or pointers would be appreciated. Thanks. Gerald kochelmonster's solution works so long as you don't try and bundle

Displaying LaTeX in pyQt/pySide QTableWidget

不羁的心 提交于 2019-11-30 06:49:00
问题 I would like to add mathematical expressions to the table labels (e.g.: 2^3 should be properly formatted) Here is a simple example of a table: http://thomas-cokelaer.info/blog/2012/10/pyqt4-example-of-tablewidget-usage/ setHorizontalHeaderLabels accepts string, only. I wonder if is it possible to implement somehow this matplotlib approach: matplotlib - write TeX on Qt form are there other options? 回答1: I've also been trying for some time to display complex labels in the header of a

PySide / Qt Import Error

北城以北 提交于 2019-11-30 04:45:59
I'm trying to import PySide / Qt into Python like so and get the follow error: from PySide import QtCore ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PySide/QtCore.so, 2): Library not loaded: libpyside-python2.7.1.2.dylib Referenced from: /usr/local/lib/python2.7/site-packages/PySide/QtCore.so Reason: image not found I'm running/installed via: Mac OSX 10.9.4 Mavericks Homebrew Python 2.7 Homebrew installed Qt Pip installed PySide The file libpyside-python2.7.1.2.dylib is located in the same path as the QtCore.so file listed in the error message. All my searches for this

PyQt/PySide: How do I convert QImage into OpenCV's MAT format

北城余情 提交于 2019-11-29 23:32:57
问题 I'm looking to create a function for converting a QImage into OpenCV's (CV2) Mat format from within the PyQt. How do I do this? My input images I've been working with so far are PNGs (either RGB or RGBA) that were loaded in as a QImage. Ultimately, I want to take two QImages and use the matchTemplate function to find one image in the other, so if there is a better way to do that than I'm finding now, I'm open to that as well. But being able to convert back and forth between the two easily

How can I find a substring and highlight it in QTextEdit?

本秂侑毒 提交于 2019-11-29 22:50:41
问题 I have a QTextEdit window that shows the content of a file. I would like to be able to find all matches inside the text using a regex and highlight them either by making the match background different or by changing the match text color or making it bold. How can I do this? 回答1: I think the simplest solution to your problem is to use the cursor associated to your editor in order to do the formatting. This way you can set the foreground, the background, the font style... The following example

Qt Widget with Transparent Background

a 夏天 提交于 2019-11-29 22:15:07
问题 (I'm using PySide, but I think the answer would be the same/similar for any language bindings). I'm trying to take the shaped clock example, located here, and cause the face of the clock (circle) to be transparent so that all I see are the clock hands and minute ticks. As is, when the example runs, it looks like this. I'm using Windows 7. So far, I've tried the following (in the constructor): self.setAttribute(QtCore.Qt.WA_TranslucentBackground) Clock appears (has presence in task bar), but I

Edit table in pyqt using QAbstractTableModel

余生长醉 提交于 2019-11-29 20:21:21
问题 I'm trying to create an editable table in PyQt. Here's the code for just displaying the table: import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * # données à représenter my_array = [['00','01','02'], ['10','11','12'], ['20','21','22']] def main(): app = QApplication(sys.argv) w = MyWindow() w.show() sys.exit(app.exec_()) # création de la vue et du conteneur class MyWindow(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) tablemodel

Loading QtDesigner's .ui files in PySide

一世执手 提交于 2019-11-29 20:10:55
I am looking for a simple example of how to directly load a QtDesigner generated .ui file into a Python application. I simply would like to avoid using pyuic4. Stephen Terry PySide, unlike PyQt, has implemented the QUiLoader class to directly read in .ui files. From the linked documentation, loader = QUiLoader() file = QFile(":/forms/myform.ui") file.open(QFile.ReadOnly) myWidget = loader.load(file, self) file.close() For the complete noobs at PySide and .ui files, here is a complete example: from PySide import QtCore, QtGui, QtUiTools def loadUiWidget(uifilename, parent=None): loader =

MVC design with Qt Designer and PyQt / PySide

南笙酒味 提交于 2019-11-29 19:46:16
Python newbie coming from Java (+SWT/Windowbuilder) and am having difficulty working out how to properly code a large desktop app in Python/Qt4(QtDesigner)/PySide. I would like to keep any view logic in a controller class outside the .ui file (and it's .py conversion). Firstly as then the logic is independent of GUI framework and secondly as the .ui and resultant .py file get overwritten on any changes!. Only examples I've found add action code to a monolithic MainWindow.py (generated from ui) or a MyForm.py (also generated from .ui). I can't see any way to link a POPO controller class to