rnd / random numbers gtk3 example

A home for all kinds of Puppy related projects
Post Reply
Message
Author
3wsparky
Posts: 25
Joined: Mon 19 May 2008, 07:47

rnd / random numbers gtk3 example

#1 Post by 3wsparky »

Has anyone ever made a gtk script that can generate a random number between 100 and 200 and show it in the gtk dialog ?

I have looked on google but not had any success as yet........

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

Code: Select all

#!/bin/bash
xmessage -title "random" -center  $(($RANDOM%100 +100))
http://hacktux.com/bash/random
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

3wsparky
Posts: 25
Joined: Mon 19 May 2008, 07:47

Question to the Gods of gtk

#3 Post by 3wsparky »

Where did you learn this code from , I haven't manage to find any good sites with examples for dimbo newbie's i.e. ME :D
I would like to find a good source on gtk

anyone got some good sources they wish to share?

3wsparky
Posts: 25
Joined: Mon 19 May 2008, 07:47

got random working

#4 Post by 3wsparky »

How do you present a variable in my example

rndnumber="123" # will be replaced with ((Random))
<entry><default>$rndnumber</default><variable>number</variable>

all it seems to display is $rndnumber how do I present that statement as a variable from above.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#5 Post by MU »

here are some tips for Gtkdialog:
http://www.murga-linux.com/puppy/viewtopic.php?t=38608

http://xpt.sourceforge.net/techdocs/lan ... 01s03.html

Here is a simple example to start with:

Code: Select all

#!/bin/bash

export a=$(($RANDOM%100 +100))

export mytest="	
<window title=\"testwindow\">
<vbox>
<hbox>

 <button>
  <label>$a</label>
  <action>rxvt &</action>
 </button>

</hbox>
</vbox>
</window>"

result=`gtkdialog3 --program=mytest --center`

echo "the grafical program exited with: $result"

exit
The random I found with google, I think I googled for "bash random".
Important is to avoid '
Instead use "
Inside two ", use: \"

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

Post Reply