pyside

How to save PySide tree view model structure

旧时模样 提交于 2019-11-28 13:12:32
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 #------------------------------------------------------------------------------- # my test data class Icon(): def __init__(self, icon, tooltip): self.pixmap = QtGui.QPixmap

PySide and PyQt clash when packaging pylab under Windows 7

本小妞迷上赌 提交于 2019-11-28 12:55:29
问题 I tried to package a small script which does some plotting with pylab. I used pyinstaller under Linux without a problem but under Windows 7 I get an error. On a different computer which has PySide but not PyQt installed the packaging worked. Thus by removing PyQt I can get it to work on my other computer. However, I would like to know if there is another way around this problem since I have some scripts which use PyQt and some which use PySide. I got a similar error by using cx_freeze. Thanks

PySide (or PyQt) signals and slots basics

耗尽温柔 提交于 2019-11-28 12:45:13
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 would you change this so that the second slider moves in the opposite direction as the first?

How to treat click events differently for an item's checkbox versus its text? (PyQt/PySide/Qt)

天大地大妈咪最大 提交于 2019-11-28 11:37:51
问题 I have a QStandardItemModel in which each item is checkable. I want different slots to be called when I click on the item's checkbox, on one hand, versus when I click on its text, on the other. My ultimate goal is to have text edits, and changes in checkbox state, go onto the QUndoStack separately. In my reimplementation of clicked I want to treat checkbox clicks and text clicks differently. So far, I have found no way to differentiate these events in the documentation for QCheckBox or

PySide Node Graph connect items

萝らか妹 提交于 2019-11-28 11:23:17
问题 The purpose of this code is node graph kind of UI. Double click creates rectangles and right click connects them with line. If you move on of the rectangle the corresponding end of line moves with it. The problem is that the line moves only with first two rectangles. If you create another pair of rectangles and connect them with line it stops moving. I have started to learn PySide/PyQt recently so maybe I don't understand all code. Here is the code: https://github.com/cyberiRex/irex/blob

How to insert a button inside a QLineEdit

好久不见. 提交于 2019-11-28 10:30:37
I need help inserting a button inside in a QLineEdit that can call a function. For example, like this google image: Avaris Below is a nearly direct translation of the Qt code from here . Differences: button is always visible clicking on the button emits buttonClicked(bool) signal Code: from PyQt4 import QtGui, QtCore class ButtonLineEdit(QtGui.QLineEdit): buttonClicked = QtCore.pyqtSignal(bool) def __init__(self, icon_file, parent=None): super(ButtonLineEdit, self).__init__(parent) self.button = QtGui.QToolButton(self) self.button.setIcon(QtGui.QIcon(icon_file)) self.button.setStyleSheet(

How to undo edit of QStandardItem in PySide/PyQt?

試著忘記壹切 提交于 2019-11-28 10:20:30
问题 Using the identical question asked about QListWidgets as a guide, I am trying to make a QStandardItemModel in which I can undo the edit of an item. As can be seen in the SSCCE below, I'm pretty much copying the example exactly, but with some minor tweaking because currentItemChanged isn't available for QStandardItemModel . To get around that, I'm using the clicked signal instead to fix the previous text for an item. Strangely, the correct description shows up in the undostack, but when I

Connect action in QMainWindow with method of view's delegate (PySide/Qt/PyQt)

99封情书 提交于 2019-11-28 10:10:11
问题 I have a QTreeView displaying data from a QStandardItemModel . One of the columns of the tree is displayed with a delegate that lets the user edit and display rich text. Below is a SSCCE that limits the editing to bold (with keyboard shortcut). When the user is editing one of the items, how can I set it up so that in addition to toggling boldness with keyboard shortcut (CTRL-B), the user can also toggle it using the toolbar icon? Thus far, the keyboard shortcut works great (you can double

Why python executable opens new window instance when function by multiprocessing module is called on windows

旧时模样 提交于 2019-11-28 08:57:13
问题 Short Question: Why python executable generated by pyinstaller opens new window instance when function by multiprocessing module is called on windows operating system I have a GUI code written using pyside. Where when we click on simple button it will calculate factorial in another process (using multiprocessing module). It works as expected when I run python program. But after I create executable using PyInstaller and when I run using exe it is creating new window when function by

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

不打扰是莪最后的温柔 提交于 2019-11-28 08:25:22
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" and "Foo". #!/usr/bin/python # This example demonstrates unwanted "Python" # application menu name on