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

QFile should have __enter__ + __exit__ (context manager)

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:
      None
    • Platform/s:
      All
    • Technical Risk:
      Low

      Description

      It would be more pythonic, if QFile would have _enter_ + _exit_ to be also full-featured py file object (=mimic io.FileIO interface a bit).

      Then you can write the dynamic .ui file loading:

       

      loader=QtUiTools.QUiLoader()
      try:
          with QtCore.QFile("path-to-ui.ui") as f:
              window = loader.load(f)
              return window
      except Exception as e:
          logger.error("... %s : %s", type(e), e)

      (Improvemement to https://bit.ly/3mapkTk)

       

         

        Attachments

        For Gerrit Dashboard: PYSIDE-1380
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            crmaurei Cristian Maureira-Fredes
            Reporter:
            mailos Miloš Korenčiak
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There is 1 open Gerrit change