[Linux-Biella] Problema con dialog

Raffaele Salmaso raffaele.salmaso a gmail.com
Ven 5 Maggio 2006 20:22:01 CEST


Federico Pistono ha scritto:
>     window_menu  "__1__" "__Choose one of the following options__"
> "__2__" "__Manage disc space__" "__3__" "__Remove games files from the
> disk__" "__4__" "__Search for users__" "__5__" "__Exit program__"
sinceramente non capisco perché metti gli undescore per poi toglierli... 
spero sia solo un esempio...

> Piuttosto che giocare sugli equivoci perche' non provi per favore un
> codice completo e mi fai vedere dove sbaglio, almeno non ci saranno
> piu' dubbi, no?
va bene anche in python?

--8<--
#!/usr/bin/env python

import sys
import os

PGM = sys.argv[0]
VERSION = '42'
AUTHOR = 'Santa Claus'
DATE = 'Today'

MENU = {
     '1' : 'Choose one of the following options',
     '2' : 'Manage disc space',
     '3' : 'Remove games files from the disk',
     '4' : 'Search for users',
     '5' : 'Exit program',
     '6' : 'Wipe all hard disk'
}

def quote(s):
     return '"' + s + '"'

def buildMenu(menu):
     s = ''
     for k in menu.keys():
         s = ' '.join([s, quote(k), 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 f.readline()

x = windowMenu()
print 'Your choice is: %s, which it means you choose "%s"' % (x,MENU[x])
-->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