Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1128

pyside2-rcc not works / Resource (qrc) not works for python

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • None
    • 5.13.1
    • PySide
    • None
    • Windows

    Description

      I have created a very simple demo:

      $ ls
      resource.qrc  resource_rc.py  this_is_a_picture.png  ui_widget.py  widget.py  widget.ui
      
      $ cat resource.qrc
      <RCC>
          <qresource prefix="/prefix">
              <file alias="aPicture">this_is_a_picture.png</file>
          </qresource>
      </RCC>
      
      $ cat widget.ui
      <?xml version="1.0" encoding="UTF-8"?>
      <ui version="4.0">
       <class&amp;amp;amp;gt;Widget</class&amp;amp;amp;gt;
       <widget class="QWidget" name="Widget">
        <property name="geometry">
         <rect>
          <x>0</x>
          <y>0</y>
          <width>724</width>
          <height>465</height>
         </rect>
        </property>
        <property name="windowTitle">
         <string>Form</string>
        </property>
        <property name="styleSheet">
         <string notr="true">background-image: url(:/prefix/aPicture);</string>
        </property>
       </widget>
       <resources>
        <include location="resource.qrc"/>
       </resources>
       <connections/>
      </ui>
      
      $ cat widget.py
      from PySide2.QtWidgets import QWidget, QApplication
      from PySide2.QtCore import QObject
      import sys
      
      class Widget(QWidget):
          def __init__(self, parent=None):
              from ui_widget import Ui_Widget
              super().__init__(parent)
              self.ui = Ui_Widget()
              self.ui.setupUi(self)
      
      if __name__ == '__main__':
          app = QApplication(sys.argv)
          widget = Widget()
          widget.show()
          sys.exit(app.exec_())
      
      

       

      #Here is how I generating the files:
      pyside2-rcc resource.qrc > resource_rc.py
      pyside2-uic widget.ui --output=ui_widget.py
      pyside2-uic --version
      PySide2 User Interface Compiler version , running on PySide2 5.13.1.
      pyside2-rcc --version
      PySide2 resource compiler
      c:\users\<user>\apps\pythonvenv37\lib\site-packages\PySide2\scripts\..\pyside2-rcc: Unknown option: '--version'
      Usage: c:\users\<user>\apps\pythonvenv37\lib\site-packages\PySide2\scripts\..\pyside2-rcc  [options] <inputs>
      

      And this example not works!!!

       

      Qt designer vs running it by python:

        

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            weiqi_chen_zy Weiqi Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes