Giving error bad window path name 
Author Message
 Giving error bad window path name

 proc plot {res titles} { ;# adapted the simple graph plotter found on
http://www.*-*-*.com/
  # --------------------------
  #   params
  # --------------------------
  # title
  # canvas width & height
  array set params \
  {
    title     {Graph}
    width     400
    height    400
   }

  # canvas
         if [winfo exists .c] { ;# delete it. Same as clear.
          destroy .c
        }
        canvas .c -width $params(width) -height $params(height) \
              -xscrollincrement 1 -bg beige
  pack .c

  wm title . $params(title)

 # get range of x & y
        set xmin 100000000
        set xmax -100000000
        set ymin 100000000
        set ymax -100000000
        set vv0 [lindex $res 1]
        set nvars [llength $vv0]
        foreach {r y} $res {
                set xmin [::math::min $xmin $r]
                set xmax [::math::max $xmax $r]
                foreach yv $y { ;# get range of Y coordinate
                        set ymin [::math::min $ymin $yv]
                        set ymax [::math::max $ymax $yv]
                }
        }

 #how often tick marks
     set tspace [expr ($xmax-$xmin)/8.0] ;# how often to draw grid in X
     set nexttic [expr int($xmin/$tspace)*$tspace]
        foreach {r y} $res { ;# draw grid
                if {$r >= $nexttic} {
                        set xpix [scale $nexttic $xmin $xmax $params(width)]
                      set nexttic [expr $nexttic+$tspace]
                      .c create text [expr $xpix-10] 0 -anchor n -text $r -fill gray
                      .c create line $xpix 0 $xpix $params(height) -fill gray
                }
         }

 #how often Ytick marks
     set tspace [expr ($ymax-$ymin)/8.0] ;# how often to draw grid in X
     set nexttic [expr int($ymin/$tspace)*$tspace]
        while {$nexttic < $ymax} { ;# draw grid
                set ypix [scale $nexttic $ymax $ymin $params(height)]
                      set nexttic [expr $nexttic+$tspace]
                      .c create text 10 [expr $ypix-10] -anchor n -text $nexttic
-fill gray
                      .c create line 0 $ypix $params(width) $ypix -fill gray
         }

 #label graphs
      .c create text 20 10 -anchor n -text [lindex $titles 0] -fill red
      .c create text 20 25 -anchor n -text [lindex $titles 1] -fill
black

        for {set iy 0} {$iy<$nvars} {incr iy} {
        set color "black"
        if {$iy==1} {set color "red"}
        if {$iy==2} {set color "green"}
        set coordlist {}
        foreach {r y} $res {
                        set xpix [scale $r $xmin $xmax $params(width)]
                set vv [lindex $y $iy]
                set v [scale $vv $ymax $ymin $params(height)]
                lappend coordlist $xpix $v
           set rold $xpix
           set yold $v   ;# vector of y values
         }
            .c create line $coordlist -fill $color
    }
    update
 }

set plot {}
    for {set i 0} {$i<20} {incr i} { lappend plot [expr $i/3.0] [expr
sin($i/3.0)]}
    plot $plot "Sine"

------ Can anybody guide what is the wrong in this program when i run
this program it gives error like "
Error in startup script: bad window path name "0"
    while executing
"scale $nexttic $xmin $xmax $params(width)"
    (procedure "plot" line 43)
    invoked from within
"plot $plot "Sine"
"
"

I am not able to remove this error because in new in Tk

-- Puneet



Fri, 27 Jul 2007 19:30:21 GMT  
 Giving error bad window path name
 > ...

Quote:
>      set nexttic [expr int($xmin/$tspace)*$tspace]
> ...
>            set ypix [scale $nexttic $ymax $ymin $params(height)]
> ------ Can anybody guide what is the wrong in this program when i run
> this program it gives error like "
> Error in startup script: bad window path name "0"
>     while executing
> "scale $nexttic $xmin $xmax $params(width)"
>     (procedure "plot" line 43)
>     invoked from within
> "plot $plot "Sine"
> "

In your code, nexttic is an integer. The first time through it has a
value of 0 (zero). You are trying to create a widget with the name "0"
which is illegal. That is why tk is saying "bad window pathname "0"".
Window pathnames must begin with a ".".


Fri, 27 Jul 2007 23:32:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Bad Window Path Name

2. ???bad window path name???

3. C4 ABC - System crashes when giving Full Path Name for a file

4. Problem with exec under Win 3.11 gives error file creation bad file number

5. CW dictionary convert gives ERROR(3) Path not found

6. Bad window path with radiobutton/labelframe

7. BUG in tk4.2 on Windows - bad library search path

8. help : Error : bad window path name ".hello"

9. __name__ in embedded python giving error

10. Giving your 'Window' a name

11. Making file path control only select directory paths not file names

12. os.path.split() with DOS path names

 

 
Powered by phpBB® Forum Software