why this is showing TypeError: 'builtin_function_or_method' object is not subscriptable [closed]
up vote
0
down vote
favorite
from tkinter import *
from tkinter import messagebox
class after_sign_in(object):
    def __init__(self):
        self.sign_in_after()
    def sign_in_after(self):
        self.sign_in=Tk()
        self.sign_in.geometry('700x300')
        self.sign_in.maxsize(height=300,width=700)
        self.sign_in.title('Account')
        def sign_out():
            messagebox.showinfo('Have A Nice Day','You Are Signed Out')
            self.sign_in.destroy()
        sign_out=Button(self.sign_in,anchor='ne',text='Sign Out',command=sign_out)
        sign_out.pack(side='right')
        sign_out.place(x=620,y=5)
        fh=open('fh.txt','r+')
        _row=0
        ct =1
        for i in range(len(fh.readlines())):
            Label(self.sign_in, text=fh.readlines[i], width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
            Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
t=after_sign_in()
python-3.x
                    closed as off-topic by tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja Nov 9 at 14:59
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
0
down vote
favorite
from tkinter import *
from tkinter import messagebox
class after_sign_in(object):
    def __init__(self):
        self.sign_in_after()
    def sign_in_after(self):
        self.sign_in=Tk()
        self.sign_in.geometry('700x300')
        self.sign_in.maxsize(height=300,width=700)
        self.sign_in.title('Account')
        def sign_out():
            messagebox.showinfo('Have A Nice Day','You Are Signed Out')
            self.sign_in.destroy()
        sign_out=Button(self.sign_in,anchor='ne',text='Sign Out',command=sign_out)
        sign_out.pack(side='right')
        sign_out.place(x=620,y=5)
        fh=open('fh.txt','r+')
        _row=0
        ct =1
        for i in range(len(fh.readlines())):
            Label(self.sign_in, text=fh.readlines[i], width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
            Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
t=after_sign_in()
python-3.x
                    closed as off-topic by tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja Nov 9 at 14:59
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja
If this question can be reworded to fit the rules in the help center, please edit the question.
 
 
 1
 
 
 
 
 Please fix the formatting, this is absolutely unreadable. And also indicate which line exactly throws the error
 – UnholySheep
 Nov 9 at 12:52
 
 
 
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
from tkinter import *
from tkinter import messagebox
class after_sign_in(object):
    def __init__(self):
        self.sign_in_after()
    def sign_in_after(self):
        self.sign_in=Tk()
        self.sign_in.geometry('700x300')
        self.sign_in.maxsize(height=300,width=700)
        self.sign_in.title('Account')
        def sign_out():
            messagebox.showinfo('Have A Nice Day','You Are Signed Out')
            self.sign_in.destroy()
        sign_out=Button(self.sign_in,anchor='ne',text='Sign Out',command=sign_out)
        sign_out.pack(side='right')
        sign_out.place(x=620,y=5)
        fh=open('fh.txt','r+')
        _row=0
        ct =1
        for i in range(len(fh.readlines())):
            Label(self.sign_in, text=fh.readlines[i], width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
            Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
t=after_sign_in()
python-3.x
from tkinter import *
from tkinter import messagebox
class after_sign_in(object):
    def __init__(self):
        self.sign_in_after()
    def sign_in_after(self):
        self.sign_in=Tk()
        self.sign_in.geometry('700x300')
        self.sign_in.maxsize(height=300,width=700)
        self.sign_in.title('Account')
        def sign_out():
            messagebox.showinfo('Have A Nice Day','You Are Signed Out')
            self.sign_in.destroy()
        sign_out=Button(self.sign_in,anchor='ne',text='Sign Out',command=sign_out)
        sign_out.pack(side='right')
        sign_out.place(x=620,y=5)
        fh=open('fh.txt','r+')
        _row=0
        ct =1
        for i in range(len(fh.readlines())):
            Label(self.sign_in, text=fh.readlines[i], width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
            Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
t=after_sign_in()
python-3.x
python-3.x
edited Nov 9 at 12:53
L3viathan
14.8k12647
14.8k12647
asked Nov 9 at 12:51
Himanshu Mishra
6
6
                    closed as off-topic by tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja Nov 9 at 14:59
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja
If this question can be reworded to fit the rules in the help center, please edit the question.
                    closed as off-topic by tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja Nov 9 at 14:59
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – tharkay, Mark Rotteveel, Tom Toms, GhostCat, stealthyninja
If this question can be reworded to fit the rules in the help center, please edit the question.
 
 
 1
 
 
 
 
 Please fix the formatting, this is absolutely unreadable. And also indicate which line exactly throws the error
 – UnholySheep
 Nov 9 at 12:52
 
 
 
add a comment |
 
 
 1
 
 
 
 
 Please fix the formatting, this is absolutely unreadable. And also indicate which line exactly throws the error
 – UnholySheep
 Nov 9 at 12:52
 
 
 
1
1
Please fix the formatting, this is absolutely unreadable. And also indicate which line exactly throws the error
– UnholySheep
Nov 9 at 12:52
Please fix the formatting, this is absolutely unreadable. And also indicate which line exactly throws the error
– UnholySheep
Nov 9 at 12:52
add a comment |
                                1 Answer
                                1
                        
active
oldest
votes
up vote
1
down vote
The problem is here:
text=fh.readlines[i]
fh.readlines is a function that you would need to call first — ideally only once. Iterating over range(len(...)) is almost always useless and can be done easier.
I suggest iterating over the file handle directly (as you don't really need the list of lines. Since you still need the index i, you can use enumerate:
for i, line in enumerate(fh):
    Label(self.sign_in, text=line, width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
    Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
add a comment |
                                1 Answer
                                1
                        
active
oldest
votes
                                1 Answer
                                1
                        
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The problem is here:
text=fh.readlines[i]
fh.readlines is a function that you would need to call first — ideally only once. Iterating over range(len(...)) is almost always useless and can be done easier.
I suggest iterating over the file handle directly (as you don't really need the list of lines. Since you still need the index i, you can use enumerate:
for i, line in enumerate(fh):
    Label(self.sign_in, text=line, width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
    Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
add a comment |
up vote
1
down vote
The problem is here:
text=fh.readlines[i]
fh.readlines is a function that you would need to call first — ideally only once. Iterating over range(len(...)) is almost always useless and can be done easier.
I suggest iterating over the file handle directly (as you don't really need the list of lines. Since you still need the index i, you can use enumerate:
for i, line in enumerate(fh):
    Label(self.sign_in, text=line, width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
    Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
add a comment |
up vote
1
down vote
up vote
1
down vote
The problem is here:
text=fh.readlines[i]
fh.readlines is a function that you would need to call first — ideally only once. Iterating over range(len(...)) is almost always useless and can be done easier.
I suggest iterating over the file handle directly (as you don't really need the list of lines. Since you still need the index i, you can use enumerate:
for i, line in enumerate(fh):
    Label(self.sign_in, text=line, width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
    Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
The problem is here:
text=fh.readlines[i]
fh.readlines is a function that you would need to call first — ideally only once. Iterating over range(len(...)) is almost always useless and can be done easier.
I suggest iterating over the file handle directly (as you don't really need the list of lines. Since you still need the index i, you can use enumerate:
for i, line in enumerate(fh):
    Label(self.sign_in, text=line, width=22, anchor='center',padx=5,pady=5 ).grid(row=i,column=1)
    Label(self.sign_in, text=str(ct), width=22, anchor='center',padx=5,pady=5 ).grid(row=i+1)
answered Nov 9 at 12:55
L3viathan
14.8k12647
14.8k12647
add a comment |
add a comment |
 
1
Please fix the formatting, this is absolutely unreadable. And also indicate which line exactly throws the error
– UnholySheep
Nov 9 at 12:52