Python Forum
Using Time to Update a Global Variable and Label in TkInter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Time to Update a Global Variable and Label in TkInter
#6
Ok, I'll tell you about the __init__ function. The __init__ function is for defining self variables and sometimes doing a few things. If I create a player class I would do the following:
  1. Make an __init__ function with parameters self, x, y, width, height, color
  2. I would define all the variables as goes -
    self.x = x
    self.y = y
    #etc.
    and you can add more variables that aren't in the parameters like this self.rect = (self.x, self.y, self.width, self.height)
  3. make a draw function in the player class. It is able to access the self variables defined in __init__ as long as I put self in the draw parameter.
  4. Then I save the class in a variables like this p = Player(paramters)
    I don't have to self or anything like that in the parameters because it automatically does that.
  5. finally to draw it I would call upon the draw function like this p.draw()

Hope you understand now
Reply


Messages In This Thread
RE: Using Time to Update a Global Variable and Label in TkInter - by SheeppOSU - Apr-22-2019, 05:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python 3 Global Variable Help Tridium 5 3,008 Jul-29-2019, 08:02 AM
Last Post: Tridium

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020