home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / hplip / ui / alignform.py < prev    next >
Encoding:
Python Source  |  2006-08-30  |  4.7 KB  |  119 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2001-2006 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. from base.g import *
  23. import os.path
  24. from qt import *
  25. #from alignform_base import AlignForm_base
  26.  
  27. class AlignForm(QDialog):
  28.     def __init__(self, parent, line_id, orientation, colors, line_count, 
  29.                  choice_count, name = None, modal = 0, fl = 0):
  30.         QDialog.__init__(self, parent, name, modal, fl)
  31.  
  32.         # line_id: 'A', 'B', etc.
  33.         # orientation: 'v' or 'h'
  34.         # colors: 'k' or 'c' or 'kc'
  35.         # line_count: 2 or 3
  36.         # choice_count: 5, 7, 9, 11, etc. (odd)
  37.         mid_point = (choice_count+1)/2
  38.         
  39.         if not name:
  40.             self.setProperty("name", QVariant("AlignForm"))
  41.  
  42.         AlignFormLayout = QGridLayout(self,1,1,11,6,"AlignFormLayout")
  43.  
  44.         self.helpButton = QPushButton(self,"helpButton")
  45.  
  46.         AlignFormLayout.addWidget(self.helpButton,1,0)
  47.  
  48.         self.CancelButton = QPushButton(self,"CancelButton")
  49.  
  50.         AlignFormLayout.addWidget(self.CancelButton,1,2)
  51.  
  52.         self.ContinueButton = QPushButton(self,"ContinueButton")
  53.  
  54.         AlignFormLayout.addWidget(self.ContinueButton,1,3)
  55.         spacer1 = QSpacerItem(270,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
  56.         AlignFormLayout.addItem(spacer1,1,1)
  57.  
  58.         self.buttonGroup = QButtonGroup(self,"buttonGroup")
  59.         self.buttonGroup.setColumnLayout(0,Qt.Vertical)
  60.         self.buttonGroup.layout().setSpacing(6)
  61.         self.buttonGroup.layout().setMargin(11)
  62.         
  63.         buttonGroupLayout = QGridLayout(self.buttonGroup.layout())
  64.         buttonGroupLayout.setAlignment(Qt.AlignTop)
  65.  
  66.         ChoiceLayout = QHBoxLayout(None,0,6,"ChoiceLayout")
  67.  
  68.         for x in range(1, choice_count+1):
  69.             exec 'self.radioButton%d = QRadioButton( self.buttonGroup, "radioButton%d" )' % (x, x) 
  70.             exec 'self.radioButton%d.setText( "%s%d" )' % (x, line_id, x) 
  71.             if x == mid_point:
  72.                 exec 'self.radioButton%d.setChecked( 1 )' % x
  73.             exec 'ChoiceLayout.addWidget( self.radioButton%d )' % x
  74.  
  75.         buttonGroupLayout.addMultiCellLayout(ChoiceLayout, 1, 1, 0, 1)
  76.  
  77.         self.Icon = QLabel(self.buttonGroup,"Icon")
  78.         self.Icon.setProperty("sizePolicy",QVariant(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.Icon.sizePolicy().hasHeightForWidth())))
  79.         self.Icon.setProperty("scaledContents",QVariant(QVariant(1,0)))
  80.  
  81.         buttonGroupLayout.addWidget(self.Icon,0,0)
  82.  
  83.         self.textLabel2_2 = QLabel(self.buttonGroup,"textLabel2_2")
  84.         self.textLabel2_2.setProperty("alignment",QVariant(QLabel.WordBreak | QLabel.AlignVCenter))
  85.  
  86.         buttonGroupLayout.addWidget(self.textLabel2_2,0,1)
  87.  
  88.         AlignFormLayout.addMultiCellWidget(self.buttonGroup,0,0,0,3)
  89.  
  90.         self.languageChange()
  91.  
  92.         self.resize(QSize(608,222).expandedTo(self.minimumSizeHint()))
  93.         self.clearWState(Qt.WState_Polished)
  94.  
  95.         self.connect(self.CancelButton,SIGNAL("clicked()"),self,SLOT("reject()"))
  96.         self.connect(self.ContinueButton,SIGNAL("clicked()"),self,SLOT("accept()"))
  97.         self.connect(self.buttonGroup,SIGNAL("clicked(int)"),self.buttonGroup_clicked)
  98.  
  99.         self.Icon.setPixmap(QPixmap(os.path.join(prop.image_dir, '%s-%s-%d.png' % (orientation, colors, line_count))))
  100.  
  101.         self.buttonGroup.setTitle(line_id)
  102.         
  103.         self.value = (choice_count + 1) / 2
  104.  
  105.     def buttonGroup_clicked(self,a0):
  106.         self.value = a0 + 1
  107.         log.debug(self.value)
  108.  
  109.     def languageChange(self):
  110.         self.setProperty("caption",QVariant(self.__tr("HP Device Manager - Alignment")))
  111.         self.helpButton.setProperty("text",QVariant(self.__tr("Help")))
  112.         self.CancelButton.setProperty("text",QVariant(self.__tr("Cancel")))
  113.         self.ContinueButton.setProperty("text",QVariant(self.__tr("Next >")))
  114.         self.buttonGroup.setProperty("title",QVariant(self.__tr("")))
  115.         self.textLabel2_2.setProperty("text",QVariant(self.__tr("Choose the set of lines where the line segments are <b>best</b> aligned.")))
  116.  
  117.     def __tr(self,s,c = None):
  118.         return qApp.translate("AlignForm",s,c)
  119.