473,412 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Tk not displaying correctly

I am building a TK interface, that has several threads. If all threads
are running actively, including the main one, the interface doesn't
update. For example, I have something like this, although more complex

import time, threading

master=Tk()

def thread:
global x
x=0
while(TRUE):
x=x+1
Label(master,text=x).grid(row=0,column=0)
time.sleep(1)

but=Button(master,command=command,text="hit me")
but.grid(row=0,column=0)

def command:
while(x<100):
time.sleep(1)
x=0

t=threading.Thread(target=thread)
t.setDaemon(1)
t.start()

master.mainloop()

What (I think) will happen is when you hit the button, until x=100, the
display will stop updating, and when the command has left it's thread,
it will return to updating again. Is there a way to make it so it
always will update, irreguardless if it's in a seporate thread, perhaps
calling a new thread that calls mainloop? Thanks!

Dec 21 '05 #1
2 1167
"Tuvas" <tu*****@gmail.com> writes:
What (I think) will happen is when you hit the button, until x=100, the
display will stop updating, and when the command has left it's thread,
it will return to updating again. Is there a way to make it so it
always will update, irreguardless if it's in a seporate thread, perhaps
calling a new thread that calls mainloop? Thanks!


Yes, you have to call mainloop in the separate thread. Be careful
because tkinter is not thread safe. You have to communicate with the
gui thread through some synchronized mechanism like queues. I usually
use the w.after operation to make a polling loop that checks a queue
for gui-updating events. The events themselves are just callables
that do gui operations when called.
Dec 21 '05 #2
Any way you could provide a fairly simple example, or a website that
shows it? I understand that I must create a thread for mainloop,
however, I can't see how to make that work, every time I do, it ends
the program only a few seconds late. Will I have to make an even for
all buttons, etc that are on the GUI? Wow, sounds like lots of work...
Anyways, thanks!

Dec 22 '05 #3

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

Similar topics

1
by: Dave Posh | last post by:
I seem to be having a problem displaying time stored in mysql. The format stored in the database is 13:15:05. The database data type is time. I'm using asp vbscript and sql to retrieve the time...
2
by: Joe Price | last post by:
Hi chaps I've got an XML file, within that file i've embedded html code using the <!]> tag I'm displaying that xml file through a browser using an xsl style sheet. However it is displaying...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
12
by: korund | last post by:
How to make javascript alert with non-english text displaying correctly on computers where english only is default system & language settings? For web page the solution is just use meta tags:...
0
by: Andy Lim | last post by:
Hi all, In my recent project, my client uses Chinese Star software to type the articles in chinese (using MS Word), and I need to display these articles within ASP.NET pages. And, for this very...
0
by: Andy Lim | last post by:
Hi all, In my recent project, my client uses Chinese Star software to type the articles in chinese (using MS Word), and I need to display these articles within ASP.NET pages. And, for this very...
0
by: anjachow | last post by:
The system generated email that are automatically sent displaying well in any web-based mail systems (yahoo, msn, etc...). The foreign characters (vowels with accents and the ñ) aren't displaying...
27
by: Phil | last post by:
I thought it would be nice to display some animated GIFs on some of my forms. I put a PictureBox control on a form, and loaded my GIF file in. It animates, but not properly. It seems very jerky and...
4
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.