]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
added a simple gui (draft)
authorMichael Wiebusch <antiquark@gmx.net>
Thu, 21 Aug 2014 12:13:56 +0000 (14:13 +0200)
committerMichael Wiebusch <antiquark@gmx.net>
Thu, 21 Aug 2014 12:13:56 +0000 (14:13 +0200)
user_interface/README [new file with mode: 0644]
user_interface/gui.pl [new file with mode: 0755]
user_interface/plot.png
user_interface/plot.sh
user_interface/plot2.png [new file with mode: 0644]
user_interface/test3.pl [new file with mode: 0755]

diff --git a/user_interface/README b/user_interface/README
new file mode 100644 (file)
index 0000000..6382199
--- /dev/null
@@ -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 (executable)
index 0000000..8a6d441
--- /dev/null
@@ -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
index 7ca953bbaf5ed18add2a6f532d46458118a284f7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
Binary files a/user_interface/plot.png and b/user_interface/plot.png differ
index 66ae3701db40bb0bf77ed53c604b1c8730749c55..a2f5b8f765121da646848df00495ab65e0531a31 100755 (executable)
@@ -5,9 +5,9 @@ right=$2
 
 ./analyzer.pl > out.dat
 cat <<EOF | gnuplot
-#set terminal png
-set terminal postscript enhanced solid color
-set output "plot.ps"
+set terminal png
+set terminal postscript enhanced solid color
+set output "plot.png"
 #set xrange [$left:$right]
 plot "out.dat" using 1:2
 EOF
diff --git a/user_interface/plot2.png b/user_interface/plot2.png
new file mode 100644 (file)
index 0000000..3f7b5ee
Binary files /dev/null and b/user_interface/plot2.png differ
diff --git a/user_interface/test3.pl b/user_interface/test3.pl
new file mode 100755 (executable)
index 0000000..f479d4e
--- /dev/null
@@ -0,0 +1,45 @@
+#!/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 ('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;