如何解决如何使用 Ada 代码关闭图形窗口/小部件?
我正在运行一个用 Ada 编写的示例代码。代码的任务是使用 plplot 库绘制函数。它设置为使用 xcairo 驱动程序。当我在 linux (opensuse) 中执行程序时,程序显示终端 shell,然后显示另一个窗口(widget-xcairo?),其中包含绘图的图形显示。如何使用 ada 命令关闭另一个窗口而不关闭正在运行的终端外壳?我可以通过用鼠标单击关闭图标来关闭另一个窗口,但我想知道如何使用 ada 代码关闭另一个窗口以进行编程。用于 PLplot 的 ada 绑定中的 End_PLplot 命令具有 plend 命令,它可能会结束 plplot 执行但不会关闭另一个窗口。下面是示例代码,
with
Ada.Strings,Ada.Strings.Unbounded,PLplot_Auxiliary,PLplot_Standard;
use
Ada.Strings,PLplot_Standard;
procedure speedplot is
driver : Unbounded_String;
x,y : Real_Vector(0 .. 100);
x_Min,y_Min : constant := 0.0;
x_Max : constant := 1.0;
y_Max : constant := 100.0;
begin
-- Prepare data to be plotted.
for i in x'range loop
x(i) := Long_Float(i) / Long_Float(x'length - 1);
y(i) := y_Max * x(i)**2;
end loop;
-- Parse and process command line arguments.
driver := To_Unbounded_String("xcairo");
Set_Device_Name(To_String(driver));
-- Initialize plplot.
Initialize_PLplot;
-- Create a labelled Box to hold the plot.
Set_Environment(x_Min,x_Max,y_Min,y_Max,Justification => Not_Justified,Axis_Style => Linear_Box_Plus);
Write_Labels
(X_Label => "x",Y_Label => "y=100 x#u2#d",Title_Label => "Simple PLplot demo of a 2D line plot");
-- Plot the data that was prepared above.
Draw_Curve(x,y);
-- Close PLplot library.
End_PLplot; -- <-- problem is here. Would like to continue running code below this line.
end speedplot;
解决方法
我通过在现有代码中添加代码行 Set_Pause(False) 解决了这个问题,
-- Stop waiting for user response
Set_Pause(False);
-- Close PLplot library.
End_PLplot;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。