1

I have a question regarding pyside2-uic as it seems to generate faulty code. First off, is there no way to disable the translation in Qt Designer? It's a pain to disable the translateable checkbox for every string and I find the retranslateUi code a bit messy.

Now to the real issue: as you can see, pyside2-uic seems to increase the item position count even for unrelated widgets. If I create a subclass and execute it, combo-boxes like combox_wb do not carry the default values as the items 7-9 probably dont exist and probably should be 0-2. (I know you could just leave them empty and do the setup manually inside the class that inherits from the uic generated one).

def retranslateUi(self, MainWindow):
    self.gbox_settings.setTitle(QtWidgets.QApplication.translate("MainWindow", "settings", None, -1))
    self.combox_colorspace.setItemText(0, QtWidgets.QApplication.translate("MainWindow", "0   Raw color (unique to each camera)", None, -1))
    self.combox_colorspace.setItemText(1, QtWidgets.QApplication.translate("MainWindow", "1   sRGB D65 (default)", None, -1))
    self.combox_colorspace.setItemText(2, QtWidgets.QApplication.translate("MainWindow", "2   Adobe RGB (1998) D65", None, -1))
    self.combox_colorspace.setItemText(3, QtWidgets.QApplication.translate("MainWindow", "3   Wide Gamut RGB D65", None, -1))
    self.combox_colorspace.setItemText(4, QtWidgets.QApplication.translate("MainWindow", "4   Kodak ProPhoto RGB D65", None, -1))
    self.combox_colorspace.setItemText(5, QtWidgets.QApplication.translate("MainWindow", "5   XYZ", None, -1))
    self.combox_colorspace.setItemText(6, QtWidgets.QApplication.translate("MainWindow", "6   ACES", None, -1))
    self.combox_wb.setItemText(7, QtWidgets.QApplication.translate("MainWindow", "ignore camera white balance", None, -1))
    self.combox_wb.setItemText(8, QtWidgets.QApplication.translate("MainWindow", "use camera white balance", None, -1))
    self.combox_wb.setItemText(9, QtWidgets.QApplication.translate("MainWindow", "specify  own raw white balance", None, -1))
    self.combox_gamma.setItemText(10, QtWidgets.QApplication.translate("MainWindow", "linear", None, -1))
    self.combox_gamma.setItemText(11, QtWidgets.QApplication.translate("MainWindow", "sRGB", None, -1))
    self.combox_bitdepth.setItemText(12, QtWidgets.QApplication.translate("MainWindow", "16-bit", None, -1))
    self.combox_bitdepth.setItemText(13, QtWidgets.QApplication.translate("MainWindow", "8-bit", None, -1))
    self.tbtn_dcrawexec.setText(QtWidgets.QApplication.translate("MainWindow", "...", None, -1))
ekhumoro
  • 98,079
  • 17
  • 183
  • 279
HdM Upload
  • 35
  • 3
  • Could you explain me better since I don't understand you – eyllanesc Aug 05 '19 at 21:17
  • self.combox_wb.setItemText cannot set itemTexts for item widgets 7-9 as they don't exist because the combox created in qtdesigner only contains 3 items so far which are 0-2 – HdM Upload Aug 05 '19 at 21:43
  • You could provide the .ui: open the .ui it with any editor and you will see that it is an XML, then paste it in your question. – eyllanesc Aug 05 '19 at 21:46
  • Alright, if you'd post it as a reply I can accept it as the correct answer. Thanks for investigating. – HdM Upload Aug 06 '19 at 21:27

2 Answers2

1

Just got the new version of PySide2. Seems like it's fixed now. If you use pip, just run "pip install --upgrade PySide2" to upgrade.

Tim Körner
  • 235
  • 1
  • 8
0

This is caused by a bug in PySide. The same ui file will work as expected when using PyQt or the old PySide (i.e. the indexing re-starts at zero for each widget). Looking at the code for pyside2uic/uiparser.py shows that they use a shared attribute (self.item_nr) for indexing - but it only ever gets reset to zero for tree-widgets.

I suggest you create a bug report.

ekhumoro
  • 98,079
  • 17
  • 183
  • 279