Skip to main content
added 25 characters in body
Source Link
Bryan Oakley
  • 384.8k
  • 53
  • 569
  • 727

I found this code for a label class for a tkinter popup iI was making. I didntdidn't understand how the label appeared, but iI just went on with it. However later iI found that iI needed to refer to the created label in order to bind to it. iI have no idea what line is the actual place the label is being created, so when iI was trying to assign the label to a variable, i didntI didn't know where. canCan someone please explain what is happening in this code and how iI can call back to the label iI just created inside the class?

I figured out the label is being created somewhere where super()super() is being used and has something to do with the LabelLabel parameter being passed directly to the class. However after researching what super().init()super().__init__() did iI figured it just allows classes to use parameters from other classes, so imI'm still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the init__init__) I

I tried asssigningassigning the super()super() to a variable, or just using LabelLabel as a variable, or removing the selfself. at the beginning.

I made a mini version of the class to see what was going on but to no success. hereHere is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

sorrySorry if this is a bad question and or itsit is answered somewhere else this is my first question on here and imI'm pretty sure theres another easy solution but iI just rlyreally want to understand what is happening here.

I found this code for a label class for a tkinter popup i was making. I didnt understand how the label appeared, but i just went on with it. However later i found that i needed to refer to the created label in order to bind to it. i have no idea what line is the actual place the label is being created, so when i was trying to assign the label to a variable, i didnt know where. can someone please explain what is happening in this code and how i can call back to the label i just created inside the class?

I figured out the label is being created somewhere where super() is being used and has something to do with the Label parameter being passed directly to the class. However after researching what super().init() did i figured it just allows classes to use parameters from other classes, so im still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the init) I tried asssigning the super() to a variable, or just using Label as a variable, or removing the self. at the beginning.

I made a mini version of the class to see what was going on but to no success. here is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

sorry if this is a bad question and or its answered somewhere else this is my first question on here and im pretty sure theres another easy solution but i just rly want to understand what is happening here

I found this code for a label class for a tkinter popup I was making. I didn't understand how the label appeared, but I just went on with it. However later I found that I needed to refer to the created label in order to bind to it. I have no idea what line is the actual place the label is being created, so when I was trying to assign the label to a variable, I didn't know where. Can someone please explain what is happening in this code and how I can call back to the label I just created inside the class?

I figured out the label is being created somewhere where super() is being used and has something to do with the Label parameter being passed directly to the class. However after researching what super().__init__() did I figured it just allows classes to use parameters from other classes, so I'm still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the __init__)

I tried assigning the super() to a variable, or just using Label as a variable, or removing the self. at the beginning.

I made a mini version of the class to see what was going on but to no success. Here is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

Sorry if this is a bad question and or it is answered somewhere else this is my first question on here and I'm pretty sure theres another easy solution but I just really want to understand what is happening here.

added 69 characters in body
Source Link
r5ne
  • 17
  • 1
  • 5

I found this code for a label class for a tkinter popup i was making. I didnt understand how the label appeared, but i just went on with it. However later i found that i needed to refer to the created label in order to bind to it. i have no idea what line is the actual place the label is being created, so when i was trying to assign the label to a variable, i didnt know where. can someone please explain what is happening in this code and how i can call back to the label i just created inside the class?

I figured out the label is being created somewhere where super() is being used and has something to do with the Label parameter being passed directly to the class. However after researching what super().init() did i figured it just allows classes to use parameters from other classes, so im still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the init) I tried asssigning the super() to a variable, or just using Label as a variable, or removing the self. at the beginning.

I made a mini version of the class to see what was going on but to no success. here is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

sorry if this is a bad question and or its answered somewhere else this is my first question on here and im pretty sure theres another easy solution but i just rly want to understand what is happening here

I found this code for a label class for a tkinter popup i was making. I didnt understand how the label appeared, but i just went on with it. However later i found that i needed to refer to the created label in order to bind to it. i have no idea what line is the actual place the label is being created, so when i was trying to assign the label to a variable, i didnt know where. can someone please explain what is happening in this code?

I figured out the label is being created somewhere where super() is being used and has something to do with the Label parameter being passed directly to the class. However after researching what super().init() did i figured it just allows classes to use parameters from other classes, so im still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the init) I tried asssigning the super() to a variable, or just using Label as a variable, or removing the self. at the beginning.

I made a mini version of the class to see what was going on but to no success. here is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

sorry if this is a bad question and or its answered somewhere else this is my first question on here and im pretty sure theres another easy solution but i just rly want to understand what is happening here

I found this code for a label class for a tkinter popup i was making. I didnt understand how the label appeared, but i just went on with it. However later i found that i needed to refer to the created label in order to bind to it. i have no idea what line is the actual place the label is being created, so when i was trying to assign the label to a variable, i didnt know where. can someone please explain what is happening in this code and how i can call back to the label i just created inside the class?

I figured out the label is being created somewhere where super() is being used and has something to do with the Label parameter being passed directly to the class. However after researching what super().init() did i figured it just allows classes to use parameters from other classes, so im still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the init) I tried asssigning the super() to a variable, or just using Label as a variable, or removing the self. at the beginning.

I made a mini version of the class to see what was going on but to no success. here is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

sorry if this is a bad question and or its answered somewhere else this is my first question on here and im pretty sure theres another easy solution but i just rly want to understand what is happening here

Source Link
r5ne
  • 17
  • 1
  • 5

no idea where tkinter label is being defined in class

I found this code for a label class for a tkinter popup i was making. I didnt understand how the label appeared, but i just went on with it. However later i found that i needed to refer to the created label in order to bind to it. i have no idea what line is the actual place the label is being created, so when i was trying to assign the label to a variable, i didnt know where. can someone please explain what is happening in this code?

I figured out the label is being created somewhere where super() is being used and has something to do with the Label parameter being passed directly to the class. However after researching what super().init() did i figured it just allows classes to use parameters from other classes, so im still confused on how it works when its referring to itself. I also am confused on where the parameters passed directly into the class go (rather that being in the init) I tried asssigning the super() to a variable, or just using Label as a variable, or removing the self. at the beginning.

I made a mini version of the class to see what was going on but to no success. here is the code:

from tkinter import *


class Label(Label):
    def __init__(self, root, text, row, col, tag):
        self.text = text
        self.row = row
        self.column = col
        self.root = root
        self.tag = tag
        super().__init__(root)
        self['text'] = self.text
        self.grid(row=self.row, column=self.column)
        # self.label.bind("<Configure>", self.move) # this is the line of code im trying to get to work, but    cant because i dont know where the label is being created. it doesnt work           
    def move(self):
        print('moving')

root = Tk()
display = Toplevel()
output = 0
ans = Label(display, output, 0, 0, 'yes')
root.mainloop()

sorry if this is a bad question and or its answered somewhere else this is my first question on here and im pretty sure theres another easy solution but i just rly want to understand what is happening here