473,399 Members | 2,159 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,399 software developers and data experts.

Tkinter problem with loops

Hi i have a program written in python which uses very big loops and i am trying to get some output by using the text widget of tkinter,the problem is that tkinter waits for the function to finish the loop before showing any result at all.Is there any way to make the program show some output even though the program loop is not yet finished?

OS: Linux

Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2.  
  3. root=Tk()
  4. root2=Tk()
  5. text="1"
  6. x=0
  7. def remove():    
  8.     if text != '1':
  9.         text.grid_remove()
  10.  
  11. def clear():
  12.     global text
  13.     global x
  14.     remove()
  15.  
  16.     while 1:
  17.         text=Text(root2,height=1,width=70)
  18.         text.insert(END,"test%d"%(x))
  19.         text.grid(row=1,column=1)
  20.         x+=1    
  21.  
  22.  
  23. execute=Button(root,text="execute",command=clear)
  24. execute.grid()
  25.  
  26. root.geometry("+100+200")
  27. root2.geometry("+500+100")
  28.  
  29. root.mainloop()
  30.  
  31.  
Oct 26 '07 #1
2 1396
Hi i have a program written in python which uses very big loops and i am trying to get some output by using the text widget of tkinter,the problem is that tkinter waits for the function to finish the loop before showing any result at all.Is there any way to make the program show some output even though the program loop is not yet finished?

OS: Linux

Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2.  
  3. root=Tk()
  4. root2=Tk()
  5. text="1"
  6. x=0
  7. def remove():    
  8.     if text != '1':
  9.         text.grid_remove()
  10.  
  11. def clear():
  12.     global text
  13.     global x
  14.     remove()
  15.  
  16.     while 1:
  17.         text=Text(root2,height=1,width=70)
  18.         text.insert(END,"test%d"%(x))
  19.         text.grid(row=1,column=1)
  20.         x+=1    
  21.  
  22.  
  23. execute=Button(root,text="execute",command=clear)
  24. execute.grid()
  25.  
  26. root.geometry("+100+200")
  27. root2.geometry("+500+100")
  28.  
  29. root.mainloop()
  30.  
  31.  
Try using this statement whenever you want to show the output:
Expand|Select|Wrap|Line Numbers
  1. root.update()
Oct 26 '07 #2
Thank you very much.It worked.
Oct 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles...
3
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter...
7
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of...
1
by: corrado | last post by:
Hello I have an application running several thread to display some financial data; basically I have a thread displaying HTML tables by means of Tkhtml, another implementing a scrolling ticker...
11
by: William Gill | last post by:
I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep references to them in a 2 dimensional list ( rBtns ). It works fine, and I can even make it so only one button per column can be...
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
1
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that...
2
by: Kevin Walzer | last post by:
I'm porting a Tkinter application to wxPython and had a question about wxPython's event loop. The Tkinter app provides a GUI to a command-line tool. It gathers user input, and opens an...
8
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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,...

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.