Friday, April 19, 2024
36
rated 0 times [  36] [ 0]  / answers: 1 / hits: 2392  / 2 Years ago, thu, april 14, 2022, 6:52:51

Is there a random generator for linux with a nice GUI, which can generate a random integer between two integers and display it with a large fontsize?


More From » software-recommendation

 Answers
3

I don't know any software. Google didn't come up with something either. Guess this is too simple a problem. It should be about 30 lines of code if you wrote it in a scripting language. You could also create a LibreOffice spreadsheet to do that. Shouldn't be terribly difficult.



Edit 1:



pseudo-random number generator - perl gui script



Below is a quick and dirty perl script I coded. You should be able to modify it yourself. When you run it with perl nameOfTheScript.pl or make it executable with chmod u+x nameOfTheScript.pl and then double click it, it will look like in the picture above.



#!/usr/bin/perl
# © 2011 [email protected]. Use permitted under MIT license: http://www.opensource.org/licenses/mit-license.php
use Gtk2 '-init'; # relies on the gnome toolkit bindings for perl

$size = 1e5; # fontsize in 0.001 pt (only god knows why)

sub randomizeLabel { #### this does the actual randomisation
$min = int($entry1->get_text);
$max = int($entry2->get_text);
$rand = int(rand($max-$min+1)) + $min;
$diplabel->set_markup( "<span size="$size">$rand</span>" );
}
#### the rest is gui stuff:
$window = Gtk2::Window->new('toplevel');
$window->set_title('Random Integer Generator');
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->signal_connect(delete_event => sub { Gtk2->main_quit; });
$window->set_border_width(10);
$vbox = Gtk2::VBox->new(0, 5); $window->add($vbox); $vbox->show;

$diplabel = Gtk2::Label->new;
$diplabel->set_markup("<span size="$size">0</span>");
$vbox->add($diplabel); $diplabel->show;

$entry1 = Gtk2::Entry->new; $vbox->add($entry1); $entry1->show;
$entry2 = Gtk2::Entry->new; $vbox->add($entry2); $entry2->show;

$button = Gtk2::Button->new("Generate!");
$button->signal_connect(clicked => &randomizeLabel, $window);
$vbox->add($button); $button->show;

$window->show; Gtk2->main;
exit 0;


Edit2



ObsessiveFOSS asked me to include another generator for random numbers (as it is this script uses Perl's build-in one). You can see a sketch on howto do it in my other answer.


[#44907] Saturday, April 16, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antebrow

Total Points: 291
Total Questions: 135
Total Answers: 117

Location: New Caledonia
Member since Thu, Mar 23, 2023
1 Year ago
antebrow questions
;