当前位置: 首页>>代码示例>>Python>>正文


Python GtkSource.View方法代码示例

本文整理汇总了Python中gi.repository.GtkSource.View方法的典型用法代码示例。如果您正苦于以下问题:Python GtkSource.View方法的具体用法?Python GtkSource.View怎么用?Python GtkSource.View使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.GtkSource的用法示例。


在下文中一共展示了GtkSource.View方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def __init__(self):
        super(DescriptionEditorView, self).__init__(name='DESCRIPTION', language='idl',
                                                    editor_style="SOURCE_EDITOR_STYLE")

        try:
            if isinstance(self.textview, GtkSource.View):
                self.textview.set_wrap_mode(True)
                self.textview.set_tab_width(4)
                self.textview.set_insert_spaces_instead_of_tabs(True)
                self.textview.set_show_line_numbers(False)
                self.textview.set_auto_indent(True)
                self.textview.set_highlight_current_line(True)
                b = self.textview.get_buffer()
                b.set_highlight_syntax(False)
        except NameError:
            pass 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:18,代码来源:description_editor.py

示例2: __init__

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def __init__(self, *args, **kwargs):
		super(SourceView, self).__init__(*args, **kwargs)
		""" GtkSource.View widget """
		self.set_show_line_numbers(True) 
开发者ID:r3vn,项目名称:badKarma,代码行数:6,代码来源:widgets.py

示例3: add_note

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def add_note(self, widget):

		""" add a note to the db """

		try:
			self.scrolledwindow.destroy()
		except: pass

		title, id = self.database.add_note(self.host.id, "note "+str(len(self.notes_liststore)), "") # FIXME
		self.notes_liststore.append([title, id])

		self.scrolledwindow = Gtk.ScrolledWindow()
		self.scrolledwindow.set_hexpand(True)
		self.scrolledwindow.set_vexpand(True)

		self.note_box = GtkSource.View()
		textbuffer = self.note_box.get_buffer()
		textbuffer.set_text("")
		self.notestree = Gtk.TreeView(model=self.notes_liststore)
		self.note_box.set_show_line_numbers(True)

		self.scrolledwindow.add(self.note_box)
		self.note_box.show()
		self.scrolledwindow.show()

		self.notes_view.add(self.scrolledwindow)

		self.note_box.connect("move-cursor", self.save_note, id)

		self.id = id 
开发者ID:r3vn,项目名称:badKarma,代码行数:32,代码来源:widgets.py

示例4: on_row_activated

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def on_row_activated(self, listbox, cell, listboxrow):

		try:
			self.save_note('','','','',self.id)
			self.scrolledwindow.destroy()
		except: pass

		(model, pathlist) = listbox.get_selection().get_selected_rows()
		for path in pathlist :

			tree_iter = model.get_iter(path)
			id = model.get_value(tree_iter,1)

			nota = self.database.get_note(id)

			self.scrolledwindow = Gtk.ScrolledWindow()
			self.scrolledwindow.set_hexpand(True)
			self.scrolledwindow.set_vexpand(True)

			self.note_box = GtkSource.View()
			textbuffer = self.note_box.get_buffer()
			textbuffer.set_text(nota.text)
			self.notestree = Gtk.TreeView(model=self.notes_liststore)
			self.note_box.set_show_line_numbers(True)

			self.scrolledwindow.add(self.note_box)
			self.note_box.show()
			self.scrolledwindow.show()

			self.notes_view.add(self.scrolledwindow)
			self.note_box.connect("move-cursor", self.save_note, id)

			self.id = id 
开发者ID:r3vn,项目名称:badKarma,代码行数:35,代码来源:widgets.py

示例5: __init__

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def __init__(self):
        GtkSource.View.__init__(self)

        self.set_hexpand(True)
        self.set_vexpand(True)

        # create buffer
        self.buf = self.get_buffer()

        # setup style and lang managers
        self.lm = GtkSource.LanguageManager()
        self.sm = GtkSource.StyleSchemeManager()

        self.lm.set_search_path([LANGDIR])
        self.sm.set_search_path([STYLEDIR])

        self.buf.set_style_scheme(self.sm.get_scheme('gcode'))
        self.buf.set_language(self.lm.get_language('gcode'))

        self.buf.set_max_undo_levels(20)

        self.set_show_line_numbers(True)
        self.set_show_line_marks(False)
        self.set_highlight_current_line(False)

        self.connect('key-press-event', self.on_key_press)

        # Set line highlight styles
        self.add_mark_category('error', '#ff7373')
        self.add_mark_category('motion', '#c5c5c5')
        self.add_mark_category('selected', '#96fef6')

        self.mark = None
        self.current_file = None
        self.error_line = None

        self.show() 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:39,代码来源:gcode_view.py

示例6: ScrolledSourceView

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def ScrolledSourceView(text=None, syntax=None):
	'''If GTKSourceView was successfullly loaded, this generates a SourceView and
	initializes it. Otherwise ScrolledTextView will be used as a fallback.

	@param text: initial text to show in the view
	@param syntax: this will try to enable syntax highlighting for the given
	language. If None, no syntax highlighting will be enabled.
	@returns: a 2-tuple of a window and a view.
	'''
	if GtkSource:
		gsvbuf = GtkSource.Buffer()
		if syntax:
			gsvbuf.set_highlight_syntax(True)
			language_manager = GtkSource.LanguageManager()
			gsvbuf.set_language(language_manager.get_language(syntax))
		if text:
			gsvbuf.set_text(text)
		textview = GtkSource.View()
		textview.set_buffer(gsvbuf)
		textview.set_property("show-line-numbers", True)
		textview.set_property("auto-indent", True)
		font = Pango.FontDescription('Monospace')
		textview.modify_font(font)
		textview.set_property("smart-home-end", True)
		window = ScrolledWindow(textview)
		return (window, textview)
	else:
		return ScrolledTextView(text=text, monospace=True) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:30,代码来源:widgets.py

示例7: __init__

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def __init__(self, git):
        GObject.type_register(GtkSource.View)
        self._git = git
        self._builder = Gtk.Builder()
        self._builder.add_from_resource('/com/nautilus/git/ui/compare.ui')
        self._builder.connect_signals({
            "file_changed": self._on_file_changed
        })

        self._window = self._builder.get_object("window")

        self._build_widgets()
        self._window.show_all() 
开发者ID:bilelmoussaoui,项目名称:nautilus-git,代码行数:15,代码来源:compare.py

示例8: __init__

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def __init__(self):
        super(SourceEditorView, self).__init__(name='SOURCE EDITOR', language='python',
                                               editor_style="SOURCE_EDITOR_STYLE", run_with_spacer=False)

        try:
            if isinstance(self.textview, GtkSource.View):
                self.textview.set_tab_width(4)
                self.textview.set_insert_spaces_instead_of_tabs(True)
                self.textview.set_show_line_numbers(True)
                self.textview.set_auto_indent(True)
                self.textview.set_highlight_current_line(True)
        except NameError:
            pass
        hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
        hbox.get_style_context().add_class("widget-toolbar")
        pylint_check_button = Gtk.CheckButton(label="Validate")
        Gtk.Widget.set_focus_on_click(pylint_check_button, True)
        pylint_check_button.set_border_width(constants.BUTTON_BORDER_WIDTH)
        pylint_check_button.get_style_context().add_class("secondary")

        open_external_button = Gtk.ToggleButton(label="Open externally")
        Gtk.Widget.set_focus_on_click(open_external_button, True)
        open_external_button.set_border_width(constants.BUTTON_BORDER_WIDTH)

        apply_button = Gtk.Button(label="Apply")
        Gtk.Widget.set_focus_on_click(apply_button, True)
        apply_button.set_border_width(constants.BUTTON_BORDER_WIDTH)

        cancel_button = Gtk.Button(label="Reset")
        Gtk.Widget.set_focus_on_click(cancel_button, True)
        cancel_button.set_border_width(constants.BUTTON_BORDER_WIDTH)

        hbox.pack_start(pylint_check_button, False, False, 0)
        hbox.pack_end(open_external_button, False, True, 0)
        hbox.pack_end(cancel_button, False, True, 0)
        hbox.pack_end(apply_button, False, True, 0)

        label.ellipsize_labels_recursively(hbox)

        self['editor_frame'].pack_start(hbox, expand=False, fill=True, padding=0)
        self['pylint_check_button'] = pylint_check_button
        self['apply_button'] = apply_button
        self['open_external_button'] = open_external_button
        self['cancel_button'] = cancel_button

        # TODO find the properties where the the next three values can be read from
        # value is an assumption because its respective property is not found till now
        self.line_numbers_width = 35
        # this value is from the main window glade file and respective right_bar_container width request
        self.tab_width = 53
        # value is an assumption because its respective property is not found till now
        self.source_view_character_size = 8
        # observe key press events to adapt pane position
        # Note: -> changed is not used because it is creating glib segfaults
        if self.spacer_frame is not None:
            self.textview.connect("key-press-event", self.on_text_view_event) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:58,代码来源:source_editor.py

示例9: _init_view

# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import View [as 别名]
def _init_view(self):
		self.buffer.object_attrib.connect('changed', self.on_attrib_changed)

		self.view = GtkSource.View()
		self.view.set_buffer(self.buffer)
		self.view.modify_font(Pango.FontDescription('monospace'))
		self.view.set_auto_indent(True)
		self.view.set_smart_home_end(True)
		self.view.set_highlight_current_line(True)
		self.view.set_right_margin_position(80)
		self.view.set_show_right_margin(True)
		self.view.set_tab_width(4)
		self.view.set_show_line_numbers(self.buffer.object_attrib['linenumbers'])
		self.view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)

		self.WRAP_MODE = {
			WRAP_NONE: Gtk.WrapMode.NONE,
			WRAP_WORD_CHAR: Gtk.WrapMode.WORD_CHAR,
			WRAP_CHAR: Gtk.WrapMode.CHAR,
			WRAP_WORD: Gtk.WrapMode.WORD,
		}

		# simple toolbar
		#~ bar = Gtk.HBox() # FIXME: use Gtk.Toolbar stuff
		#~ lang_selector = Gtk.ComboBoxText()
		#~ lang_selector.append_text('(None)')
		#~ for l in lang_names: lang_selector.append_text(l)
		#~ try:
			#~ lang_selector.set_active(lang_ids.index(self._attrib['lang'])+1)
			#~ self.set_language(self._attrib['lang'] or None, False)
		#~ except (ValueError, KeyError):
			#~ lang_selector.set_active(0)
			#~ self.set_language(None, False)
		#~ lang_selector.connect('changed', self.on_lang_changed)
		#~ bar.pack_start(lang_selector, False, False)

		#~ line_numbers = Gtk.ToggleButton('Line numbers')
		#~ try:
			#~ line_numbers.set_active(self._attrib['linenumbers']=='true')
			#~ self.show_line_numbers(self._attrib['linenumbers'], False)
		#~ except (ValueError, KeyError):
			#~ line_numbers.set_active(True)
			#~ self.show_line_numbers(True, False)
		#~ line_numbers.connect('toggled', self.on_line_numbers_toggled)
		#~ bar.pack_start(line_numbers, False, False)
		#~ self.add_header(bar)

		# TODO: other toolbar options
		# TODO: autohide toolbar if textbuffer is not active

		win = ScrolledWindow(self.view, Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER, Gtk.ShadowType.NONE)
		self.add(win)

		self.view.connect('populate-popup', self.on_populate_popup) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:56,代码来源:sourceview.py


注:本文中的gi.repository.GtkSource.View方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。