I have two quick questions with the plugin I built:

  1. (Red circle) How can I set the size of the plugin window when it loads into QGIS? The default size when loaded is a little bit too small and not all tabs are visible.

  2. (Yellow circle) Is there any method to change the name of the plugin? I change the code of the Sava_attribute plugin (in the tutorial) to make my own but I would like the change the name of the plugin.

enter image description here

1 Answer 1


You can change the size (and position) of your plugin window fairly easily. You should be able to add the following line in the initGui() method of your main plugin python file (change the parameters to suit your needs):

self.dlg.setGeometry(100, 100, 750, 500)

The parameters are: x position (distance from left of screen), y position (distance from top of screen), width of dialog window, height of dialog window.

And just bear in mind that the x, y position is anchored to the top left corner of the central frame of the window, not the corner of the window itself (see image):

*interestingly, it seems the exception to this is if you use a 0, 0 position which, on my Windows laptop at least, results in the dialog window locking perfectly in to the corner of the screen; while a 5, 5 position cuts off the window title bar.

enter image description here

As for changing the name, if you just want to change the title of the plugin dialog window (circled in yellow in your screenshot) you should get away with just adding another line to the initGui() method:

self.dlg.setWindowTitle('Window Title You Want')

However if you want to change the name of the entire plugin everywhere including in the plugin manger etc. that would be a lot more tedious. If you used Plugin Builder, the generated files use the name you entered as your plugin name and this name is referenced throughout the plugin e.g. in the metadata, in the plugin dialog file to load the ui, in the main plugin file to import the dialog class, to add the plugin to menus and icons to toolbars etc. etc.

I suppose you could technically replace all references to the old name with the new, but this would be quite time consuming and prone to error and could cause the plugin not to load properly. In that case, it might be quicker and easier to run Plugin Builder again and generate all the necessary files with the new name and copy the code containing your 'plugin logic' from one to the other. If you spent a lot of time modifying the ui file in Designer, you could probably re-use that by renaming it and copying into the plugin folder.

  • Does anyone know what the 'main plugin python file' is? I've searched everywhere but don't really know what i'm looking for.
    – KWx
    May 31, 2022 at 6:35
  • @KWx, by 'main plugin python file' I mean the file which defines the plugin class e.g. class YourPluginName: containing the methods __init__(), initGui(), unload() etc. For example, if you use Plugin Builder, a file will be created called your_plugin_name.py. Please have a read of: docs.qgis.org/3.22/en/docs/pyqgis_developer_cookbook/plugins/…. Also, look at the structure of some plugins from the official repository. For a simpler, minimal plugin structure example see: github.com/wonder-sk/qgis-minimal-plugin
    – Ben W
    May 31, 2022 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.