MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / PhotoImage

Class PhotoImage

tools/python-3.11.9-amd64/Lib/tkinter/__init__.py:4142–4223  ·  view source on GitHub ↗

Widget which can display images in PGM, PPM, GIF, PNG format.

Source from the content-addressed store, hash-verified

4140
4141
4142class PhotoImage(Image):
4143 """Widget which can display images in PGM, PPM, GIF, PNG format."""
4144
4145 def __init__(self, name=None, cnf={}, master=None, **kw):
4146 """Create an image with NAME.
4147
4148 Valid resource names: data, format, file, gamma, height, palette,
4149 width."""
4150 Image.__init__(self, 'photo', name, cnf, master, **kw)
4151
4152 def blank(self):
4153 """Display a transparent image."""
4154 self.tk.call(self.name, 'blank')
4155
4156 def cget(self, option):
4157 """Return the value of OPTION."""
4158 return self.tk.call(self.name, 'cget', '-' + option)
4159 # XXX config
4160
4161 def __getitem__(self, key):
4162 return self.tk.call(self.name, 'cget', '-' + key)
4163 # XXX copy -from, -to, ...?
4164
4165 def copy(self):
4166 """Return a new PhotoImage with the same image as this widget."""
4167 destImage = PhotoImage(master=self.tk)
4168 self.tk.call(destImage, 'copy', self.name)
4169 return destImage
4170
4171 def zoom(self, x, y=''):
4172 """Return a new PhotoImage with the same image as this widget
4173 but zoom it with a factor of x in the X direction and y in the Y
4174 direction. If y is not given, the default value is the same as x.
4175 """
4176 destImage = PhotoImage(master=self.tk)
4177 if y=='': y=x
4178 self.tk.call(destImage, 'copy', self.name, '-zoom',x,y)
4179 return destImage
4180
4181 def subsample(self, x, y=''):
4182 """Return a new PhotoImage based on the same image as this widget
4183 but use only every Xth or Yth pixel. If y is not given, the
4184 default value is the same as x.
4185 """
4186 destImage = PhotoImage(master=self.tk)
4187 if y=='': y=x
4188 self.tk.call(destImage, 'copy', self.name, '-subsample',x,y)
4189 return destImage
4190
4191 def get(self, x, y):
4192 """Return the color (red, green, blue) of the pixel at X,Y."""
4193 return self.tk.call(self.name, 'get', x, y)
4194
4195 def put(self, data, to=None):
4196 """Put row formatted colors to image starting from
4197 position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))"""
4198 args = (self.name, 'put', data)
4199 if to:

Callers 7

create_widgetsMethod · 0.90
copyMethod · 0.85
zoomMethod · 0.85
subsampleMethod · 0.85
mainFunction · 0.85
listiconsFunction · 0.85
geticonimageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected