| Author |
Message |
vovchik

Joined: 23 Oct 2006 Posts: 1231 Location: Ukraine
|
Posted: Tue 29 Nov 2011, 16:24 Post subject:
BMI Calculator (GUI) - IMPERIAL UPDATE 2 Dec 2011 Subject description: Now with SI, US and UK units - v. 0.2 |
|
Dear Puppians,
Here is a quick little hack to calculate your BMI (body mass index). I wrote a little CLI prog in BaCon to do the calculation and did the gui in gtkdialog4 (although it could all be done nicely in BaCon and I just might do that next). The screenshots are pretty self-explanatory. A menu item will be created in the Personal category called BMI Calculator. The Calc Info button will take you to a screen that explains the BMI system. NOTE that I compiled this in Lucid, so it will not work in older puppies. I also make use of Thunor's latest gtkdialog4 (called as gtkdialog by the gui). The BaCon source file is in the /usr/local/BMI-gui/src directory, so you can recompile it for older puppies if you have devx and BaCon installed.
Eat, drink and be merry
WIth kind regards,
vovchik
UPDATE1: I posted version version 0.1b, since Terryphi found a real mistake in the BMI calculation. Sorry about that. That happens when you code late at night. I should have gone to bed several hours hence. I also eliminated the dependency on "fmt" and made a suitable replacement with tr and sed. I am certain technosaurus could do it using straight bash, making it even less dependent on externals. I will now think about how to do the calculations with bc.
UPDATE2: See my post below for the details. I eliminated nearly all external depencies and coded all the calcualtions in bash/bc, so there is no longer a call to an external program. It should run on all puppies provided that they get Thunor's update to gtkdialog. Pemasu has provided a link for getting the source, and others on the forum have posted ready-to-use pets of the latest version. I will add the links to this first post if you can indicate where they are. Thanks.
UPDATE3: As requested by Terryphi, I have included Imperial units (stone) and made it easier to input height as feet and inches. All calculations are done now by bc, so, from a puppy dependencies standpoint, all you need is a recent gtkdialog for the program to work. The new pics show the revised gui.
UPDATE3a: I just made a slight adjustment in that the inches spinboxes had a minimum value set at 0.5 and I changed that to 0.0. The little bug was noticed when I put in my own height - which is 6'0" - and I saw that it couldn't be done! It now can.
 |
| Description |
|

Download |
| Filename |
bmi-gui-0.2.pet |
| Filesize |
50.41 KB |
| Downloaded |
125 Time(s) |
| Description |
|
| Filesize |
43.46 KB |
| Viewed |
519 Time(s) |

|
| Description |
|
| Filesize |
84.93 KB |
| Viewed |
510 Time(s) |

|
Last edited by vovchik on Fri 02 Dec 2011, 11:06; edited 5 times in total
|
|
Back to top
|
|
 |
Jim1911
Joined: 19 May 2008 Posts: 2353 Location: Texas, USA
|
Posted: Tue 29 Nov 2011, 17:27 Post subject:
|
|
It doesn't appear to work using Dpup Experimo 5.x.10. Calculated BMI results isn't shown as it is in your posted image. It's a great little program. I'll check it out with some other pups.
Thanks,
Jim
| Description |
|
| Filesize |
48.64 KB |
| Viewed |
723 Time(s) |

|
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1231 Location: Ukraine
|
Posted: Tue 29 Nov 2011, 17:41 Post subject:
|
|
Dear Jim,
It seems to me that the bmi command line program is not kicking in. If you go to the /usr/local/BMI-gui/bin directory and open a terminal, try running:
and please report what is says. It will probably complain, which means that you might have an older version of certain system libs than I do. I will try tomorrow to post a pet for use with older pets, since I also have a 3.01 puppy installation and can compile it there. That should work on ALL puppies from 2007 onwards.
With kind regards,
vovchik
|
|
Back to top
|
|
 |
pemasu

Joined: 08 Jul 2009 Posts: 5170 Location: Finland
|
Posted: Tue 29 Nov 2011, 17:54 Post subject:
|
|
I think the reason is that I have used coreutils pet which does not have fmt binary included.
Crap the /usr/bin/fmt from Lucid Puppy or trace coreutils package which have it or...if you are lazy....which you probably are not....install the attached pet.
By the way....this is first medical app I have tested in dpup exprimo or any puppy. I have kept my hands out of them. But those pics of different fat contents made the urge irresistable.
Thank you.
| Description |
|

Download |
| Filename |
fmt-from-coreutils-lucid-0.0.1.pet |
| Filesize |
17.86 KB |
| Downloaded |
87 Time(s) |
|
|
Back to top
|
|
 |
Jim1911
Joined: 19 May 2008 Posts: 2353 Location: Texas, USA
|
Posted: Tue 29 Nov 2011, 18:53 Post subject:
|
|
Pemasu's pet corrected the problem. Looks great except for the overweight category that showed up for me.
| Description |
|
| Filesize |
65.82 KB |
| Viewed |
690 Time(s) |

|
|
|
Back to top
|
|
 |
pemasu

Joined: 08 Jul 2009 Posts: 5170 Location: Finland
|
Posted: Tue 29 Nov 2011, 19:11 Post subject:
|
|
Hmm...to my eye...there seems to be slight problem. I will post my tough diet advices soon to your pm.
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1231 Location: Ukraine
|
Posted: Wed 30 Nov 2011, 04:18 Post subject:
|
|
Dear puppians,
Thanks to pemasu for supplying the "fmt" command, which is called by a function in the gui prog. I had the mistaken impression that it was on all *nixs. Oh well, live and learn I think I should include a check for it, or, better, just do the reformatting in sed or using plain bash. I have no doubts that technosaurus has a brilliant bash replacement for "fmt" in his arsenal.
The impetus for writing this this little program came from this thread: http://puppylinux.info/topic.php?id=55. I then checked the wiki BMI page and looked at a few implementations in php and javascript. The equation is REALLY elementary, and I was surprised that many (even commercial) implementations complicated it unnecessarily (i.e. computing the BMI separately for English and Metric system units), which is pure nonsense, rather than first doing the unit standarization bit and then calculating, which results in more efficient code and should be self-evident to anybody. Enough ranting for now...
Cheers,
vovchik
|
|
Back to top
|
|
 |
Terryphi

Joined: 02 Jul 2008 Posts: 698 Location: West Wales, Britain.
|
Posted: Wed 30 Nov 2011, 07:17 Post subject:
|
|
You can compare the results with this online BMI calculator:
http://www.bbc.co.uk/health/tools/bmi_calculator/bmi.shtml
We Brits like Imperial measurements.
_________________ Opera browser SFS package for Precise, Slacko, Racy, Wary, Lucid, Quirky, etc available here 
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1231 Location: Ukraine
|
Posted: Wed 30 Nov 2011, 08:04 Post subject:
|
|
Dear Terryphi,
Thanks for checking. My next version will do stone too, but you IMPORTANTLY discovered some flaw in the calculation (whoops! mea culpa!) that made everybody seem fatter and that has now been fixed. I also removed the fmt dependency (only tr and sed), so please get the update from the first post!
With kind regards,
vovchik
PS. The fix is nice since it represents "virtual slimming", much like twitter or facebook serve as as proxies for communication.
|
|
Back to top
|
|
 |
Terryphi

Joined: 02 Jul 2008 Posts: 698 Location: West Wales, Britain.
|
Posted: Wed 30 Nov 2011, 09:59 Post subject:
|
|
Vovchik ,
Happy to help. Can you do a virtual fix for the world economy as well?
_________________ Opera browser SFS package for Precise, Slacko, Racy, Wary, Lucid, Quirky, etc available here 
|
|
Back to top
|
|
 |
UncleBaldie

Joined: 03 Feb 2008 Posts: 35 Location: Staffordshire, UK
|
Posted: Wed 30 Nov 2011, 11:48 Post subject:
|
|
Hi,
I have d/l and installed BMI, but 'fraid it doesn't work for me.
I am running Lucid528 with update 002.
I get the following message when run from a terminal:
** ERROR **: gtkdialog: Error in line 30, near token 'string': syntax error
aborting...
/usr/local/BMI-gui/bmi-gui: line 304: 4268 Aborted gtkdialog --program main_gui
rm: cannot remove `/tmp/bmi.txt': No such file or directory
Any suggestions (of a computing nature, obviously !!).
Phil
_________________ Crackin' cheese, Gromit lad...
Toshiba Satellite U200-P115 - Lucid Pup528/PCLinuxOS/MacPup528/Fluppy13
Lenovo 3000-C100 - Win 7/LucidPup528
Woof-woof......oh yes !!
|
|
Back to top
|
|
 |
UncleBaldie

Joined: 03 Feb 2008 Posts: 35 Location: Staffordshire, UK
|
Posted: Wed 30 Nov 2011, 12:15 Post subject:
Subject description: Solved !! |
|
Hi,
It appears that gtkdialog on my system is a symlink to gtkdialog3.
I edited bmi-gui to call gtkdialog4, and all is well...
Oops.....
Phil
_________________ Crackin' cheese, Gromit lad...
Toshiba Satellite U200-P115 - Lucid Pup528/PCLinuxOS/MacPup528/Fluppy13
Lenovo 3000-C100 - Win 7/LucidPup528
Woof-woof......oh yes !!
|
|
Back to top
|
|
 |
pemasu

Joined: 08 Jul 2009 Posts: 5170 Location: Finland
|
Posted: Wed 30 Nov 2011, 12:49 Post subject:
|
|
Thank you of corrections to the reuploaded pet. I tested it again and it works now without fmt binary. I will include BMI calculator to my next Puppy build.
It will be my way to increase the global need for healthy measures of human body. Maybe you and I can inhibit the problem of global concern of metabolic syndrome by letting people to check their status.
I had and have still this message when launched in console:
| Code: | # ./bmi-gui
widget_text_refresh(): <width> not implemented for this widget. |
|
|
Back to top
|
|
 |
majorfoo
Joined: 07 Mar 2011 Posts: 420 Location: Wish I knew
|
Posted: Wed 30 Nov 2011, 17:14 Post subject:
|
|
d/l pet and tried in luci-529 I(three headed dog)
did not work - received forllowing
/root
# bmi-gui
** ERROR **: gtkdialog: Error in line 30, near token 'string': syntax error
aborting...
/usr/local/BMI-gui/bmi-gui: line 304: 10809 Aborted gtkdialog --program main_gui
rm: cannot remove `/tmp/bmi.txt': No such file or directory
/root
#
Edit---
failed to read above post - changed gtkdialog to gtkdialog4 in bmi-gui
and works in luci-529
|
|
Back to top
|
|
 |
pemasu

Joined: 08 Jul 2009 Posts: 5170 Location: Finland
|
Posted: Wed 30 Nov 2011, 17:26 Post subject:
|
|
I believe that luci has gtkdialog as symlink to gtkdialog3.
I suggest you autocompile newest gtkdialog4 with attached script.
Remove phony .gz, give it executable permissions and launch it from console.
It downloads, compiles, strips, etc...and creates folder to the /tmp like gtkdialog...something. Copy gtkdialog and symlinks gtkdialog3 and gtkdialog4 which points to the gtkdialog from that folder to the /usr/sbin folder.
I am not sure if Lucid is compatible with newer gtkdialog4 but....you will find out soon.
If you face problems, restore older stuff from /initrd/pup_ro2/.....
Edit. I see now that previous post has been edited. And the fix was posted earlier. Oh well. Here is my solution suggestion anyway....lol...
| Description |
|

Download |
| Filename |
update-gtkdialog.gz |
| Filesize |
503 Bytes |
| Downloaded |
83 Time(s) |
|
|
Back to top
|
|
 |
|