MCPcopy Index your code
hub / github.com/python/cpython / ViewFrame

Class ViewFrame

Lib/idlelib/textview.py:72–102  ·  view source on GitHub ↗

Display TextFrame and Close button.

Source from the content-addressed store, hash-verified

70
71
72class ViewFrame(Frame):
73 "Display TextFrame and Close button."
74 def __init__(self, parent, contents, wrap='word'):
75 """Create a frame for viewing text with a "Close" button.
76
77 parent - parent widget for this frame
78 contents - text to display
79 wrap - type of text wrapping to use ('word', 'char' or 'none')
80
81 The Text widget is accessible via the 'text' attribute.
82 """
83 super().__init__(parent)
84 self.parent = parent
85 self.bind('<Return>', self.ok)
86 self.bind('<Escape>', self.ok)
87 self.textframe = ScrollableTextFrame(self, relief=SUNKEN, height=700)
88
89 text = self.text = self.textframe.text
90 text.insert('1.0', contents)
91 text.configure(wrap=wrap, highlightthickness=0, state='disabled')
92 color_config(text)
93 text.focus_set()
94
95 self.button_ok = button_ok = Button(
96 self, text='Close', command=self.ok, takefocus=False)
97 self.textframe.pack(side='top', expand=True, fill='both')
98 button_ok.pack(side='bottom')
99
100 def ok(self, event=None):
101 """Dismiss text viewer dialog."""
102 self.parent.destroy()
103
104
105class ViewWindow(Toplevel):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…