Hi Dexter1997
Hier eine leicht angepasste Variante:
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
# Tkinter for Python 2.xx
import Tkinter as tk
except ImportError:
# Tkinter for Python 3.xx
import tkinter as tk
APP_TITLE = "Money Rising"
APP_XPOS = 100
APP_YPOS = 100
APP_WIDTH = 300
APP_HEIGHT = 150
INC_TIME = 1000
LABEL_FONT = ('Helevetica', 30, 'bold')
LABEL_FG_COLOR = 'green'
class Application(tk.Frame):
def __init__(self, parent, **kwargs):
self.parent = parent
tk.Frame.__init__(self, parent, **kwargs)
self.money = 0
self.money_flag = False
self.money_var = tk.StringVar()
tk.Label(self, textvariable=self.money_var, font=LABEL_FONT,
fg=LABEL_FG_COLOR).pack(expand=True, pady=4)
self.money_var.set(self.money)
tk.Button(self, text="Rise the Money!", command=self.start_money_rising
).pack()
def start_money_rising(self):
if not self.money_flag:
self.money_flag = True
self.rise_money()
def rise_money(self):
if self.money < 10:
self.money += 1
self.money_var.set(self.money)
else:
self.money_var.set("Wonderfull!")
self.money_flag = False
self.money = 0
return
self.after(INC_TIME, self.rise_money)
def main():
app_win = tk.Tk()
app_win.title(APP_TITLE)
app_win.geometry("+{}+{}".format(APP_XPOS, APP_YPOS))
app_win.geometry("{}x{}".format(APP_WIDTH, APP_HEIGHT))
Application(app_win).pack(expand=True)
app_win.mainloop()
if __name__ == '__main__':
main()
Gruss wuf