[Matplotlib-users] How can I solve this ... ???

2010-07-03 Thread Ademir Francisco da Silva

 Hello all,

I really need a help to solve this problem below ..., so let's go ...

I have a Python script( plus Tkinter, Pmw and PmwContribD, matplotlib ) 
with more than 5.000 lines and when I have included a matplot Button 
code ( look excerpt of may code below ) appears this error message after 
I use /on_clicked( self.button_12Click )/  to quit of that figure and 
ask to Tkinter run it again ...


Error: 1
class '_tkinter.TclError' Exception in Tk callback
  Function: function callit at 0x073B2C88 (type: type 
'function')

  Args: ()
Traceback (innermost last):
  File C:\Python26\lib\site-packages\Pmw\Pmw_1_3\lib\PmwBase.py, line 
1747, in __call__

return apply(self.func, args)
  File C:\Python26\lib\lib-tk\Tkinter.py, line 495, in callit
func(*args)
  File 
C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py, 
line 273, in idle_draw

self.draw()
  File 
C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py, 
line 259, in draw

tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File C:\Python26\lib\site-packages\matplotlib\backends\tkagg.py, 
line 19, in blit
tk.call(PyAggImagePhoto, photoimage, id(aggimage), colormode, 
id(bbox_array))

class '_tkinter.TclError': this isn't a Tk application

Apparently the problem is in /tkagg.py module/ , so how can I solved 
this ???


Excerpt of my code .:

def graphic_1( self ):
fig = pyplot.figure( figsize = ( 7.5, 4.5 ), dpi = 100 )
Several code here 
widgets.Button( pyplot.axes( [ .91, .1, .08, .06 ] ), 
self.textName[ 19 ],
color = self.cor[ 403 ][ 1 ], 
hovercolor = self.cor[ 46 ][ 1 ] ).\

on_clicked( self.button_12Click )
Several code here 
pyplot.show()

def button_12Click( self, e = None ):pyplot.close( all )

I have tried to use this /self.Master.update_idletasks()/  with no 
sucess. Please aid me to find a solution.



Thank you very much.



--
Ademir Francisco da Silva

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How can I solve this ... ??? II

2010-07-03 Thread Ademir Francisco da Silva

 Hello all,

I have another problem to solve but I guess be easier than my first 
message for this list ..., so let's go again ...,


I have this error message as follow ...

Exception in Tkinter callback
Traceback (most recent call last):
  File C:\Python26\lib\lib-tk\Tkinter.py, line 1410, in __call__
return self.func(*args)
  File C:\Users\Ademir\Documents\Ademir\Python\Modulos\Lottery.py, 
line 1361, in table_2Rel
if askyesno( self.textName[ 21 ], self.textName[ 22 ] ):   
self.graphic_2()
  File C:\Users\Ademir\Documents\Ademir\Python\Modulos\Lottery.py, 
line 1469, in graphic_2

else:   pyplot.draw()
  File C:\Python26\lib\site-packages\matplotlib\pyplot.py, line 349, 
in draw

get_current_fig_manager().canvas.draw()
  File 
C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py, 
line 258, in draw

FigureCanvasAgg.draw(self)
  File 
C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py, line 
394, in draw

self.figure.draw(self.renderer)
  File C:\Python26\lib\site-packages\matplotlib\artist.py, line 55, 
in draw_wrapper

draw(artist, renderer, *args, **kwargs)
  File C:\Python26\lib\site-packages\matplotlib\figure.py, line 802, 
in draw

func(*args)
  File C:\Python26\lib\site-packages\matplotlib\artist.py, line 55, 
in draw_wrapper

draw(artist, renderer, *args, **kwargs)
  File C:\Python26\lib\site-packages\matplotlib\text.py, line 524, in 
draw

bbox, info = self._get_layout(renderer)
  File C:\Python26\lib\site-packages\matplotlib\text.py, line 303, in 
_get_layout

clean_line, ismath = self.is_math_text(line)
  File C:\Python26\lib\site-packages\matplotlib\text.py, line 978, in 
is_math_text

if cbook.is_math_text(s):
  File C:\Python26\lib\site-packages\matplotlib\cbook.py, line 1682, 
in is_math_text

s = unicode(s)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 5: 
ordinal not in range(128)


excerpt of may code is ...

fig.suptitle( LotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight = 
extra bold,
  fontstyle = italic, color = self.cor[ 608 ][ 1 
], lod = True )


The problem is /LotoFácil/  . I solve it just using LotoFacil instead 
but I'm Brazilian and this is not correct for us. Help me please.



Thank you very much,


--
Ademir Francisco da Silva

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How can I solve this ... ??? II

2010-07-03 Thread Ryan May
On Sat, Jul 3, 2010 at 4:12 PM, Ademir Francisco da Silva
ademirfs_...@itelefonica.com.br wrote:
 excerpt of may code is ...
 fig.suptitle( LotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight = extra 
 bold,
   fontstyle = italic, color = self.cor[ 608 ][ 1 ], lod 
 = True )

 but I'm Brazilian and this is not correct for us. Help me please.

Try using a python unicode string instead:

fig.suptitle( uLotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight
= extra bold,
   fontstyle = italic, color = self.cor[ 608 ][
1 ], lod = True )

That works for me here (though with the original, I just get missing
characters, not an error).

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How can I solve this ... ??? II

2010-07-03 Thread Ademir Francisco da Silva

 Ryan ...,

Very good ..., it works perfectly ...

It's so easy but I didn't remember to use it ...

In fact my problem is slightly more complicated than this because I have 
used  textName[ 2 ]  instead of literal  LotoFácil  as I told you ( I 
know I didn't say this before, my fault ), the correct code is ...


fig.suptitle( textName[ 2 ], fontsize = self.fon[ 6 ][ 1 ], fontweight = 
extra bold,
  fontstyle = italic, color = self.cor[ 608 ][ 1 
], lod = True )


however, after your mention about /unicode string/ you gave me a good 
idea so I solved my problem this way ...


fig.suptitle( unicode( self.textName[ 2 ], cp1252 ), fontsize = 
self.fon[ 6 ][ 1 ], fontweight = extra bold,
  fontstyle = italic, color = self.cor[ 608 ][ 1 
], lod = True )


and everything works perfectly again.

But I was thinking that the correct way is to fix it there in cbook.py, 
anyway ...


File C:\Python26\lib\site-packages\matplotlib\cbook.py, line 1682, in 
is_math_text

s = unicode(s)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 5: 
ordinal not in range(128)



Thank you very much for your prompt aid,



Ademir Francisco da Silva


Em 03/07/2010 19:05, Ryan May escreveu:

On Sat, Jul 3, 2010 at 4:12 PM, Ademir Francisco da Silva
ademirfs_...@itelefonica.com.br  wrote:

excerpt of may code is ...
fig.suptitle( LotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight = extra 
bold,
   fontstyle = italic, color = self.cor[ 608 ][ 1 ], lod 
= True )

but I'm Brazilian and this is not correct for us. Help me please.

Try using a python unicode string instead:

fig.suptitle( uLotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight
= extra bold,
fontstyle = italic, color = self.cor[ 608 ][
1 ], lod = True )

That works for me here (though with the original, I just get missing
characters, not an error).

Ryan




--
Ademir Francisco da Silva

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How can I solve this ... ??? II

2010-07-03 Thread Benjamin Root
Ademir,

I am glad it is working for you now.  Just as a note, the unicode() function
uses whatever encoding that is default on your system.  Therefore, if it is
possible for you to get inputs of strings in other encodings, then it is
considered good practice to handle this at the point of string creation.
Therefore, the rest of the code can simply assume that the strings are in
the system's default encoding.

Therefore, something like your solution would be better than changing the
unicode() call in the suptitle() function.

Ben Root


On Sat, Jul 3, 2010 at 9:22 PM, Ademir Francisco da Silva 
ademirfs_...@itelefonica.com.br wrote:

  Ryan ...,

 Very good ..., it works perfectly ...

 It's so easy but I didn't remember to use it ...

 In fact my problem is slightly more complicated than this because I have
 used  textName[ 2 ]  instead of literal  LotoFácil  as I told you ( I know I
 didn't say this before, my fault ), the correct code is ...

 fig.suptitle( textName[ 2 ], fontsize = self.fon[ 6 ][ 1 ], fontweight =
 extra bold,

   fontstyle = italic, color = self.cor[ 608 ][ 1 ],
 lod = True )

 however, after your mention about *unicode string* you gave me a good idea
 so I solved my problem this way ...

 fig.suptitle( unicode( self.textName[ 2 ], cp1252 ), fontsize = self.fon[
 6 ][ 1 ], fontweight = extra bold,

   fontstyle = italic, color = self.cor[ 608 ][ 1 ],
 lod = True )

 and everything works perfectly again.

 But I was thinking that the correct way is to fix it there in cbook.py,
 anyway ...

 File C:\Python26\lib\site-packages\matplotlib\cbook.py, line 1682, in
 is_math_text
 s = unicode(s)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 5:
 ordinal not in range(128)


 Thank you very much for your prompt aid,



 Ademir Francisco da Silva


 Em 03/07/2010 19:05, Ryan May escreveu:

 On Sat, Jul 3, 2010 at 4:12 PM, Ademir Francisco da 
 Silvaademirfs_...@itelefonica.com.br ademirfs_...@itelefonica.com.br 
 wrote:

  excerpt of may code is ...
 fig.suptitle( LotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight = extra 
 bold,
   fontstyle = italic, color = self.cor[ 608 ][ 1 ], lod 
 = True )

 but I'm Brazilian and this is not correct for us. Help me please.

  Try using a python unicode string instead:

 fig.suptitle( uLotoFácil, fontsize = self.fon[ 6 ][ 1 ], fontweight
 = extra bold,
fontstyle = italic, color = self.cor[ 608 ][
 1 ], lod = True )

 That works for me here (though with the original, I just get missing
 characters, not an error).

 Ryan




 --
 Ademir Francisco da Silva



 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users