本文整理汇总了Python中gtk.TextView方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.TextView方法的具体用法?Python gtk.TextView怎么用?Python gtk.TextView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.TextView方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def __init__(self):
gtk.TextView.__init__(self)
self.modify_font(pango.FontDescription('Mono'))
self.set_cursor_visible(True)
self.text_buffer = self.get_buffer()
self.mark = self.text_buffer.create_mark('scroll_mark',
self.text_buffer.get_end_iter(),
False)
for code in ansi_colors:
self.text_buffer.create_tag(code,
foreground=ansi_colors[code],
weight=700)
self.text_buffer.create_tag('0')
self.text_buffer.create_tag('notouch', editable=False)
self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
self.line_start = \
self.text_buffer.create_mark('line_start',
self.text_buffer.get_end_iter(), True
)
self.connect('key-press-event', self._onKeypress)
self.last_cursor_pos = 0
示例2: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def __init__(self):
'''
Initialize console view.
'''
gtk.TextView.__init__(self)
self.modify_font(pango.FontDescription('Mono'))
self.set_cursor_visible(True)
self.text_buffer = self.get_buffer()
self.mark = self.text_buffer.create_mark('scroll_mark',
self.text_buffer.get_end_iter(),
False)
for code in self.ANSI_COLORS:
self.text_buffer.create_tag(code,
foreground=self.ANSI_COLORS[code],
weight=700)
self.text_buffer.create_tag('0')
self.text_buffer.create_tag('notouch', editable=False)
self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
self.line_start = \
self.text_buffer.create_mark('line_start',
self.text_buffer.get_end_iter(), True)
self.connect('key-press-event', self.onKeyPress)
示例3: display_text
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def display_text(self, title, text, parent=None, modal=False):
dialog = InfoDialog(title, None, parent, modal)
text_view = gtk.TextView()
text_view.get_buffer().set_text(text)
text_view.set_editable(False)
text_view.set_cursor_visible(False)
text_view.show()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.show()
sw.add(text_view)
detail_view = gtk.Frame()
detail_view.set_shadow_type(gtk.SHADOW_IN)
detail_view.add(sw)
detail_view.set_border_width(6)
dialog.vbox.add(detail_view)
detail_view.show()
text_view.set_size_request(485, 300)
dialog.run_async()
return
示例4: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def __init__(self):
"""
Initialize console view.
"""
gtk.TextView.__init__(self)
self.modify_font(pango.FontDescription('Mono'))
self.set_cursor_visible(True)
self.text_buffer = self.get_buffer()
self.mark = self.text_buffer.create_mark('scroll_mark',
self.text_buffer.get_end_iter(),
False)
for code in self.ANSI_COLORS:
self.text_buffer.create_tag(code,
foreground=self.ANSI_COLORS[code],
weight=700)
self.text_buffer.create_tag('0')
self.text_buffer.create_tag('notouch', editable=False)
self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
self.line_start = \
self.text_buffer.create_mark('line_start',
self.text_buffer.get_end_iter(), True)
self.connect('key-press-event', self.onKeyPress)
示例5: _get_details_expander
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def _get_details_expander(details_text, details_label):
expander = gtk.Expander()
expander.set_use_markup(True)
expander.set_label("<b>" + details_label + "</b>")
scrolled_window = gtk.ScrolledWindow()
scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scrolled_window.set_size_request(400, 200)
scrolled_window.set_shadow_type(gtk.SHADOW_IN)
exception_text_view = gtk.TextView()
exception_text_view.set_editable(False)
exception_text_view.set_wrap_mode(gtk.WRAP_WORD)
exception_text_view.set_cursor_visible(False)
exception_text_view.set_pixels_above_lines(1)
exception_text_view.set_pixels_below_lines(1)
exception_text_view.set_pixels_inside_wrap(0)
exception_text_view.set_left_margin(5)
exception_text_view.set_right_margin(5)
exception_text_view.get_buffer().set_text(details_text)
scrolled_window.add(exception_text_view)
expander.add(scrolled_window)
return expander
示例6: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def __init__(self):
super(CodePanel, self).__init__()
label = gtk.Label("Enter R code to evaluate")
label.show()
self.pack_start(label, False, True, 0)
s_window = gtk.ScrolledWindow()
s_window.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
s_window.show()
self._rpad = gtk.TextView(buffer=None)
self._rpad.set_editable(True)
self._rpad.show()
s_window.add(self._rpad)
self.add(s_window)
evalButton = gtk.Button("Evaluate highlighted code")
evalButton.connect("clicked", self.evaluateAction, "evaluate")
evalButton.show()
self.pack_start(evalButton, False, False, 0)
self._evalButton = evalButton
示例7: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def __init__(self, tagtable=None):
VView.__init__(self)
self.textview = gtk.TextView()
self.textview.connect("populate_popup", self.vwGetPopup)
self.add(self.textview)
if tagtable == None:
tagtable = gtk.TextTagTable()
self.vwSetTagTable(tagtable)
style = gtk.Style()
style.base[gtk.STATE_NORMAL] = gdk.Color(0,0,0)
style.text[gtk.STATE_NORMAL] = gdk.Color(0,0,0xff)
style.base[gtk.STATE_INSENSITIVE] = gdk.Color(0,0,0)
style.text[gtk.STATE_INSENSITIVE] = gdk.Color(20,20,20)
self.textview.set_style(style)
self.tagcfg = ConfigParser()
self.curtag = None # Is a current tag selected?
#self.deftag =
self.vwInitTag(VTextTag("default"))
start,end = self.textbuf.get_bounds()
self.textbuf.create_mark("insertend", end)
示例8: createClockDisplayWidgets
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def createClockDisplayWidgets(self):
"""Create the Clock Display widgets."""
self.tableClockDisplays = gtk.Table(rows=3, columns=3, homogeneous=False)
self.tableClockDisplays.set_row_spacings(5)
self.tableClockDisplays.set_col_spacings(5)
createLabel(self.tableClockDisplays, text="Show", gridX=0, gridY=0, xPadding=10)
self.clockCheckButton = createCheckButton(self.tableClockDisplays, active=True, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred)
createLabel(self.tableClockDisplays, text="Time 1 Format", gridX=0, gridY=1, xPadding=10)
self.clock1Format = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_FMT_1, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred)
self.clock1CheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred)
self.registerComponent("time1_format", self.clock1Format)
createLabel(self.tableClockDisplays, text="Time 1 Font", gridX=0, gridY=2, xPadding=10)
self.clock1FontButton = createFontButton(self.tableClockDisplays, font=self.defaults["font"], gridX=1, gridY=2, handler=self.changeOccurred)
self.registerComponent("time1_font", self.clock1FontButton)
createLabel(self.tableClockDisplays, text="Time 2 Format", gridX=0, gridY=3, xPadding=10)
self.clock2Format = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_FMT_2, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred)
self.clock2CheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred)
self.registerComponent("time2_format", self.clock2Format)
createLabel(self.tableClockDisplays, text="Time 2 Font", gridX=0, gridY=4, xPadding=10)
self.clock2FontButton = createFontButton(self.tableClockDisplays, font=self.defaults["font"], gridX=1, gridY=4, handler=self.changeOccurred)
self.registerComponent("time2_font", self.clock2FontButton)
createLabel(self.tableClockDisplays, text="Tooltip Format", gridX=0, gridY=5, xPadding=10)
self.clockTooltipFormat = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_TOOLTIP, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred)
self.clockTooltipCheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred)
self.registerComponent("clock_tooltip", self.clockTooltipFormat)
self.clockArea = gtk.ScrolledWindow()
self.clockBuf = gtk.TextBuffer()
self.clockTextView = gtk.TextView(self.clockBuf)
self.clockBuf.insert_at_cursor("%H 00-23 (24-hour) %I 01-12 (12-hour) %l 1-12 (12-hour) %M 00-59 (minutes)\n%S 00-59 (seconds) %P am/pm %b Jan-Dec %B January-December\n%a Sun-Sat %A Sunday-Saturday %d 01-31 (day) %e 1-31 (day)\n%y 2 digit year, e.g. 09 %Y 4 digit year, e.g. 2009")
self.clockTextView.set_editable(False)
self.clockArea.add_with_viewport(self.clockTextView)
self.tableClockDisplays.attach(self.clockArea, 0, 3, 6, 7, xpadding=10)
示例9: show_new_files
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def show_new_files(self, files):
"""
Given a list of new files, display message showing them to the user
Args:
files: list of files or file => linked file pairs
"""
message = """FileBot has created the following new files:\n"""
title = "New Files Created"
dialog = InfoDialog(title, message)
files = [' => '.join(f) if isinstance(f, tuple) else f for f in files]
files = pprint.pformat(files)
text_view = gtk.TextView()
text_view.get_buffer().set_text(files)
text_view.set_editable(False)
text_view.set_cursor_visible(False)
text_view.show()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.show()
sw.add(text_view)
detail_view = gtk.Frame()
detail_view.set_shadow_type(gtk.SHADOW_IN)
detail_view.add(sw)
detail_view.set_border_width(6)
dialog.vbox.add(detail_view)
text_view.set_size_request(485, 300)
detail_view.show()
dialog.run_async()
return
示例10: _init_gui
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TextView [as 别名]
def _init_gui(self):
self._label_message = gtk.Label()
self._label_message.set_alignment(0.0, 0.5)
self._label_message.set_ellipsize(pango.ELLIPSIZE_END)
self._label_button_more = gtk.Label(_("_More"))
self._label_button_more.set_use_underline(True)
self._hbox_button_more = gtk.HBox()
self._hbox_button_more.set_spacing(self._MORE_BUTTON_LABEL_AND_ARROW_SPACING)
self._hbox_button_more.pack_start(
self._label_button_more, expand=True, fill=True)
self._hbox_button_more.pack_start(
gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_IN), expand=False, fill=False)
self._button_more = gtk.Button()
self._button_more.set_relief(gtk.RELIEF_NONE)
self._button_more.add(self._hbox_button_more)
self._button_more.show_all()
self._button_more.hide()
self._button_more.set_no_show_all(True)
self._text_view_more = gtk.TextView()
self._text_view_more.set_wrap_mode(gtk.WRAP_WORD)
self._text_view_more.set_left_margin(self._TEXT_VIEW_MARGIN)
self._text_view_more.set_right_margin(self._TEXT_VIEW_MARGIN)
self._text_view_more.set_editable(False)
self._scrolled_window_more = gtk.ScrolledWindow()
self._scrolled_window_more.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
self._scrolled_window_more.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self._scrolled_window_more.add(self._text_view_more)
self._popup_more = gtk.Window(type=gtk.WINDOW_POPUP)
self._popup_more.set_resizable(False)
self._popup_more.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP)
self._popup_more.set_property("width-request", self._POPUP_WIDTH)
self._popup_more.add(self._scrolled_window_more)
self._popup_more.show_all()
self._popup_more.hide()
self.set_spacing(self._MESSAGE_AND_MORE_BUTTON_SPACING)
self.pack_start(self._label_message, expand=True, fill=True)
self.pack_start(self._button_more, expand=False, fill=False)