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

Method compareto

tools/python-3.11.9-amd64/Tools/demo/sortvisu.py:301–322  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

299 self.canvas.itemconfig(other.item_id, fill=otherfill)
300
301 def compareto(self, other):
302 myfill = self.canvas.itemcget(self.item_id, 'fill')
303 otherfill = self.canvas.itemcget(other.item_id, 'fill')
304 if self.value < other.value:
305 myflash = 'white'
306 otherflash = 'black'
307 outcome = -1
308 elif self.value > other.value:
309 myflash = 'black'
310 otherflash = 'white'
311 outcome = 1
312 else:
313 myflash = otherflash = 'grey'
314 outcome = 0
315 try:
316 self.canvas.itemconfig(self.item_id, fill=myflash)
317 self.canvas.itemconfig(other.item_id, fill=otherflash)
318 self.array.wait(500)
319 finally:
320 self.canvas.itemconfig(self.item_id, fill=myfill)
321 self.canvas.itemconfig(other.item_id, fill=otherfill)
322 return outcome
323
324 def position(self):
325 x1 = (self.index+1)*XGRID - WIDTH//2

Callers 1

compareMethod · 0.80

Calls 2

itemcgetMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected