@@ -133,37 +133,36 @@ def is_active(self):
133133 return bool (self .tipwindow )
134134
135135
136+ def _calltip_window (parent ):
137+ root = Tk ()
138+ root .title ("Test calltips" )
139+ width , height , x , y = list (map (int , re .split ('[x+]' , parent .geometry ())))
140+ root .geometry ("+%d+%d" % (x , y + 150 ))
136141
137- ###############################
138- #
139- # Test Code
140- #
141- class container : # Conceptually an editor_window
142- def __init__ (self ):
143- root = Tk ()
144- text = self .text = Text (root )
145- text .pack (side = LEFT , fill = BOTH , expand = 1 )
146- text .insert ("insert" , "string.split" )
147- root .update ()
148- self .calltip = CallTip (text )
149-
150- text .event_add ("<<calltip-show>>" , "(" )
151- text .event_add ("<<calltip-hide>>" , ")" )
152- text .bind ("<<calltip-show>>" , self .calltip_show )
153- text .bind ("<<calltip-hide>>" , self .calltip_hide )
154-
155- text .focus_set ()
156- root .mainloop ()
157-
158- def calltip_show (self , event ):
159- self .calltip .showtip ("Hello world" )
160-
161- def calltip_hide (self , event ):
162- self .calltip .hidetip ()
163-
164- def main ():
165- # Test code
166- c = container ()
142+ class MyEditWin : # comparenceptually an editor_window
143+ def __init__ (self ):
144+ text = self .text = Text (root )
145+ text .pack (side = LEFT , fill = BOTH , expand = 1 )
146+ text .insert ("insert" , "string.split" )
147+ root .update ()
148+ self .calltip = CallTip (text )
149+
150+ text .event_add ("<<calltip-show>>" , "(" )
151+ text .event_add ("<<calltip-hide>>" , ")" )
152+ text .bind ("<<calltip-show>>" , self .calltip_show )
153+ text .bind ("<<calltip-hide>>" , self .calltip_hide )
154+
155+ text .focus_set ()
156+ root .mainloop ()
157+
158+ def calltip_show (self , event ):
159+ self .calltip .showtip ("Hello world" , "insert" , "end" )
160+
161+ def calltip_hide (self , event ):
162+ self .calltip .hidetip ()
163+
164+ editwin = MyEditWin ()
167165
168166if __name__ == '__main__' :
169- main ()
167+ from idlelib .idle_test .htest import run
168+ run (_calltip_window )
0 commit comments