1

I am trying to learn coding in tkinter, while I am trying to switch between login page and signup page images are not displaying and not switching between login page and signup page.

Tkinter library

import sqlite3 #sqlite 3 library for database
from tkinter import * 
from tkinter import messagebox
import sys
import os
from PIL import ImageTk,Image
root = Tk()
root.resizable(width=False, height=False)  #Window size
root.geometry('1300x700')
root.configure(background='grey')
root.title("LPG GAS SYSTEM")
f1 = Frame(root,width = 1300,height=100,relief=SUNKEN)
f1.pack(side=TOP)
def logingui():
    f2 = Frame(root,width = 1300,height=600,relief=SUNKEN)
    f2.pack(side=BOTTOM)
    lblinfo = Label(f1, font=( 'aria' ,30, 'bold' ),text="LPG GAS SYSTEM",fg="steel blue",bd=10)
    lblinfo.place(x=400,y=10)
    i=ImageTk.PhotoImage(Image.open("1.jpg"))
    Label(f2,image=i,height=600,width=1300).pack(side=BOTTOM)
    username=StringVar()
    password=StringVar()
    login=Label(f2,font=('aria',30),bg='black',fg='white',text="Mobile No",bd=5,anchor=N)
    login.place(x=1000,y=150)
    txtlogin=Entry(f2,font=('ariel' ,16,'bold') , bd=6,insertwidth=10 ,bg="powder blue" ,justify='left',textvariable=username)
    txtlogin.place(x=1000,y=200)
    passs=Label(f2,font=('aria',30),text="Password",bg="black",fg="white",bd=5,anchor=N)
    passs.place(x=1000,y=250)
    txtpassword=Entry(f2,font=('ariel' ,16,'bold') ,show='*', bd=6,insertwidth=4,bg="powder blue" ,justify='left',textvariable=password)
    txtpassword.place(x=1000,y=300)
    b1 = Button(f2, text="Login",anchor=W,bd=6,command=lambda:login())
    b1.place(x=1075,y=350)
    b2 = Button(f2, text="SignUp Page",anchor=W,bd=6,command=lambda:logtosign())
    b2.place(x=1070,y=400)
def signupgui():
    f3 = Frame(root,width = 1300,height=600,relief=SUNKEN)
    f3.pack(side=BOTTOM)
    j=ImageTk.PhotoImage(Image.open("1.jpg"))
    Label(f3,image=i,height=600,width=1300).pack(side=BOTTOM)
    name=StringVar()
    name1=StringVar()
    mobile=StringVar()
    password=StringVar()
    dob=StringVar()
    la1=Label(f3,font=('ariel' ,20,'bold'),text="First Name",bg='grey').place(x=50,y=0)
    en1=Entry(f3,font=('ariel' ,20,'bold'),bg="powder blue" ,border=1,textvariable=name)
    en1.place(x=50,y=50)
    la2=Label(f3,font=('ariel' ,20,'bold'),bg='grey',text="Last Name").place(x=800,y=0)
    en2=Entry(f3,font=('ariel' ,20,'bold'),bg="powder blue" ,border=1,textvariable=name1)
    en2.place(x=800,y=50)
    la3=Label(f3,font=('ariel' ,20,'bold'),bg='grey',text="Mobile Number  ").place(x=50,y=100)
    en3=Entry(f3,font=('ariel' ,20,'bold'),bg="powder blue" ,border=1,textvariable=mobile)
    en3.place(x=50,y=150)
    la4=Label(f3,font=('ariel' ,20,'bold'),bg='grey',text="Password",).place(x=800,y=100)
    en4=Entry(f3,font=('ariel' ,20,'bold'),bg="powder blue" ,border=1,textvariable=password,show="*")
    en4.place(x=800,y=150)
    la4=Label(f3,font=('ariel' ,20,'bold'),bg='grey',text="Aadhar number",).place(x=50,y=200)
    en4=Entry(f3,font=('ariel' ,20,'bold'),bg="powder blue" ,border=1,textvariable=dob)
    en4.place(x=50,y=250)
    b3=Button(f3,text="Sign Up",bd=6,command=lambda:signup())
    b3.place(x=545,y=450)
    b4 = Button(f2, text="Login page",bd=6,command=lambda:signtolog())
    b4.place(x=550,y=500)
def logtosign():
    f2.pack_forget()
    signupgui()
def signtolog():
    f3.pack_forget()    
    logingui()
def start():
    logingui()
start()

I expected out put should contain images and when we click on sign up button it will go to sign up page from login page,,In sign up page when we click login page it will go to login page from sign up page

Sai Sharan
  • 26
  • 5
  • 2
    You aren't saving a reference to your images, so they're getting garbage-collected immediately. See *every question ever asked on this site about disappearing Tkinter images* for details. – jasonharper Sep 30 '19 at 02:58
  • Can you help me jasonharper I'm using letter " i " as referrence – Sai Sharan Sep 30 '19 at 03:40

0 Answers0