Picard & Qt Designer / Creator .. Where to Start?

So … for editing, I’ve been using PyCharm mostly because, well, I know how to use their UI and it seems like a good IDE for Python, what with having never looked at a line of any of it before a few months ago.

But now- for the UI and such, in general.

“No coding required”. Really? :wink: Sure thing.

Do I just pick a .ui file? Do I need to setup a Project? Is there a ‘main file’ or something to load first? PyCharm pretty much parsed the whole sourcetree and figured it out where as Qt Designer took me through a similar setup, suggested some file type filters to apply and then starts at an empty window and I can’t see any of the files in /picard. So un-intuitive.

I see where there’s comments that say "don’t edit, use build_ui or whatever… "

I’m still used to a nice big long source file in a single window. The I and E in IDE are still “amazing” to me, how (PyCharm, not Qt Designer, at least) seems to want to help you with whats going on.

Anyone have a quick run down on what/where to start?
What parts of Picard I should be editing with what, etc?

QT uses an xml based layout engine to determine what widgets to put where on the screen.
So I would download and install the QT Designer to edit the xml files and use the ide of your choice for everything else.
QT Designer gives you a drag and drop layout designer so you can put the buttons and widgets where you like.

The python side of things you will be loading these xml files and that will create all the python objects representing the gui.
For example in your python code you may need to write the code that will find the checkbox and see if it is checked or unchecked and update a variable in your code.

2 Likes

Qt designer is a graphical interface designer and is used solely to generate and edit the .ui files.

After you edited a .ui file or created a new one you need to run:

 python setup.py build_ui

This will generate the necessary code from the UI files. All Python code editing should be done in your IDE / code editor of choice. PyCharm is a good one. I personally use Visual Studio Code.

2 Likes

Just to add to the existing replies and address the point quoted:
To avoid starting with a blank window, you could pick an existing plugin with a ui that you makes a suitable starting point - many of them include the ui file in the plugin folder.
I find QT Designer fairly easy to use, but it is worth being careful about naming conventions, particularly if you have a lot of options.

If you look at the code in Classical Extras - which has the biggest ui and option set of all the plugins (not necessarily a good thing!) - you will see that:

  1. There is a separate module called const.py to hold all the options (as well as constants)
  2. Each of the options is a dictionary with the structure:
    {‘option’: ‘name in QT Designer’,
    ‘name’: ‘user-friendly name’,
    ‘type’: ‘Boolean or whatever’,
    ‘default’: True or False (for Boolean) etc.
    }
    Multi-choice options are multiple boolean options with the same ‘name’ and an additional dictionary entry ‘value’ for the value of the choice.
  3. The main _init_.py has an API call “register_options_page(ClassicalExtrasOptionsPage)”
  4. There is a class ClassicalExtrasOptionsPage(OptionsPage) where the load and save functions call a “parsing” function called “plugin_options(option_type)” which reads the relevant part of const.py

There may be better ways of doing things (I’m open to suggestions!), but this works quite well for me. When I create a new option in the QT ui, I just copy the name into an options item in const.py - no further coding needed (except for the business logic of what to do with the option, of course).

3 Likes