def button_clicked(self): code = self.text().lower() if not code: for mode in get_clipboard_modes(): text = get_clipboard_text(mode) if is_valid_code(text): self.setText(text) elif is_valid_code(code): self.go.emit(code) else: self.setText("")
def update_action_button(self, text=None): text = text if text else self.text() if not text: self.action_button.setIcon(QIcon()) self.action_button.setToolTip("") for mode in get_clipboard_modes(): if is_valid_code(get_clipboard_text(mode)): self.action_button.setIcon(self.paste_icon) self.action_button.setToolTip("Paste") elif is_valid_code(text): self.action_button.setIcon(self.go_icon) self.action_button.setToolTip("Go") else: self.action_button.setIcon(self.clear_icon) self.action_button.setToolTip("Clear")
def update_action_button(self, text=None): text = (text if text else self.text()) if not text: self.action_button.setIcon(QIcon()) self.action_button.setToolTip('') for mode in get_clipboard_modes(): if is_valid(get_clipboard_text(mode)): self.action_button.setIcon(QIcon(resource('paste.png'))) self.action_button.setToolTip("Paste") elif is_valid(text): self.action_button.setIcon(QIcon(resource('arrow-right.png'))) self.action_button.setToolTip("Go") else: self.action_button.setIcon(QIcon(resource('close.png'))) self.action_button.setToolTip("Clear")
def test_clipboard_text(): set_clipboard_text('test') assert get_clipboard_text() == 'test'
def test_clipboard_text(): set_clipboard_text("test") assert get_clipboard_text() == "test"