Reputation: 3
I'm having troubles using the "after" method in my GUI. The goal is to create a loop, which calculates "flow" with given input variables. So far I didn't manage to get my code running, with the documentation on "after" or this post Tkinter only calls after_idle once
My Code:
import Tkinter as tk
from Tkinter import *
import ttk
import tkMessageBox
class Regeln():
def __init__(self):
bla=1
def lesen(self,faktor,stromdichte,flaeche,anzahl,elektronen,konzentration):
self.faktor=faktor
self.stromdichte=stromdichte
self.flaeche=flaeche
self.anzahl=anzahl
self.elektronen=elektronen
self.konzentration=konzentration
try:
self.faktor=float(self.faktor)
self.stromdichte=float(self.stromdichte)
self.flaeche=float(self.flaeche)
self.anzahl=float(self.anzahl)
self.elektronen=float(self.elektronen)
self.konzentration=float(self.konzentration)
except:
tkMessageBox.showerror("Achtung!","Nur Zahlen eingeben!")
try:
1/(self.faktor*self.stromdichte*self.flaeche*self.anzahl*self.elektronen*self.konzentration)
except:
tkMessageBox.showerror("Achtung!","Nur Werte größer 0 eingeben!")
self.algorithmus()
def algorithmus(self):
flow=self.faktor*self.stromdichte*self.elektronen*60/(96485.34*self.konzentration*0.75/100)*self.flaeche*self.anzahl/1000
print flow
self.after(1500,self.algorithmus)
With this I get an "AttributeError". Anybody has any idea how to get it running?
Upvotes: 0
Views: 1052
Reputation: 385920
after
is a method available on all tkinter widgets. In your specific case, self
is not a widget, so naturally it won't have this method.
You need to call after
from an existing widget. For example, if you initially created your GUI with something like this:
root = tk.Tk()
You can later call after
like this:
root.after(...)
Upvotes: 3