I\'ve been studying tkinter in python3 and find it very hard to find good documentation and answers online. To help others struggling with the same problems I decided to post a
Thanks for your work- I used it as inspiration for this example that, while extremely light in terms of the content, is a cool way to make an arbitrary number of windows that you can switch between. You could move the location of the next and back buttons, turn them into arrows, whatever you want.
from tkinter import *
master=Tk()
class makeframe(object):
def __init__(self,i):
self.i=i
self.frame=Frame(master)
self.nextbutton=Button(self.frame,text='next',command=self.next)
self.nextbutton.grid(column=2,row=0)
self.backbutton=Button(self.frame,text='back',command=self.back)
self.backbutton.grid(column=0,row=0)
self.label=Label(self.frame,text='%i'%(self.i+1)).grid(column=1,row=0)
def next(self):
self.frame.grid_forget()
p[self.i+1].frame.grid()
def back(self):
self.frame.grid_forget()
p[self.i-1].frame.grid()
n=7
p=[0]*n
for i in range(n):
p[i]=makeframe(i)
p[0].frame.grid()
p[0].backbutton.config(state=DISABLED)
p[-1].nextbutton.config(state=DISABLED)
As you've taken the liberty to post an answer as a question. I'd like to post a comment as an answer and suggest that perhaps you should contribute this to TkDocs (click their About tab and they talk about contributing to the site).
I think it'd be better if that site were to improved with more examples than to turn this site into a cookbook. I think you can also contribute to the Active State recipes, and they seem to be the carriers of the torch for Tcl/Tk, so Tkinter stuff makes a lot of sense there too.