pyside2

PySide2 QMainWindow loaded from ui file not triggering window events

雨燕双飞 提交于 2020-06-23 11:47:48
问题 I am loading a QMainWindow from an .ui file - it's working fine but window events like resize won't be triggered. I can't really figure out what I am doing wrong. This is the code: class TestWindow(QMainWindow): def __init__(self, parent=None): super(TestWindow, self).__init__(parent) loader = QUiLoader() file = QFile(abspath("ui/mainwindow.ui")) file.open(QFile.ReadOnly) self.window = loader.load(file, parent) file.close() self.window.show() def resizeEvent(self, event): print "resize" app =

PySide2 QMainWindow loaded from ui file not triggering window events

僤鯓⒐⒋嵵緔 提交于 2020-06-23 11:47:28
问题 I am loading a QMainWindow from an .ui file - it's working fine but window events like resize won't be triggered. I can't really figure out what I am doing wrong. This is the code: class TestWindow(QMainWindow): def __init__(self, parent=None): super(TestWindow, self).__init__(parent) loader = QUiLoader() file = QFile(abspath("ui/mainwindow.ui")) file.open(QFile.ReadOnly) self.window = loader.load(file, parent) file.close() self.window.show() def resizeEvent(self, event): print "resize" app =

Python QT findChildren does not find any children from UI file

半腔热情 提交于 2020-06-20 05:04:06
问题 I have a UI file like this <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>RoverPlanner</class> <widget class="QWidget" name="RoverPlanner"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>752</width> <height>555</height> </rect> </property> <property name="windowTitle"> <string>RoverPlanner</string> </property> <widget class="QWidget" name="horizontalLayoutWidget_6"> <property name="geometry"> <rect> <x>0</x> <y>10</y> <width>641</width> <height>501</height> <

background color of cells in QTableview, PySide2

泄露秘密 提交于 2020-06-17 13:13:06
问题 Is it possible to conditionally change the background color of items in a QTableView, using PySide2? I've read a lot on the model view framework . I cannot figure out if it is necessary to use a Delegate or not. Recently I was able to get a column of checkboxes without a Delegate. I believe that the virtual methods setItemData(index, roles) and itemData(index) could be what I need. However, there is no QMap in PySide2. My model must need somewhere to store the extra information to be used by

Using QComboBox to select different set of widgets displayed in PyQt5 / PySide2

回眸只為那壹抹淺笑 提交于 2020-06-08 12:41:12
问题 I'm working on an image viewer with a toolbar on the left. As I have many measures to make but want to use most of the display for the picture and keep the toolbar thin, I would like to use combo_box1 and combo_box2 to select the different widgets displayed in the toolbar. Example 1: if I choose measurements set 1 in combo_box1 I would then be able to choose between measurements P1-P2 and P3-P4 in combo_box2 . Example 2: if I choose measurements set 2 in combo_box1 I would then be able to

PySide2/QML populate and animate Gridview model/delegate

蓝咒 提交于 2020-05-30 08:43:19
问题 I'm newbie to QML and looking for help on below points How to filter QAbstractListModel data (Title) in Gridview model via PySide2 based on TextField input (as Regex ). How to animate delegate of Gridview on mouse hover (as showen in below image.) Here is the test code qmlHoverView.py from PySide2 import QtCore, QtQuick, QtGui, QtWidgets, QtQml import os import sys class inventoryModel(QtCore.QAbstractListModel): def __init__(self, entries, parent=None): super(inventoryModel, self).__init__

Path error in PySide2 application after packaging with PyInstaller

末鹿安然 提交于 2020-05-30 08:12:27
问题 I'm trying to package a PySide2 test application with the following structure: . ├── main.py ├── main.spec └── wizardUI ├── 10.toolBoxBtns.ui ├── 11.toolBoxShrCt.ui ├── 12.propertyBox.ui ├── 13.printing.ui ├── 14.settings.ui ├── 15.coclusion.ui ├── 1.welcomePage.ui ├── 2.graphicsScene.ui ├── 3.graphicsSceneText.ui ├── 4.textDialog.ui ├── 5.codeDialog.ui ├── 6.graphicsSceneBox.ui ├── 7.graphicsScenePixmap.ui ├── 8.graphicsSceneShrCt.ui ├── 9.toolbox.ui └── wizard.py When I try to run an

reading UI file and connecting elements such as buttons, text, etc

自作多情 提交于 2020-05-29 09:43:32
问题 I'm looking at using PySide2, but reading UI files, instead of generating Python via pyside2-uic. Strangely, I can't seem to find an example of this simple connectivity. I see the difference between PyQt5 and PySide2: https://www.learnpyqt.com/blog/pyqt5-vs-pyside2/ but am unclear on how a button would hook up in using PySide2. The simplest code which brings up the window is here; what I can't quite figure is the bit that hooks up to the element (btnTest) which was created in the UI. I've

reading UI file and connecting elements such as buttons, text, etc

萝らか妹 提交于 2020-05-29 09:41:45
问题 I'm looking at using PySide2, but reading UI files, instead of generating Python via pyside2-uic. Strangely, I can't seem to find an example of this simple connectivity. I see the difference between PyQt5 and PySide2: https://www.learnpyqt.com/blog/pyqt5-vs-pyside2/ but am unclear on how a button would hook up in using PySide2. The simplest code which brings up the window is here; what I can't quite figure is the bit that hooks up to the element (btnTest) which was created in the UI. I've

Python 'called with the wrong argument type' error

こ雲淡風輕ζ 提交于 2020-05-23 21:36:10
问题 I understand why I am getting this error, it's looking for my object as an argument, and receiving a string value. But I'm confused as to what the solution would be? The following code snippet is simply trying to run this command; self.buttonGroup.addButton(self.ui.m001) x number of times: num = 0 range_ = 10 prefix = "m" for i in range (range_): if num <(range_-1): numString = "00"+str(num) if (num >9): numString = "0"+str(num) button = "self.ui."+prefix+numString self.buttonGroup.addButton