[Linux-Biella] Problema con dialog
Raffaele Salmaso
raffaele.salmaso a gmail.com
Sab 6 Maggio 2006 08:45:52 CEST
Raffaele Salmaso ha scritto:
> va bene anche in python?
o ma anche
--8<--
#!/usr/bin/env python
import sys
import os
PGM = sys.argv[0]
VERSION = '42'
AUTHOR = 'Santa Claus'
DATE = 'Today'
MENU = [
'Choose one of the following options',
'Manage disc space',
'Remove games files from the disk',
'Search for users',
'Exit program',
'Wipe all hard disk'
]
def quote(s):
return '"' + s + '"'
def buildMenu(menu):
s = ''
for k in range(len(menu)):
s = ' '.join([s, str(k+1), quote(menu[k])])
return s
def windowMenu():
f = os.popen('dialog --backtitle "%s v%s - %s %s" --title "Menu"
--menu "Menu" 0 0 0 %s 2>&1' % (PGM, VERSION, AUTHOR, DATE,
buildMenu(MENU)))
return int(f.readline())
x = windowMenu()
print 'Your choice is: %d, which it means you choose "%s"' % (x,MENU[x-1])
-->8--
--
()_() | NN KAPISCO XK' CELLHAVETE T'ANNTO CN ME SL | +----
(o.o) | XK' SKRIVO 1 P'HO VELLOCE MA HALL'ORA DITTELO | +---+
'm m' | KE SIETE VOI K CI HAVVETE PROBBLEMI NO PENSATECI | O |
(___) | HE SENZA RANKORI CIAOOOO |
raffaele punto salmaso at gmail punto com
Maggiori informazioni sulla lista
Linux