Howto:Adding a canvas to a GUI dialog
Jump to navigation
Jump to search
The FlightGear forum has a subforum related to: Canvas |
You can just open an existing dialog from $FG_ROOT/gui/dialogs, and copy a simple dialog like the exit/about dialog, and customize it according to your needs - i.e. by naming it "fgplot.xml", remove any stuff that you don't need, then add a new canvas widget to the dialog, like this:
<canvas>
<name>fgplot</name>
<valign>fill</valign>
<halign>fill</halign>
<stretch>true</stretch>
<pref-width>600</pref-width>
<pref-height>400</pref-height>
<nasal>
<!-- this is the Nasal/canvas section where you can run your own Nasal code -->
<load><![CDATA[
# you can add your canvas code here
var my_canvas = canvas.get( cmdarg() );
print("Hello world from the embedded canvas section!\n");
]]>
</load>
</nasal>
</canvas>
You can then use Nasal to animate your canvas and draw graphics etc.