本文整理汇总了Python中qttable.QTable.text方法的典型用法代码示例。如果您正苦于以下问题:Python QTable.text方法的具体用法?Python QTable.text怎么用?Python QTable.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qttable.QTable
的用法示例。
在下文中一共展示了QTable.text方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BrowserBrick
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import text [as 别名]
#.........这里部分代码省略.........
# resize the splitter to something like 1/4-3/4
# width = self.main_layout.width()
# left = width / 4.0
# right = width - left
# logging.debug('setting splitter sizes to %d and %d', left, right)
# self.main_layout.setSizes([left, right])
def sort_column(self, col_number):
logging.debug('%s: sorting with column %d', self, col_number)
if col_number == self.sort_column:
# switch the sort order
self.sort_order = self.sort_order ^ True
else:
self.sort_order = True #else, ascending
self.sort_column = col_number
self.history.sortColumn(col_number, self.sort_order, True)
# put the right decoration on the header label
if self.sort_order:
direction = Qt.Ascending
else:
direction = Qt.Descending
self.history.horizontalHeader().setSortIndicator(col_number, direction)
def load_file(self, path):
if self.browser.mimeSourceFactory().data(path) == None:
self.browser.setText('<center>FILE NOT FOUND</center>')
else:
self.browser.setSource(abspath(path))
def history_changed(self, row, col):
logging.debug('history elem selected: %d:%d', row, col)
index = (str(self.history.text(row,0)),
str(self.history.text(row,1)),
str(self.history.text(row,2)))
try:
path = self.history_map[index]
self.load_file(path)
except KeyError as e:
# can happen when qt sends us the signal with
# null data and we get the key ("","","")
pass
def new_html(self, html_path, image_prefix, run_number):
logging.getLogger().debug('got a new html page: %s, prefix: %r, run number: %s', html_path, image_prefix, run_number)
# prepend the time and date to the path we just got so
# the history is more readable
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
index = (time_string, str(image_prefix), str(run_number))
self.history_map[index] = html_path
# synchronize the history prop
if self.current_user is not None:
whole_history = pickle.loads(self.getProperty('history').getValue())
whole_history[self.current_user] = self.history_map
self.getProperty('history').setValue(pickle.dumps(whole_history))
self.history.insertRows(self.history.numRows())
logging.debug('numRows() is %d', self.history.numRows())
rows = self.history.numRows() - 1
self.history.setText(rows, 0, QString(time_string))
self.history.setText(rows, 1, QString(str(image_prefix)))
self.history.setText(rows, 2, QString(str(run_number)))
示例2: Form1
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import text [as 别名]
#.........这里部分代码省略.........
self.menunew_itemAction.setText(self.__tr("new item"))
self.menunew_itemAction.setMenuText(self.__tr("new item"))
self.toolBar.setLabel(self.__tr("Tools"))
if self.MenuBar.findItem(1):
self.MenuBar.findItem(1).setText(self.__tr("&File"))
if self.MenuBar.findItem(2):
self.MenuBar.findItem(2).setText(self.__tr("Edit"))
if self.MenuBar.findItem(3):
self.MenuBar.findItem(3).setText(self.__tr("&Help"))
def run_programs(self):
import glob
from commands import getoutput
from thread import start_new_thread
if len(glob.glob(getoutput("echo ~") + "/.qtplumb")) > 0:
file = open(getoutput("echo ~") + "/.qtplumb", "r")
command = file.readline()
xterm_loc = file.readline()
for i in range(0, 5):
if xterm_loc != "\n":
break
xterm_loc = file.readline()
file.close()
command = command[0:(len(command) - 1)]
command = xterm_loc + " -hold -e " + command
else:
command = "../testadj "
for i in range(0, len(self.programs)):
command += " \"%d:" % (i + 1) + self.programs[i] + "\" "
command += " -e "
for i in range(1, len(self.programs) + 2):
for j in range(1, len(self.programs) + 2):
if self.table1.text(i, j).ascii() == "X":
command += " %d," % (i - 1) + "%d " % (j - 1)
def command_runner(x):
getoutput(command)
start_new_thread(command_runner, (0, ))
def table_click(self,row,col,button,point):
if (row == 0) or (row > len(self.programs) + 1) or (col > (len(self.programs) + 1)) or ((row == 1) and (col == 0)):
self.disable_ed()
return
if col == 0:
self.selectedEntry = [row,col]
self.replaceButton.setEnabled(1)
self.deleteButton.setEnabled(1)
self.lineEdit1.setText(self.table1.text(row,col))
return
if self.table1.text(row, col).ascii() != "X":
self.table1.setText(row, col, QString("X"))
else:
self.table1.setText(row, col, QString(""))
self.disable_ed()
def add_entry(self):
s = self.lineEdit1.text().ascii()
self.programs.append(s)
self.table1.setText(len(self.programs) + 1, 0, s)
self.table1.setText(0, len(self.programs) + 1, s)
def replace_entry(self):
s = self.lineEdit1.text().ascii()
示例3: ChannelWidgetSettingsDialog
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import text [as 别名]
#.........这里部分代码省略.........
self.tblComboChoices.setNumRows(10)
for i in range(10):
self.tblComboChoices.verticalHeader().setLabel(i, "%2.0f" % (i+1))
self.tblComboChoices.setText(i, 0, "%2.0f" % (i+1))
self.tblComboChoices.horizontalHeader().setLabel(0, "value")
self.tblComboChoices.horizontalHeader().setLabel(1, "label")
self.combopanel.hide()
ok_cancel = QHBox(self)
self.cmdOk = QPushButton("ok", ok_cancel)
HorizontalSpacer(ok_cancel)
self.cmdCancel = QPushButton("cancel", ok_cancel)
QObject.connect(self.cmdOk, SIGNAL("clicked()"), self.accept)
QObject.connect(self.cmdCancel, SIGNAL("clicked()"), self.reject)
QVBoxLayout(self, 5, 10)
self.layout().addWidget(self.innerbox)
self.layout().addWidget(ok_cancel)
def _showComboPanel(self, show=True):
if show:
self.resize(QSize(self.width()*2, self.height()))
self.combopanel.show()
self.innerbox.setSizes([self.width()/2,self.width()/2])
else:
self.resize(QSize(self.width()/2, self.height()))
self.combopanel.hide()
def lstChannelStylesChanged(self, idx):
if idx == 2:
# combo
self._showComboPanel()
else:
self._showComboPanel(False)
def channelWidget(self, parent, running=False, config=None):
if config is None:
config = self.channelConfig()
else:
self.setChannelConfig(config)
w = ControlPanelWidget(parent, config, running=running)
if config["label_pos"] == "above":
QVBoxLayout(w, 2, 0)
alignment_prefix = "v"
else:
QHBoxLayout(w, 2, 0)
alignment_prefix = "h"
alignment_flag = ChannelWidgetSettingsDialog.alignment_flags[alignment_prefix + config["label_align"]]
w.layout().addWidget(QLabel(config["label"], w), 0, alignment_flag)
w.value = ChannelWidgetSettingsDialog.value_display_widgets[config["value_display_style"]](w)
if "combo" in config:
for value, label in config["combo"]:
w.value.insertItem(label)
w.layout().addWidget(w.value)
return w
def setChannelConfig(self, config):
self.txtLabel.setText(config["label"])
self.optLabelAbove.setChecked(config["label_pos"]=="above")
self.optLabelLeft.setChecked(config["label_pos"]=="left")
self.optLabelAlignLeft.setChecked(config["label_align"]=="left")
self.optLabelAlignRight.setChecked(config["label_align"]=="right")
self.optLabelAlignCenter.setChecked(config["label_align"]=="centre")
self.lstChannelStyles.setCurrentText(config["value_display_style"])
self.txtFormat.setText(config["value_display_format"])
if "combo" in config:
i = 0
for value, label in config["combo"]:
self.tblComboChoices.setText(i, 0, value)
self.tblComboChoices.setText(i, 1, label)
i += 1
self._showComboPanel()
def channelConfig(self):
config = { "type": "channel",
"name": str(self.name()),
"label": str(self.txtLabel.text()),
"label_pos": self.optLabelAbove.isChecked() and "above" or "left",
"value_display_style": str(self.lstChannelStyles.currentText()),
"label_align": self.optLabelAlignLeft.isChecked() and "left" or self.optLabelAlignRight.isChecked() and "right" or "centre",
"value_display_format": str(self.txtFormat.text()) }
if config["value_display_style"] == "combo":
combocfg = []
for i in range(10):
value = self.tblComboChoices.text(i, 0)
label = self.tblComboChoices.text(i, 1)
combocfg.append((value, label))
config["combo"] = combocfg
return config
示例4: BrowserBrick
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import text [as 别名]
#.........这里部分代码省略.........
header = self.history.horizontalHeader()
header.setLabel(0, 'Time and date')
header.setLabel(1, 'Prefix')
header.setLabel(2, 'Run number')
self.clear_history_button = QPushButton('Clear history', self.history_box)
self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
QObject.connect(self.clear_history_button, SIGNAL('clicked()'),
self.clear_history)
# Right part of the splitter
self.browser_box = QWidget(self.main_layout)
QVBoxLayout(self.browser_box)
self.browser_box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
self.top_layout = QHBoxLayout(self.browser_box)
self.back_button = QToolButton(self.browser_box)
self.back_button.setIconSet(QIconSet(Icons.load('Left2')))
self.back_button.setTextLabel('Back')
self.back_button.setUsesTextLabel(True)
self.back_button.setTextPosition(QToolButton.BelowIcon)
self.back_button.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
self.forward_button = QToolButton(self.browser_box)
self.forward_button.setIconSet(QIconSet(Icons.load('Right2')))
self.forward_button.setTextLabel('Forward')
self.forward_button.setUsesTextLabel(True)
self.forward_button.setTextPosition(QToolButton.BelowIcon)
self.forward_button.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
self.top_layout.addWidget(self.back_button)
self.top_layout.addWidget(self.forward_button)
self.browser_box.layout().addLayout(self.top_layout)
self.browser = QTextBrowser(self.browser_box)
self.browser.setReadOnly(True)
self.browser_box.layout().addWidget(self.browser)
self.layout.addWidget(self.main_layout)
#initially disabled
self.forward_button.setEnabled(False)
self.back_button.setEnabled(False)
#connections
QObject.connect(self.browser, SIGNAL('backwardAvailable(bool)'),
self.back_button.setEnabled)
QObject.connect(self.browser, SIGNAL('forwardAvailable(bool)'),
self.forward_button.setEnabled)
QObject.connect(self.back_button, SIGNAL('clicked()'),
self.browser.backward)
QObject.connect(self.forward_button, SIGNAL('clicked()'),
self.browser.forward)
self.edna = None
# resize the splitter to something like 1/4-3/4
# width = self.main_layout.width()
# left = width / 4.0
# right = width - left
# logging.debug('setting splitter sizes to %d and %d', left, right)
# self.main_layout.setSizes([left, right])
def sort_column(self, col_number):
logging.debug('%s: sorting with column %d', self, col_number)
if col_number == self.sort_column:
# switch the sort order
self.sort_order = self.sort_order ^ True
else:
self.sort_order = True #else, ascending
self.sort_column = col_number
self.history.sortColumn(col_number, self.sort_order, True)
# put the right decoration on the header label
if self.sort_order:
direction = Qt.Ascending
else:
direction = Qt.Descending
self.history.horizontalHeader().setSortIndicator(col_number, direction)
def load_file(self, path):
if self.browser.mimeSourceFactory().data(path) == None:
self.browser.setText('<center>FILE NOT FOUND</center>')
else:
self.browser.setSource(abspath(path))
def history_changed(self, row, col):
logging.debug('history elem selected: %d:%d', row, col)
index = (str(self.history.text(row,0)),
str(self.history.text(row,1)),
str(self.history.text(row,2)))
try:
path = self.history_map[index]
self.load_file(path)
except KeyError, e:
# can happen when qt sends us the signal with
# null data and we get the key ("","","")
pass
示例5: Grid
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import text [as 别名]
#.........这里部分代码省略.........
for _ in range(self.__idu.n_var()):
self.table1.horizontalHeader().setLabel(i, self.__idu.var(i).name())
i += 1
for _ in range(self.__idu.n_var(), self.table1.horizontalHeader().count()):
self.table1.horizontalHeader().setLabel(i, '')
i += 1
def __mostrar_lateral_t_reg(self):
"""Muestra los numeros laterales. Sirve para el filtrado"""
lateral = self.table1.verticalHeader()
#lista=self.__idu.getCol(self.__gestorfiltro.variable,filtrado=False)
for i in range(self.__idu.n_reg()):
# if self.__gestorfiltro.variable and not lista[i]:
# lateral.setLabel(i,"--"+str(i))
# else:
lateral.setLabel(i, str(i+1))
def __combotableitem(self):
"""Devuelve un nuevo objeto tipo combotableitem con la lista de tipos"""
lista = QStringList()
from Driza.listas import SL
for tipo in SL.nombrevariables:
lista.append(tipo)
return QComboTableItem(self.table2, lista)
def __botontableitem(self):
"""Devuelve un nuevo objeto tipo combotableitem con la lista de tipos"""
return ButtonTableItem(self.table2, self.dcasos)
def __modificacion_t_var(self, fila, columna):
"""Funcion a que conecta con la introduccion de nuevos datos en la tabla de variables"""
if columna == 1 and (self.table2.text(fila, columna).latin1() == self.__idu.var(fila).tipo):
return # Se ha solicitado un cambio de tipo al propio tipo
self.__portero.guardar_estado()
if fila >= self.__idu.n_var(): #Es una nueva variable
#Variables intermedias (creadas con los valores por defecto)
for valorintermedio in range (self.__idu.n_var(), fila):
self.__insertar_variable()
self.__mostrar_var(valorintermedio)
self.__insertar_variable()
#Variable modificada
variable = self.__idu.var(fila)
if columna == 1: # El usuario quiere cambiar el tipo
textoencuestion = self.table2.text(fila, columna).latin1()
#preguntar el tipo de conversion
metododeseado = self.__preguntar_conversion(variable, textoencuestion)
if metododeseado:
variable, columna = self.__agenteconversion(variable, textoencuestion, metododeseado) #Pareja variable-list
self.__idu.establecer_var(fila, variable, columna)
self.__mostrar_t_reg()
else: #Restos de campos (Texto)
from Driza.excepciones import VariableExisteException
try:
self.__idu.modificar_var(variable, columna, str(self.table2.text(fila, columna).latin1()))
except VariableExisteException:
QMessageBox.warning(self, u'Atención', u'El nombre de variable ya existe')
except NameError:
QMessageBox.warning(self, u'Atención', u'Nombre de variable Erróneo')
self.__mostrar_var(fila)
#En todos los casos, actualizamos el titulo de la tabla de datos
self.__mostrar_titulo_t_reg()
def __actualizar_reg_interfazdatos(self, row, col, valor):