Similar reference for different tabs in tab widget ? Strange [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am creating tabs dynamically in a tabwidget using this method :
def add_new_tab(self,index,text):
self.new_tab = InterfaceTemplateDialog()
self.tabs.addTab(self.new_tab,text)
self.tabs.setTabText(index,text)
Trying to print the reference of selected tab using this method :
def onChange(self):
currentIndex = self.tabs.currentIndex()
print InterfaceTemplateDialog()
I get the same reference for every selected tab except for the first selected:
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F842F0>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
<OptionsTRANUS.interface_template.InterfaceTemplateDialog object at 0x0000000014F8EE18>
If references are similar, I cannot control actions on tabs.
So what is this strange problem ?
Thank you in advance for your help.

I think the correct way to get the correct reference is to use :
currentTabWidget = self.tabs.currentWidget()
with self.tabs = self.findChild(QtGui.QTabWidget, 'tabWidget')
I tested, it works well. Thanks.

Related

why can't I use '.' to access my dictionary [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
This post was edited and submitted for review 9 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I'm trying to make a game in python and am organizing my data.
game={
'img':{
'bg':'wouir'
}
}
print(stuff.img.bg)
When I push build it has an error on the last line saying:
AttributeError: 'dict' object has no attribute 'img'
It seems I have a problem, what is it?
You cannot access object's items through dot-notation in Python. You're supposed to use braces.
screen.draw(game["img"]["bg"], (0,0))
In Python, the keys of a dictionary are not its attributes. This means you cannot call them with the .. You have to use ['img'] instead of .img.
Change your loop to this:
while True:
screen.draw(game['img']['bg'], (0,0)) # I've only corrected game.img.bg

Getting TypeError: 'list' object is not callable while using Map method in python [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
s = [1,2,3,4]
list(map(lambda parameter : parameter*2, s))
I am trying to run this simple line of code, but ending up getting
TypeError: 'list' object is not callable
can anybody please suggest me a solution for this
Your code works as is. I'm guessing (for lack of info) that somewhere above these lines of code you've overridden list as an actual list...
Check your code for this kind of error, and if it exists then refactor and rename so as to not use list as a parameter in your code.

Class instantiation with and without parantheses [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
Consider the following:
class car:
pass
tesla=car()
When I do type(tesla), this gives __main__.car, as I expect.
But if I have:
class car:
pass
tesla=car
then type(car) gives type.
From another post here on SO, it really shouldn't matter how I instantiate the class. But clearly as we see here, the type of the object is different. I am an absolute beginner to python, could you please let me know what is going on here.
Thanks!
In the second case, you're not instantiating the class, just giving it another name, tesla. The parentheses are required for instantiation.

Why is it giving me this syntax error? I’m following a tutorial. (Beginner) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
It's saying there's a syntax error (seems simple enough) but I've double-checked the video (and my brain). I don't see why it would be saying that.
Been following this tutorial and taking notes to a T (if I need to include more code let me know).
I defined "run_test" and am entering the parameters in question. Help?
You have extra opening parenthesis before ‘str(len(...))’
There should be a closing brackets for str in print statement ')' , add this and your program will work
If i am not wrong, you haven't defined the list of questions yet. If you have defined your list of questions it is probably a typing error in your code. If there is the full code under the tutorial you are doing then i would compare my code to the code from the tutorial.

How to open a text file in python 3.0 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
Hey So i typed in this code:
opennote = open('C:\\Users\\My_username\\coolnotepad.txt')
(with my username ofc)
yet i keep getting this
TypeError: 'str' object is not callable
Helpp!
A callable has a __call__ method defined, meaning you can follow it with () to invoke its functionality.
open is a reserved keyword, which, if overridden by a variable, shows the behavior you are seeing.
Using a text editor that supports the python syntax with highlighting can help you avoid issues like this.

Categories

Resources