我有以下用Gtk3用Python编写的代码.
from gi.repository import Gtk
class DialogTaskDescription(Gtk.Dialog):
def __init__(self):
Gtk.Dialog.__init__(self, "Create ToDo.txt Entry", 0, 0,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
self.set_default_size(150, 100)
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
self.label = Gtk.Label("Task Description:")
self.taskDescription = Gtk.Entry()
hbox.pack_start(self.label, False, True, 0)
hbox.pack_start(self.taskDescription, True, True, 0)
box = self.get_content_area()
box.add(hbox)
self.show_all()
def getTaskDescription(self):
return self.taskDescription.get_text()
class TaskDescription:
def __init__(self):
self.dialog = DialogTaskDescription()
def getTaskDescription(self):
response = self.dialog.run()
taskDescription = ''
if response == Gtk.ResponseType.OK:
taskDescription = self.dialog.getTaskDescription()
self.dialog.destroy()
return taskDescription
Run Code Online (Sandbox Code Playgroud)
现在,如果用户按下"taskDescription"输入字段上的回车键,我想触发单击"确定"按钮.知道我怎么能这样做吗?非常感谢!
编辑:
我找到了一个解决方案......不确定它是否应该这样做,但是这样可行:
我在DialogTaskDescription()的init方法中添加了以下行:
# enter …Run Code Online (Sandbox Code Playgroud) 我正在使用 Visual Studio Code 进行 PHP 开发。我可以单击一个方法并选择“转到定义”,这将指向定义该方法的接口。我缺少的是从接口定义跳转到方法实现位置的操作。
我可以在接口定义上使用“查找所有引用”,在所有函数调用中,这也会列出实现,但如果在许多不同的地方使用一个方法,则很难找到它们。有没有办法只搜索某个方法的所有实现?