Advertisement
Guest User

Untitled

a guest
Dec 19th, 2012
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 32.57 KB | None | 0 0
  1. sorry still has no clue, i'll paste full code from rapid gui developement book example:
  2. ships-delegate_ans.py
  3.  
  4.    import sys
  5.    from PyQt4.QtCore import *
  6.    from PyQt4.QtGui import *
  7.    import ships_ans as ships
  8.    
  9.    MAC = "qt_mac_set_native_menubar" in dir()
  10.    
  11.    
  12.    class MainForm(QDialog):
  13.    
  14.        def __init__(self, parent=None):
  15.            super(MainForm, self).__init__(parent)
  16.    
  17.            self.model = ships.ShipTableModel(QString("ships.dat"))
  18.            tableLabel1 = QLabel("Table &1")
  19.            self.tableView1 = QTableView()
  20.            tableLabel1.setBuddy(self.tableView1)
  21.            self.tableView1.setModel(self.model)
  22.            self.tableView1.setItemDelegate(ships.ShipDelegate(self))
  23.            tableLabel2 = QLabel("Table &2")
  24.            self.tableView2 = QTableView()
  25.            tableLabel2.setBuddy(self.tableView2)
  26.            self.tableView2.setModel(self.model)
  27.            self.tableView2.setItemDelegate(ships.ShipDelegate(self))
  28.    
  29.            addShipButton = QPushButton("&Add Ship")
  30.            removeShipButton = QPushButton("&Remove Ship")
  31.            exportButton = QPushButton("E&xport...")
  32.            quitButton = QPushButton("&Quit")
  33.            if not MAC:
  34.                addShipButton.setFocusPolicy(Qt.NoFocus)
  35.                removeShipButton.setFocusPolicy(Qt.NoFocus)
  36.                exportButton.setFocusPolicy(Qt.NoFocus)
  37.                quitButton.setFocusPolicy(Qt.NoFocus)
  38.    
  39.            buttonLayout = QHBoxLayout()
  40.            buttonLayout.addWidget(addShipButton)
  41.            buttonLayout.addWidget(removeShipButton)
  42.            buttonLayout.addWidget(exportButton)
  43.            buttonLayout.addStretch()
  44.            buttonLayout.addWidget(quitButton)
  45.            splitter = QSplitter(Qt.Horizontal)
  46.            vbox = QVBoxLayout()
  47.            vbox.addWidget(tableLabel1)
  48.            vbox.addWidget(self.tableView1)
  49.            widget = QWidget()
  50.            widget.setLayout(vbox)
  51.            splitter.addWidget(widget)
  52.            vbox = QVBoxLayout()
  53.            vbox.addWidget(tableLabel2)
  54.            vbox.addWidget(self.tableView2)
  55.            widget = QWidget()
  56.            widget.setLayout(vbox)
  57.            splitter.addWidget(widget)
  58.            layout = QVBoxLayout()
  59.            layout.addWidget(splitter)
  60.            layout.addLayout(buttonLayout)
  61.            self.setLayout(layout)
  62.    
  63.            for tableView in (self.tableView1, self.tableView2):
  64.                header = tableView.horizontalHeader()
  65.                self.connect(header, SIGNAL("sectionClicked(int)"),
  66.                             self.sortTable)
  67.            self.connect(addShipButton, SIGNAL("clicked()"), self.addShip)
  68.            self.connect(removeShipButton, SIGNAL("clicked()"),
  69.                         self.removeShip)
  70.            self.connect(exportButton, SIGNAL("clicked()"), self.export)
  71.            self.connect(quitButton, SIGNAL("clicked()"), self.accept)
  72.    
  73.            self.setWindowTitle("Ships (delegate)")
  74.            QTimer.singleShot(0, self.initialLoad)
  75.    
  76.    
  77.        def initialLoad(self):
  78.            if not QFile.exists(self.model.filename):
  79.                for ship in ships.generateFakeShips():
  80.                    self.model.ships.append(ship)
  81.                    self.model.owners.add(unicode(ship.owner))
  82.                    self.model.countries.add(unicode(ship.country))
  83.                self.model.reset()
  84.                self.model.dirty = False
  85.            else:
  86.                try:
  87.                    self.model.load()
  88.                except IOError, e:
  89.                    QMessageBox.warning(self, "Ships - Error",
  90.                            "Failed to load: %s" % e)
  91.            self.model.sortByName()
  92.            self.resizeColumns()
  93.    
  94.    
  95.        def resizeColumns(self):
  96.            self.tableView1.resizeColumnsToContents()
  97.            self.tableView2.resizeColumnsToContents()
  98.    
  99.    
  100.        def reject(self):
  101.            self.accept()
  102.    
  103.    
  104.        def accept(self):
  105.            if self.model.dirty and \
  106.               QMessageBox.question(self, "Ships - Save?",
  107.                        "Save unsaved changes?",
  108.                        QMessageBox.Yes|QMessageBox.No) == QMessageBox.Yes:
  109.                try:
  110.                    self.model.save()
  111.                except IOError, e:
  112.                    QMessageBox.warning(self, "Ships - Error",
  113.                            "Failed to save: %s" % e)
  114.            QDialog.accept(self)
  115.    
  116.        
  117.        def sortTable(self, section):
  118.            if section in (ships.OWNER, ships.COUNTRY):
  119.                self.model.sortByCountryOwner()
  120.            elif section == ships.TEU:
  121.                self.model.sortByTEU()
  122.            else:
  123.                self.model.sortByName()
  124.            self.resizeColumns()
  125.    
  126.    
  127.        def addShip(self):
  128.            row = self.model.rowCount()
  129.            self.model.insertRows(row)
  130.            index = self.model.index(row, 0)
  131.            tableView = self.tableView1
  132.            if self.tableView2.hasFocus():
  133.                tableView = self.tableView2
  134.            tableView.setFocus()
  135.            tableView.setCurrentIndex(index)
  136.            tableView.edit(index)
  137.    
  138.    
  139.        def removeShip(self):
  140.            tableView = self.tableView1
  141.            if self.tableView2.hasFocus():
  142.                tableView = self.tableView2
  143.            index = tableView.currentIndex()
  144.            if not index.isValid():
  145.                return
  146.            row = index.row()
  147.            name = self.model.data(
  148.                        self.model.index(row, ships.NAME)).toString()
  149.            owner = self.model.data(
  150.                        self.model.index(row, ships.OWNER)).toString()
  151.            country = self.model.data(
  152.                        self.model.index(row, ships.COUNTRY)).toString()
  153.            if QMessageBox.question(self, "Ships - Remove",
  154.                    QString("Remove %1 of %2/%3?").arg(name).arg(owner) \
  155.                            .arg(country),
  156.                    QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
  157.                return
  158.            self.model.removeRows(row)
  159.            self.resizeColumns()
  160.    
  161.    
  162.        def export(self):
  163.            filename = unicode(QFileDialog.getSaveFileName(self,
  164.                                "Ships - Choose Export File", ".",
  165.                                "Export files (*.txt)"))
  166.            if not filename:
  167.                return
  168.            htmlTags = QRegExp(r"<[^>]+>")
  169.            htmlTags.setMinimal(True)
  170.            nonDigits = QRegExp("[., ]")
  171.            self.model.sortByCountryOwner()
  172.            fh = None
  173.            try:
  174.                fh = QFile(filename)
  175.                if not fh.open(QIODevice.WriteOnly):
  176.                    raise IOError, unicode(fh.errorString())
  177.                stream = QTextStream(fh)
  178.                stream.setCodec("UTF-8")
  179.                for row in range(self.model.rowCount()):
  180.                    name = self.model.data(
  181.                            self.model.index(row, ships.NAME)).toString()
  182.                    owner = self.model.data(
  183.                            self.model.index(row, ships.OWNER)).toString()
  184.                    country = self.model.data(
  185.                            self.model.index(row, ships.COUNTRY)).toString()
  186.                    teu = self.model.data(
  187.                            self.model.index(row, ships.TEU)).toString()
  188.                    teu = teu.replace(nonDigits, "").toInt()[0]
  189.                    description = self.model.data(
  190.                            self.model.index(row, ships.DESCRIPTION)) \
  191.                                    .toString()
  192.                    description = description.replace(htmlTags, "")
  193.                    stream << name << "|" << owner << "|" << country \
  194.                           << "|" << teu << "|" << description << "\n"
  195.            except (IOError, OSError), e:
  196.                QMessageBox.warning(self, "Ships - Error",
  197.                        "Failed to export: %s" % e)
  198.            finally:
  199.                if fh:
  200.                    fh.close()
  201.            QMessageBox.warning(self, "Ships - Export",
  202.                    "Successfully exported ship to %s" % filename)
  203.    
  204.    
  205.    app = QApplication(sys.argv)
  206.    form = MainForm()
  207.    form.show()
  208.    app.exec_()
  209.  
  210.  
  211. ships-model.py
  212.  
  213.    import platform
  214.    from PyQt4.QtCore import *
  215.    from PyQt4.QtGui import *
  216.    import richtextlineedit
  217.    
  218.    
  219.    NAME, OWNER, COUNTRY, DESCRIPTION, TEU = range(5)
  220.    
  221.    MAGIC_NUMBER = 0x570C4
  222.    FILE_VERSION = 1
  223.    
  224.    
  225.    class Ship(object):
  226.    
  227.        def __init__(self, name, owner, country, teu=0, description=""):
  228.            self.name = QString(name)
  229.            self.owner = QString(owner)
  230.            self.country = QString(country)
  231.            self.teu = teu
  232.            self.description = QString(description)
  233.    
  234.    
  235.        def __cmp__(self, other):
  236.            return QString.localeAwareCompare(self.name.toLower(),
  237.                                              other.name.toLower())
  238.    
  239.    
  240.    class ShipTableModel(QAbstractTableModel):
  241.    
  242.        def __init__(self, filename=QString()):
  243.            super(ShipTableModel, self).__init__()
  244.            self.filename = filename
  245.            self.dirty = False
  246.            self.ships = []
  247.            self.owners = set()
  248.            self.countries = set()
  249.    
  250.    
  251.        def sortByName(self):
  252.            self.ships = sorted(self.ships)
  253.            self.reset()
  254.    
  255.    
  256.        def sortByTEU(self):
  257.            ships = [(ship.teu, ship) for ship in self.ships]
  258.            ships.sort()
  259.            self.ships = [ship for teu, ship in ships]
  260.            self.reset()
  261.    
  262.    
  263.        def sortByCountryOwner(self):
  264.            def compare(a, b):
  265.                if a.country != b.country:
  266.                    return QString.localeAwareCompare(a.country, b.country)
  267.                if a.owner != b.owner:
  268.                    return QString.localeAwareCompare(a.owner, b.owner)
  269.                return QString.localeAwareCompare(a.name, b.name)
  270.            self.ships = sorted(self.ships, compare)
  271.            self.reset()
  272.    
  273.    
  274.        def flags(self, index):
  275.            if not index.isValid():
  276.                return Qt.ItemIsEnabled
  277.            return Qt.ItemFlags(QAbstractTableModel.flags(self, index)|
  278.                                Qt.ItemIsEditable)
  279.    
  280.    
  281.        def data(self, index, role=Qt.DisplayRole):
  282.            if not index.isValid() or \
  283.               not (0 <= index.row() < len(self.ships)):
  284.                return QVariant()
  285.            ship = self.ships[index.row()]
  286.            column = index.column()
  287.            if role == Qt.DisplayRole:
  288.                if column == NAME:
  289.                    return QVariant(ship.name)
  290.                elif column == OWNER:
  291.                    return QVariant(ship.owner)
  292.                elif column == COUNTRY:
  293.                    return QVariant(ship.country)
  294.                elif column == DESCRIPTION:
  295.                    return QVariant(ship.description)
  296.                elif column == TEU:
  297.                    return QVariant(QString("%L1").arg(ship.teu))
  298.            elif role == Qt.TextAlignmentRole:
  299.                if column == TEU:
  300.                    return QVariant(int(Qt.AlignRight|Qt.AlignVCenter))
  301.                return QVariant(int(Qt.AlignLeft|Qt.AlignVCenter))
  302.            elif role == Qt.TextColorRole and column == TEU:
  303.                if ship.teu < 80000:
  304.                    return QVariant(QColor(Qt.black))
  305.                elif ship.teu < 100000:
  306.                    return QVariant(QColor(Qt.darkBlue))
  307.                elif ship.teu < 120000:
  308.                    return QVariant(QColor(Qt.blue))
  309.                else:
  310.                    return QVariant(QColor(Qt.red))
  311.            elif role == Qt.BackgroundColorRole:
  312.                if ship.country in (u"Bahamas", u"Cyprus", u"Denmark",
  313.                        u"France", u"Germany", u"Greece"):
  314.                    return QVariant(QColor(250, 230, 250))
  315.                elif ship.country in (u"Hong Kong", u"Japan", u"Taiwan"):
  316.                    return QVariant(QColor(250, 250, 230))
  317.                elif ship.country in (u"Marshall Islands",):
  318.                    return QVariant(QColor(230, 250, 250))
  319.                else:
  320.                    return QVariant(QColor(210, 230, 230))
  321.            elif role == Qt.ToolTipRole:
  322.                msg = "<br>(minimum of 3 characters)"
  323.                if column == NAME:
  324.                    return QVariant(ship.name + msg)
  325.                elif column == OWNER:
  326.                    return QVariant(ship.owner + msg)
  327.                elif column == COUNTRY:
  328.                    return QVariant(ship.country + msg)
  329.                elif column == DESCRIPTION:
  330.                    return QVariant(ship.description)
  331.                elif column == TEU:
  332.                    return QVariant(QString("%L1 twenty foot equivalents") \
  333.                            .arg(ship.teu))
  334.            return QVariant()
  335.    
  336.    
  337.        def headerData(self, section, orientation, role=Qt.DisplayRole):
  338.            if role == Qt.TextAlignmentRole:
  339.                if orientation == Qt.Horizontal:
  340.                    return QVariant(int(Qt.AlignLeft|Qt.AlignVCenter))
  341.                return QVariant(int(Qt.AlignRight|Qt.AlignVCenter))
  342.            if role != Qt.DisplayRole:
  343.                return QVariant()
  344.            if orientation == Qt.Horizontal:
  345.                if section == NAME:
  346.                    return QVariant("Name")
  347.                elif section == OWNER:
  348.                    return QVariant("Owner")
  349.                elif section == COUNTRY:
  350.                    return QVariant("Country")
  351.                elif section == DESCRIPTION:
  352.                    return QVariant("Description")
  353.                elif section == TEU:
  354.                    return QVariant("TEU")
  355.            return QVariant(int(section + 1))
  356.    
  357.    
  358.        def rowCount(self, index=QModelIndex()):
  359.            return len(self.ships)
  360.    
  361.    
  362.        def columnCount(self, index=QModelIndex()):
  363.            return 5
  364.    
  365.    
  366.        def setData(self, index, value, role=Qt.EditRole):
  367.            if index.isValid() and 0 <= index.row() < len(self.ships):
  368.                ship = self.ships[index.row()]
  369.                column = index.column()
  370.                if column == NAME:
  371.                    ship.name = value.toString()
  372.                elif column == OWNER:
  373.                    ship.owner = value.toString()
  374.                elif column == COUNTRY:
  375.                    ship.country = value.toString()
  376.                elif column == DESCRIPTION:
  377.                    ship.description = value.toString()
  378.                elif column == TEU:
  379.                    value, ok = value.toInt()
  380.                    if ok:
  381.                        ship.teu = value
  382.                self.dirty = True
  383.                self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
  384.                          index, index)
  385.                return True
  386.            return False
  387.    
  388.    
  389.        def insertRows(self, position, rows=1, index=QModelIndex()):
  390.            self.beginInsertRows(QModelIndex(), position,
  391.                                 position + rows - 1)
  392.            for row in range(rows):
  393.                self.ships.insert(position + row,
  394.                                  Ship(" Unknown", " Unknown", " Unknown"))
  395.            self.endInsertRows()
  396.            self.dirty = True
  397.            return True
  398.    
  399.    
  400.        def removeRows(self, position, rows=1, index=QModelIndex()):
  401.            self.beginRemoveRows(QModelIndex(), position,
  402.                                 position + rows - 1)
  403.            self.ships = self.ships[:position] + \
  404.                         self.ships[position + rows:]
  405.            self.endRemoveRows()
  406.            self.dirty = True
  407.            return True
  408.    
  409.    
  410.        def load(self):
  411.            exception = None
  412.            fh = None
  413.            try:
  414.                if self.filename.isEmpty():
  415.                    raise IOError, "no filename specified for loading"
  416.                fh = QFile(self.filename)
  417.                if not fh.open(QIODevice.ReadOnly):
  418.                    raise IOError, unicode(fh.errorString())
  419.                stream = QDataStream(fh)
  420.                magic = stream.readInt32()
  421.                if magic != MAGIC_NUMBER:
  422.                    raise IOError, "unrecognized file type"
  423.                fileVersion = stream.readInt16()
  424.                if fileVersion != FILE_VERSION:
  425.                    raise IOError, "unrecognized file type version"
  426.                self.ships = []
  427.                while not stream.atEnd():
  428.                    name = QString()
  429.                    owner = QString()
  430.                    country = QString()
  431.                    description = QString()
  432.                    stream >> name >> owner >> country >> description
  433.                    teu = stream.readInt32()
  434.                    self.ships.append(Ship(name, owner, country, teu,
  435.                                           description))
  436.                    self.owners.add(unicode(owner))
  437.                    self.countries.add(unicode(country))
  438.                self.dirty = False
  439.            except IOError, e:
  440.                exception = e
  441.            finally:
  442.                if fh is not None:
  443.                    fh.close()
  444.                if exception is not None:
  445.                    raise exception
  446.    
  447.    
  448.        def save(self):
  449.            exception = None
  450.            fh = None
  451.            try:
  452.                if self.filename.isEmpty():
  453.                    raise IOError, "no filename specified for saving"
  454.                fh = QFile(self.filename)
  455.                if not fh.open(QIODevice.WriteOnly):
  456.                    raise IOError, unicode(fh.errorString())
  457.                stream = QDataStream(fh)
  458.                stream.writeInt32(MAGIC_NUMBER)
  459.                stream.writeInt16(FILE_VERSION)
  460.                stream.setVersion(QDataStream.Qt_4_1)
  461.                for ship in self.ships:
  462.                    stream << ship.name << ship.owner << ship.country \
  463.                           << ship.description
  464.                    stream.writeInt32(ship.teu)
  465.                self.dirty = False
  466.            except IOError, e:
  467.                exception = e
  468.            finally:
  469.                if fh is not None:
  470.                    fh.close()
  471.                if exception is not None:
  472.                    raise exception
  473.    
  474.    
  475.    class ShipDelegate(QItemDelegate):
  476.    
  477.        def __init__(self, parent=None):
  478.            super(ShipDelegate, self).__init__(parent)
  479.    
  480.    
  481.        def paint(self, painter, option, index):
  482.            if index.column() == DESCRIPTION:
  483.                text = index.model().data(index).toString()
  484.                palette = QApplication.palette()
  485.                document = QTextDocument()
  486.                document.setDefaultFont(option.font)
  487.                if option.state & QStyle.State_Selected:
  488.                    document.setHtml(QString("<font color=%1>%2</font>") \
  489.                            .arg(palette.highlightedText().color().name())\
  490.                            .arg(text))
  491.                else:
  492.                    document.setHtml(text)
  493.                color = palette.highlight().color() \
  494.                    if option.state & QStyle.State_Selected \
  495.                    else QColor(index.model().data(index,
  496.                            Qt.BackgroundColorRole))
  497.                painter.save()
  498.                painter.fillRect(option.rect, color)
  499.                painter.translate(option.rect.x(), option.rect.y())
  500.                document.drawContents(painter)
  501.                painter.restore()
  502.            else:
  503.                QItemDelegate.paint(self, painter, option, index)
  504.    
  505.    
  506.        def sizeHint(self, option, index):
  507.            fm = option.fontMetrics
  508.            if index.column() == TEU:
  509.                return QSize(fm.width("9,999,999"), fm.height())
  510.            if index.column() == DESCRIPTION:
  511.                text = index.model().data(index).toString()
  512.                document = QTextDocument()
  513.                document.setDefaultFont(option.font)
  514.                document.setHtml(text)
  515.                return QSize(document.idealWidth() + 5, fm.height())
  516.            return QItemDelegate.sizeHint(self, option, index)
  517.    
  518.    
  519.        def createEditor(self, parent, option, index):
  520.            if index.column() == TEU:
  521.                spinbox = QSpinBox(parent)
  522.                spinbox.setRange(0, 200000)
  523.                spinbox.setSingleStep(1000)
  524.                spinbox.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
  525.                return spinbox
  526.            elif index.column() == OWNER:
  527.                combobox = QComboBox(parent)
  528.                combobox.addItems(sorted(index.model().owners))
  529.                combobox.setEditable(True)
  530.                return combobox
  531.            elif index.column() == COUNTRY:
  532.                combobox = QComboBox(parent)
  533.                combobox.addItems(sorted(index.model().countries))
  534.                combobox.setEditable(True)
  535.                return combobox
  536.            elif index.column() == NAME:
  537.                editor = QLineEdit(parent)
  538.                self.connect(editor, SIGNAL("returnPressed()"),
  539.                             self.commitAndCloseEditor)
  540.                return editor
  541.            elif index.column() == DESCRIPTION:
  542.                editor = richtextlineedit.RichTextLineEdit(parent)
  543.                self.connect(editor, SIGNAL("returnPressed()"),
  544.                             self.commitAndCloseEditor)
  545.                return editor
  546.            else:
  547.                return QItemDelegate.createEditor(self, parent, option,
  548.                                                  index)
  549.    
  550.    
  551.        def commitAndCloseEditor(self):
  552.            editor = self.sender()
  553.            if isinstance(editor, (QTextEdit, QLineEdit)):
  554.                self.emit(SIGNAL("commitData(QWidget*)"), editor)
  555.                self.emit(SIGNAL("closeEditor(QWidget*)"), editor)
  556.    
  557.    
  558.        def setEditorData(self, editor, index):
  559.            text = index.model().data(index, Qt.DisplayRole).toString()
  560.            if index.column() == TEU:
  561.                value = text.replace(QRegExp("[., ]"), "").toInt()[0]
  562.                editor.setValue(value)
  563.            elif index.column() in (OWNER, COUNTRY):
  564.                i = editor.findText(text)
  565.                if i == -1:
  566.                    i = 0
  567.                editor.setCurrentIndex(i)
  568.            elif index.column() == NAME:
  569.                editor.setText(text)
  570.            elif index.column() == DESCRIPTION:
  571.                editor.setHtml(text)
  572.            else:
  573.                QItemDelegate.setEditorData(self, editor, index)
  574.    
  575.    
  576.        def setModelData(self, editor, model, index):
  577.            if index.column() == TEU:
  578.                model.setData(index, QVariant(editor.value()))
  579.            elif index.column() in (OWNER, COUNTRY):
  580.                text = editor.currentText()
  581.                if text.length() >= 3:
  582.                    model.setData(index, QVariant(text))
  583.            elif index.column() == NAME:
  584.                text = editor.text()
  585.                if text.length() >= 3:
  586.                    model.setData(index, QVariant(text))
  587.            elif index.column() == DESCRIPTION:
  588.                model.setData(index, QVariant(editor.toSimpleHtml()))
  589.            else:
  590.                QItemDelegate.setModelData(self, editor, model, index)
  591.    
  592.    
  593.    def generateFakeShips():
  594.        for name, owner, country, teu, description in (
  595.    (u"Emma M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 151687,
  596.     u"<b>W\u00E4rtsil\u00E4-Sulzer RTA96-C</b> main engine,"
  597.     u"<font color=green>109,000 hp</font>"),
  598.    (u"MSC Pamela", u"MSC", u"Liberia", 90449,
  599.     u"Draft <font color=green>15m</font>"),
  600.    (u"Colombo Express", u"Hapag-Lloyd", u"Germany", 93750,
  601.     u"Main engine, <font color=green>93,500 hp</font>"),
  602.    (u"Houston Express", u"Norddeutsche Reederei", u"Germany", 95000,
  603.     u"Features a <u>twisted leading edge full spade rudder</u>. "
  604.     u"Sister of <i>Savannah Express</i>"),
  605.    (u"Savannah Express", u"Norddeutsche Reederei", u"Germany", 95000,
  606.     u"Sister of <i>Houston Express</i>"),
  607.    (u"MSC Susanna", u"MSC", u"Liberia", 90449, u""),
  608.    (u"Eleonora M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 151687,
  609.     u"Captain <i>Hallam</i>"),
  610.    (u"Estelle M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 151687,
  611.     u"Captain <i>Wells</i>"),
  612.    (u"Evelyn M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 151687,
  613.      u"Captain <i>Byrne</i>"),
  614.    (u"Georg M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 97933, u""),
  615.    (u"Gerd M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 97933, u""),
  616.    (u"Gjertrud M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 97933, u""),
  617.    (u"Grete M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 97933, u""),
  618.    (u"Gudrun M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 97933, u""),
  619.    (u"Gunvor M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 97933, u""),
  620.    (u"CSCL Le Havre", u"Danaos Shipping", u"Cyprus", 107200, u""),
  621.    (u"CSCL Pusan", u"Danaos Shipping", u"Cyprus", 107200,
  622.     u"Captain <i>Watts</i>"),
  623.    (u"Xin Los Angeles", u"China Shipping Container Lines (CSCL)",
  624.     u"Hong Kong", 107200, u""),
  625.    (u"Xin Shanghai", u"China Shipping Container Lines (CSCL)", u"Hong Kong",
  626.     107200, u""),
  627.    (u"Cosco Beijing", u"Costamare Shipping", u"Greece", 99833, u""),
  628.    (u"Cosco Hellas", u"Costamare Shipping", u"Greece", 99833, u""),
  629.    (u"Cosco Guangzhou", u"Costamare Shipping", u"Greece", 99833, u""),
  630.    (u"Cosco Ningbo", u"Costamare Shipping", u"Greece", 99833, u""),
  631.    (u"Cosco Yantian", u"Costamare Shipping", u"Greece", 99833, u""),
  632.    (u"CMA CGM Fidelio", u"CMA CGM", u"France", 99500, u""),
  633.    (u"CMA CGM Medea", u"CMA CGM", u"France", 95000, u""),
  634.    (u"CMA CGM Norma", u"CMA CGM", u"Bahamas", 95000, u""),
  635.    (u"CMA CGM Rigoletto", u"CMA CGM", u"France", 99500, u""),
  636.    (u"Arnold M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 93496,
  637.     u"Captain <i>Morrell</i>"),
  638.    (u"Anna M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 93496,
  639.     u"Captain <i>Lockhart</i>"),
  640.    (u"Albert M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 93496,
  641.     u"Captain <i>Tallow</i>"),
  642.    (u"Adrian M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 93496,
  643.     u"Captain <i>G. E. Ericson</i>"),
  644.    (u"Arthur M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 93496, u""),
  645.    (u"Axel M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 93496, u""),
  646.    (u"NYK Vega", u"Nippon Yusen Kaisha", u"Panama", 97825, u""),
  647.    (u"MSC Esthi", u"MSC", u"Liberia", 99500, u""),
  648.    (u"MSC Chicago", u"Offen Claus-Peter", u"Liberia", 90449, u""),
  649.    (u"MSC Bruxelles", u"Offen Claus-Peter", u"Liberia", 90449, u""),
  650.    (u"MSC Roma", u"Offen Claus-Peter", u"Liberia", 99500, u""),
  651.    (u"MSC Madeleine", u"MSC", u"Liberia", 107551, u""),
  652.    (u"MSC Ines", u"MSC", u"Liberia", 107551, u""),
  653.    (u"Hannover Bridge", u"Kawasaki Kisen Kaisha", u"Japan", 99500, u""),
  654.    (u"Charlotte M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  655.    (u"Clementine M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  656.    (u"Columbine M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  657.    (u"Cornelia M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  658.    (u"Chicago Express", u"Hapag-Lloyd", u"Germany", 93750, u""),
  659.    (u"Kyoto Express", u"Hapag-Lloyd", u"Germany", 93750, u""),
  660.    (u"Clifford M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  661.    (u"Sally M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  662.    (u"Sine M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  663.    (u"Skagen M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  664.    (u"Sofie M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  665.    (u"Sor\u00F8 M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  666.    (u"Sovereing M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  667.    (u"Susan M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  668.    (u"Svend M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  669.    (u"Svendborg M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  670.    (u"A.P. M\u00F8ller", u"M\u00E6rsk Line", u"Denmark", 91690,
  671.     u"Captain <i>Ferraby</i>"),
  672.    (u"Caroline M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  673.    (u"Carsten M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  674.    (u"Chastine M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  675.    (u"Cornelius M\u00E6rsk", u"M\u00E6rsk Line", u"Denmark", 91690, u""),
  676.    (u"CMA CGM Otello", u"CMA CGM", u"France", 91400, u""),
  677.    (u"CMA CGM Tosca", u"CMA CGM", u"France", 91400, u""),
  678.    (u"CMA CGM Nabucco", u"CMA CGM", u"France", 91400, u""),
  679.    (u"CMA CGM La Traviata", u"CMA CGM", u"France", 91400, u""),
  680.    (u"CSCL Europe", u"Danaos Shipping", u"Cyprus", 90645, u""),
  681.    (u"CSCL Africa", u"Seaspan Container Line", u"Cyprus", 90645, u""),
  682.    (u"CSCL America", u"Danaos Shipping ", u"Cyprus", 90645, u""),
  683.    (u"CSCL Asia", u"Seaspan Container Line", u"Hong Kong", 90645, u""),
  684.    (u"CSCL Oceania", u"Seaspan Container Line", u"Hong Kong", 90645,
  685.     u"Captain <i>Baker</i>"),
  686.    (u"M\u00E6rsk Seville", u"Blue Star GmbH", u"Liberia", 94724, u""),
  687.    (u"M\u00E6rsk Santana", u"Blue Star GmbH", u"Liberia", 94724, u""),
  688.    (u"M\u00E6rsk Sheerness", u"Blue Star GmbH", u"Liberia", 94724, u""),
  689.    (u"M\u00E6rsk Sarnia", u"Blue Star GmbH", u"Liberia", 94724, u""),
  690.    (u"M\u00E6rsk Sydney", u"Blue Star GmbH", u"Liberia", 94724, u""),
  691.    (u"MSC Heidi", u"MSC", u"Panama", 95000, u""),
  692.    (u"MSC Rania", u"MSC", u"Panama", 95000, u""),
  693.    (u"MSC Silvana", u"MSC", u"Panama", 95000, u""),
  694.    (u"M\u00E6rsk Stralsund", u"Blue Star GmbH", u"Liberia", 95000, u""),
  695.    (u"M\u00E6rsk Saigon", u"Blue Star GmbH", u"Liberia", 95000, u""),
  696.    (u"M\u00E6rsk Seoul", u"Blue Star Ship Managment GmbH", u"Germany",
  697.     95000, u""),
  698.    (u"M\u00E6rsk Surabaya", u"Offen Claus-Peter", u"Germany", 98400, u""),
  699.    (u"CMA CGM Hugo", u"NSB Niederelbe", u"Germany", 90745, u""),
  700.    (u"CMA CGM Vivaldi", u"CMA CGM", u"Bahamas", 90745, u""),
  701.    (u"MSC Rachele", u"NSB Niederelbe", u"Germany", 90745, u""),
  702.    (u"Pacific Link", u"NSB Niederelbe", u"Germany", 90745, u""),
  703.    (u"CMA CGM Carmen", u"E R Schiffahrt", u"Liberia", 89800, u""),
  704.    (u"CMA CGM Don Carlos", u"E R Schiffahrt", u"Liberia", 89800, u""),
  705.    (u"CMA CGM Don Giovanni", u"E R Schiffahrt", u"Liberia", 89800, u""),
  706.    (u"CMA CGM Parsifal", u"E R Schiffahrt", u"Liberia", 89800, u""),
  707.    (u"Cosco China", u"E R Schiffahrt", u"Liberia", 91649, u""),
  708.    (u"Cosco Germany", u"E R Schiffahrt", u"Liberia", 89800, u""),
  709.    (u"Cosco Napoli", u"E R Schiffahrt", u"Liberia", 89800, u""),
  710.    (u"YM Unison", u"Yang Ming Line", u"Taiwan", 88600, u""),
  711.    (u"YM Utmost", u"Yang Ming Line", u"Taiwan", 88600, u""),
  712.    (u"MSC Lucy", u"MSC", u"Panama", 89954, u""),
  713.    (u"MSC Maeva", u"MSC", u"Panama", 89954, u""),
  714.    (u"MSC Rita", u"MSC", u"Panama", 89954, u""),
  715.    (u"MSC Busan", u"Offen Claus-Peter", u"Panama", 89954, u""),
  716.    (u"MSC Beijing", u"Offen Claus-Peter", u"Panama", 89954, u""),
  717.    (u"MSC Toronto", u"Offen Claus-Peter", u"Panama", 89954, u""),
  718.    (u"MSC Charleston", u"Offen Claus-Peter", u"Panama", 89954, u""),
  719.    (u"MSC Vittoria", u"MSC", u"Panama", 89954, u""),
  720.    (u"Ever Champion", u"NSB Niederelbe", u"Marshall Islands", 90449,
  721.     u"Captain <i>Phillips</i>"),
  722.    (u"Ever Charming", u"NSB Niederelbe", u"Marshall Islands", 90449,
  723.     u"Captain <i>Tonbridge</i>"),
  724.    (u"Ever Chivalry", u"NSB Niederelbe", u"Marshall Islands", 90449, u""),
  725.    (u"Ever Conquest", u"NSB Niederelbe", u"Marshall Islands", 90449, u""),
  726.    (u"Ital Contessa", u"NSB Niederelbe", u"Marshall Islands", 90449, u""),
  727.    (u"Lt Cortesia", u"NSB Niederelbe", u"Marshall Islands", 90449, u""),
  728.    (u"OOCL Asia", u"OOCL", u"Hong Kong", 89097, u""),
  729.    (u"OOCL Atlanta", u"OOCL", u"Hong Kong", 89000, u""),
  730.    (u"OOCL Europe", u"OOCL", u"Hong Kong", 89097, u""),
  731.    (u"OOCL Hamburg", u"OOCL", u"Marshall Islands", 89097, u""),
  732.    (u"OOCL Long Beach", u"OOCL", u"Marshall Islands", 89097, u""),
  733.    (u"OOCL Ningbo", u"OOCL", u"Marshall Islands", 89097, u""),
  734.    (u"OOCL Shenzhen", u"OOCL", u"Hong Kong", 89097, u""),
  735.    (u"OOCL Tianjin", u"OOCL", u"Marshall Islands", 89097, u""),
  736.    (u"OOCL Tokyo", u"OOCL", u"Hong Kong", 89097, u"")):
  737.            yield Ship(name, owner, country, teu, description)
  738.  
  739.  
  740. how do i change to code to make cell background color change after edting the cell ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement