Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

TypeError: argument of type 'method' is not iterable

Writer Sebastian Wright

Error

Traceback (most recent call last): File "C:/Users/RCS/Desktop/Project/SHM.py", line 435, in <module> app = SHM() File "C:/Users/RCS/Desktop/Project/SHM.py", line 34, in __init__ frame = F(container, self) File "C:/Users/RCS/Desktop/Project/SHM.py", line 384, in __init__ if "3202" in q:
TypeError: argument of type 'method' is not iterable

code

some part of code, initialisation and all

while 1: q = variable1.get if "3202" in q: variable2.set("NI NODE3202") try: switch(labelframe2, labelframe1) except: switch(labelframe3, labelframe1) elif "3212" in q: variable2.set("NI NODE3212") try: switch(labelframe1, labelframe2) except: switch(labelframe3, labelframe2) elif "3214" in q: variable2.set("NI NODE3214") try: switch(labelframe1, labelframe3) except: switch(labelframe2, labelframe3) else: None

some other part of code

def switch(x, y): if x.isGridded: x.isGridded = False x.grid_forget() y.isGridded = True y.grid(row=0, column=0) else: return False

I am trying to create a switch between three labelframes which are inside another labelframe, and outside this labelframe are other labelframes that are not changing.

I have read some similar answers but I don't want to use __iter__() in my code. Can anybody provide any other suggestions?

1

2 Answers

You forgot to call the Entry.get() method:

q = variable1.get()
# ^^ call the method

Because the method object itself doesn't support containment testing directly, Python is instead trying to iterate over the object to see if there are any elements contained in it that match your string.

If you call the method, you get a string value instead. Strings do support containment testing.

The reason you got that error was because you did not add "()" after.get query hence the error to fix this change q = variable1.get to q = variable.get()

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy