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


Python QTableWidgetItem.setTextAlignment方法代码示例

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


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

示例1: appendTable

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setTextAlignment [as 别名]
	def appendTable(self, header, ws):
		try:
			font  = QFont('TypeWriter', pointSize = 10, weight=QFont.Bold)
			for text in header:
				self.table.insertColumn(0)
			for c in xrange(len(header)):
				det = self.determine(header[c])
				item = QTableWidgetItem(header[c])
				if det == 0:
					item.setBackground(QBrush(QColor('#FF8D00')))
				else:
					item.setBackground(QBrush(QColor('#005588')))
				item.setFont(font)
				item.setTextAlignment(Qt.AlignCenter)
				self.table.setItem(0, c, item)	

				nComboBox = self.newCombo()
				nComboBox.setCurrentIndex(det)
				self.table.setCellWidget(1, c, (nComboBox))
				
				for r in xrange(2,26,1):
					item = QTableWidgetItem(ws[c][r-2])
					item.setFont(font)
					item.setTextAlignment(Qt.AlignCenter)
					self.table.setItem(r, c, item)
			self.addStatus(  u'  狀態:  勤務表預覽成功', -1)
			return 0
		except:
			self.addStatus(  u'  狀態:  勤務表預覽失敗', 1)
			return 'error'
开发者ID:s910324,项目名称:AutoSchedule,代码行数:32,代码来源:AutoSchedule.py

示例2: add_link

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setTextAlignment [as 别名]
    def add_link( self, url ):

        """
            Adds a link to the link widget.

            Only adds if its not already present.
        """

        if url not in self.links:

            self.links.add( url )


            rowCounts = self.links_ui.rowCount()
            nextRow = rowCounts + 1
            nextPosition = rowCounts    # row count is the length, but position is zero-based

            self.links_ui.setRowCount( nextRow )

            urlEntry = QTableWidgetItem( url )
            statusEntry = QTableWidgetItem( '' )

            statusEntry.setTextAlignment( Qt.AlignCenter )

            urlEntry.setFlags( urlEntry.flags() & ~Qt.ItemIsEditable ) # not editable
            statusEntry.setFlags( statusEntry.flags() & ~Qt.ItemIsEditable ) # not editable

            self.links_ui.setItem( nextPosition, 0, urlEntry )
            self.links_ui.setItem( nextPosition, 1, statusEntry )


                # check if online
            stream = Stream( url.split() )

            stream.is_online( statusEntry )
开发者ID:ckorn,项目名称:livestreamer-ui,代码行数:37,代码来源:main.py

示例3: setUpTable

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setTextAlignment [as 别名]
	def setUpTable(self):
		self.table.horizontalHeader().setVisible(False)
		for i in xrange(0, 26, 1):
			self.vhfont = QFont('Times', pointSize = 10, weight=QFont.Bold)
			timePos = i+6
			if   i == 0:
				item = QTableWidgetItem(u'[標題]')
			elif i == 1:
				item = QTableWidgetItem(u'[設定]')
			elif 2 < timePos < 24:
				item = QTableWidgetItem(('{0}~{1}').format(timePos, timePos+1))
			else:
				item = QTableWidgetItem(('{0}~{1}').format(timePos-24, timePos-23))
			item.setFont(self.vhfont)
			item.setTextAlignment(Qt.AlignCenter)
			self.table.setVerticalHeaderItem(i, item)
开发者ID:s910324,项目名称:AutoSchedule,代码行数:18,代码来源:AutoSchedule.py

示例4: add_data

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setTextAlignment [as 别名]
 def add_data(self, widget):
     # delete vertical headers
     for i in xrange(widget.rowCount()):
         widget.setVerticalHeaderItem(i, QTableWidgetItem())
     # set horizontal headers
     for i in xrange(widget.columnCount()):
         # the text
         item = QTableWidgetItem('No {0}'.format(i))
         # the alignment
         item.setTextAlignment(Qt.AlignRight)
         widget.setHorizontalHeaderItem(i, item)
     # set data
     for y, row in enumerate(DATA):
         for x, cell in enumerate(row):
             # the text
             item = QTableWidgetItem(cell)
             # the alignment
             item.setTextAlignment(Qt.AlignCenter)
             widget.setItem(y, x, item)
开发者ID:MiguelCarrilhoGT,项目名称:snippets,代码行数:21,代码来源:table_header_alignment.py

示例5: __init__

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setTextAlignment [as 别名]
    def __init__(self, messages, hiddenLifelines, parent = None):
        super(HiddenMessageDialog, self).__init__(parent)

        self.lifelineList = hiddenLifelines
        self.msgList = messages
        layout = QVBoxLayout(self)

        listTitle = QLabel('Hidden Messages')
        layout.addWidget(listTitle)

        self.listHiddenMessages = QtGui.QTableWidget(len(self.msgList),4)
        self.listHiddenMessages.setHorizontalHeaderLabels(['Index','Name','Departure','Destination'])
        self.listHiddenMessages.setFixedWidth(400)
        #self.listHiddenMessages.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
        self.listHiddenMessages.setSelectionBehavior(QAbstractItemView.SelectRows)

        for idx, msg in enumerate(self.msgList):
            self.listHiddenMessages.setItem(idx,0,QTableWidgetItem("%d" % msg['messageindex']))
            self.listHiddenMessages.setItem(idx,1,QTableWidgetItem(msg['message']))
            item = QTableWidgetItem(msg['departure']['class'])
            item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
            if msg['departure']['class'] in self.lifelineList:
                item.setForeground(QColor(200,200,200)) 
            self.listHiddenMessages.setItem(idx,2,item)

            item = QTableWidgetItem(msg['dest'])
            item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
            if msg['dest'] in self.lifelineList:
                item.setForeground(QColor(200,200,200)) 
            self.listHiddenMessages.setItem(idx,3,item)

        layout.addWidget(self.listHiddenMessages)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
        buttons.button(QDialogButtonBox.Ok).setText('Show')
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)
开发者ID:OpenDanbi,项目名称:Sherlock,代码行数:40,代码来源:HiddenMessageDialog.py

示例6: setupUi

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setTextAlignment [as 别名]
  def setupUi(self, MainWindow):
      MainWindow.setObjectName("MainWindow")
      MainWindow.setFixedSize(800, 600)
      self.centralwidget = QWidget(MainWindow)
      self.centralwidget.setObjectName("centralwidget")
      self.FilterLbl = QLabel(self.centralwidget)
      self.FilterLbl.setGeometry(QtCore.QRect(30, 150, 60, 15))
      self.FilterLbl.setObjectName("FilterLbl")
      self.FilterCB = QComboBox(self.centralwidget)
      self.FilterCB.setGeometry(QtCore.QRect(450, 150, 100, 22))
      self.FilterCB.setObjectName("FilterCB")
      self.FilterCB.addItem("")
      self.FilterCB.addItem("")
      self.FilterCB.addItem("")
      self.FilterCB.addItem("")         
      self.FilterTF = QLineEdit(self.centralwidget)
      self.FilterTF.setGeometry(QtCore.QRect(100, 150, 320, 20))        
      self.tableView = QTableWidget(self.centralwidget)
      self.tableView.setGeometry(QtCore.QRect(10, 180, 781, 511))
      self.tableView.setObjectName("tableView")
      self.tableView.setColumnCount(4)
      self.tableView.setRowCount(0)
      item = QTableWidgetItem("Cena za kg/l")
      self.tableView.setHorizontalHeaderItem(0, item)
      item = QTableWidgetItem("Cena ze kus")
      self.tableView.setHorizontalHeaderItem(1, item)
      item = QTableWidgetItem(u"Gramaž")
      self.tableView.setHorizontalHeaderItem(2, item)
      item = QTableWidgetItem("Popis")
      item.setTextAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)
      font = QtGui.QFont()
      font.setPointSize(8)
      item.setFont(font)
      self.tableView.setHorizontalHeaderItem(3, item)
      self.tableView.horizontalHeader().setStretchLastSection(True)
      
      self.SaveBtn = QPushButton(self.centralwidget)
      self.SaveBtn.setGeometry(QtCore.QRect(30, 10, 100, 23))
      self.SaveBtn.setObjectName("SaveBtn")
      self.PrintSelectedToFileBtn = QPushButton(self.centralwidget)
      self.PrintSelectedToFileBtn.setGeometry(QtCore.QRect(225, 10, 100, 23))        
      self.PrintSelectedToFileBtn.setObjectName("PrintSelectedToFileBtn")
      self.PriceForUnitTF = QLineEdit(self.centralwidget)
      self.PriceForUnitTF.setGeometry(QtCore.QRect(100, 70, 113, 20))
      self.PriceForUnitTF.setObjectName("PriceForUnitTF")
      self.PriceForUnitLbl = QLabel(self.centralwidget)
      self.PriceForUnitLbl.setGeometry(QtCore.QRect(30, 70, 60, 13))
      self.PriceForUnitLbl.setObjectName("PriceForUnitLbl")
      self.ArtikelTF = QLineEdit(self.centralwidget)
      self.ArtikelTF.setGeometry(QtCore.QRect(100, 100, 113, 20))
      self.ArtikelTF.setObjectName("ArtikelTF")
      self.ArtikelLbl = QLabel(self.centralwidget)
      self.ArtikelLbl.setGeometry(QtCore.QRect(30, 100, 46, 13))
      self.ArtikelLbl.setObjectName("ArtikelLbl")
      self.DescriptionLbl = QLabel(self.centralwidget)
      self.DescriptionLbl.setGeometry(QtCore.QRect(455, 70, 75, 13))
      self.DescriptionLbl.setObjectName("DescriptionLbl")
      self.UnitLbl = QLabel(self.centralwidget)
      self.UnitLbl.setGeometry(QtCore.QRect(250, 70, 60, 15))
      self.UnitLbl.setObjectName("UnitLbl")
      self.WeightLbl = QLabel(self.centralwidget)
      self.WeightLbl.setGeometry(QtCore.QRect(250, 100, 60, 13))
      self.WeightLbl.setObjectName("UnitLbl")
      self.WeightTF = QLineEdit(self.centralwidget)
      self.WeightTF.setGeometry(QtCore.QRect(320, 100, 100, 20))
      self.WeightTF.setObjectName("WeightTF")        
      self.UnitCB = QComboBox(self.centralwidget)
      self.UnitCB.setGeometry(QtCore.QRect(320, 70, 100, 22))
      self.UnitCB.setObjectName("UnitCB")
      self.UnitCB.addItem("")
      self.UnitCB.addItem("")
      self.DescriptionTE = QPlainTextEdit(self.centralwidget)
      self.DescriptionTE.setGeometry(QtCore.QRect(540, 30, 241, 61))
      self.DescriptionTE.setObjectName("DescriptionTE")
      self.PrintToFileBtn = QPushButton(self.centralwidget)
      self.PrintToFileBtn.setGeometry(QtCore.QRect(140, 10, 75, 23))
      self.PrintToFileBtn.setObjectName("PrintToFileBtn")
      self.AddRecordBtn = QPushButton(self.centralwidget)
      self.AddRecordBtn.setGeometry(QtCore.QRect(450, 100, 75, 23))
      self.AddRecordBtn.setObjectName("AddRecordBtn")        
      self.SaveChangeBtn = QPushButton(self.centralwidget)
      self.SaveChangeBtn.setGeometry(QtCore.QRect(550, 100, 75, 23))
      self.SaveChangeBtn.setObjectName("SaveChangeBtn")
      self.DeleteRecordBtn = QPushButton(self.centralwidget)
      self.DeleteRecordBtn.setGeometry(QtCore.QRect(650, 100, 75, 23))
      self.DeleteRecordBtn.setObjectName("DeleteRecordBtn")
      MainWindow.setCentralWidget(self.centralwidget)
      self.menubar = QMenuBar(MainWindow)
      self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
      self.menubar.setObjectName("menubar")
      MainWindow.setMenuBar(self.menubar)
      self.statusbar = QStatusBar(MainWindow)
      self.statusbar.setObjectName("statusbar")
 
      self.FilterTF.textChanged.connect(self.on_lineEdit_textChanged)
      self.FilterCB.currentIndexChanged.connect(self.on_comboBox_currentIndexChanged)
      self.retranslateUi(MainWindow)
      QtCore.QMetaObject.connectSlotsByName(MainWindow)
开发者ID:Radymus,项目名称:label-marker,代码行数:100,代码来源:gui.py


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