pyside

pyside / pyqt: simple way to bind multiple buttons that shares the same functionality

我是研究僧i 提交于 2019-12-19 10:27:07
问题 I'm new to PyQt / PySide. I have a lot of line edit (for displaying file location) and for each line text I have a push button (to display open file dialog). I have a method: def selectSelf1(self): """ browse for file dialog """ myDialog = QtGui.QFileDialog self.lineSelf1.setText(myDialog.getOpenFileName()) and a push button is binded using the following code self.btnSelf1.clicked.connect(self.selectSelf1) I have about 20 of those buttons and 20 of those line edits. Is there an easy way to

PyQt or PySide: QTextEdit deselect all

允我心安 提交于 2019-12-19 09:26:37
问题 I'm using PySide(PyQt is fine as well) and I want to deselect everything inside a QTextEdit. Selecting everything is very easy and it's done by self.textedit.selectAll(), but I can't find a simple way to deselect everything. Is there a straightforward way to do it that I'm not aware of or is it more complicated than that? Thanks. 回答1: You want to first get the QTextCursor for the QTextEdit my_text_cursor = my_text_edit.textCursor() Then clear the selection of the QTextCursor my_text_cursor

QTreeView with custom items

喜夏-厌秋 提交于 2019-12-19 04:05:58
问题 I'm writing my first Qt application with PySide and am having some trouble creating a custom tree view. I'd like to list my own data in one column. Each item must have text with tooltip, different text color, different background color, icons with actions and tooltip. The default tree works. I have view: class TreeView(PySide.QtGui.QTreeView): and model: class TreeModel(PySide.QtCore.QAbstractItemModel): How can I add different icons to my items? Here is my example: import sys from PySide

python qt, display text/label above another widget(phonon)

强颜欢笑 提交于 2019-12-18 18:38:40
问题 I'm making a video player using PySide which is a python bind to the Qt framework. I'm using phonon(a module) to display the video and I want to display text above the video as a subtitle. How can I put another widget above my phonon widget. Is opengl an option? 回答1: If you just create your label and set the phonon widget as the parent, the label should appear over it. QLabel *label = new QLabel(phononWidget); label->setText("Text over video!"); (I realize this is C++ and you are working in

Pyinstaller: ImportError: cannot import name QtGui

早过忘川 提交于 2019-12-18 17:54:38
问题 Using the latest pyinstaller on Windows 7 to make a standalone exe (-F), when running the exe: ImportError: cannot import name QtGui In the pyinstaller hooks directory there is special handling for PyQt4 though not PySide. Hoping for a workaround for this or something to try. Environment Windows 7 64-bit Python 2.7 32-bit PYTHONHOME=c:\python27 PYTHONPATH=c:\python27\lib PYTHONLIB=c:\python27\libs\python27.lib;c:\python27\lib\site-packages Steps 1. Add PySide from http://releases.qt-project

PySide Qt: Auto vertical growth for TextEdit Widget, and spacing between widgets in a vertical layout

房东的猫 提交于 2019-12-18 13:13:41
问题 I need to Solve two problems With my widget above. I'd like to be able to define the amount of space put between the post widgets shown in the image (they look fine as is, but I wanna know it's done). I'd like to grow the text edits vertically based on the amount of text they contain without growing horizontally. For 1 the code that populates the widgets is as follows : self._body_frame = QWidget() self._body_frame.setMinimumWidth(750) self._body_layout = QVBoxLayout() self._body_layout

Access values of dropActions in model (PySide/PyQt/Qt)

a 夏天 提交于 2019-12-18 09:08:24
问题 In a QTableModel when I enter the following: print model.supportedDropActions() I just get: <PyQt4.QtCore.DropActions object at 0x00000000081172E8> How can I access an actual list of the supported drop actions from this object? At the documentation, it says, "The DropActions type is a typedef for QFlags. It stores an OR combination of DropAction values." Note I am doing this in Python (PySide). Related posts: Drag and drop rows within QTableWidget 回答1: Background First, make sure you

Display data from QAbstractTableModel in QTreeView

和自甴很熟 提交于 2019-12-18 09:06:18
问题 Short version I am trying to display data from a QAbstracctTableModel in a QTreeView . When I do, I end up with the entire table displayed as the child of every node (and grandchild, and so-on). How can I display a treeview of an abstract table model? Details I am trying to display some data in a QAbstractTableModel in a QTreeView . In the Model-View Tutorial, after presenting an example QAbstractTableModel , it makes it seem it's as simple as replacing QTableView with QTreeView : You can

PySide Qt script doesn't launch from Spyder but works from shell

醉酒当歌 提交于 2019-12-18 07:25:11
问题 I have a weird bug in my project that uses PySide for its Qt GUI, and in response I'm trying to test with simpler code that sets up the environment. Here is the code I am testing with: https://stackoverflow.com/a/6906552/130164 When I launch that from my shell ( python test.py ), it works perfectly. However, when I run that script in Spyder, I get the following error: Traceback (most recent call last): File "/home/test/Desktop/test/test.py", line 31, in <module> app = QtGui.QApplication(sys

PySide Qt script doesn't launch from Spyder but works from shell

江枫思渺然 提交于 2019-12-18 07:25:05
问题 I have a weird bug in my project that uses PySide for its Qt GUI, and in response I'm trying to test with simpler code that sets up the environment. Here is the code I am testing with: https://stackoverflow.com/a/6906552/130164 When I launch that from my shell ( python test.py ), it works perfectly. However, when I run that script in Spyder, I get the following error: Traceback (most recent call last): File "/home/test/Desktop/test/test.py", line 31, in <module> app = QtGui.QApplication(sys