Opened 10 years ago

Closed 10 years ago

Last modified 6 years ago

#1872 closed defect (fixed)

Internal Error: TclError: bad screen distance "640.0"

Reported by: didley@… Owned by: Bhuricha Deen Sethanandha
Priority: normal Component: TracMetrixPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11


After using Tracmetrix I received a error message:

File "f:\programme\python25\lib\site-packages\Trac-0.11dev-py2.5.egg\trac\web\", line 434, in dispatch_request
File "f:\programme\python25\lib\site-packages\Trac-0.11dev-py2.5.egg\trac\web\", line 217, in dispatch
  resp = chosen_handler.process_request(req)
File "build\bdist.win32\egg\tracmetrixplugin\", line 416, in process_requestFile "build\bdist.win32\egg\tracmetrixplugin\", line 537, in _render_viewFile "build\bdist.win32\egg\tracmetrixplugin\", line 287, in create_cummulative_chartFile "F:\Programme\Python25\Lib\site-packages\matplotlib\", line 2317, in cla
  ret =  gca().cla(*args, **kwargs)
File "F:\Programme\Python25\Lib\site-packages\matplotlib\", line 883, in gca
  ax =  gcf().gca(**kwargs)
File "F:\Programme\Python25\Lib\site-packages\matplotlib\", line 893, in gcf
  return figure()
File "F:\Programme\Python25\Lib\site-packages\matplotlib\", line 859, in figure
  figManager = new_figure_manager(num, figsize=figsize, dpi=dpi, facecolor=facecolor, edgecolor=edgecolor, frameon=frameon, FigureClass=FigureClass, **kwargs)
File "F:\Programme\Python25\Lib\site-packages\matplotlib\backends\", line 90, in new_figure_manager
  figManager = FigureManagerTkAgg(canvas, num, window)
File "F:\Programme\Python25\Lib\site-packages\matplotlib\backends\", line 274, in __init__
  self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
File "F:\Programme\Python25\Lib\site-packages\matplotlib\backends\", line 545, in __init__
  NavigationToolbar2.__init__(self, canvas)
File "F:\Programme\Python25\Lib\site-packages\matplotlib\", line 1163, in __init__
File "F:\Programme\Python25\Lib\site-packages\matplotlib\backends\", line 585, in _init_toolbar
File "F:\Programme\Python25\lib\lib-tk\", line 2442, in __init__
  Widget.__init__(self, master, 'frame', cnf, {}, extra)
File "F:\Programme\Python25\lib\lib-tk\", line 1930, in __init__
  (widgetName, self._w) + extra + self._options(cnf))

code fragment:

1925.   for k in cnf.keys():
1926. if type(k) is ClassType:
1927. classes.append((k, cnf[k]))
1928. del cnf[k]
1930. (widgetName, self._w) + extra + self._options(cnf))
1931. for k, v in classes:
1932. k.configure(self, v)
1933. def destroy(self):
1934. """Destroy this and all descendants widgets."""
1935. for c in self.children.values(): c.destroy()

local variables:

classes  	[]
cnf 	{'width': 640.0, 'borderwidth': 2, 'height': 50}
extra 	()
k 	'height'
kw 	{}
master 	<Tkinter.Tk instance at 0x027E2C60>
self 	<matplotlib.backends.backend_tkagg.NavigationToolbar2TkAgg instance at ...
widgetName 	'frame'

Attachments (0)

Change History (9)

comment:1 Changed 10 years ago by Bhuricha Deen Sethanandha


Look like you have problem with Matplotlib module. I use following configuration and it works.

I am not sure when I will be able to get to this bug as I am working on the enhancement. It would be great if you could try to use plugin on the same configuration and see if the problem exists.

comment:2 Changed 10 years ago by didley@…

Sorry! But I cant try to install with python 2.4.4 . I'm using Python 25. But after a reinstall now I have an another error. Looks not so hard.

TclError: bad screen distance "640.0"

What means that?

comment:3 Changed 10 years ago by didley@…

Sorry! But there is no time to try to install with python 2.4.4 . I'm using python 2.5

Maybe in my private time.

comment:4 Changed 10 years ago by Bhuricha Deen Sethanandha

didley, thanks for your interest. I will get to this bug once I completed the baseline functionality on Aug 20.

Please also tell me the version of the packages you use. (numpy, matplotlib, gtk) I will try to replicate your configuration and test it.

comment:5 Changed 10 years ago by didley@…


I'm using

  • Python 2.5
  • Python 2.5 numpy-1.0.3
  • Python 2.5 pygtk-2.10.4
  • Python 2.5 matplotlib-0.90.1
  • Python 2.5 svn-python-1.43

comment:6 Changed 10 years ago by Bhuricha Deen Sethanandha

Resolution: fixed
Status: newclosed

comment:7 Changed 8 years ago by lexter


I'm getting the same error while running some code. The weird thing it's that I get the error only in some computers, in others works perfect. Even in the same computer, for one user works OK and for another one not.

Some help please, I've spent 2 days running in circles...

comment:8 Changed 7 years ago by anonymous


I get also the problem of

tkinter.TclError: bad screen distance "320.0"

The error occurs, when I import

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure from matplotlib.pyplot import imshow

and proceed



self.dpi = 100

self.fig = Figure(dpi=self.dpi)

self.canvas = FigureCanvas(self.fig)

I want to use imshow in an QT-Application to have fast look for intensity plots.

Would be great, if anybody could help me!

comment:9 Changed 6 years ago by John Doe III.


just for completeness' sake and because this page was the first one Google came up with when searching for that error (and because it drove us nuts for two days): We have observed the same error message ("bad screen distance 640.0") with python 2.7.0, 2.7.1 and 2.7.2 when trying to plot with matplotlib 1.0.1 (all in Windows 64 bit).

The weird thing was that it worked on one machine, but not on the one next to it, which was set up in exactly the same way - or at least we thought so. We found the solution on It turns out the numerical locale was different on the two machines. It worked when the locale was English, but failed for German. I.e., it seems the "640.0" is being converted from a string to float/integer at some point, and that only works in the English numerical locale, where the decimal point is the "." (in German it's the ",").

For us, it worked to manually set the locale just before initializing the matplotlib figure (from the linked bug report):

import locale
locale.setlocale(locale.LC_NUMERIC, 'C')

Cheers, JD

Modify Ticket

as closed The owner will remain Bhuricha Deen Sethanandha.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.