php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57695 newt_scale stuck at 100%
Submitted: 2007-06-06 11:49 UTC Modified: 2007-10-27 20:06 UTC
From: ar018 at yahoo dot com Assigned:
Status: Closed Package: newt (PECL)
PHP Version: 5.2.1 OS: linux 2.6.20-15
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ar018 at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-06-06 11:49 UTC] ar018 at yahoo dot com
Description:
------------
System: Kubuntu Feisty, libnewt0.52_0.52.2-8ubuntu2, 
libnewt-dev_0.52.2-8ubuntu2, php-cli 5.2.1, pecl/newt-1.1

newt_scale_set shows the scale at 100% regardless of the 
input given. Cross checked with whiptail, which uses the 
same libnewt (might be compiled statically against another 
libnewt version though - I don't know), and seen that 
whiptail's "--gauge" works as expected.

Reproduce code:
---------------
#!/usr/bin/php
<?php
newt_init(); newt_cls();
newt_centered_window(60, 9, "Please wait...");
$waitlbl = newt_label(30, 3, "");
$waitscl = newt_scale(5, 6, 50, 100);
$waitform = newt_form();
newt_form_add_components($waitform, array($waitlbl, $waitscl));
newt_form_set_timer($waitform, 1);
newt_run_form($waitform);
for ($i = 1; $i <= 100; $i++) {
    sleep(1);
    newt_label_set_text($waitlbl, $i);
    newt_scale_set($waitscl, $percent);
    newt_refresh();
}
newt_form_destroy($waitform);
newt_pop_window ();
newt_finished ();
?>

Expected result:
----------------
A window with a label and scale widget, both counting from 
0 up to 100 in sync.

Actual result:
--------------
Label widget counts up. Scale widget shows 0% at initial 
creation, but then gets stuck at 100% at the first (and 
subsequent) newt_scale_set() updates.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-06 12:01 UTC] ar018 at yahoo dot com
3rd line in the for() body needs to be corrected as:

    newt_scale_set($waitscl, $i);

The result is the same. This err of mine revealed that 
it's the same for newt_scale_set() if it's been given a 
valid amount or null. It doesn't get/see/process the 
amount value passed.
 [2007-06-06 15:24 UTC] ar018 at yahoo dot com
$ file /usr/bin/whiptail
/usr/bin/whiptail: ELF 32-bit LSB executable, Intel 80386, 
version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked 
(uses shared libs), stripped

So whiptail is using the same libnewt, then this is not a 
libnewt bug. The script I used to test with whiptail 
follows:

#!/bin/bash
{
    for ((i = 0 ; i <= 100 ; i++)); do
        sleep 1
        echo $i
    done
} | whiptail --gauge "Please wait" 5 50 77


As a workaround, I've written 2 functions (mewt_scale and 
mewt_scale_set) to mimic the originals:

function mewt_scale($mewt_left, $mewt_top, $mewt_width, 
$mewt_full_value) {
	global $mewt_scale_instances;
	$mewt_barlen = $mewt_width - 6;
	$mewt_scale_this = newt_label($mewt_left, 
$mewt_top, "[" . str_repeat("_", $mewt_barlen) . "]% --");
	$mewt_scale_instances[$mewt_scale_this] = 
array($mewt_left, $mewt_top, $mewt_barlen, 
$mewt_full_value);
	return $mewt_scale_this;
}

function mewt_scale_set($mewt_scale_this, $mewt_amount) {
	global $mewt_scale_instances;
	list($mewt_left, $mewt_top, $mewt_barlen, 
$mewt_full_value) = 
$mewt_scale_instances[$mewt_scale_this];
	$mewt_amount = min(max(0, $mewt_amount),
$mewt_full_value);
	$mewt_percent = (int) ($mewt_amount * 100.0 / 
$mewt_full_value + 0.5);
	$mewt_barfull = (int) ($mewt_barlen * 
$mewt_percent / 100 + 0.5);
	$mewt_barempty = $mewt_barlen - $mewt_barfull;
	$mewt_barcontent = substr("[" . str_repeat("*", 
$mewt_barfull) . str_repeat(" ", $mewt_barempty) . "]%" . 
sprintf("%3d   ", $mewt_percent), 0, $mewt_barlen + 6);
	newt_label_set_text($mewt_scale_this, 
$mewt_barcontent);
}
 [2007-09-10 06:38 UTC] spektom at gmail dot com
Thank you for taking the time to write to us, but this is not
a bug.

Can't re-create. This script works pretty well:

<?php
newt_init(); newt_cls();
newt_centered_window(60, 9, "Please wait...");
$waitlbl = newt_label(30, 3, "");
$waitscl = newt_scale(5, 6, 50, 100);
$waitform = newt_form();
newt_form_add_components($waitform, array($waitlbl, $waitscl));
newt_form_set_timer($waitform, 1);
newt_run_form($waitform);
for ($i = 1; $i <= 100; $i++) {
    usleep(100);
    newt_label_set_text($waitlbl, $i);
    newt_scale_set($waitscl, $i);
    newt_refresh();
}
newt_form_destroy($waitform);
newt_pop_window ();
newt_finished ();
?>
 [2007-10-27 20:06 UTC] ar018 at yahoo dot com
The bug was (and still is) existing in Feisty, but it is 
now working in Gutsy. Here are the relevant differences 
between the two: (from "pear info newt" and "php -v")

Feisty (buggy):
Newt Version:1.1 Release Date:2005-07-07 Last 
Modified:2007-05-24
PHP-Cli: 5.2.1

Gutsy (works):
Newt Version:1.1 Release Date:2005-07-07 Last 
Modified:2007-10-27
PHP-Cli: 5.2.3-1ubuntu6

Anyway it now works, so  I've closed the report. Thank you 
for your time.
 [2011-09-03 22:13 UTC] mitsuya at mitsuya-eng dot jp
http://www.medmuster.com/ ordering priligy =-) http://www.pillslife.net/ accutane %-((
 [2011-09-12 19:45 UTC] graessle at caritas-dicv-fr dot de
http://www.pricechampion.net/ accutane 8-] http://www.qualitytablets.net/ lexapro withdrawls gzwla
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 23:01:23 2020 UTC