Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 25 May 2013, 02:48
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
BMI Calculator (GUI) - IMPERIAL UPDATE 2 Dec 2011
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [17 Posts]   Goto page: 1, 2 Next
Author Message
vovchik


Joined: 23 Oct 2006
Posts: 1231
Location: Ukraine

PostPosted: 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 Smile

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. Smile 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.
bmi-gui-0.2.pet
Description 
pet

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

bmi01.jpg

bmi02.jpg
 Description   
 Filesize   84.93 KB
 Viewed   510 Time(s)

bmi02.jpg


Last edited by vovchik on Fri 02 Dec 2011, 11:06; edited 5 times in total
Back to top
View user's profile Send private message 
Jim1911

Joined: 19 May 2008
Posts: 2353
Location: Texas, USA

PostPosted: 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
image-2.jpg
 Description   
 Filesize   48.64 KB
 Viewed   723 Time(s)

image-2.jpg

Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1231
Location: Ukraine

PostPosted: 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:
Code:
./bmi

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
View user's profile Send private message 
pemasu


Joined: 08 Jul 2009
Posts: 5170
Location: Finland

PostPosted: 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.
fmt-from-coreutils-lucid-0.0.1.pet
Description 
pet

 Download 
Filename  fmt-from-coreutils-lucid-0.0.1.pet 
Filesize  17.86 KB 
Downloaded  87 Time(s) 
Back to top
View user's profile Send private message 
Jim1911

Joined: 19 May 2008
Posts: 2353
Location: Texas, USA

PostPosted: 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. Sad
image-3.jpg
 Description   
 Filesize   65.82 KB
 Viewed   690 Time(s)

image-3.jpg

Back to top
View user's profile Send private message 
pemasu


Joined: 08 Jul 2009
Posts: 5170
Location: Finland

PostPosted: 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
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1231
Location: Ukraine

PostPosted: 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 Smile 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...Smile

Cheers,
vovchik
Back to top
View user's profile Send private message 
Terryphi


Joined: 02 Jul 2008
Posts: 698
Location: West Wales, Britain.

PostPosted: 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. Wink

_________________
Opera browser SFS package for Precise, Slacko, Racy, Wary, Lucid, Quirky, etc available here Smile
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1231
Location: Ukraine

PostPosted: 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
View user's profile Send private message 
Terryphi


Joined: 02 Jul 2008
Posts: 698
Location: West Wales, Britain.

PostPosted: Wed 30 Nov 2011, 09:59    Post subject:  

Vovchik ,

Happy to help. Can you do a virtual fix for the world economy as well? Wink

_________________
Opera browser SFS package for Precise, Slacko, Racy, Wary, Lucid, Quirky, etc available here Smile
Back to top
View user's profile Send private message Visit poster's website 
UncleBaldie


Joined: 03 Feb 2008
Posts: 35
Location: Staffordshire, UK

PostPosted: 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
View user's profile Send private message MSN Messenger 
UncleBaldie


Joined: 03 Feb 2008
Posts: 35
Location: Staffordshire, UK

PostPosted: 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
View user's profile Send private message MSN Messenger 
pemasu


Joined: 08 Jul 2009
Posts: 5170
Location: Finland

PostPosted: 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. Very Happy Very Happy Very Happy

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
View user's profile Send private message 
majorfoo

Joined: 07 Mar 2011
Posts: 420
Location: Wish I knew

PostPosted: 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
View user's profile Send private message 
pemasu


Joined: 08 Jul 2009
Posts: 5170
Location: Finland

PostPosted: 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...
update-gtkdialog.gz
Description 
gz

 Download 
Filename  update-gtkdialog.gz 
Filesize  503 Bytes 
Downloaded  83 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [17 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0706s ][ Queries: 13 (0.0045s) ][ GZIP on ]