Nyall Dawson 8f36cdfa44 [processing] Add API to allow a string parameter to show as a combobox
with preset choices in processing GUI

In some circumstances it is desirable to restrict the values available
when a user is asked to enter a string parameter to a list of predetermined
"valid" values, yet these values will vary installation by installation
(e.g. a "printer name" parameter, where you want users to pick from
printers installed on the system, but since the printer names will
vary install to install an enum parameter is not a valid choice)

This can now be done by setting the widget wrapper metadata
"value_hints" option, as demonstrated below. (While this provides a mechanism
for guiding users to select from valid string values when running a Processing
algorithm through the GUI, it does not place any limits on the string values
accepted via PyQGIS codes or when running the algorithm via other non-gui
means. Algorithms should gracefully handle other values accordingly.)

    param = QgsProcessingParameterString( 'PRINTER_NAME', 'Printer name')
    # show only printers which are available on the current system as options
    # for the string input.
    param.setMetadata( {'widget_wrapper':
      { 'value_hints': ['Inkjet printer', 'Laser printer'] }
    })
2021-08-01 05:33:51 +10:00
..
2021-03-22 21:13:52 +01:00
2021-03-22 21:13:52 +01:00
2021-03-22 21:13:52 +01:00
2021-03-22 21:13:52 +01:00
2021-03-22 21:13:52 +01:00
2021-03-22 21:13:52 +01:00