Python Forum
[Tkinter] switching frames
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] switching frames
#3
(Apr-16-2019, 07:30 PM)wuf Wrote: Hi nick123

Try out following modified script:
from tkinter import *
from functools import partial
 
def raise_frame(frame):
    frame.tkraise()
 
main_win = Tk()
main_win.geometry('500x500')
main_win.title("Registration Form")

second_frame = Frame(main_win)
second_frame.place(x=0, y=0, width=500, height=500)

first_frame = Frame(main_win)
first_frame.place(x=0, y=0, width=500, height=500)


label_0 = Label(first_frame, text="Registration form",width=20,font=("bold", 20))
label_0.place(x=90,y=53)
 
 
label_1 = Label(first_frame, text="FullName",width=20,font=("bold", 10))
label_1.place(x=80,y=130)
 
entry_1 = Entry(first_frame)
entry_1.place(x=240,y=130)
 
label_2 = Label(first_frame, text="Email",width=20,font=("bold", 10))
label_2.place(x=68,y=180)
 
entry_2 = Entry(first_frame)
entry_2.place(x=240,y=180)
 
label_3 = Label(first_frame, text="Gender",width=20,font=("bold", 10))
label_3.place(x=70,y=230)
var = IntVar()
Radiobutton(first_frame, text="Male",padx = 5, variable=var, value=1).place(x=235,y=230)
Radiobutton(first_frame, text="Female",padx = 20, variable=var, value=2).place(x=290,y=230)
 
label_4 = Label(first_frame, text="country",width=20,font=("bold", 10))
label_4.place(x=70,y=280)
 
list1 = ['Canada','India','UK','Nepal','Iceland','South Africa'];
c=StringVar()
droplist=OptionMenu(first_frame,c, *list1)
droplist.config(width=15)
c.set('select your country') 
droplist.place(x=240,y=280)
 
label_4 = Label(first_frame, text="Programming",width=20,font=("bold", 10))
label_4.place(x=85,y=330)
var1 = IntVar()
Checkbutton(first_frame, text="java", variable=var1).place(x=235,y=330)
var2 = IntVar()
Checkbutton(first_frame, text="python", variable=var2).place(x=290,y=330)
 
Button(first_frame, text='Submit',width=20,bg='brown',fg='white', command=lambda:raise_frame(second_frame)).place(x=180,y=380)

label_8 = Label(second_frame, text="Welcome to page 2",width=20,font=("bold", 10))
label_8.place(x=70,y=230)

Button(second_frame, text="Switch back to page 1",width=20,bg='brown',fg='white', command=lambda:raise_frame(first_frame)).place(x=180,y=380) 

main_win.mainloop()
wuf :-)
Hi wuf, i'm working on this code also, much more complex with more features, my main question is, how can anyone, after fulfill all the questions send to an specific email after the submitted button is pressed? I've tried several codes on searches i have made, but none works, it reports errors, like SMTP doesn't have this or that. Probably those codes don't work on the newest version of python, can you provide assitance on this matter, regards, Francisco.
Reply


Messages In This Thread
switching frames - by nick123 - Apr-16-2019, 03:00 PM
RE: switching frames - by wuf - Apr-16-2019, 07:30 PM
RE: switching frames - by francisco_neves2020 - Apr-18-2019, 04:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issue with GUI screen switching in Python QT5 code greenelephant 1 247 Apr-04-2024, 09:58 PM
Last Post: deanhystad
  Switching from tkinter to gtk is difficult! snakes 1 1,468 Aug-08-2022, 10:35 PM
Last Post: woooee
  [Tkinter] Unable to Access global Variable when switching between frames tziyong 1 3,485 Nov-03-2019, 01:08 AM
Last Post: balenaucigasa
  [Tkinter] Call a function when switching layouts 4096 0 3,544 Sep-22-2019, 07:39 PM
Last Post: 4096
  [PyGUI] Switching between two frames using Tkinter jenkins43 1 4,636 Jul-17-2019, 10:53 AM
Last Post: metulburr
  Problem with pygame not switching the mouse image Mondaythe1st 6 6,762 Jul-26-2017, 10:53 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020