Skip to content

Code: Adding new option to GUI CLI

Gilbert edited this page May 7, 2018 · 5 revisions

Files of interest for new GUI or CLI options.

Other notes

  • Once an option has been added to the PrintConfig, and populated it is available in under the config object in Perl.

Adding to GUI Preferences dialog

An example for how to add a new GUI Preferences dialog option.

  • Add the item and its default value to lib/Slic3r/GUI.pm, specifically the our $Settings variable.
  • Add a new line in lib/Slic3r/GUI/Preferences.pm
    $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
        opt_id      => 'view_mode', # this needs to match the name chosen in $Settings
        type        => 'select', # option type, use a different type if desired
        label       => '3D View Mode', # Label text
        tooltip     => 'Choose between orthographic view in 3D (default) and a less accurate perspective view (artsy).', # tooltop text
        labels      => ['Orthographic','Perspective'], # this is for a select box, it's an array of values
        values      => ['ortho','perspective'], # these are the values that a selectbox can take. 
        default     => $Slic3r::GUI::Settings->{_}{}, # this is a reference to what you put in GUI.pm
        width       => 130, # change this if the box is too small.
    ));
  • You can now reference the new setting as $Slic3r::GUI::Settings->{_}{name} (where name is whatever you called it) elsewhere in the program.