Giter VIP home page Giter VIP logo

Comments (8)

mottosso avatar mottosso commented on May 30, 2024

Ah, interesting, I've never used these myself. What do they do?

from qt.py.

fredrikaverpil avatar fredrikaverpil commented on May 30, 2024

They are used to load .ui files made in Qt Designer.

These seem to be the most common modules to use when loading a .ui file:

  • PyQt4.uic
  • PySide.QtUiTools.QUiLoader

However, there's an issue with PySide's QUiLoader which makes it behave differently than PyQt's uic. When you've loaded the UI using QUiLoader, you don't access the objects through the expected namespace (if you consider PyQt to be "god"). I believe that could have been why pysideuic was developed, as it fixes that – but I don't for a fact this was the reasoning on why pysideuic was made.

Here's an example where I use pysideuic to load the UI if you're using PySide -- or use PyQt4.uic if you're using PyQt4. And regardless of choice, you can perform the self.listWidget.addItem('Hello world') at the end of main.py which would modify the UI (if it has a listWidget).

  • All of this is really useful and nice when you jump between Maya, Nuke and PySide/PyQt.
  • So far, I can tell that this same behaviour is true for PyQt5/PySide2.
  • It's important to note that functions of PyQt4.uic and pysideuic are not the same.

I'm not sure myself if this is a good idea, and I might have a better idea at the end of the week. I'm afraid we may be making code harder to read if we create e.g. PySide.uic and PySide2.uic. And especially since they will need a separate module installed (pysideuic).

Hacketihackhack.

from qt.py.

mottosso avatar mottosso commented on May 30, 2024

Here's an example

Isn't there an easier way of doing that? It seems awefully complex.

With PyQt4 there is this.

If we're wrapping any of that, I would expect something along these lines.

from Qt import loadUi

Where loadUi is our own version and behaves like PySide2.

from qt.py.

fredrikaverpil avatar fredrikaverpil commented on May 30, 2024

It seems awefully complex.

Agreed. But there's no real equivalent of PyQt4.uic.loadUi in PySide. Instead, you have to use PySide.QtUiTools.QUiLoader. Which is why I've gone through all that trouble.

PySide.QtUiTools.QUiLoader works fairly well if you only load one ui file, example here with comparisons to PyQt4.uic.loadUi.

I'll try to write up an example to show when it'll become problematic with QUiLoader. But I digress somewhat. Since there are multiple choices of .ui loaders to choose between, perhaps it's not a good thing that we choose for the end-user.

I'd like to close my own question with a "no, not right now anyways".

from qt.py.

mottosso avatar mottosso commented on May 30, 2024

Agreed. But there's no real equivalent of PyQt4.uic.loadUi in PySide.

Ah, I see.

I'd be fine with a loadUi convenience function coming from this project, that does what it does for PyQt. That seems like the simplest method.

I'd like to close my own question with a "no, not right now anyways".

Let's keep it open, the question is bound to come up again sooner or later.

from qt.py.

fredrikaverpil avatar fredrikaverpil commented on May 30, 2024

So perhaps it could be interesting to explore after all. I've been tinkering and here's a gist.

Some issues:

  • UI file is not loaded into self. Instead it is loaded into e.g. self.ui.
  • The second UI file cannot be loaded into self.ui and any widgets we need to access needs to be moved into self.ui manually.
  • Haven't tested this with PyQt5 as that errors out at the moment #28

from qt.py.

mottosso avatar mottosso commented on May 30, 2024

I'll let you decide what's best here, as I don't use this feature.

from qt.py.

fredrikaverpil avatar fredrikaverpil commented on May 30, 2024

Sure, will do. I'll be back with a suggestion/PR.

from qt.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.