@@ -24,34 +24,33 @@ def __init__(self, master): # constructor method
24
24
25
25
# store image in the label obj to keep it in the scope as
26
26
# long as label is displayed and to avoid getting the image getting garbage collected
27
- imgpath = 'simple_gif.gif'
28
- self .label .img = tk .PhotoImage (file = imgpath )
29
- self .label .config (compound = 'left' ) # to display image in left of text
30
-
27
+ imgpath = 'simple_gif.gif' # path of the image
28
+ self .label .img = tk .PhotoImage (file = imgpath ) # read_image :: saving image within label_object to prevent its garbage collection
29
+ self .label .config (image = self . label . img ) # display image in label widget
30
+ self . label . config ( compound = 'left' ) # to display image in left of text
31
31
32
32
self .label .pack () # pack label to the window with pack() geometry method of Label
33
33
self .btn .pack ()
34
- self .label .config (wraplength = 200 )
35
- self .label .config (justify = tk .CENTER ) # justify can be CENTER, RIGHT, LEFT
34
+
35
+ self .label .config (wraplength = 200 ) # specify wraplength of text in label
36
+ self .label .config (justify = tk .CENTER ) # justify text in label to (CENTER, RIGHT or LEFT)
36
37
self .label .config (foreground = 'blue' , background = 'yellow' ) # insert font color (foreground) and background color
37
38
self .label .config (font = ('Times' , 10 , 'bold' )) # font = (font_name, font_size, font_type)
38
39
39
- # store image in the label obj to keep it in the scope as
40
- # long as label is displayed and to avoid getting the image getting garbage collected
41
- imgpath = 'simple_gif.gif'
42
- self .label .img = tk .PhotoImage (file = imgpath )
43
- self .label .config (image = self .label .img )
44
- self .label .config (compound = 'left' ) # to display image in left of text
45
-
46
40
def handle_text (self ):
47
41
if self .label ['text' ] == self .greet_list [0 ]:
48
42
self .label .config (text = self .greet_list [1 ])
49
43
else :
50
44
self .label .config (text = self .greet_list [0 ])
51
-
52
- def test ():
45
+
46
+
47
+ def GreetingAppLaunch (): # function to use class defined
53
48
root = tk .Tk ()
54
49
GreetingApp (root )
55
50
root .mainloop ()
51
+
52
+
53
+ def test ():
54
+ GreetingAppLaunch ()
56
55
57
56
if __name__ == '__main__' : test ()
0 commit comments