当前位置: 首页>>代码示例>>Python>>正文


Python QTreeWidgetItem.setText方法代码示例

本文整理汇总了Python中PyQt4.Qt.QTreeWidgetItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidgetItem.setText方法的具体用法?Python QTreeWidgetItem.setText怎么用?Python QTreeWidgetItem.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.Qt.QTreeWidgetItem的用法示例。


在下文中一共展示了QTreeWidgetItem.setText方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateMessageView

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
 def updateMessageView(self, maxcount = 0):
     maxcount = maxcount or 200
     mt = self.ui.messageTable
     items = [ (n, str(i.text(1)), mt.itemWidget(i, 0), i)
               for n, i in enumerate(map(lambda n:mt.topLevelItem(n),
                           range(mt.topLevelItemCount()))) ]
     pids = [ str(item[2].id.text()) for item in items ]
     olditems = list(items)
     olds = list(pids)
     n = 0
     self.app.icons.avatar_cache = {}
     messages = self.app.db.get_messages_from_cache(maxcount)
     print "* update message view", len(messages)
     for _blob in messages:
         blob = prepare_post(_blob.__dict__)
         if str(blob.pid) in olds:
             i = olds.index(str(blob.pid))
             olditems.pop(i)
             olds.pop(i)
         if str(blob.pid) not in pids:
             pids.append(blob.pid)
             msg, time = self.build_message_item(blob)
             i = QTreeWidgetItem(mt)
             i.setText(1, time)
             mt.setItemWidget(i, 0, msg)
     # now remove the too old ones
     items.sort(key=lambda i:i[1])
     for old in list(reversed(items))[maxcount-1:] + olditems:
         mt.removeItemWidget(old[3], 0)
         item = old[2]
         del item
开发者ID:payload,项目名称:blain,代码行数:33,代码来源:main.py

示例2: __init__

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def __init__(self, window, msg, formats):
        '''
        formats is a list of tuples: [(format, exists, convertible)].
            format: Lower case format identifier. E.G. mobi
            exists: String representing the number of books that
                    exist in the format.
            convertible: True if the format is a convertible format.
        formats should be ordered in the device's preferred format ordering.
        '''
        QDialog.__init__(self, window)
        Ui_ChooseFormatDeviceDialog.__init__(self)
        self.setupUi(self)
        self.formats.activated[QModelIndex].connect(self.activated_slot)

        self.msg.setText(msg)
        for i, (format, exists, convertible) in enumerate(formats):
            t_item = QTreeWidgetItem()
            t_item.setIcon(0, file_icon_provider().icon_from_ext(format.lower()))
            t_item.setText(0, format.upper())
            t_item.setText(1, exists)
            if convertible:
                t_item.setIcon(2, QIcon(I('ok.png')))
            self.formats.addTopLevelItem(t_item)
            if i == 0:
                self.formats.setCurrentItem(t_item)
                t_item.setSelected(True)
        self.formats.resizeColumnToContents(2)
        self.formats.resizeColumnToContents(1)
        self.formats.resizeColumnToContents(0)
        self.formats.header().resizeSection(0, self.formats.header().sectionSize(0) * 2)
        self._format = None
开发者ID:Hainish,项目名称:calibre,代码行数:33,代码来源:choose_format_device.py

示例3: process_node

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
 def process_node(toc, parent):
     for child in toc:
         node = QTreeWidgetItem(parent)
         node.setText(0, child.title or '')
         node.setData(0, DEST_ROLE, child.dest or '')
         node.setData(0, FRAG_ROLE, child.frag or '')
         tt = _('File: {0}\nAnchor: {1}').format(
             child.dest or '', child.frag or _('Top of file'))
         node.setData(0, Qt.ToolTipRole, tt)
         process_node(child, node)
开发者ID:089git,项目名称:calibre,代码行数:12,代码来源:toc.py

示例4: _addDPSubItem

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
 def _addDPSubItem(self, dp, parent, after):
     item = QTreeWidgetItem(parent, after)
     item.setText(1, dp.filename)
     item.setToolTip(1, dp.filename)
     item.setText(2, dp.comment or "")
     item.setToolTip(2, dp.comment or "")
     item._ientry = None
     item._dp = dp
     item._menu = self._archived_dp_menu
     item._set_menu_title = lambda: self._archived_dp_menu_title.setText(os.path.basename(dp.filename))
     return item
开发者ID:kernsuite-debian,项目名称:purr,代码行数:13,代码来源:MainWindow.py

示例5: showConversation

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
 def showConversation(self, item, _):
     mt = self.ui.messageTable
     msg = mt.itemWidget(item, 0)
     if item.isExpanded():
         msg.replyLabel.setVisible(True)
         return # allready added
     if not msg.replyLabel.isVisible():
         return # no conversation
     msg.replyLabel.setVisible(False)
     if item.childCount(): return # allready added
     messages = self.app.db.get_conversation_messages(int(msg.id.text()))
     for _blob in messages:
         blob = prepare_post(_blob.__dict__)
         msg, time = self.build_message_item(blob)
         msg.replyLabel.setVisible(False) # no conversation trees possible
         i = QTreeWidgetItem(item)
         i.setText(1, time)
         mt.setItemWidget(i, 0, msg)
开发者ID:payload,项目名称:blain,代码行数:20,代码来源:main.py

示例6: updateProv

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
 def updateProv(self):
     self.treeProvis.clear()
     for x,y in self.provis.iteritems():
         item = QTreeWidgetItem(self.treeProvis)
         item.setText(0, x)
         item.setText(1, str(round(y.y,3)))
         item.setText(2, str(round(y.x,3)))
         item.setText(3, str(round(y.h,3)))
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:10,代码来源:main1.py

示例7: readControlFile

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def readControlFile(self, filename):
        self.control = controlPoints(self.N,filename)
#         obs=obsSplit(obs)
        for x,y in self.control.iteritems():
            #print coord
            item = QTreeWidgetItem(self.treeControl)
            item.setText(0, x)
            item.setText(1, str(round(y.y,3)))
            item.setText(2, str(round(y.x,3)))
            item.setText(3, str(round(y.h,3)))
            item.setCheckState(0, Qt.Checked)
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:13,代码来源:main1.py

示例8: calcProv

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def calcProv(self):
        self.nodeg.setVisible(False)
        self.unknowns=getUnknowns(self.N,self.control)
        self.provisionals= getProvisionals(self.N,self.control,self.unknowns) 
        self.treeProvis.clear()
        self.saveProvisButton.setVisible(True)
        self.bowditch.setVisible(True)
#         for name in self.stationsOrder:
#             item = QTreeWidgetItem(self.treeProvis)
#             item.setText(0, name)
#             
#             
#             item.setText(1, str(round(self.provisionals[name].x,3)))
#             item.setText(2, str(round(self.provisionals[name].y,3)))
#             item.setText(3, str(round(self.provisionals[name].h,3)))
            
        for x,y in self.provisionals.iteritems():
            item = QTreeWidgetItem(self.treeProvis)
            item.setText(0, x)
            item.setText(1, str(round(y.y,3)))
            item.setText(2, str(round(y.x,3)))
            item.setText(3, str(round(y.h,3)))
        self.updateGraph()
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:25,代码来源:main1.py

示例9: build_dictionaries

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def build_dictionaries(self, reread=False):
        all_dictionaries = builtin_dictionaries() | custom_dictionaries(reread=reread)
        languages = defaultdict(lambda : defaultdict(set))
        for d in all_dictionaries:
            for locale in d.locales | {d.primary_locale}:
                languages[locale.langcode][locale.countrycode].add(d)
        bf = QFont(self.dictionaries.font())
        bf.setBold(True)
        itf = QFont(self.dictionaries.font())
        itf.setItalic(True)
        self.dictionaries.clear()

        for lc in sorted(languages, key=lambda x:sort_key(calibre_langcode_to_name(x))):
            i = QTreeWidgetItem(self.dictionaries, LANG)
            i.setText(0, calibre_langcode_to_name(lc))
            i.setData(0, Qt.UserRole, lc)
            best_country = getattr(best_locale_for_language(lc), 'countrycode', None)
            for countrycode in sorted(languages[lc], key=lambda x: country_map()['names'].get(x, x)):
                j = QTreeWidgetItem(i, COUNTRY)
                j.setText(0, country_map()['names'].get(countrycode, countrycode))
                j.setData(0, Qt.UserRole, countrycode)
                if countrycode == best_country:
                    j.setData(0, Qt.FontRole, bf)
                pd = get_dictionary(DictionaryLocale(lc, countrycode))
                for dictionary in sorted(languages[lc][countrycode], key=lambda d:d.name):
                    k = QTreeWidgetItem(j, DICTIONARY)
                    pl = calibre_langcode_to_name(dictionary.primary_locale.langcode)
                    if dictionary.primary_locale.countrycode:
                        pl += '-' + dictionary.primary_locale.countrycode.upper()
                    k.setText(0, dictionary.name or (_('<Builtin dictionary for {0}>').format(pl)))
                    k.setData(0, Qt.UserRole, dictionary)
                    if dictionary.name:
                        k.setFlags(k.flags() | Qt.ItemIsEditable)
                    if pd == dictionary:
                        k.setData(0, Qt.FontRole, itf)

        self.dictionaries.expandAll()
开发者ID:charliehower,项目名称:calibre,代码行数:39,代码来源:spell.py

示例10: build

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def build(self, container):
        self.clear()
        self.root = self.invisibleRootItem()
        self.root.setFlags(Qt.ItemIsDragEnabled)
        self.categories = {}
        for category, text, icon in (
            ('text', _('Text'), 'keyboard-prefs.png'),
            ('styles', _('Styles'), 'lookfeel.png'),
            ('images', _('Images'), 'view-image.png'),
            ('fonts', _('Fonts'), 'font.png'),
            ('misc', _('Miscellaneous'), 'mimetypes/dir.png'),
        ):
            self.categories[category] = i = QTreeWidgetItem(self.root, 0)
            i.setText(0, text)
            i.setIcon(0, QIcon(I(icon)))
            f = i.font(0)
            f.setBold(True)
            i.setFont(0, f)
            i.setData(0, NAME_ROLE, category)
            flags = Qt.ItemIsEnabled
            if category == 'text':
                flags |= Qt.ItemIsDropEnabled
            i.setFlags(flags)

        processed, seen = set(), {}

        def get_display_name(name, item):
            parts = name.split('/')
            text = parts[-1]
            while text in seen and parts:
                text = parts.pop() + '/' + text
            seen[text] = item
            return text

        for name, linear in container.spine_names:
            processed.add(name)
            i = QTreeWidgetItem(self.categories['text'], 1)
            prefix = '' if linear else '[nl] '
            if not linear:
                i.setIcon(self.non_linear_icon)
            i.setText(0, prefix + get_display_name(name, i))
            i.setStatusTip(0, _('Full path: ') + name)
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsSelectable)
            i.setData(0, NAME_ROLE, name)

        font_types = {guess_type('a.'+x)[0] for x in ('ttf', 'otf', 'woff')}

        def get_category(mt):
            category = 'misc'
            if mt.startswith('image/'):
                category = 'images'
            elif mt in font_types:
                category = 'fonts'
            elif mt in OEB_STYLES:
                category = 'styles'
            return category

        all_files = list(container.manifest_type_map.iteritems())
        all_files.append((guess_type('a.opf')[0], [container.opf_name]))

        for name in container.name_path_map:
            if name in processed:
                continue
            processed.add(name)
            imt = container.mime_map.get(name, guess_type(name)[0])
            icat = get_category(imt)
            i = QTreeWidgetItem(self.categories[icat], 1)
            i.setText(0, get_display_name(name, i))
            i.setStatusTip(0, _('Full path: ') + name)
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            i.setData(0, NAME_ROLE, name)

        for c in self.categories.itervalues():
            self.expandItem(c)
开发者ID:shootstar,项目名称:calibre,代码行数:76,代码来源:file_list.py

示例11: readObsFile

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
 def readObsFile(self, filename):
     self.N,self.stationsOrder,self.obsOrder = Observations(filename)
     N=self.N
     self.obs1,self.ObsList=getObs(N)
     self.obs=obsSplit(self.obs1)
     for name in self.stationsOrder:
         item = QTreeWidgetItem(self.treeObs)
         item.setText(0, name)
         
         for t,j in self.obs[name].iteritems():
             subitem=QTreeWidgetItem(item)
             subitem.setText(1, t[0:-2])
             if j.type=='direction':
                 subitem.setText(2,str( rad2dms(j.direction))) 
                 subitem.setCheckState(0, Qt.Checked)          
             if j.type=='distance':
                 subitem.setCheckState(0, Qt.Checked)
                 subitem.setText(3, str(j.distance))
             if j.type=='both':
                 subitem.setText(2,str( rad2dms(j.direction))) 
                 subitem.setCheckState(0, Qt.Checked)
                 subitem.setText(3, str(j.distance))
             item.setCheckState(0, Qt.Checked)
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:25,代码来源:main1.py

示例12: residuals

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def residuals(self):
        self.stdDevTree.clear()
        self.resid={}
        for x in self.unknowns:
            list=[]
            
            name=x[0:-2]
            item = QTreeWidgetItem(self.stdDevTree)
            item.setText(0, name)
            if not self.resid.has_key(name):
                self.resid[name]=[None,None,None]
            
            if x[-1]=="o":
                self.resid[name][2]=(self.precisi[name+"_o"])
                item.setText(3, str(round(float(self.resid[name][2]),3)))
                
            elif x[-1]=="x":
                self.resid[name][0]=(self.precisi[name+"_x"])
                item.setText(1, str(round(float(self.resid[name][0]),3)))
                
                
            elif x[-1]=="y":
                self.resid[name][1]=(self.precisi[name+"_y"])
                item.setText(2, str(round(float(self.resid[name][1]),3)))
                
        for name in self.unknowns:
            name=x[0:-2]
               
            if not (self.resid[name][2])==None:
                
                if (self.resid[name][0])==None and (self.resid[name][1])==None:
                        item.setText(0, name+"(control)")
        
        self.vtpvLabel.setText("VTPV: "+str(self.vtpv))
        self.vtpvLabel.setVisible(True)
        if float(round(float((self.A.T*self.P*self.V).T*(self.A.T*self.P*self.V)),6))==0.:
            self.numcheckLabel.setVisible(True)
        self.posteriori.setText("Posteriori: "+str(self.posterioriValue))
        self.posteriori.setVisible(True)
        self.posteriori_2.setText(str(round(self.posterioriValue,5)))
        self.posteriori_2.setVisible(True)
        check1=globalCheck(self.provis,self.control,self.V,self.obs,self.unknowns,self.Xdict)
        for x,ob in self.XOdict.iteritems():
            list=[]
            name=x[0:-2]
            item = QTreeWidgetItem(self.stdDevTree)
            item.setText(0, name+" orientation:")
            item.setText(3, str(round(float(self.XOdict[x]),3)))
        sum=0
        for i in check1.values():
            sum+=round(i,4)
        if round(sum,3)==0.:
            self.glocheckLabel.setVisible(True)
        else:
            self.glocheckLabel.setText("GLOBAL UNSUCCESS")       
#             self.glocheckLabel.setStyleSheet(color="red")     
            self.glocheckLabel.setVisible(True) 
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:59,代码来源:main1.py

示例13: residuals2

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setText [as 别名]
    def residuals2(self):
        self.AObs=self.posterioriValue*self.A*(self.A.T*self.P*self.A)**-1*self.A.T
        self.cofactorM=self.A*(self.A.T*self.P*self.A)**-1*self.A.T
        self.AResObs=self.posterioriValue*(self.P**-1 - self.A*(self.A.T*self.P*self.A)**-1*self.A.T)
#         print (self.A.T*self.P*self.A)**-1
#         print self.posterioriValue
#         print self.posterioriValue*(self.A.T*self.P*self.A)**-1
        self.cofactorAObs.clear()
        self.cofactorZ.clear()
        self.residA=OrderedDict()
        self.residARe=OrderedDict()
#         print self.cofactorM   
        count = 0
        for i,j in self.obs.iteritems():
            for k,l in j.iteritems():
                count+=1
        self.obsCount=count
        self.cofactorAObs.setColumnCount(count)
        self.cofactorAObs.setRowCount(count)
        self.cofactorZ.setColumnCount(count)
        self.cofactorZ.setRowCount(count)
        for i in range (count):
            for j in range (count):
                temp=QTableWidgetItem()
                temp.setText(str(self.cofactorM[i,j]))
                self.cofactorAObs.setItem(i,j,temp)
        for i in range (count):
            for j in range (count):
                temp=QTableWidgetItem()
                temp.setText(str(self.AResObs[i,j]))
                self.cofactorZ.setItem(i,j,temp)
        i=0
        for x,sta in self.obs.iteritems():
            for tn,tar in sta.iteritems():

                name=x
    #             name=x[0:-2]
                if not self.residA.has_key(x+tn):
                    self.residA[x+tn]=[None]
                if not self.residARe.has_key(x+tn):
                    self.residARe[x+tn]=[None]
                
    
                self.residA[x+tn][0]=sqrt(self.AObs[i,i])
                self.residARe[x+tn][0]=sqrt(self.AResObs[i,i])
                i+=1
#         print self.residA
#         print self.residARe
        for x,sta in self.obs.iteritems():
           for tn,target in sta.iteritems(): 
                name=x+tn
                item1 = QTreeWidgetItem(self.stdDevAtree)
                item2 = QTreeWidgetItem(self.stdDevObsTree)
                if tn[-1]=="D":
                    item1.setText(0, "Direction from"+ x +"to :"+tn[0:-2])
                    item2.setText(0,"Direction from"+ x+"to :"+tn[0:-2])
                elif tn[-1]=="d":
                    item1.setText(0, "Distance from"+ x+"to :"+tn[0:-2])
                    item2.setText(0,"Distance from"+ x+"to :"+tn[0:-2])
                    
                    
                    
                item1.setText(1, str(round(float(self.residA[name][0]),3)))
                item2.setText(1, str(round(float(self.residARe[name][0]),3)))
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:66,代码来源:main1.py


注:本文中的PyQt4.Qt.QTreeWidgetItem.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。