本文整理汇总了Python中core.Core.paste方法的典型用法代码示例。如果您正苦于以下问题:Python Core.paste方法的具体用法?Python Core.paste怎么用?Python Core.paste使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.Core
的用法示例。
在下文中一共展示了Core.paste方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UploadDialog
# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import paste [as 别名]
#.........这里部分代码省略.........
self.visibility_combo = self.builder.get_object("visibility_combo")
self.set_visibilities()
def fill_combo_box(self, combo, items, active_item):
model = combo.get_model()
i = 0
for item in items:
model.append([item])
if item.lower() == active_item.lower():
combo.set_active(i)
i = i + 1
if combo.get_active() == -1:
combo.set_active(0)
cell = gtk.CellRendererText()
combo.pack_start(cell, True)
combo.add_attribute(cell, "text", 0)
def set_name(self, doc):
name = doc.get_short_name_for_display()
self.name_entry.set_text(name)
def set_langs(self, doc):
src_lang = doc.get_language()
lang = "None"
if src_lang is not None:
lang = src_lang.get_name()
langs = self.core.get_langs()
self.fill_combo_box(self.langs_combo, langs, lang)
def set_dates(self):
dates = self.core.get_dates()
self.fill_combo_box(self.dates_combo, dates, "")
def set_visibilities(self):
visibilities = self.core.get_visibilities()
self.fill_combo_box(self.visibility_combo, visibilities, "")
def on_cancel_button_clicked(self, widget, data=None):
self.dialog.destroy()
def on_upload_button_clicked(self, widget, data=None):
sel_radio = self.builder.get_object("sel_radio")
text = ""
if sel_radio.get_active():
sel = self.doc.get_selection_bounds()
if sel != ():
(start, end) = sel
if start.ends_line():
start.forward_line()
elif not start.starts_line():
start.set_line_offset(0)
if end.starts_line():
end.backward_char()
elif not end.ends_line():
end.forward_to_line_end()
text = start.get_text(end)
else:
# Get paste text
start = self.doc.get_start_iter()
end = self.doc.get_end_iter()
text = start.get_text(end)
args = {}
args["name"] = self.name_entry.get_text()
lang_index = self.langs_combo.get_active()
lang_model = self.langs_combo.get_model()
args["lang"] = lang_model[lang_index][0]
date_index = self.dates_combo.get_active()
date_model = self.dates_combo.get_model()
args["date"] = date_model[date_index][0]
visibility_index = self.visibility_combo.get_active()
visibility_model = self.visibility_combo.get_model()
args["visibility"] = visibility_model[visibility_index][0]
# Get usr & pwd
if self.account.exists():
usr, pwd = self.account.get_details()
args["usr"] = usr
args["pwd"] = pwd
self.dialog.destroy()
try:
url = self.core.paste(text, **args)
opts={}
opts["buttons"] = gtk.BUTTONS_OK
opts["message_format"] = "Pastebin URI"
dialog = gtk.MessageDialog(**opts)
dialog.connect("response", lambda d, r: d.destroy())
dialog.set_title("Pastebin Plugin")
dialog.format_secondary_text(url)
dialog.show()
except CoreError as e:
ed = ExceptionDialog(e)
dialog = ed.get_dialog()
dialog.show()
def on_name_entry_icon_press(self, entry, icon_pos, data=None):
entry.set_text("")