#!/usr/bin/env python
# coding=utf8
from gi.repository import Gdk, Gtk

class Test(object):
	def __init__(self):
		box = Gtk.Box(Gtk.Orientation.HORIZONTAL)
		
		searchBar = Gtk.SearchBar()
		searchBar_Entry = Gtk.Entry()
		searchBar.connect_entry(searchBar_Entry)
		searchBar.add(searchBar_Entry)
		box.add(searchBar)
		
		# main window
		window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL, title="Test", default_width=500, default_height=300)
		window.connect_after('destroy', self.on_window_destroy)
		window.add(box)
		window.connect("key_press_event", self.test, searchBar)
		window.show_all()
		Gtk.main()
	
	def test(self, window, event, searchBar):
		print(searchBar)
		print(event.type)
		searchBar.handle_event(event)
	
	def on_window_destroy(self, widget, data=None):
		Gtk.main_quit()

if __name__ == "__main__":
	test = Test()
