473,289 Members | 1,808 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,289 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 1390
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.