Beispiel #1
0
 def __init__(self, spine, toc, depth, all_items, parent=None):
     text = toc.text
     if text:
         text = re.sub(r'\s', ' ', text)
     self.title = text
     self.parent = parent
     QStandardItem.__init__(self, text if text else '')
     self.abspath = toc.abspath if toc.href else None
     self.fragment = toc.fragment
     all_items.append(self)
     self.bold_font = QFont(self.font())
     self.bold_font.setBold(True)
     self.normal_font = self.font()
     for t in toc:
         self.appendRow(TOCItem(spine, t, depth+1, all_items, parent=self))
     self.setFlags(Qt.ItemIsEnabled)
     spos = 0
     for i, si in enumerate(spine):
         if si == self.abspath:
             spos = i
             break
     am = {}
     if self.abspath is not None:
         try:
             am = getattr(spine[i], 'anchor_map', {})
         except UnboundLocalError:
             # Spine was empty?
             pass
     frag = self.fragment if (self.fragment and self.fragment in am) else None
     self.starts_at = spos
     self.start_anchor = frag
     self.start_src_offset = am.get(frag, 0)
     self.depth = depth
     self.is_being_viewed = False
Beispiel #2
0
 def __init__(self, spine, toc, depth, all_items, parent=None):
     text = toc.text
     if text:
         text = re.sub(r'\s', ' ', text)
     self.title = text
     self.parent = parent
     QStandardItem.__init__(self, text if text else '')
     self.abspath = toc.abspath
     self.fragment = toc.fragment
     all_items.append(self)
     self.bold_font = QFont(self.font())
     self.bold_font.setBold(True)
     self.normal_font = self.font()
     for t in toc:
         self.appendRow(TOCItem(spine, t, depth+1, all_items, parent=self))
     self.setFlags(Qt.ItemIsEnabled)
     spos = 0
     for i, si in enumerate(spine):
         if si == self.abspath:
             spos = i
             break
     try:
         am = getattr(spine[i], 'anchor_map', {})
     except UnboundLocalError:
         # Spine was empty?
         am = {}
     frag = self.fragment if (self.fragment and self.fragment in am) else None
     self.starts_at = spos
     self.start_anchor = frag
     self.start_src_offset = am.get(frag, 0)
     self.depth = depth
     self.is_being_viewed = False
 def loadMovieCollection(self):
     json = urllib2.urlopen("http://" + HOST_IP + ":" + HOST_PORT + "/moviecollection").read()
     movieCollection = jsonpickle.decode(json)
     model = QStandardItemModel(self.ui.lvMovies)
     
     for movie in movieCollection:
         item = QStandardItem(movie['title'])
         item.setData(movie['ean'])
         model.appendRow(item)
     
     self.ui.lvMovies.setModel(model)       
Beispiel #4
0
    def __init__(self, spine, toc=None):
        QStandardItemModel.__init__(self)
        if toc is None:
            toc = MTOC()
        self.all_items = depth_first = []
        for t in toc:
            self.appendRow(TOCItem(spine, t, 0, depth_first))
        self.setHorizontalHeaderItem(0, QStandardItem(_('Table of Contents')))

        for x in depth_first:
            possible_enders = [
                t for t in depth_first
                if t.depth <= x.depth and t.starts_at >= x.starts_at
                and t is not x and t not in x.ancestors
            ]
            if possible_enders:
                min_spine = min(t.starts_at for t in possible_enders)
                possible_enders = {
                    t.fragment
                    for t in possible_enders if t.starts_at == min_spine
                }
            else:
                min_spine = len(spine) - 1
                possible_enders = set()
            x.ends_at = min_spine
            x.possible_end_anchors = possible_enders

        self.currently_viewed_entry = None
Beispiel #5
0
    def init_labels(self):
        j = 0
        k = 1
        self.Controler = {}
        for i in sorted(self.devices):
            i = self.devices[i].properties
            if 'Input' in i.keys():
                self.main.Scan_Detector_comboBox.addItem(_fromUtf8(""))
                self.main.Scan_Detector_comboBox.setItemText(
                    j, _translate("MainWindow", i['Name'], None))
                self.main.Monitor_comboBox.addItem(_fromUtf8(""))
                self.main.Monitor_comboBox.setItemText(
                    j, _translate("MainWindow", i['Name'], None))
                self.main.Controler_Detector_comboBox.addItem(_fromUtf8(""))
                self.main.Controler_Detector_comboBox.setItemText(
                    j, _translate("MainWindow", i['Name'], None))
                item = QStandardItem(i['Name'])
                item.setCheckable(True)
                item.setEditable(False)
                self.main.Scan_Dropdown.model.appendRow(item)
                if j == 0:
                    self.main.Scan_Detector_UnitLabel.setText(
                        _translate("MainWindow",
                                   i['Input']['Calibration']['Unit'], None))
                j += 1
            if 'Output' in i.keys():
                unit = i['Output']['Calibration']['Unit']
                self.main.Scan_1st_comboBox.addItem(
                    _translate("MainWindow", i['Name'], None))
                self.main.Scan_2nd_comboBox.addItem(
                    _translate("MainWindow", i['Name'], None))
                self.main.Scan_3rd_comboBox.addItem(
                    _translate("MainWindow", i['Name'], None))
                self.main.Controler_1st_comboBox.addItem(
                    _translate("MainWindow", i['Name'], None))
                self.main.Controler_2nd_comboBox.addItem(
                    _translate("MainWindow", i['Name'], None))
                self.main.Controler_3rd_comboBox.addItem(
                    _translate("MainWindow", i['Name'], None))
                self.Controler[i['Name']] = {
                    'NameLabel': None,
                    'PosBox': None,
                    'IncBox': None,
                    'UnitLabel': None,
                    'AddButton': None,
                    'MinButton': None
                }
                self.Controler[i['Name']]['NameLabel'] = QtGui.QLabel(
                    self.main.gridLayoutWidget_2)
                self.Controler[i['Name']]['NameLabel'].setObjectName(
                    _fromUtf8("Controler_NameLabeln_%s" % i['Name']))
                self.main.Controler_gridLayout.addWidget(
                    self.Controler[i['Name']]['NameLabel'], k + 5, 0, 1, 1)
                self.Controler[i['Name']]['NameLabel'].setText(
                    _translate("MainWindow", i['Name'], None))

                self.Controler[i['Name']]['PosBox'] = QtGui.QDoubleSpinBox(
                    self.main.gridLayoutWidget_2)
                self.Controler[i['Name']]['PosBox'].setObjectName(
                    _fromUtf8("Controler_Pos_doubleSpinBoxn_%s" % i['Name']))
                self.Controler[i['Name']]['PosBox'].setKeyboardTracking(False)
                self.Controler[i['Name']]['PosBox'].setSuffix(" " + unit)
                self.main.Controler_gridLayout.addWidget(
                    self.Controler[i['Name']]['PosBox'], k + 5, 1, 1, 1)

                self.Controler[i['Name']]['IncBox'] = QtGui.QDoubleSpinBox(
                    self.main.gridLayoutWidget_2)
                self.Controler[i['Name']]['IncBox'].setObjectName(
                    _fromUtf8("Controler_Inc_doubleSpinBoxn_%s" % i['Name']))
                self.Controler[i['Name']]['IncBox'].setSingleStep(0.05)
                self.Controler[i['Name']]['IncBox'].setSuffix(" " + unit)
                self.main.Controler_gridLayout.addWidget(
                    self.Controler[i['Name']]['IncBox'], k + 5, 2, 1, 1)

                self.Controler[i['Name']]['AddButton'] = QtGui.QPushButton(
                    self.main.gridLayoutWidget_2)
                self.Controler[i['Name']]['AddButton'].setEnabled(True)
                self.Controler[i['Name']]['AddButton'].setObjectName(
                    _fromUtf8("Controler_Add_pushButton_%s" % i['Name']))
                self.main.Controler_gridLayout.addWidget(
                    self.Controler[i['Name']]['AddButton'], k + 5, 3, 1, 1)
                self.Controler[i['Name']]['AddButton'].setText(
                    _translate("MainWindow", "+", None))

                self.Controler[i['Name']]['MinButton'] = QtGui.QPushButton(
                    self.main.gridLayoutWidget_2)
                self.Controler[i['Name']]['MinButton'].setEnabled(True)
                self.Controler[i['Name']]['MinButton'].setObjectName(
                    _fromUtf8("Controler_Min_pushButtonn_%s" % i['Name']))
                self.main.Controler_gridLayout.addWidget(
                    self.Controler[i['Name']]['MinButton'], k + 5, 4, 1, 1)
                self.Controler[i['Name']]['MinButton'].setText(
                    _translate("MainWindow", "-", None))

                QtCore.QObject.connect(self.Controler[i['Name']]['AddButton'],
                                       QtCore.SIGNAL("clicked()"),
                                       self.ChangePos)
                QtCore.QObject.connect(self.Controler[i['Name']]['MinButton'],
                                       QtCore.SIGNAL("clicked()"),
                                       self.ChangePos)
                QtCore.QObject.connect(self.Controler[i['Name']]['PosBox'],
                                       QtCore.SIGNAL("valueChanged(double)"),
                                       self.ChangePos)
                k += 1

        self.help_menu.addAction('&About', self.about)
        self.connect(self.main.Monitor_pushButton, SIGNAL("clicked()"),
                     self.Monitor)
        QtCore.QObject.connect(self.main.Scan_Detector_comboBox,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.ChangeUnit)
        QtCore.QObject.connect(self.main.Scan_1st_comboBox,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.ChangeUnit)
        QtCore.QObject.connect(self.main.Scan_2nd_comboBox,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.ChangeUnit)
        QtCore.QObject.connect(self.main.Scan_3rd_comboBox,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.ChangeUnit)
        QtCore.QObject.connect(self.main.Scan_start_pushButton,
                               QtCore.SIGNAL("clicked()"), self.StartScan)
        QtCore.QObject.connect(self.main.Scan_stop_pushButton,
                               QtCore.SIGNAL("clicked()"), self.StopScan)
        QtCore.QObject.connect(self.main.Scan_Mult_Detector_comboBox,
                               QtCore.SIGNAL("clicked()"), self.Mult_detect)
        QtCore.QObject.connect(self.main.Controler_Go,
                               QtCore.SIGNAL("clicked()"), self.Go2Pos)
        QtCore.QObject.connect(self.main.Controler_Refocus,
                               QtCore.SIGNAL("clicked()"), self.Refocus)

        self.main.Scan_Dropdown.create()
        self.InitDevices()
Beispiel #6
0
    def update_filename_box(self):
        doing_multiple = self.doing_multiple

        model = QStandardItemModel()
        self.filename_box.setModel(model)
        self.icon_file_names.sort(key=sort_key)
        if doing_multiple:
            item = QStandardItem(_('Open to see checkboxes'))
        else:
            item = QStandardItem('')
        model.appendRow(item)

        for i,filename in enumerate(self.icon_file_names):
            item = QStandardItem(filename)
            if doing_multiple:
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                item.setData(Qt.Unchecked, Qt.CheckStateRole)
            else:
                item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            icon = QIcon(os.path.join(self.icon_folder, filename))
            item.setIcon(icon)
            model.appendRow(item)
Beispiel #7
0
##     'Chocolate whipped cream' # Must be plentiful
## ]
## 
## for food in foods:
##     # create an item with a caption
##     item = QStandardItem(food)
## 
##     # add a checkbox to it
##     item.setCheckable(True)
## 
##     # Add the item to the model
##     model.appendRow(item)

for pick in cat[-40].picks:
     # create an item with a caption
     item = QStandardItem(str(pick.resource_id))
 
     # add a checkbox to it
     item.setCheckable(True)
     item.setEditable(False)
     item.setTristate(True)
 
     # Add the item to the model
     model.appendRow(item)

# Apply the model to the list view
list.setModel(model)

# Show the window and run the app
list.show()
app.exec_()
Beispiel #8
0
##     'Chocolate whipped cream' # Must be plentiful
## ]
##
## for food in foods:
##     # create an item with a caption
##     item = QStandardItem(food)
##
##     # add a checkbox to it
##     item.setCheckable(True)
##
##     # Add the item to the model
##     model.appendRow(item)

for pick in cat[-40].picks:
    # create an item with a caption
    item = QStandardItem(str(pick.resource_id))

    # add a checkbox to it
    item.setCheckable(True)
    item.setEditable(False)
    item.setTristate(True)

    # Add the item to the model
    model.appendRow(item)

# Apply the model to the list view
list.setModel(model)

# Show the window and run the app
list.show()
app.exec_()
Beispiel #9
0
    def update_filename_box(self):
        doing_multiple = self.multiple_icon_cb.isChecked()

        model = QStandardItemModel()
        self.filename_box.setModel(model)
        self.icon_file_names.sort(key=sort_key)
        if doing_multiple:
            item = QStandardItem(_('Open to see checkboxes'))
        else:
            item = QStandardItem('')
        model.appendRow(item)

        for i, filename in enumerate(self.icon_file_names):
            item = QStandardItem(filename)
            if doing_multiple:
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                item.setData(Qt.Unchecked, Qt.CheckStateRole)
            else:
                item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            icon = QIcon(os.path.join(config_dir, 'cc_icons', filename))
            item.setIcon(icon)
            model.appendRow(item)