From: Michael Wiebusch Date: Thu, 21 Aug 2014 12:13:56 +0000 (+0200) Subject: added a simple gui (draft) X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=b246f548282646b83ef8f3c1f45f30b930391a69;p=coral.git added a simple gui (draft) --- diff --git a/user_interface/README b/user_interface/README new file mode 100644 index 0000000..6382199 --- /dev/null +++ b/user_interface/README @@ -0,0 +1 @@ +i have added an origin repository at jspc55.1/mwiebusch/padiwa-analyzer diff --git a/user_interface/gui.pl b/user_interface/gui.pl new file mode 100755 index 0000000..8a6d441 --- /dev/null +++ b/user_interface/gui.pl @@ -0,0 +1,112 @@ +#!/usr/bin/perl -w + +use strict; +use Gtk2 '-init'; + +use constant TRUE => 1; +use constant FALSE => 0; + +my $window = Gtk2::Window->new; +$window->set_title ('FPGA based pulse width analyzer'); +$window->signal_connect (destroy => sub { Gtk2->main_quit; }); +$window->set_border_width(3); + +my $vbox = Gtk2::VBox->new(FALSE, 6); +$window->add($vbox); + +my $actions_frame = Gtk2::Frame->new('Actions'); +$vbox->pack_start($actions_frame, TRUE, TRUE, 0); +$actions_frame->set_border_width(3); + +my $plot_frame = Gtk2::Frame->new('Plot'); +$vbox->pack_start($plot_frame, TRUE, TRUE, 0); +$plot_frame->set_border_width(3); + + +my $hbox = Gtk2::HBox->new(FALSE, 6); +$actions_frame->add($hbox); +$hbox->set_border_width(3); + + + +################################################## +## buttons ## +################################################## + +my $inc_button = Gtk2::Button->new('_Click Me'); +$hbox->pack_start($inc_button, FALSE, FALSE, 0); +my $count = 1; + +my $plot_button = Gtk2::Button->new('_Plot'); +$hbox->pack_start($plot_button, FALSE, FALSE, 0); + +my $clear_button = Gtk2::Button->new('_Clear'); +$hbox->pack_start($clear_button, FALSE, FALSE, 0); + +my $quit_button = Gtk2::Button->new('_Quit'); +$hbox->pack_start($quit_button, FALSE, FALSE, 0); +$quit_button->signal_connect( clicked => sub { + Gtk2->main_quit; + }); + + +my $image = Gtk2::Image->new_from_file ("plot.png"); +# $vbox->pack_start($image, TRUE, TRUE, 0); +$plot_frame->add($image); + + + + +# my $label = Gtk2::Label->new('Clicked 0 times.'); +# $vbox->pack_start($label, TRUE, TRUE, 0); + + + +################################################## +## button functions ## +################################################## +# has to be done after we've created the label so we can get to it +$inc_button->signal_connect( clicked => \&update_clicks); +sub update_clicks { + +# $label->set_text("Clicked $count times."); + $count++; + +} + + +$plot_button->signal_connect( clicked => sub { + +# $label->set_text(qx%echo blah%); + execute("./plot.sh"); + $plot_frame->remove($image); + $image->clear; + $image = Gtk2::Image->new_from_file ("plot.png"); + $plot_frame->add($image); + $window->show_all; + +}); + +$clear_button->signal_connect( clicked => sub { + + execute("./analyzer.pl --clear"); + +}); + + + + +sub execute { + my $command = shift; + print "execute:\n$command\n"; + system($command); + print "\n\n"; + +} + + + + + +$window->show_all; +Gtk2->main; \ No newline at end of file diff --git a/user_interface/plot.png b/user_interface/plot.png index 7ca953b..e69de29 100644 Binary files a/user_interface/plot.png and b/user_interface/plot.png differ diff --git a/user_interface/plot.sh b/user_interface/plot.sh index 66ae370..a2f5b8f 100755 --- a/user_interface/plot.sh +++ b/user_interface/plot.sh @@ -5,9 +5,9 @@ right=$2 ./analyzer.pl > out.dat cat < 1; +use constant FALSE => 0; + +my $window = Gtk2::Window->new; +$window->set_title ('Widget Layout'); +$window->signal_connect (destroy => sub { Gtk2->main_quit; }); +$window->set_border_width(3); + +my $vbox = Gtk2::VBox->new(FALSE, 6); +$window->add($vbox); + +my $frame = Gtk2::Frame->new('Buttons'); +$vbox->pack_start($frame, TRUE, TRUE, 0); +$frame->set_border_width(3); + +my $hbox = Gtk2::HBox->new(FALSE, 6); +$frame->add($hbox); +$hbox->set_border_width(3); + +my $inc_button = Gtk2::Button->new('_Click Me'); +$hbox->pack_start($inc_button, FALSE, FALSE, 0); +my $count = 1; + +my $quit_button = Gtk2::Button->new('_Quit'); +$hbox->pack_start($quit_button, FALSE, FALSE, 0); +$quit_button->signal_connect( clicked => sub { + Gtk2->main_quit; + }); + +my $label = Gtk2::Label->new('Clicked 0 times.'); +$vbox->pack_start($label, TRUE, TRUE, 0); + +# has to be done after we've created the label so we can get to it +$inc_button->signal_connect( clicked => sub { + $label->set_text("Clicked $count times."); + $count++; + }); + +$window->show_all; +Gtk2->main;