You are not logged in.
Pages: 1
Zenity is a great app for hacking GUIs into bash scripts. What I really miss in it is the ability to create menus. I know you can create a list dialog with zenity, but what I'm talking about is a menu in the sense of a context menu (the one you get at right click).
Does anyone know of such a scriptable program that can be used in bash scripts to create such menus?
If not; any ideas on how to accomplish this? (I would like to write it in PyGTK; maybe C in case python has no chance to work.)
The first problem I see is that this menu will essentially be windowless. That is, you don't have to see any window, just the menu.
Second issue is that the menu should appear where the mouse is.
Any ideas?
Last edited by spupy (2009-08-20 00:39:58)
There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.
Offline
I have NO idea about GTK, but here is a trivial PyQt4 program that displays a context menu at the mouse position (and no other windows).
#!/usr/bin/python
import sys, os
from PyQt4 import QtGui as Gui
from PyQt4 import QtCore
def main():
app = Gui.QApplication(sys.argv)
menu = Gui.QMenu()
exit_act = menu.addAction("Exit")
menu.connect(
exit_act, QtCore.SIGNAL('triggered()'),
app, QtCore.SLOT('quit()')
)
menu.popup(Gui.QCursor.pos())
app.exec_()
if __name__ == "__main__":
main()
Offline
I have NO idea about GTK, but here is a trivial PyQt4 program that displays a context menu at the mouse position (and no other windows).
--snip--
Thank you very much! I'm not using your code (I haven't installed PyQt), but it "told" me how to do it with PyGTK. After reading the reference manual, I noticed that the gtk menu also has a popup function, albeit with very different parameters, it does the same thing.
This is how it looks in pygtk:
#!/usr/bin/python
import gtk
def main():
filemenu = gtk.Menu()
open = gtk.MenuItem("Open")
open.connect("activate", gtk.main_quit)
filemenu.append(open)
exit = gtk.MenuItem("Exit")
exit.connect("activate", gtk.main_quit)
filemenu.append(exit)
filemenu.show_all()
filemenu.popup(None, None, None, 0, 0)
gtk.main()
if __name__ == "__main__":
main()
Moral of the story: RTFM. Thank you again!
There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.
Offline
Pages: 1