-ordi- 6 Junior Poster in Training

Hey, I have a problem, if checkboxes is activated, it could be download packages ( Ubuntu ), would be necessary to verify to checkboxes and if it's true, then these packages, which should installed my system ( Ubuntu ).

#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright (C) 2010 

from PyQt4 import QtCore, QtGui

class Dialog(QtGui.QDialog):
    def __init__(self):
        super(Dialog, self).__init__()
        tabWidget = QtGui.QTabWidget()
        ''' Window minimum size '''
        tabWidget.setMinimumSize(550, 350) 
        ''' Adding names for tab's and called them '''
        tabWidget.addTab(InternetTab(), "Internet")
        tabWidget.addTab(MultimediaTab(), "Multimeedia")
        tabWidget.addTab(GraphicsTab(), "Graafika")
        tabWidget.addTab(OfficeTab(), "Kontoritoo")
        ''' Button box '''
        buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
        ''' Set up information => tooltips '''
        buttonBox.setToolTip("<font color=blue size=3><b>"\
                                            + "Muudatuste salvestamiseks vajuta OK, katkestamiseks Cancel"\
                                            + "</b></font>")
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        ''' Main layout '''
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(tabWidget)
        mainLayout.addWidget(buttonBox)
        self.setLayout(mainLayout)
        ''' Add window title & tooltip '''
        self.setWindowTitle("Programmide paigaldaja")
        self.setToolTip("Tere tulemast kasutama Estobuntu pakettide paigaldajat!")
        
class MultimediaTab(QtGui.QWidget):
    def __init__(self):
        super(MultimediaTab, self).__init__()
        multimediaGroup = QtGui.QGroupBox("Multimeedia programmid")
        ''' By default => CheckBox is activated '''
        amarok = QtGui.QCheckBox("Amarok")
        amarok.setToolTip("Amarok on Estobuntu meediaplayer, millega saab kuulata muusikat ja raadiot.")
        amarok.setChecked(True)
        k3b = QtGui.QCheckBox("K3b")
        k3b.setToolTip("K3b'ga saab kirjutada plaate.")
        k3b.setChecked(True)
        vlc = QtGui.QCheckBox("VLC")
        vlc.setChecked(True)
        dragon = QtGui.QCheckBox("Dragoni")
        dragon.setChecked(True)
        textGroup = QtGui.QGroupBox("Eemalda programmi nime eest linnuke, kui sa ei soovi seda paigaldada.")
        multimediaLayout = QtGui.QVBoxLayout()
        multimediaLayout.addWidget(amarok)
        multimediaLayout.addWidget(k3b)
        multimediaLayout.addWidget(vlc)
        multimediaLayout.addWidget(dragon)
        multimediaGroup.setLayout(multimediaLayout)
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(multimediaGroup)
        mainLayout.addWidget(textGroup)
        self.setLayout(mainLayout)

class InternetTab(QtGui.QWidget):
    def __init__(self):
        super(InternetTab, self).__init__()
        internetGroup = QtGui.QGroupBox("Interneti programmid")
        textGroup = QtGui.QGroupBox("Eemalda programmi nime eest linnuke, kui sa ei soovi seda paigaldada.")
        firefox = QtGui.QCheckBox("Firefox")
        firefox.setChecked(True)
        konqueror = QtGui.QCheckBox("Konqueror")
        konqueror.setChecked(True)
        opera = QtGui.QCheckBox("Opera")
        opera.setChecked(True)
        google = QtGui.QCheckBox("Google Chrome")
        google.setChecked(True)
        kmess = QtGui.QCheckBox("KMess")
        kmess.setChecked(True)
        kopete = QtGui.QCheckBox("Kopete")
        kopete.setChecked(True)
        skype = QtGui.QCheckBox("Skype")
        skype.setChecked(True)
        kTorrent = QtGui.QCheckBox("KTorrent")
        kTorrent.setChecked(True) 
        java = QtGui.QCheckBox("Java")
        java.setChecked(True)
        kmail = QtGui.QCheckBox("KMail")
        kmail.setChecked(True)
        internetLayout = QtGui.QVBoxLayout()
        textLayout = QtGui.QVBoxLayout()
        internetLayout.addWidget(firefox)
        internetLayout.addWidget(opera)
        internetLayout.addWidget(konqueror)
        internetLayout.addWidget(google)
        internetLayout.addWidget(kmess)
        internetLayout.addWidget(kopete)
        internetLayout.addWidget(skype)
        internetLayout.addWidget(kTorrent)
        internetLayout.addWidget(kmail)
        internetLayout.addWidget(java)
        internetGroup.setLayout(internetLayout)
        textGroup.setLayout(textLayout)
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(internetGroup)
        mainLayout.addWidget(textGroup)
        self.setLayout(mainLayout)
        
class GraphicsTab(QtGui.QWidget):
    def __init__(self):
        super(GraphicsTab, self).__init__()
        graphicsGroup = QtGui.QGroupBox("Graafika programmid")
        textGroup = QtGui.QGroupBox("Eemalda programmi nime eest linnuke, kui sa ei soovi seda paigaldada.")
        gimp = QtGui.QCheckBox("Gimp")
        gimp.setChecked(True)
        digikam = QtGui.QCheckBox("digiKam")
        digikam.setChecked(True)
        okular = QtGui.QCheckBox("Okular")
        okular.setChecked(True)
        gwenview = QtGui.QCheckBox("Gwenview")
        gwenview.setChecked(True)
        kamoso = QtGui.QCheckBox("Kamoso")
        kamoso.setChecked(True)
        ksnapshot = QtGui.QCheckBox("KSnapshot")
        ksnapshot.setChecked(True) 
        graphicsLayout = QtGui.QVBoxLayout()
        textLayout = QtGui.QVBoxLayout()
        graphicsLayout.addWidget(gimp)
        graphicsLayout.addWidget(digikam)
        graphicsLayout.addWidget(okular)
        graphicsLayout.addWidget(gwenview)
        graphicsLayout.addWidget(kamoso)
        graphicsLayout.addWidget(ksnapshot)
        graphicsGroup.setLayout(graphicsLayout)
        textGroup.setLayout(textLayout)
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(graphicsGroup)
        mainLayout.addWidget(textGroup)
        self.setLayout(mainLayout)
        
class OfficeTab(QtGui.QWidget):
    def __init__(self):
        super(OfficeTab, self).__init__()
        officeGroup = QtGui.QGroupBox("Kontoritoo programmid")
        textGroup = QtGui.QGroupBox("Eemalda programmi nime eest linnuke, kui sa ei soovi seda paigaldada.")
        openoffice = QtGui.QCheckBox("OpenOffice.org")
        openoffice.setChecked(True)
        digikam = QtGui.QCheckBox("digiKam")
        digikam.setChecked(True)
        okular = QtGui.QCheckBox("Okular")
        okular.setChecked(True)
        gwenview = QtGui.QCheckBox("Gwenview")
        gwenview.setChecked(True)
        kamoso = QtGui.QCheckBox("Kamoso")
        kamoso.setChecked(True)
        ksnapshot = QtGui.QCheckBox("KSnapshot")
        ksnapshot.setChecked(True) 
        officeLayout = QtGui.QVBoxLayout()
        textLayout = QtGui.QVBoxLayout()
        officeLayout.addWidget(openoffice)
        officeLayout.addWidget(digikam)
        officeLayout.addWidget(okular)
        officeLayout.addWidget(gwenview)
        officeLayout.addWidget(kamoso)
        officeLayout.addWidget(ksnapshot)
        officeGroup.setLayout(officeLayout)
        textGroup.setLayout(textLayout)
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(officeGroup)
        mainLayout.addWidget(textGroup)
        self.setLayout(mainLayout)
        
class DPKGManager(object):
    '''System independent interface to the package manager.'''
    def __init__(self, sys_info):
        self.sys_info = sys_info # System info
        self.src_dir = None  # Repository sources directory
        self.src_file = None # Name of the repository source file 
        self.repo = None     # Repository
        
    def pkg_install(self, name, fatal = True):
        self.check_can_pkg_install()
        
    def check_can_pkg_install(self):
        pass

    def repo_install(self):
        ''' Adds repository to the list of package manager repository sources 
        and open file to writing '''
        if os.path.isdir(self.src_dir):
            f = open(self.src_file, "w")
            try:
                f.write("# File was automatically generated by %s\n")
                f.write("# Repository for the %s\n")
                f.write("%s\n" % self.repo)
            finally:
                f.close()
        else:	# If file not found 
            print "There is no %s on this system!" % self.src_dir
            print "You will have to set up %s repository yourself (%s)"\
                % (self.repo)

class AptDpkgManager(DPKGManager):
    ''' Apt package manager '''
    def __init__(self, sys_info):
        DPKGManager.__init__(self, sys_info)
        self.src_dir = "/etc/apt/sources.list.d" 
        self.src_file = os.path.join(self.src_dir, "%s.list")

    def pkg_install(self, name, fatal = True):
        DPKGManager.pkg_install(self, name)
        ''' Updating and installing packages '''
        self._exec_cmd("apt-get update -qq", fatal)
        self._exec_cmd("apt-get install %s --force-yes -y" % name, fatal)

    def repo_install(self):
        DPKGManager.repo_install(self)
        
    def exec_cmd(command, pwd_ent = None):
        ''' Executes a command and returns the result '''
        if pwd_ent:
            MSGR.log("Executing as user %s: %s" % (pwd_ent.pw_name, command))
        else:
            MSGR.log("Executing: %s" % (command,))

if __name__ == '__main__':

    import sys
    
    app = QtGui.QApplication(sys.argv)
    basic = Dialog()
    sys.exit(basic.exec_())