MCPcopy Index your code
hub / github.com/csev/py4e / Entry

Class Entry

code/graphics/graphics.py:764–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

762 return '"%s" at %s' % (self.getText(), self.anchor.coordStr())
763
764class Entry(GraphicsObject):
765
766 def __init__(self, centerPt, width):
767 GraphicsObject.__init__(self, [])
768 self.anchor = centerPt.clone()
769 #print self.anchor
770 self.width = width
771 #self.text = tk.StringVar(_root)
772 #self.text.set("")
773 self.text = _tkCall(tk.StringVar, _root)
774 _tkCall(self.text.set, "")
775 self.fill = "gray"
776 self.color = "black"
777 self.font = DEFAULT_CONFIG['font']
778 self.entry = None
779
780 def _draw(self, canvas, options):
781 p = self.anchor
782 x,y = canvas.toScreen(p.x,p.y)
783 frm = tk.Frame(canvas.master)
784 self.entry = tk.Entry(frm,
785 width=self.width,
786 textvariable=self.text,
787 bg = self.fill,
788 fg = self.color,
789 font=self.font)
790 self.entry.pack()
791 #self.setFill(self.fill)
792 return canvas.create_window(x,y,window=frm)
793
794 def getText(self):
795 return _tkCall(self.text.get)
796
797 def _move(self, dx, dy):
798 self.anchor.move(dx,dy)
799
800 def getAnchor(self):
801 return self.anchor.clone()
802
803 def clone(self):
804 other = Entry(self.anchor, self.width)
805 return _tkCall(self.__clone_help, other)
806
807 def __clone_help(self, other):
808 other.config = self.config.copy()
809 other.text = tk.StringVar()
810 other.text.set(self.text.get())
811 other.fill = self.fill
812 return other
813
814 def setText(self, text):
815 #self.text.set(t)
816 _tkCall(self.text.set, text)
817
818 def setFill(self, color):
819 self.fill = color
820 if self.entry:
821 #self.entry.config(bg=color)

Callers 2

cloneMethod · 0.85
testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected