File tree Expand file tree Collapse file tree 1 file changed +37
-3
lines changed
Expand file tree Collapse file tree 1 file changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -103,12 +103,46 @@ def destroy(
103103
104104class Image (Object ):
105105 """
106- Displays an image (from file or URL) on the given Screen, packs it with optional args,
107- and provides a destroy() method for cleanup. Supports basic transformations (resize, scale, position).
106+ Displays an image on the given Screen, packs it with optional args,
107+ and provides a destroy() method for cleanup.
108108 """
109109
110110 image_obj : tk .Label
111- _photo_image : Any
111+
112+ def __init__ (
113+ self ,
114+ screen_obj : Screen ,
115+ / ,
116+ image_path : str ,
117+ packargs : Optional [dict [Any , Optional [Any ]]] = None ,
118+ ** kwargs
119+ ) -> None :
120+
121+ if packargs is None :
122+ packargs = {}
123+
124+ if not isinstance (screen_obj , Screen ):
125+ raise TypeError ("screen_obj must be an instance of Screen" )
126+
127+ img = tk .PhotoImage (file = image_path )
128+ self .image_obj = tk .Label (screen_obj .root , image = img , ** kwargs )
129+ self .image_obj .image = img
130+ self .image_obj .pack (** {k : v for k , v in packargs .items () if v is not None })
131+
132+ def config (
133+ self ,
134+ ** kwargs
135+ ) -> None :
136+ """Configure object"""
137+
138+ self .image_obj .config (** kwargs )
139+
140+ def destroy (
141+ self
142+ ) -> None :
143+ """Destroy image"""
144+
145+ self .image_obj .destroy ()
112146
113147class Input (Object ):
114148 """
You can’t perform that action at this time.
0 commit comments