Skip to content

Instantly share code, notes, and snippets.

@vahit
Last active August 29, 2015 14:03
Show Gist options
  • Save vahit/e4df063c4fd3e9d48731 to your computer and use it in GitHub Desktop.
Save vahit/e4df063c4fd3e9d48731 to your computer and use it in GitHub Desktop.
Another simple multiwindow application
#!/usr/sbin/env python
from tkinter import *
from tkinter import ttk
import pdb
# pdb.set_trace()
win=Tk()
def create_frame1():
global show_frame2, frame1
frame1=ttk.Frame(win)
lbl=ttk.Label(frame1, text='Frame1', font='Times 35')
lbl.grid(row=0, column=0, columnspan=2)
bt_next=ttk.Button(frame1, text='Next', command=show_frame2)
bt_quit=ttk.Button(frame1, text='Quit', command=win.destroy)
bt_next.grid(row=1, column=1)
bt_quit.grid(row=1, column=0)
def show_frame1():
global frame2, frame1
frame2.grid_forget()
frame1.grid()
def create_frame2():
global show_frame3, show_frame1, frame2
frame2=ttk.Frame(win)
lbl=ttk.Label(frame2, text='Frame2', font='Times 35')
lbl.grid(row=0, column=0, columnspan=2)
bt_next=ttk.Button(frame2, text='Next', command=show_frame3)
bt_next.grid(row=1, column=1)
bt_back=ttk.Button(frame2, text='Back', command=show_frame1)
bt_back.grid(row=1, column=0)
def show_frame2():
global farme1, frame3, frame2
frame3.grid_forget()
frame1.grid_forget()
frame2.grid()
def create_frame3():
global show_frame2, frame3
frame3=ttk.Frame(win)
lbl=ttk.Label(frame3, text='Frame3', font='Times 35')
lbl.grid(row=0, column=0, columnspan=2)
bt_back=ttk.Button(frame3, text='Back', command=show_frame2)
bt_back.grid(row=1, column=0)
bt_quit=ttk.Button(frame3, text='Quit', command=win.destroy)
bt_quit.grid(row=1, column=1)
def show_frame3():
global frame2, frame3
frame2.grid_forget()
frame3.grid()
def main():
create_frame1()
create_frame2()
create_frame3()
show_frame1()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment