Picard Options / MainWindow Design/Layout Changes?

Tags: #<Tag:0x00007f7d00441d88>

Is the Main Window layout all done within mainwindow and no Qt Creator files?

I see there are .ui files for the Options and other secondary windows.

Would getting Line Numbers and ‘find/search’ abilities into the Renaming Options be something that’s possible with Qt Creator or Designer, or is there more involved?

I know… "Why does he want a Find option in the QTextEdit for the renaming script… "

I’ve got a lot of scripting in there :wink: It’s easier to jump around when editing by using find/search for keywords.

Like finding the right place for something like this? :wink:

QTextCursor cursor = ui.textEdit->textCursor();
int y = cursor.blockNumber() + 1;
int x = cursor.columnNumber() + 1;

…and/or https://doc.qt.io/archives/4.6/uitools-textfinder.html

I’m up to no good…

The main window is constructed in code. For the option pages there are layout files, look for the options_*.ui files.

There is more involved. Qt designer allows you to add the “search” button to the layout (place it somewhere). But you still need to implement the actual search action in Python.

In general Qt Designer is not much magic. It just is a visual UI designer, where you can build a UI by placing the elements by drag and drop. It can be very convenient especially for a UI with many elements, as it is the case for most option pages.

The UI gets stored in a Qt specific XML format in the .ui files. When you run setup.py build_ui those XML files get converted to actual Python code as the picard/ui_*.py files. E.g. take a look at the picard/ui/ui_options_renaming.py, that code got autogenerated from the corresponding ui file. It defines a Ui_RenamingOptionsPage class.

The actual renaming option dialog is manually implemented in picard/ui/options/renaming.py. In the constructor the autogenerated code from Ui_RenamingOptionsPage gets called to create the UI elements.

def __init__(self, parent=None):
    super().__init__(parent)
    self.ui = Ui_RenamingOptionsPage()
    self.ui.setupUi(self)
    # ...

In general Picard does not use UI files for everything. Sometimes the UI is generated from code, sometimes via UI files. Depending on what is being done one way can be easier than another. Also a hybrid approach is possible, where parts of the UI are configured in the ui file, but certain things are setup in code.

3 Likes