Der selbe Code, nur ohne global, aber immer noch mit zu vielen festen Fenstergrößen und Positionen.
Code: Alles auswählen
import tkinter as tk
class Mainframe(tk.LabelFrame):
def __init__(self,master,**kwargs):
tk.LabelFrame.__init__(self,master,**kwargs)
tk.Button(self, text='wish on', command=self.wish_on).place(y=243,x=50)
self.button_frame = ButtonFrame(self, width=200, text='Noch ein Fenster', bd=0, relief='flat', bg='#d9d93c', height=150)
self.button_frame.place(y=300, x=0)
def wish_on(self):
self.button_frame.wish(300,140,-1)
class ButtonFrame(tk.LabelFrame):
def __init__(self, master, **kwargs):
tk.LabelFrame.__init__(self, master, **kwargs)
tk.Button(self, text='wish off', command=self.wish_off).place(y=83,x=50)
def wish_off(self):
self.wish(140,300,1)
def wish(self, y0, yn, step):
def do_move(y):
y += step
self.place(y=y)
if y != yn:
self.after(3, do_move, y)
do_move(y0)
def main():
app = tk.Tk()
app.geometry("280x370")
mainframe = Mainframe(app, width=200, text='Screen', bd=0, relief='flat', bg='#d949d9', height=300)
mainframe.place(y=28, x=43)
app.mainloop()
if __name__ == '__main__':
main()