pyside

Unable to change __class__ of PySide.QtGui objects

爷,独闯天下 提交于 2019-12-04 13:45:51
I've used PyQt4 quite a lot - sometimes I like to overload some of the objects to allow me to add some functionality. This works fine in PyQt4, eg: from PyQt4 import QtGui button = QtGui.QPushButton() class MyPushButton(QtGui.QPushButton): pass button.__class__ = MyPushButton However, I'm trying to adapt some of my code so that it uses PySide instead of PyQt4. My understanding is that they should have the same functionality. PySide will not allow me to do the same thing. from PySide import QtGui button = QtGui.QPushButton() class MyPushButton(QtGui.QPushButton): pass button.__class__ =

Qt animating a button

筅森魡賤 提交于 2019-12-04 13:22:09
Can anyone provide or point to a simple example in Qt, where we can slide a button downwards or upward if another button is clicked. For example, a simple dialog which have three buttons vertically positioned. When we click the upper button, the middle and the lower button should slide down 20-30 pixel leaving a space between the upper and other two buttons. Also if middle button is clicked, the buttons should attain their initial position and a similar animation should occur between the middle and the lowermost button. That is, the lower button should slide down leaving a space between it and

Crash on close and quit

我与影子孤独终老i 提交于 2019-12-04 13:21:33
I have a PySide application that hosts a VLC MediaPlayer instance within a QWidget. When the application is closed via the QMainWindow's close event, or by using QApplication.quit(), the UI disappears and then I get a Windows dialog "python.exe has stopped working". The QApplication hosts a custom QMainWindow class, which contains a custom QWidget (which handles all the UI tasks, with QMainWindow handling messaging between threads - the app records keystrokes and writes output files in background threads). There is also a timer running the the main QWidget that updates a LineEdit with the

connection of Pyside QPushButton and matplotlib

时光毁灭记忆、已成空白 提交于 2019-12-04 12:57:15
I'm trying to develop a very simple pyside/Qt program using matplotlib. I want that a graph is draw when a button is pressed. So far, I can draw something on the constructor, but I can't connect the Pyside event with matplotlib. Is there a way to do that? import sys import platform import numpy as np import PySide from PySide.QtGui import QApplication, QMainWindow, QTextEdit,\ QPushButton, QMessageBox, QWidget, QVBoxLayout from PySide import QtCore __version__ = '0.0.1' import matplotlib matplotlib.use('Qt4Agg') matplotlib.rcParams['backend.qt4']='PySide' from matplotlib.figure import Figure

How to style (rich text) in QListWidgetItem and QCombobox items? (PyQt/PySide)

淺唱寂寞╮ 提交于 2019-12-04 11:31:34
I have found similar questions being asked, but without answers or where the answer is an alternative solution. I need to create a breadcrumb trail in both QComboBoxes and QListWidgets (in PySide), and I'm thinking making these items' text bold. However, I have a hard time finding information on how to achieve this. This is what I have: # QComboBox for server in servers: if optionValue == 'top secret': optionValue = server else: optionValue = '<b>' + server + '</b>' self.comboBox_servers.addItem( optionValue, 'data to store for this QCombobox item' ) # QListWidgetItem for folder in folders:

Error loading ipython qtconsole

别来无恙 提交于 2019-12-04 10:44:23
I need some advise here. I've installed ipython (sudo pip install ipython[all]) I've python 2.7, mac osx 10.9 64bits. I'm trying to lunch qtconsole camilo-mbp:mvc cami$ ipython qtconsole Traceback (most recent call last): File "/usr/local/bin/ipython", line 8, in <module> load_entry_point('ipython==2.2.0', 'console_scripts', 'ipython')() File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 120, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 563, in launch_instance app.initialize(argv)

How do I emit a PySide signal with a custom python type argument?

Deadly 提交于 2019-12-04 10:33:21
I am having trouble correctly using signals in my PySide python Qt program. I want to emit a signal that takes a single argument of a custom python type. The documentation says Signals can be defined using the QtCore.signal() class. Python types and C types can be passed as parameters to it. So I tried the following: from PySide import QtCore from PySide.QtCore import QObject class Foo: pass class Bar(QObject): sig = QtCore.Signal(Foo) def baz(self): foo = Foo() self.sig.emit(foo) bar = Bar() bar.baz() But get the following error: Traceback (most recent call last): File "test.py", line 15, in

Multi-level QTreeView

放肆的年华 提交于 2019-12-04 10:16:32
I'm having a hard time understanding how to set a multilevel QTree using the QTreeView and QStandardItemModel. Here's what I have: from PySide.QtGui import * import sys class MainFrame(QWidget): def __init__(self): QWidget.__init__(self) tree = {'root': { "1": ["A", "B", "C"], "2": { "2-1": ["G", "H", "I"], "2-2": ["J", "K", "L"]}, "3": ["D", "E", "F"]} } self.tree = QTreeView(self) root_model = QStandardItemModel() self.tree.setModel(root_model) for r,root in enumerate(sorted(tree)): root_item = QStandardItem(root) root_model.setItem(r,root_item) for c,child in enumerate(sorted(tree[root])):

Loading an image using QPixmap

跟風遠走 提交于 2019-12-04 10:10:53
I have an image file , as C:/44637landscapes-2007.jpg I want to load this file using QPixmap using PySide I tried as following . pixmap = QPixmap('C:/44637landscapes-2007.jpg') But documentation says like QPixmap(':/xxxxxx.jpeg') . What does ':' means ? How do I load an image at 'C:\' ? EDIT : The problem was with trying to load "JPEG" . It was able to load "PNG" , with no issues. So what else , I need to do to load "JPEG" ? Thanks Jijoy Gerald If you're trying to build your Python code to an executable this covers the issue for .ico files but the process is the same for JPEG: PyQt/PySide -

Simple File browser / file chooser in Python program with Qt-GUI?

纵饮孤独 提交于 2019-12-04 09:41:17
问题 I'm currently trying to implement some kind of file browser / "explorer" into a programme... I'm using Python and PySide in connection with the Qt-window-toolkit. More or less this youtube-video shows the behaviour I want to have at the end. However, this tutorial used C++ as programming language and I haven't been able yet to reason the right python code from the C++ example. Basically, my problem is to get the right column (file view) showing the content of the folder clicked in the left