As someone who is new to programming, I constantly find myself running into errors and issues and, while finding answers and solution, I rarely find out why it is that way. This time, it with Tkinter on Python 2.7.
The issue at hand is every time the "submit" button I created is pressed, the GUI freezes. Research has told me that the issue is because there is no callback to allow the program to reach the mainloop. The problem i am facing is the program that runs with the GUI is a never ending automation loop on a timer. I've searched on this site as well, but, like usual, I only get answers where it says things like "Do this because I said it works". As someone who is really interested and trying to get deeper and deeper into the glorious black hole that is programming, an explanation of why it needs to be that way and how you came to that conclusion would be a big help to me. I fully understand that programming is one of those things that is so broad, yet so particular, that explanations become different and sometimes bias, but I find it difficult to learn any other way.
The simplified version of my code I have so far is as follows:
(I know simplified code is not preferred on this site, but I don't have the means to transfer the code to any other computer without writing it all down and typing it on here. I know you guys will yell at me for it later. So, for that, I am sorry.)
import os
import time
from datetime import datetime
import shutil
from Tkinter import *
root=Tk()
root.title("Automation")
root.config(bg="black")
root.geometry("500x500")
def submit():
input=e1.get()
#the input is a limit set for a variable in the timer that when
#it hits that limit, it jumps to the 400 lines of code
def Timer():
<timer code>
<400 lines of code that has been tested to work 100%>
Timer()
b1=Button(root, command=submit)
button.grid(row=0, column =0)
e1=Entry(root, width=50)
e1.grid(row=0, column=1)
mainloop()
Also, as I find it hard to discover and clear information on how to GUI program without it saying "Hey... just do this because I said so", and links to some study/reference materials would be greatly appreciated.
As always, I greatly appreciate all of the help that is provided throughout this site and all of the vastly intelligent individuals that make it the place that it is. Thank you all!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…