1 Replies - 138 Views - Last Post: 14 September 2019 - 01:23 PM Rate Topic: -----

#1 liamisko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-September 19

Having problems with writing to notepad(python)

Posted 14 September 2019 - 12:21 PM

Hey guys I am kinda new to programming , I am trying though. So i just wanted to kind of register / login thing but i can't get thought this problem. The thing is that the info i write won't show up in notepad as they should i guess pls help
Here is the code (in python) :




from tkinter import *

def register():
    username_info = username.get()
    password_info = password.get()
 
    file=open(username_info+".txt", "w")
    file.write(username_info)
    file.write(password_info)
    file.close()
    
 
    username_entry.delete(0, END)
    password_entry.delete(0, END)
 
    label1 = Label(regtab, text = "Registration Sucessful", fg = "green" ,font = ("calibri", 11))
    label1.pack()

def regtab():
    global username
    global password
    global username_entry
    global password_entry
    global regtab

    regtab = Tk()
    regtab.geometry("300x150")

    username = StringVar()
    password = StringVar()
         
    username_entry = Entry(regtab, textvariable=username)
    username_entry.pack()

    password_entry = Entry(regtab, textvariable=password) 
    password_entry.pack()
    
    buttonreg = Button(regtab, text="registration", command=register) 
    buttonreg.pack()



def logtab():
    logtab = Tk()
    logtab.geometry("300x150")
    




maintab = Tk()
maintab.title("program")
maintab.geometry("150x50")

rebbutton = Button(maintab, text="register", width=20, command=regtab) .grid(row=1, column=1)

logbutton = Button(maintab, text="login", width=20, command=logtab) .grid(row=2, column=1)
:code:

This post has been edited by modi123_1: 14 September 2019 - 12:28 PM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: Having problems with writing to notepad(python)

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15331
  • View blog
  • Posts: 61,450
  • Joined: 12-June 08

Re: Having problems with writing to notepad(python)

Posted 14 September 2019 - 01:23 PM

04	    username_info = username.get()
05	    password_info = password.get()



I believe you are looking for these 'entry' objects and not what you are currently using with .get().

username_entry
password_entry

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1