def __init__(self, *args, **kwargs): super(Notepad, self).__init__(*args, **kwargs) self.scrolled = Gtk.ScrolledWindow() self.scrolled.set_hexpand(True) self.scrolled.set_vexpand(True) self.sourceview = GtkSource.View() self.sourcebuffer = self.sourceview.get_buffer() self.sourceview.set_show_line_numbers(True) self.sourceview.set_smart_home_end(0) self.sourceview.set_auto_indent(True) self.scrolled.add(self.sourceview) self.sourcebuffer.set_highlight_syntax(True) self.sourcebuffer.set_highlight_matching_brackets(True) start, end = self.sourcebuffer.get_bounds() self.sourcebuffer.ensure_highlight(start, end) self.sourcelanguagemanager = GtkSource.LanguageManager() lang = self.sourcelanguagemanager.get_default() abc = self.sourcelanguagemanager.get_language("python") self.sourcebuffer.set_language(abc) self.sourcestyle = GtkSource.Style() self.sourcestylescheme = GtkSource.StyleScheme() self.sourcestyleschememanager = GtkSource.StyleSchemeManager() self.sourcestyleschememanager.append_search_path(os.getcwd()) style = self.sourcestyleschememanager.get_scheme("oblivion") self.sourcebuffer.set_style_scheme(style) self.sourcesearch = GtkSource.SearchContext.new(self.sourcebuffer) self.sourcesearchsettings = GtkSource.SearchSettings() self.sourcesearch.set_settings(self.sourcesearchsettings) self.sourcesearch.set_highlight(True) self.textiter = Gtk.TextIter() self.searchtoolbar = Gtk.Toolbar() self.toolitem = Gtk.ToolItem() self.search_bar = Gtk.Entry() self.search_bar.set_width_chars(30) self.toolitem.add(self.search_bar) self.searchtoolbar.insert(self.toolitem, -1) self.toolitem2 = Gtk.ToolItem() self.search_bar_button = Gtk.Button(label="Ara") self.search_bar_button.connect("clicked", self.search) self.toolitem2.add(self.search_bar_button) self.searchtoolbar.insert(self.toolitem2, -1) self.toolitem_case_sensitive = Gtk.ToolItem() self.case_sensitive_button = Gtk.ToggleButton( label="Büyük küçük ayrımı") self.case_sensitive_button.connect("toggled", self.case_sensitive_toogled) self.toolitem_case_sensitive.add(self.case_sensitive_button) self.searchtoolbar.insert(self.toolitem_case_sensitive, -1) self.toolitem3 = Gtk.ToolItem() self.search_bar_button = Gtk.Button(label="Çık") self.search_bar_button.connect("clicked", self.search_bar_close) self.toolitem3.add(self.search_bar_button) self.searchtoolbar.insert(self.toolitem3, -1) self.replacetoolbar = Gtk.Toolbar() self.toolitem4 = Gtk.ToolItem() self.replace_entry_1 = Gtk.Entry() self.replace_entry_1.set_width_chars(30) self.toolitem4.add(self.replace_entry_1) self.replacetoolbar.insert(self.toolitem4, 0) self.toolitem5 = Gtk.ToolItem() self.replace_entry_2 = Gtk.Entry() self.replace_entry_2.set_width_chars(30) self.toolitem5.add(self.replace_entry_2) self.replacetoolbar.insert(self.toolitem5, -1) self.toolitem6 = Gtk.ToolItem() self.search_bar_button = Gtk.Button(label="Değiştir") self.search_bar_button.connect("clicked", self.replace_text) self.toolitem6.add(self.search_bar_button) self.replacetoolbar.insert(self.toolitem6, -1) self.toolitem7 = Gtk.ToolItem() self.search_bar_button = Gtk.Button(label="Çık") self.search_bar_button.connect("clicked", self.replace_bar_close) self.toolitem7.add(self.search_bar_button) self.replacetoolbar.insert(self.toolitem7, -1) self.pack_start(self.scrolled, True, True, 0) self.pack_start(self.searchtoolbar, False, True, 0) self.pack_start(self.replacetoolbar, False, True, 0) self.show() self.searchtoolbar.hide() self.replacetoolbar.hide() self.scrolled.show_all()
def __init__(self, *args, **kwargs): super(Notepad, self).__init__(*args, **kwargs) self.scrolled = Gtk.ScrolledWindow() self.scrolled.set_hexpand(True) self.scrolled.set_vexpand(True) self.sourceview = GtkSource.View() self.sourcebuffer = self.sourceview.get_buffer() self.sourceview.set_show_line_numbers(True) self.sourceview.set_smart_home_end(0) self.sourceview.set_auto_indent(True) self.scrolled.add(self.sourceview) self.sourcebuffer.set_highlight_syntax(True) self.sourcebuffer.set_highlight_matching_brackets(True) start, end = self.sourcebuffer.get_bounds() self.sourcebuffer.ensure_highlight(start, end) self.sourcelanguagemanager = GtkSource.LanguageManager() lang = self.sourcelanguagemanager.get_default() abc = self.sourcelanguagemanager.get_language("python") self.sourcebuffer.set_language(abc) self.sourcestyle = GtkSource.Style() self.sourcestylescheme = GtkSource.StyleScheme() self.sourcestyleschememanager = GtkSource.StyleSchemeManager() style = self.sourcestyleschememanager.get_scheme("oblivion") self.sourcebuffer.set_style_scheme(style) self.sourcesearch = GtkSource.SearchContext.new(self.sourcebuffer) self.sourcesearchsettings = GtkSource.SearchSettings() self.sourcesearchsettings.set_search_text("deneme") self.sourcesearch.set_settings(self.sourcesearchsettings) self.sourcesearch.set_highlight(True) self.textiter = Gtk.TextIter() self.searchtoolbar = Gtk.Toolbar() self.toolitem = Gtk.ToolItem() self.search_bar = Gtk.Entry() self.search_bar.set_width_chars(30) self.search_bar.connect("activate", self.search) self.toolitem.add(self.search_bar) self.searchtoolbar.insert(self.toolitem, 0) self.replacetoolbar = Gtk.Toolbar() self.toolitem2 = Gtk.ToolItem() self.search_bar2 = Gtk.Entry() self.search_bar2.set_width_chars(30) self.search_bar2.connect("activate", self.search) self.toolitem2.add(self.search_bar2) self.replacetoolbar.insert(self.toolitem2, 0) self.toolitem3 = Gtk.ToolItem() self.search_bar3 = Gtk.Entry() self.search_bar3.set_width_chars(30) self.search_bar3.connect("activate", self.search) self.toolitem3.add(self.search_bar3) self.replacetoolbar.insert(self.toolitem3, 0) self.pack_start(self.scrolled, True, True, 0) self.pack_start(self.searchtoolbar, False, True, 0) self.pack_start(self.replacetoolbar, False, True, 0) self.show() self.scrolled.show_all()