473,761 Members | 10,057 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 2692
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
3213
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
2429
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
2343
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
1313
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
1895
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
4010
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
1162
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
2551
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
9521
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
9333
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
10107
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9900
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
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
5214
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...
1
3863
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
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.