home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / envy / instun / interfaceclasses.py < prev    next >
Encoding:
Python Source  |  2007-03-01  |  3.5 KB  |  96 lines

  1. #!/usr/bin/env python
  2. #Developed by Alberto Milone (aka tseliot)
  3.  
  4. import sys
  5. import commands
  6. import string
  7. import os, popen2, fcntl, fcntl, select
  8. from os.path import isfile
  9. import shutil
  10. import objects, classes, main, idcardlist
  11.  
  12. class Interface:
  13.     #linetxt = ['-', '', '         Welcome to Envy ' + ver, ' ', 'Developed by Alberto Milone aka tseliot', '', '-']
  14.     #def init(self):
  15.     #    self.linetxt = []
  16.     def page(self):
  17.         left_margin = 7
  18.         border = ' ' * 4
  19.         lines = []
  20.         lenlinetxt = []
  21.         for i in self.linetxt:#calculate the lenght of each element of linetxt and append them to lenlinetxt
  22.             lenlinetxt.append(len(i))
  23.         
  24.         diffs = []
  25.         diffspc = []
  26.         it = 0#iterator
  27.         it <= len(self.linetxt)#make sure it's not out of range
  28.         for line in self.linetxt:
  29.             maxlen = max(lenlinetxt)
  30.             diffstmp = (maxlen - lenlinetxt[it]) / 2
  31.             diffs.append(diffstmp)
  32.             if it == 0 or it == len(self.linetxt)-1:#treat the 1st and the last line differently
  33.                 diffspctmp = '-' * diffs[it]#put -
  34.                 #rightmargin = '-' * (maxlen - (diffs[it] + lenlinetxt[it]) )
  35.                 rightmargin = '-' * (maxlen - lenlinetxt[it] )
  36.             else:
  37.                 diffspctmp = ' ' * diffs[it]#put ' '
  38.                 #rightmargin = ' ' * (maxlen - (diffs[it] + lenlinetxt[it]) )
  39.                 rightmargin = ' ' * (maxlen - lenlinetxt[it] )
  40.             diffspc.append(diffspctmp)
  41.             genline = self.linetxt[it] + rightmargin #diffspc[it] +
  42.             lines.append(genline)
  43.             it += 1
  44.         
  45.         maxintlen = len(border)*2 + max(diffs)*2
  46.         print '\n'
  47.         print ' ' * left_margin + '+' + ('-' * len(border)) + lines[0] + ('-' * len(border)) + '+'#1st line
  48.         for line in lines[1:-1]:
  49.             print ' ' * left_margin + '|' + border + line + border + '|'# + '\n'
  50.         print ' ' * left_margin + '+' + ('-' * len(border)) + lines[len(self.linetxt)-1] + ('-' * len(border)) + '+'#last line
  51.         linetxt2 = []
  52.         for l in lines:#calculate the lenght of each element of linetxt and append them to lenlinetxt
  53.             linetxt2.append(len(l))
  54.     def process(self):
  55.         #NVIDIA INSTALLATION
  56.         if self.operation == 'nvinstall':
  57.             objects.nvinstconfirm()
  58.         #NVIDIA UNINSTALLATION
  59.         elif self.operation == 'nvuninstall':
  60.             objects.nvuninstconfirm()
  61.         #ATI INSTALLATION
  62.         elif self.operation == 'atiinstall':
  63.             objects.atiinstconfirm()
  64.         #ATI UNINSTALLATION#
  65.         elif self.operation == 'atiuninstall':
  66.             objects.atiuninstconfirm()
  67.         #MANUAL INSTALLATION
  68.         elif self.operation == 'maninstall':
  69.             objects.maninstconfirm()
  70.         #NVIDIA CLEAN
  71.         elif self.operation == 'nvidiaclean':
  72.             objects.nvcleanconfirm()
  73.         #RESTART THE XSERVER
  74.         elif self.operation == 'xorgrestart':
  75.             main.xserverstart()
  76.     def confirm(self):
  77.         while 1:
  78.             choice = raw_input('Do you really want to ' + self.operation + ' the ' + self.brand + ' ? (Type either "yes" or "no")\n').strip()
  79.             if choice.lower() == 'yes':
  80.                 self.gotoop#the operation to launch
  81.                 break
  82.             elif choice.lower() == 'no':
  83.                 objects.mainmenu()
  84.                 break    
  85.     
  86.     
  87. #class Confirmchoice:
  88.     #def init():
  89.     #    self.operation = 'none'
  90.     #    self.brand = 'none'
  91.     #    self.gotoop = 'none'#the operation to launch
  92.     
  93.  
  94.  
  95.  
  96.