本文整理汇总了Python中core.Core.get_dates方法的典型用法代码示例。如果您正苦于以下问题:Python Core.get_dates方法的具体用法?Python Core.get_dates怎么用?Python Core.get_dates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.Core
的用法示例。
在下文中一共展示了Core.get_dates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UploadDialog
# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import get_dates [as 别名]
class UploadDialog():
def __init__(self, doc):
self.doc = doc
self.core = Core()
self.account = Account()
def create_dialog(self):
self.builder = gtk.Builder()
f = os.path.join(os.path.dirname(__file__), "upload.glade")
self.builder.add_from_file(f)
self.builder.connect_signals(self)
self.dialog = self.builder.get_object("upload_dialog")
self.init_widgets()
self.dialog.show()
def init_widgets(self):
self.name_entry = self.builder.get_object("name_entry")
self.set_name(self.doc)
self.langs_combo = self.builder.get_object("langs_combo")
self.set_langs(self.doc)
self.dates_combo = self.builder.get_object("dates_combo")
self.set_dates()
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
#.........这里部分代码省略.........