def create_widgets(self): try: clipboard = self.selection_get(selection="CLIPBOARD") except TclError: clipboard = '' log.debug(" detecting clipboard : %s", clipboard) if clipboard.startswith("http://"): self.url = ZEntry(self, label="Url : ", value=clipboard, width=50, state=DISABLED) self.title = ZEntry(self, label="Title : ", value=get_title(clipboard), width=50) else: self.url = ZEntry(self, label="Url : ", width=50) self.title = ZEntry(self, label="Title : ", width=50) self.url.add_listener("<Double-Button-1>", self.on_url_dbl_click) self.url.grid(row=1, column=1) self.title.grid(row=3, column=1) self.tags = ZEntry(self, label="Tags : ", width=50) self.tags.grid(row=5, column=1) self.tags.focus() box = Frame(self) w = Button(box, text="Save", command=self.save_post, width=10, default=ACTIVE) w.pack(side=LEFT, padx=5, pady=5) w = Button(box, text="Cancel", command=self.quit, width=10) w.pack(side=LEFT, padx=5, pady=5) self.winfo_toplevel().bind("<Return>", self.save_post) box.grid(row=7, column=1) self.tags_suggest = ZSuggestion(self.tags, multi=True)
def __init__(self, parent=None): """ Constructor """ QMainWindow.__init__(self, parent) self.setupUi(self) if not config.username or not config.password: login = Login(self) login.setModal(True) login.show() self.setWindowTitle("Delicious bookmarks : %s : save a bookmark" % config.username) clipboard = unicode(QApplication.clipboard().text()) log.debug(" detecting clipboard : %s", clipboard) if clipboard.startswith("http://"): self.url.setText(clipboard) self.url.setDisabled(True) self.show_url.setEnabled(True) self.title.setText(get_title(clipboard)) self.tags.setFocus()