pyside2

PySide2 | Finding out which QKeySequence was pressed

时光毁灭记忆、已成空白 提交于 2019-12-11 04:48:42
问题 I'm using PySide2 and I want to have multiple shortcuts that carry out the same function but also would depend on which key was pressed. I tried to link the functions as such inside a QMainWindow: QtWidgets.QShortcut(QtGui.QKeySequence("1"),self).activated.connect(self.test_func) QtWidgets.QShortcut(QtGui.QKeySequence("2"),self).activated.connect(self.test_func) Such that they both execute this function. def test_func(self, signal): print(signal) Hoping that print("1") happens when the key "1

How do I make a shortcut using arrow key with PySide2?

风流意气都作罢 提交于 2019-12-10 18:50:59
问题 I want to add a keyboard shortcut to a button with Qt5 + Python (Pyside2). Code for making a shortcut with a regular key: import sys import random from PySide2 import QtCore, QtWidgets, QtGui class MyWidget(QtWidgets.QWidget): def __init__(self): super().__init__() self.hello = ["Hallo Welt", "你好,世界", "Hei maailma",\ "Hola Mundo", "Привет мир"] self.button = QtWidgets.QPushButton("Click me!") self.text = QtWidgets.QLabel("Hello World") self.text.setAlignment(QtCore.Qt.AlignCenter) self.text

How to embed matplotlib canvases in a PySide2 application

孤者浪人 提交于 2019-12-10 17:50:40
问题 I am trying to embed a matplotlib canvas into a PySide2 application. I have tried to use this example: https://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html The example runs fine using PyQt5. However, if I change line 19 from from PyQt5 import QtCore, QtWidgets into from PySide2 import QtCore, QtWidgets then Python crashes with the message Fatal Python error: deallocating None as soon as the application window is closed. Is there any way to get this working properly using

PySide2 composite widget Hover Effect

你离开我真会死。 提交于 2019-12-07 20:54:20
问题 How to animate position,scale or any other attributes of composed elements inside custom widget, on mouse pointer enters or leaves the QListWidgetItem ? (see reference image below) And is there any better way to manage space around ListWidgetItem ? item_widget.sizeHint() gives unwanted extra space, which is why i added hard coded value to setSizeHint. ProductMainWindow.py from PySide2 import QtCore, QtGui, QtWidgets import productThumbnailWidget import sys sys.path.append('E:/code') class

PySide2 composite widget Hover Effect

拟墨画扇 提交于 2019-12-06 09:15:16
How to animate position,scale or any other attributes of composed elements inside custom widget, on mouse pointer enters or leaves the QListWidgetItem ? (see reference image below) And is there any better way to manage space around ListWidgetItem ? item_widget.sizeHint() gives unwanted extra space, which is why i added hard coded value to setSizeHint. ProductMainWindow.py from PySide2 import QtCore, QtGui, QtWidgets import productThumbnailWidget import sys sys.path.append('E:/code') class prodMainWindowUI(QtWidgets.QMainWindow): def __init__(self): QtWidgets.QMainWindow.__init__(self) self

PySide2 application failed to start

好久不见. 提交于 2019-12-05 02:16:37
问题 I just tried to test the newly released version of PySide2 (5.11) on Windows 10, 64 bit version. But the "Hello World" example does not work. I am using Python 3.6 with PyCharm. The interpreter I use is from Anaconda. So I pip installed the PySide2 version and also tried to install via "conda install ..." the older version of PySide2. Both installations worked, but I get the same error message for both libraries. The error message is popping up in a separate screen saying: "This application

Using a custom PySide2 widget in Qt Designer

99封情书 提交于 2019-12-04 05:22:42
问题 I'm searching for a way to use custom widgets in Qt Designer written with Qt for Python (PySide2) effectively. I found out, that it is possible to design the GUI with the base widget, then just swap out the class to my custom widget in the UI File and informing the QUiLoader about the subclass loader.registerCustomWidget(MyMainWindow) , but then opening it again in Qt Designer doesn't work that well. I read in this similar question for PyQt that you have to write a Plugin for the custom

PyQt5 to PySide2, loading UI-Files in different classes

不问归期 提交于 2019-12-04 04:17:43
问题 I have a python application which runs under python3.6 and is using PyQt5 for loading Ui windows. These windows were created with Qt Designer 5.9.4. The Code below shows a working example with PyQt5. Now i want to have exactly the same functionality but with PySide2. For now, I couldn't work out how to load an Ui File and use its objects (buttons, tables etc.) in a separate class. For example: by clicking a button in the first window/class, a second window apears which functions are defined

Pyside2 How can i move box?

为君一笑 提交于 2019-12-04 04:15:42
问题 I want to move my SimpleItem object if I move mouse pressing left button. I have successed getting the position of mouse cursor if I press the object. but I have no idea how to move the item to that position. Could you help me? import sys from PySide2 import QtGui, QtWidgets, QtCore class SimpleItem(QtWidgets.QGraphicsItem): def __init__(self): QtWidgets.QGraphicsItem.__init__(self) self.location = 1.0 def boundingRect(self): penWidth = 1.0 return QtCore.QRectF(-10 - penWidth / 2, -10 -

How to deploy pyside2 applications? - The Qt way

自作多情 提交于 2019-12-03 21:17:45
问题 I need to deploy a pyside2 application based on Qt 5.12.1 for all major 3 Operative Systems (Windows, Linux and MacOS). I already checked on How to make a Python script standalone executable to run without ANY dependency? but that is not what I want because I need a Qt-related approach like windeployqt , macdeployqt , linuxdeployqt (separate project). As pointed by eyllanesc: "python is a scripting language that does not generate a binary" . However, the The Qt Company should figure that too