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

Method __init__

Lib/idlelib/textview.py:108–141  ·  view source on GitHub ↗

Show the given text in a scrollable window with a 'close' button. If modal is left True, users cannot interact with other windows until the textview window is closed. parent - parent of this dialog title - string which is title of popup dialog contents - tex

(self, parent, title, contents, modal=True, wrap=WORD,
                 *, _htest=False, _utest=False)

Source from the content-addressed store, hash-verified

106 "A simple text viewer dialog for IDLE."
107
108 def __init__(self, parent, title, contents, modal=True, wrap=WORD,
109 *, _htest=False, _utest=False):
110 """Show the given text in a scrollable window with a 'close' button.
111
112 If modal is left True, users cannot interact with other windows
113 until the textview window is closed.
114
115 parent - parent of this dialog
116 title - string which is title of popup dialog
117 contents - text to display in dialog
118 wrap - type of text wrapping to use ('word', 'char' or 'none')
119 _htest - bool; change box location when running htest.
120 _utest - bool; don't wait_window when running unittest.
121 """
122 super().__init__(parent)
123 self['borderwidth'] = 5
124 # Place dialog below parent if running htest.
125 x = parent.winfo_rootx() + 10
126 y = parent.winfo_rooty() + (10 if not _htest else 100)
127 self.geometry(f'=750x500+{x}+{y}')
128
129 self.title(title)
130 self.viewframe = ViewFrame(self, contents, wrap=wrap)
131 self.protocol("WM_DELETE_WINDOW", self.ok)
132 self.button_ok = Button(self, text='Close',
133 command=self.ok, takefocus=False)
134 self.viewframe.pack(side='top', expand=True, fill='both')
135
136 self.is_modal = modal
137 if self.is_modal:
138 self.transient(parent)
139 self.grab_set()
140 if not _utest:
141 self.wait_window()
142
143 def ok(self, event=None):
144 """Dismiss text viewer dialog."""

Callers

nothing calls this directly

Calls 11

ButtonClass · 0.90
superClass · 0.85
ViewFrameClass · 0.85
winfo_rootxMethod · 0.80
winfo_rootyMethod · 0.80
protocolMethod · 0.80
grab_setMethod · 0.80
wait_windowMethod · 0.80
__init__Method · 0.45
titleMethod · 0.45
packMethod · 0.45

Tested by

no test coverage detected