473,695 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python/Tkinter crash.

Hi,

I get the following:

hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted

and I am back at the bash prompt - this is most frustrating, as there is no
friendly traceback to help me guess where its coming from.

And what is worse, the script runs for a varying time before it simply exits
like this.

What can I do to dig deeper to try to find a clue? - I don't even know if its
Python, Tkinter or Linux...

Some background:

The application is a prototype gui for a controller of an injection moulding
machine.
It has two rows of five buttons across the top, and a canvas containing various
objects over the rest of the screen.
Extensive use is made of configure to change the text of the buttons, as well as
their command bindings,
to keep "the state of the system" current - its quite a hack at this time, as I
am still experimenting with getting the interface intuitive.
On the canvas, there are multiple instances of a Meter class to show things like
temperatures and pressures,
as well as a schematic representation of the machine, created out of polygons
and lines.
The schematic, as well as the Meters, are crudely animated by deleting and
redrawing the objects repetitively with slightly different parameters in
response to button presses. This is done by starting different threads to
implement the various motions, which repetitively call kill and draw methods in
the main app, after which they (the threads) commit seppoku by returning.

Everything seems to work fine. - there is a thread that runs to move the meter
values around continuously, and this has been stable for some time now, and I
can get the various "machine" parts to move around the screen by pushing the
buttons.
The trouble occurs when I put the "machine" into Auto mode, simulating the
various motions in a loop, - it runs for anything from a few tens to a few
hundreds of cycles before handing in its dinner pail like this.

Any Ideas on what to do next to find the culprit?

- Hendrik

Oct 4 '06 #1
14 2680
Hendrik van Rooyen wrote:
Hi,

I get the following:

hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted

and I am back at the bash prompt - this is most frustrating, as there is no
friendly traceback to help me guess where its coming from.

And what is worse, the script runs for a varying time before it simply exits
like this.

What can I do to dig deeper to try to find a clue? - I don't even know if its
Python, Tkinter or Linux...

Some background:

The application is a prototype gui for a controller of an injection moulding
machine.
It has two rows of five buttons across the top, and a canvas containing various
objects over the rest of the screen.
Extensive use is made of configure to change the text of the buttons, as well as
their command bindings,
to keep "the state of the system" current - its quite a hack at this time, as I
am still experimenting with getting the interface intuitive.
On the canvas, there are multiple instances of a Meter class to show things like
temperatures and pressures,
as well as a schematic representation of the machine, created out of polygons
and lines.
The schematic, as well as the Meters, are crudely animated by deleting and
redrawing the objects repetitively with slightly different parameters in
response to button presses. This is done by starting different threads to
implement the various motions, which repetitively call kill and draw methods in
the main app, after which they (the threads) commit seppoku by returning.

Everything seems to work fine. - there is a thread that runs to move the meter
values around continuously, and this has been stable for some time now, and I
can get the various "machine" parts to move around the screen by pushing the
buttons.
The trouble occurs when I put the "machine" into Auto mode, simulating the
various motions in a loop, - it runs for anything from a few tens to a few
hundreds of cycles before handing in its dinner pail like this.

Any Ideas on what to do next to find the culprit?

- Hendrik
Minimal source code to reproduce this error would help tremendously.
Oct 4 '06 #2
"James Stroud" <js*****@mbi.uc la.eduwrote:
Hendrik van Rooyen wrote:
Hi,

I get the following:

hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted

and I am back at the bash prompt - this is most frustrating, as there is no
friendly traceback to help me guess where its coming from.

And what is worse, the script runs for a varying time before it simply exits
like this.

What can I do to dig deeper to try to find a clue? - I don't even know if
its
Python, Tkinter or Linux...

Some background:

The application is a prototype gui for a controller of an injection moulding
machine.
It has two rows of five buttons across the top, and a canvas containing
various
objects over the rest of the screen.
Extensive use is made of configure to change the text of the buttons, as
well as
their command bindings,
to keep "the state of the system" current - its quite a hack at this time,
as I
am still experimenting with getting the interface intuitive.
On the canvas, there are multiple instances of a Meter class to show things
like
temperatures and pressures,
as well as a schematic representation of the machine, created out of
polygons
and lines.
The schematic, as well as the Meters, are crudely animated by deleting and
redrawing the objects repetitively with slightly different parameters in
response to button presses. This is done by starting different threads to
implement the various motions, which repetitively call kill and draw methods
in
the main app, after which they (the threads) commit seppoku by returning.

Everything seems to work fine. - there is a thread that runs to move the
meter
values around continuously, and this has been stable for some time now, and
I
can get the various "machine" parts to move around the screen by pushing the
buttons.
The trouble occurs when I put the "machine" into Auto mode, simulating the
various motions in a loop, - it runs for anything from a few tens to a few
hundreds of cycles before handing in its dinner pail like this.

Any Ideas on what to do next to find the culprit?

- Hendrik

Minimal source code to reproduce this error would help tremendously.
I was hoping for some advice as to how to choose the broken stuff out of the
approximately 1400 lines of code - what do I keep in, and what do I leave out -
If I knew in which area the thing was cracking up, or if I could form a theory
of why it is breaking, I could choose better, and maybe reproduce it - as it is,
to produce the strace that I submitted took most of the morning, and I am
frankly no further along the road...

- Hendrik
Oct 4 '06 #3
On Wed, 04 Oct 2006 10:33:55 +0200, Hendrik van Rooyen
<ma**@microcorp .co.zawrote:
Hi,

I get the following:

hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted

and I am back at the bash prompt - this is most frustrating, as there is
no
friendly traceback to help me guess where its coming from.

And what is worse, the script runs for a varying time before it simply
exits
like this.

What can I do to dig deeper to try to find a clue? - I don't even know
if its
Python, Tkinter or Linux...
Neither of them: it's a tcl problem. The message you get is in the file
generic/tclObj.c in the tcl source directory.

I know the problem happens sometimes on one of my Tkinter applications,
but I never succeeded in reproducing it systematically. I've browsed the
tcl bugs, but didn't find anything. Maybe you'll be luckier than I... If
you are, I'm interested in any hint you can find.
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
Oct 4 '06 #4
In article <ma************ *************** ************@py thon.org>,
"Hendrik van Rooyen" <ma**@microcorp .co.zawrote:
>Hi,

I get the following:

hvr@LINUXBOXMi crocorp:~/Controller/libpython display.py
UpdateStringPr oc should not be invoked for type font
Aborted
...
Everything seems to work fine. - there is a thread that runs to move the meter
values around continuously, and this has been stable for some time now, and I
can get the various "machine" parts to move around the screen by pushing the
buttons...
You mention threads several times in your posting. Do you have multiple
threads talking to Tkinter? If so, try recoding to avoid this (e.g. by
having the background threads communicate with the main thread via
Queues).

-- Russell
Oct 4 '06 #5

"Eric Brunel" <er*********@de spammed.comwrot e:

On Wed, 04 Oct 2006 10:33:55 +0200, Hendrik van Rooyen
<ma**@microcorp .co.zawrote:
Hi,

I get the following:

hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted

and I am back at the bash prompt - this is most frustrating, as there is
no
friendly traceback to help me guess where its coming from.

And what is worse, the script runs for a varying time before it simply
exits
like this.

What can I do to dig deeper to try to find a clue? - I don't even know
if its
Python, Tkinter or Linux...

Neither of them: it's a tcl problem. The message you get is in the file
generic/tclObj.c in the tcl source directory.

I know the problem happens sometimes on one of my Tkinter applications,
but I never succeeded in reproducing it systematically. I've browsed the
tcl bugs, but didn't find anything. Maybe you'll be luckier than I... If
you are, I'm interested in any hint you can find.
Ouch! - this is a bit the wrong answer...

What I have seen, in mucking about today, is that it seems to be related to
threading - I have a silly sort of thread that runs, updating my meters, more or
less continuously, to simulate data from the field - it just adds some values to
the seven display variables and calls the update methods that delete and redraw
the arcs representing the analogue style meters, deleting and replacing the text
objects that show the values, and then it sleeps for a while, and does it all
again.

At the same time, one other thread (other than the main thread), can be created
to move a component on the canvas around by calling its delete and draw
methods. - but this is also done more or less continuously, as a new thread is
created as soon as the previous one dies to move the next object around.

Now these two things are asynchronous with each other, so that given enough
time, they are bound to make calls to Tkinter in a re-entrant fashion, and I
suspect that it is this that is causing the problem - my "evidence" for this is
that I implemented a boolean as a sort of "lock" and had the Meter updating back
down in favour of the other animation to try and avoid any sort of re - entrancy
to the Tkinter canvas object's delete and draw methods...

Now the Jury is still out on this - it seems to have helped, as the thing has
been running for some hours now without crashing - but maybe I have just applied
a band aid to sword cut - I don't know - if it runs through the night I will
feel much better...

Will update again as soon as I have more data...

- Hendrik
Oct 4 '06 #6
On Wed, 04 Oct 2006 20:02:56 +0200, Hendrik van Rooyen
<ma**@microcorp .co.zawrote:
"Eric Brunel" <er*********@de spammed.comwrot e:
>I know the problem happens sometimes on one of my Tkinter applications,
but I never succeeded in reproducing it systematically. I've browsed the
tcl bugs, but didn't find anything. Maybe you'll be luckier than I...If
you are, I'm interested in any hint you can find.

Ouch! - this is a bit the wrong answer...
Sorry for that. I realize I wasn't very helpful, here...
What I have seen, in mucking about today, is that it seems to be related
to
threading - I have a silly sort of thread that runs, updating my meters,
more or
less continuously, to simulate data from the field - it just adds some
values to
the seven display variables and calls the update methods that delete and
redraw
the arcs representing the analogue style meters, deleting and replacing
the text
objects that show the values, and then it sleeps for a while, and does
it all
again.

At the same time, one other thread (other than the main thread), can be
created
to move a component on the canvas around by calling its delete and draw
methods. - but this is also done more or less continuously, as a new
thread is
created as soon as the previous one dies to move the next object around.

Now these two things are asynchronous with each other, so that given
enough
time, they are bound to make calls to Tkinter in a re-entrant fashion,
and I
suspect that it is this that is causing the problem - my "evidence" for
this is
that I implemented a boolean as a sort of "lock" and had the Meter
updating back
down in favour of the other animation to try and avoid any sort of re -
entrancy
to the Tkinter canvas object's delete and draw methods...
AFAIK, Tkinter is not thread safe. Using some kind of lock to serialize
the calls from different threads may seem to work (I never tested it
actually), but the safest way I found to use threads with Tkinter was to
call it only from the thread where the main loop executes. The only thing
that seems to work reliably in secondary threads is to generate custom
events (widget.event_g enerate('<<MyCu stomEvent>>', when='tail')), and to
treat them in Tkinter's thread via bindings
(widget.bind('< <MyCustomEvent> >', treatment_comma nd)). This makes thingsa
bit messy, but it works quite well.

Now, as I said before, someone reported that he *did* get the error you
got from time to time. So maybe the problem I have is not the same as
yours, or maybe there are some cases in my application where Tkinter stuff
still gets called directly from secondary threads. I'll try to investigate
that when I've time and I'll keep you informed.

HTH a little this time...
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
Oct 5 '06 #7
Eric Brunel wrote:
AFAIK, Tkinter is not thread safe. Using some kind of lock to serialize
the calls from different threads may seem to work (I never tested it
actually), but the safest way I found to use threads with Tkinter was to
call it only from the thread where the main loop executes.
the Tkinter binding contains some code that attempts to deal with re-
entrant calls, but I don't know/remember to what extent it's actually
supposed to work (in other words, if the observed problems are bugs or
just limitations).

(maybe Martin's memory is better?)

anyway, I usually play it safe and make sure to use a single thread to
deal with the UI.

</F>

Oct 5 '06 #8
"Russell E. Owen" <ro***@cesmail. netwrote:

In article <ma************ *************** ************@py thon.org>,
"Hendrik van Rooyen" <ma**@microcorp .co.zawrote:
Hi,

I get the following:

hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted
...
Everything seems to work fine. - there is a thread that runs to move the
meter
values around continuously, and this has been stable for some time now, and I
can get the various "machine" parts to move around the screen by pushing the
buttons...

You mention threads several times in your posting. Do you have multiple
threads talking to Tkinter? If so, try recoding to avoid this (e.g. by
having the background threads communicate with the main thread via
Queues).

-- Russell
I am not sure how to do this - once I have called the Tkinter mainloop - that
main thread is essentially event driven - and figuring out how to get it to poll
a queue for content is not obvious - I suppose I could arrange some external
wake up event that I could activate to make it look at the queue - must read up
on this...

Thanks it is a good idea as it will make the interface cleaner, and as I have to
sort out inter process communication anyway it will make sense to also use a
queueing mechanism between the threads in this display process.

There is already one queue defined - but its a hack as I use it to pass the main
threads id to get around the problem of referring to a class before its
defined...

- Hendrik
Oct 5 '06 #9
"Hendrik van Rooyen" <ma**@microcorp .co.zawrote:
"Eric Brunel" <er*********@de spammed.comwrot e:

On Wed, 04 Oct 2006 10:33:55 +0200, Hendrik van Rooyen
<ma**@microcorp .co.zawrote:
Hi,
>
I get the following:
>
hvr@LINUXBOXMic rocorp:~/Controller/libpython display.py
UpdateStringPro c should not be invoked for type font
Aborted
>
and I am back at the bash prompt - this is most frustrating, as there is
no
friendly traceback to help me guess where its coming from.
>
And what is worse, the script runs for a varying time before it simply
exits
like this.
>
What can I do to dig deeper to try to find a clue? - I don't even know
if its
Python, Tkinter or Linux...
Neither of them: it's a tcl problem. The message you get is in the file
generic/tclObj.c in the tcl source directory.

I know the problem happens sometimes on one of my Tkinter applications,
but I never succeeded in reproducing it systematically. I've browsed the
tcl bugs, but didn't find anything. Maybe you'll be luckier than I... If
you are, I'm interested in any hint you can find.

Ouch! - this is a bit the wrong answer...

What I have seen, in mucking about today, is that it seems to be related to
threading - I have a silly sort of thread that runs, updating my meters, more
or
less continuously, to simulate data from the field - it just adds some values
to
the seven display variables and calls the update methods that delete and
redraw
the arcs representing the analogue style meters, deleting and replacing the
text
objects that show the values, and then it sleeps for a while, and does it all
again.

At the same time, one other thread (other than the main thread), can be
created
to move a component on the canvas around by calling its delete and draw
methods. - but this is also done more or less continuously, as a new thread is
created as soon as the previous one dies to move the next object around.

Now these two things are asynchronous with each other, so that given enough
time, they are bound to make calls to Tkinter in a re-entrant fashion, and I
suspect that it is this that is causing the problem - my "evidence" for this
is
that I implemented a boolean as a sort of "lock" and had the Meter updating
back
down in favour of the other animation to try and avoid any sort of re -
entrancy
to the Tkinter canvas object's delete and draw methods...

Now the Jury is still out on this - it seems to have helped, as the thing has
been running for some hours now without crashing - but maybe I have just
applied
a band aid to sword cut - I don't know - if it runs through the night I will
feel much better...

Will update again as soon as I have more data...
OK - It has run through the night and as I type it is still running, so the band
aid has helped a bit...

Eric - if you are interested and contact me, then I will comment out the "fix"
and email you the bits that you need to run this horror - if you need a reliably
failing thingy to study the problem with :-)
It was your post yesterday or so in another thread here that prompted me to try
this style of fix... Thank you.

BTW - I am curious - in your app that exhibits the same crash - what did you do
to work around the problem ? - Is it also running a thread and calling methods
that are normally event driven commands in the main thread? Or two other
threads like me? It would be interesting to try to spot any similarities...

Is it even allowed to asynchronously call a main thread method from another
thread? - it seems to work - but I am not sure why it does - what is the main
thread's mainloop doing while this is going on? - your other comment in the
other thread here implies that it is a strict no - no... Is it safe to call
invoke from another thread? - what is the difference between calling invoke and
calling the bound method directly?

- Hendrik

Oct 5 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3209
by: Eric Brunel | last post by:
Hi all, I was creating a Tkinter widget in the style of the reversed tabs below Excel worksheets and I stepped in a serious problem: the code I made makes python crash with a seg fault, bus error or X11 BadGC error on both Solaris (2.6 and 2.7) and Linux (Mandrake 8.0); it doesn't crash on Windows. I tried to simplify the script, but I couldn't reproduce the crash with a simpler code. So the code below is somewhat long; sorry for that. ...
3
2425
by: Gary Richardson | last post by:
I've just switched to Python 2.3.2 and have encountered a problem that causes a program to crash. The program was working with Python 2.2. The code below will illustrate the problem. A listbox is created and the mouse wheel is used to scroll the entries. The program crashes as soon as the mouse wheel is moved. The program appears to work OK otherwise. The problem occurs when the program is run within the IDE or from a DOS prompt. I'm using...
3
2337
by: Mickel Grönroos | last post by:
Hi everybody, I'm using QuickTimeTcl (3.1) to be able to play movie files in my Tkinter application (Python 2.3.2) on Windows 2000. I was planning to write a simple wrapper class, QuickTimeMovie, that would wrap up the QuickTimeTcl Tcl extension as a Python class. All seems to work pretty fine until the Tkinter application is closed, when the Python interpreter crashes with an error of the following kind: The instruction at...
0
1309
by: Bryan Olson | last post by:
I've run into a problem with Python/TkInter crashing, with an attempt to read illegal addresses, on Win on Win2000 and WinXP. With some web-searching, I found that people say not to manipulate TkInter from multiple threads, except that the call event_generate() is safe. I assume the call adds an event to Tk's queue, and later the thread running mainloop will() pick up the event. I tried to write a general-purpose thread-runner. In...
0
1892
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 241 open ( -6) / 2622 closed (+26) / 2863 total (+20) Bugs : 764 open ( +6) / 4453 closed (+38) / 5217 total (+44) RFE : 150 open ( +2) / 131 closed ( +0) / 281 total ( +2) New / Reopened Patches ______________________
3
4002
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office 2000, but in Office 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)" Please help me :-( the code of the module that crash is (only in Excel 2003, in 2000 not): import os
0
1158
kudos
by: kudos | last post by:
Hi, a couple of months ago, I made a xmas chistmas "card" to this community(http://www.thescripts.com/forum/thread580722.html) Now its soon easter, and I hacked together something for easter as well.... import Tkinter import random import colorsys import time # Happy easter 2007 folks! from kudos@spray.no
2
2550
by: Russell Blau | last post by:
I have some Tkinter programs that I run on two different machines. On Machine W, which runs Python 2.5.1 on Windows XP, these programs run fine. On Machine H, which runs Python 2.5.1 on Windows XP, however, the same programs crash regularly. The crashes are not Python exceptions, but rather are reported by Windows as errors in pythonw.exe. (Of course, the error messages themselves contain absolutely no useful information.) This happens...
0
8647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3024
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.