<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>&nbsp;</DIV>
<DIV 
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV><FONT size=3 face=Calibri></FONT></DIV>
<DIV 
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none"></DIV></DIV>
<DIV class=gmail_quote>
<DIV>If you're going to put a function inside your class (since you're using 
self in there, I'm sure that's what you meant to do), you should change it 
to:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def change_value_the_time(self):</DIV>
<DIV>&nbsp;</DIV>
<DIV>and call it with</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; self.display_time.after(20, 
self.change_value_the_time)</DIV>
<DIV>&nbsp;</DIV>
<DIV>But your program also has unnecessary code. First, since you have a class 
then instead of using a global, you should simply declare `self.the_time = ''` 
in your __init__ for your class.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Personally, I would have written the function more like this:</DIV>
<DIV>&nbsp;</DIV>
<DIV>def update_time(self):</DIV>
<DIV>&nbsp;&nbsp;&nbsp; self.display_time.config(text=time.strftime('%H:%M:%S'), 
font='40')<BR>&nbsp;&nbsp;&nbsp; self.after(20, self.update_time)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Then at the end of my __init__ function I would call 
self.update_time()</DIV>
<DIV>&nbsp;</DIV>
<DIV>I'm not sure how that will work with your current setup, though.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>-------------------------------------------------------------------------------------------------------------------------------------</DIV>
<DIV class=gmail_quote>
<DIV>&nbsp;</DIV>
<DIV>I have now worked to stop using the global scope and instead put my prior 
global variable into</DIV>
<DIV>the constructor in the class. I believe that I have managed to do that 
now.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Do you believe that this is correctly done?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Trying putting the_time'' in constructor instead of</DIV>
<DIV>#putting it in the global scope to shorten code.</DIV>
<DIV>&nbsp;</DIV>
<DIV>from tkinter import*</DIV>
<DIV>import time</DIV>
<DIV>import os</DIV>
<DIV>&nbsp;</DIV>
<DIV>class Window(Frame):</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def __init__(self,master):</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super 
(Window,self).__init__(master)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.grid()</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.the_time=''</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.create_widgets()</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.update_time()</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def create_widgets(self):</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #Create a hello Button:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.hellobttn=Button(self, 
text="Hey")</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.hellobttn.grid(row=0, 
column=1)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #Create a label that displays 
time.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.display_time=Label(self, 
text=self.the_time)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.display_time.grid(row=1, 
column=1)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def update_time(self):</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.display_time.config(text=time.strftime('%H:%M:%S'), font='40')</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.after(20, self.update_time)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>root=Tk()</DIV>
<DIV>root.title("Test")</DIV>
<DIV>root.geometry("200x200")</DIV>
<DIV>app=Window(root)</DIV>
<DIV>root.mainloop()&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>I get no error while doing this, and the program works fine.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have another question.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Say that I have a class and I want to make 100 objects. </DIV>
<DIV>Then it could look like this:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#How to shorten this?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Create the class.</DIV>
<DIV>class Chairs(object):</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def __init__(self, age, weight):</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.age=age</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.weight=weight</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def __str__(self):</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rep=self.age+self.weight</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return rep</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#Create the objects</DIV>
<DIV>chair1=Chairs("10","20")</DIV>
<DIV>chair2=Chairs("10","20")</DIV>
<DIV>chair3=Chairs("10","20")</DIV>
<DIV>chair4=Chairs("10","20")</DIV>
<DIV>chair5=Chairs("10","20")</DIV>
<DIV>chair6=Chairs("10","20")</DIV>
<DIV>chair7=Chairs("10","20")</DIV>
<DIV>chair8=Chairs("10","20")</DIV>
<DIV>chair9=Chairs("10","20")</DIV>
<DIV>#And so on</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>How do I shorten this? I have thought of using a for sling. I have looked 
in my programming</DIV>
<DIV>book and on the internet, but I don’t know how to make this shorter. The 
arguements (“10”, “20”)</DIV>
<DIV>should be the same for every object, which should make it easier than if 
they were different each time?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Right now, it feels like a lot of my code in my other programs could be 
made dramatically shorter.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks!</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
class=gmail_quote>
  <DIV dir=ltr>
  <DIV dir=ltr>
  <DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
  <DIV class=im></DIV>
  <DIV>&nbsp;</DIV></DIV></DIV></DIV></BLOCKQUOTE></DIV></DIV></DIV></DIV></BODY></HTML>