我不知道这是你在找什么,但是如果你在你的模块中创建了另一个窗口,并且当你释放拖拽时让你的代码显示它呢?你可以获取光标的当前位置,并在那里绘制窗口。
This should help you get the mouse position on the root window.
所以,你的代码可能看起来有点像这样(这是未经测试的代码!)我只显示了什么走了进去__ __初始化的相关部分。
def __init__(self):
...
#Some of your code here.
...
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
#Note that I am creating a popup window separately.
popwin = gtk.Window(gtk.WINDOW_POPUP)
#I am setting "decorated" to False, so it will have no titlebar or window controls.
#Be sure to compensate for this by having another means of closing it.
popwin.set_decorated(False)
def ShowPopup():
#You may need to put additional arguments in above if this is to be an event.
#For sake of example, I'm leaving this open ended.
#Get the cursor position.
rootwin = widget.get_screen().get_root_window()
curx, cury, mods = rootwin.get_pointer()
#Set the popup window position.
popwin.move(curx, cury)
popwin.show()
def HidePopup():
#This is just an example for how to hide the popup when you're done with it.
popwin.hide()
...
#More of your code here.
...
#Of course, here is the code showing your program's main window automatically.
win.show()
一个非常简单的方法,但它应该给出你想要的外观。
你可以用pygtk处理onclick/release处理程序吗?你能在屏幕上画一个盒子吗?如果是这样,你还需要什么? –
问题最难的部分是在根窗口上绘制一个框 - 而不是在子窗口/小部件上。我没有使用pygtk在根窗口上绘制任何东西。 – jwegner