本文整理汇总了Python中history.History.disctinct_contacts方法的典型用法代码示例。如果您正苦于以下问题:Python History.disctinct_contacts方法的具体用法?Python History.disctinct_contacts怎么用?Python History.disctinct_contacts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类history.History
的用法示例。
在下文中一共展示了History.disctinct_contacts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import disctinct_contacts [as 别名]
#.........这里部分代码省略.........
chars = len(text)
colour = "darkgreen"
if chars > 625:
self.message.get_buffer().set_text(text[:625])
self.alert(self.message, "Překročena maximální délka zprávy!")
text = self.message.get_buffer().get_text(self.message.get_buffer().get_start_iter(), self.message.get_buffer().get_end_iter())
chars = len(text)
colour = "red"
label = "Napsáno %d/125" % (chars % 125)
if chars > 125:
label += "Počet zpráv %d/5" % (((chars - 1) / 125) + 1)
preformat = '<span foreground="%s">' % colour
postformat= '</span>'
label = preformat + label + postformat
self.charcounter.set_markup(label)
def on_number_changed(self, model):
cislo = True
try:
text = int(self.number.get_text())
except ValueError:
cislo = False
self.store.clear()
self.update_model(self.store, cislo)
def update_model(self, model, number):
#GET FROM CONTACTS
try:
for i in self.contacts.list_all():
if number:
model.append(None, [i[0], i[1]])
else:
model.append(None, [i[1], i[0]])
except TypeError:
print "No contacts stored"
#GET FROM HISTORY
try:
for i in self.history.disctinct_contacts():
model.append(None, [i[0], ""])
except TypeError:
print "History doesnt contain \"non-contact\" numbers"
return model
def info(self, msg):
dialog = gtk.MessageDialog(None, 0,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
msg)
choice = dialog.run()
if choice != None:
dialog.hide()
def alert(self, what, msg):
#call alert from "what" with message "msg"
dialog = gtk.MessageDialog(None, 0,
gtk.MESSAGE_WARNING,
gtk.BUTTONS_OK,
msg)
choice = dialog.run()
if choice != None:
dialog.hide()
if what:
what.grab_focus()
def on_about_activate(self, widget):
self.about_dialog.run()
self.about_dialog.hide()
def history_browsing(self, widget):
self.history_window = History_UI(parent=self)
self.history_window.builder.get_object("history_dialog").show()
if self.history_window.result:
self.number.set_text(str(self.history_window.result[0]))
self.message.get_buffer().set_text(self.history_window.result[1])
def contact_browsing(self, widget):
self.contact_window = Contacts_UI(parent=self)
def ok_clicked(self, widget):
if isInteger(self.number.get_text()):
cislo = int(self.number.get_text())
if (len(self.number.get_text()) != 9):
self.alert(self.nubmer, "Číslo příjemce není 9 místné číslo")
return 1
else:
cislo = self.contacts.get_num(self.number.get_text())
if cislo == None:
self.alert(self.number, "Uvedený kontakt nebyl nalezen")
return 1
text = self.message.get_buffer().get_text(self.message.get_buffer().get_start_iter(), self.message.get_buffer().get_end_iter())
if (text == ""):
self.alert(self.message, "Nelze odeslat prázdnou zprávu!")
return 1
while text <> "":
if not(self.send(cislo, text[:125])):
self.alert(None, "Chyba při odesílání! Změna enginu poskytovatele?")
text = text[125:]
else:
# ukládání do historie
if (self.check_box.get_active()):
self.history.add(cislo, text[:125])
text = text[125:]
self.message.get_buffer().set_text("")
self.number.set_text("")
def on_progressok_clicked(self,widget):
self.progress_dialog.hide()