本文整理汇总了Python中qttable.QTable.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QTable.setText方法的具体用法?Python QTable.setText怎么用?Python QTable.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qttable.QTable
的用法示例。
在下文中一共展示了QTable.setText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BrowserBrick
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
class BrowserBrick(BaseComponents.BlissWidget):
def __init__(self, *args):
BaseComponents.BlissWidget.__init__(self, *args)
#map displayed string in the history list -> actual file path
self.history_map = dict()
self.layout = QVBoxLayout(self)
self.defineSlot('load_file', ())
self.defineSlot('login_changed', ())
self.addProperty('mnemonic', 'string', '')
self.addProperty('history', 'string', '', hidden=True)
self.addProperty('sessions ttl (in days)', 'integer', '30')
#make sure the history property is a pickled dict
try:
hist = pickle.loads(self.getProperty('history').getValue())
except: # EOFError if the string is empty but let's not count on it
self.getProperty('history').setValue(pickle.dumps(dict()))
# maybe defer that for later
self.cleanup_history()
self.main_layout = QSplitter(self)
self.main_layout.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
# left part of the splitter
self.history_box = QVBox(self.main_layout)
self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
self.sort_order = True
self.sort_col = None
self.history = QTable(self.history_box)
self.history.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding))
self.history.setSelectionMode(QTable.SingleRow)
self.history.setNumCols(3)
self.history.verticalHeader().hide()
self.history.setLeftMargin(0)
self.history.setSorting(False)
QObject.connect(self.history,
SIGNAL('currentChanged(int,int)'),
self.history_changed)
#by default sorting only sorts the columns and not whole rows.
#let's reimplement that
QObject.connect(self.history.horizontalHeader(),
SIGNAL('clicked(int)'),
self.sort_column)
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)
#.........这里部分代码省略.........
示例2: Form1
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
#.........这里部分代码省略.........
self.resize(QSize(1000,556).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)
self.connect(self.fileExitAction,SIGNAL("activated()"),self.close)
self.connect(self.pushButton1_2,SIGNAL("clicked()"),self.close)
self.connect(self.table1,SIGNAL("pressed(int,int,int,const QPoint&)"),self.table_click)
self.connect(self.addButton,SIGNAL("clicked()"),self.add_entry)
self.connect(self.replaceButton,SIGNAL("clicked()"),self.replace_entry)
self.connect(self.lineEdit1,SIGNAL("returnPressed()"),self.add_entry)
self.connect(self.deleteButton,SIGNAL("clicked()"),self.delete_entry)
self.connect(self.addButton,SIGNAL("clicked()"),self.lineEdit1.clear)
self.connect(self.lineEdit1,SIGNAL("returnPressed()"),self.lineEdit1.clear)
self.connect(self.replaceButton,SIGNAL("clicked()"),self.lineEdit1.clear)
self.connect(self.deleteButton,SIGNAL("clicked()"),self.lineEdit1.clear)
self.connect(self.pushButton1,SIGNAL("clicked()"),self.run_programs)
self.connect(self.fileNewAction,SIGNAL("activated()"),self.new_graph)
self.connect(self.editSettingsAction,SIGNAL("activated()"),self.display_config)
self.connect(self.fileOpenAction,SIGNAL("activated()"),self.open_command)
self.connect(self.fileSaveAction,SIGNAL("activated()"),self.save_command)
self.connect(self.fileSaveAsAction,SIGNAL("activated()"),self.saveas_command)
self.connect(self.helpAboutAction,SIGNAL("activated()"),self.show_about)
self.setTabOrder(self.lineEdit1,self.addButton)
self.setTabOrder(self.addButton,self.replaceButton)
self.setTabOrder(self.replaceButton,self.deleteButton)
self.setTabOrder(self.deleteButton,self.pushButton1)
self.setTabOrder(self.pushButton1,self.pushButton1_2)
self.setTabOrder(self.pushButton1_2,self.table1)
def languageChange(self):
self.setCaption(self.__tr("QTPlumb"))
self.addButton.setText(self.__tr("Add"))
self.replaceButton.setText(self.__tr("Replace"))
self.deleteButton.setText(self.__tr("Delete"))
self.pushButton1.setText(self.__tr("Run Programs"))
self.pushButton1_2.setText(self.__tr("Close"))
QToolTip.add(self.table1,self.__tr("Click on the spreadsheet to create connections"))
QToolTip.add(self.lineEdit1,self.__tr("Enter your programs here"))
self.fileNewAction.setText(self.__tr("New"))
self.fileNewAction.setMenuText(self.__tr("&New"))
self.fileNewAction.setAccel(self.__tr("Ctrl+N"))
self.fileOpenAction.setText(self.__tr("Open"))
self.fileOpenAction.setMenuText(self.__tr("&Open..."))
self.fileOpenAction.setAccel(self.__tr("Ctrl+O"))
self.fileSaveAction.setText(self.__tr("Save"))
self.fileSaveAction.setMenuText(self.__tr("&Save"))
self.fileSaveAction.setAccel(self.__tr("Ctrl+S"))
self.fileSaveAsAction.setText(self.__tr("Save As"))
self.fileSaveAsAction.setMenuText(self.__tr("Save &As..."))
self.fileSaveAsAction.setAccel(QString.null)
self.filePrintAction.setText(self.__tr("Print"))
self.filePrintAction.setMenuText(self.__tr("&Print..."))
self.filePrintAction.setAccel(self.__tr("Ctrl+P"))
self.fileExitAction.setText(self.__tr("E&xit"))
self.fileExitAction.setMenuText(self.__tr("E&xit"))
self.fileExitAction.setAccel(QString.null)
self.helpContentsAction.setText(self.__tr("Contents"))
self.helpContentsAction.setMenuText(self.__tr("&Contents..."))
self.helpContentsAction.setAccel(QString.null)
self.helpIndexAction.setText(self.__tr("Index"))
self.helpIndexAction.setMenuText(self.__tr("&Index..."))
self.helpIndexAction.setAccel(QString.null)
self.helpAboutAction.setText(self.__tr("About"))
self.helpAboutAction.setMenuText(self.__tr("&About"))
示例3: ParametersTable
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
class ParametersTable(QWidget):
def __init__(self, parent = None, name = "parameter_table"):
QWidget.__init__(self, parent, name)
self.__dc_parameters = None
self.add_dc_cb = None
self.parameters_label = QLabel(self, "parameters_label")
self.parameter_table = QTable(self, "parameter_table")
self.parameter_table.setNumCols(3)
self.parameter_table.horizontalHeader().\
setLabel(0, self.__tr("Name"), -1)
self.parameter_table.horizontalHeader().\
setLabel(1, self.__tr("Value"))
self.parameter_table.verticalHeader().hide()
self.parameter_table.horizontalHeader().setClickEnabled(False, 0);
self.parameter_table.horizontalHeader().setClickEnabled(False, 1);
self.parameter_table.setColumnWidth(0, 200)
self.parameter_table.setColumnWidth(1, 200)
self.parameter_table.hideColumn(2)
self.parameter_table.setColumnReadOnly(0, True)
self.parameter_table.setLeftMargin(0)
self.parameter_table.setNumRows(0)
self.position_label = QLabel("Positions", self, "position_view")
self.position_label.setAlignment(Qt.AlignTop)
## self.add_button = QPushButton(self, "add_button")
#self.add_button.setDisabled(True)
h_layout = QGridLayout(self, 1, 2)
v_layout_position = QVBoxLayout(self)
v_layout_position.addWidget(self.position_label)
v_layout_table = QVBoxLayout(self)
h_layout.addLayout(v_layout_table, 0, 0)
h_layout.addLayout(v_layout_position, 0, 1)
v_layout_table.addWidget(self.parameters_label)
v_layout_table.addWidget(self.parameter_table)
## v_layout_table.addWidget(self.add_button)
## self.languageChange()
## QObject.connect(self.add_button, SIGNAL("clicked()"),
## self.__add_data_collection)
QObject.connect(self.parameter_table,
SIGNAL("valueChanged(int, int)"),
self.__parameter_value_change)
#self.populate_parameter_table(self.__dc_parameters)
## def languageChange(self):
## self.add_button.setText("Add")
def __tr(self, s, c = None):
return qApp.translate("parameter_table", s, c)
def __add_data_collection(self):
return self.add_dc_cb(self.__dc_parameters, self.collection_type)
def populate_parameter_table(self, parameters):
self.parameter_table.setNumRows(11)
i = 0
for param_key, parameter in parameters.items():
if param_key != 'positions':
self.parameter_table.setText(i, 0, parameter[0])
self.parameter_table.setText(i, 1, parameter[1])
self.parameter_table.setText(i, 2, param_key)
i += 1
## def add_positions(self, positions):
## self.__dc_parameters['positions'].extend(positions)
def __parameter_value_change(self, row, col):
self.__dc_parameters[str(self.parameter_table.item(row, 2).text())][1] = \
str(self.parameter_table.item(row, 1).text())
示例4: Form2
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
class Form2(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)
if not name:
self.setName("Form2")
self.pushButton2 = QPushButton(self,"pushButton2")
self.pushButton2.setGeometry(QRect(620,330,141,31))
self.pushButton3 = QPushButton(self,"pushButton3")
self.pushButton3.setGeometry(QRect(620,370,141,31))
self.pushButton5 = QPushButton(self,"pushButton5")
self.pushButton5.setGeometry(QRect(260,340,111,31))
self.table1 = QTable(self,"table1")
self.table1.setGeometry(QRect(30,20,800,310))
self.table1.setLineWidth(1)
self.table1.setNumRows(101)
self.table1.setNumCols(15)
self.textLabel1 = QLabel(self,"textLabel1")
self.textLabel1.setGeometry(QRect(140,340,70,31))
self.textLabel1.setPaletteBackgroundColor(QColor(0,255,255))
pal = QPalette()
cg = QColorGroup()
cg.setColor(QColorGroup.Foreground,Qt.black)
cg.setColor(QColorGroup.Button,QColor(192,192,192))
cg.setColor(QColorGroup.Light,Qt.white)
cg.setColor(QColorGroup.Midlight,QColor(223,223,223))
cg.setColor(QColorGroup.Dark,QColor(96,96,96))
cg.setColor(QColorGroup.Mid,QColor(128,128,128))
cg.setColor(QColorGroup.Text,Qt.black)
cg.setColor(QColorGroup.BrightText,Qt.white)
cg.setColor(QColorGroup.ButtonText,Qt.black)
cg.setColor(QColorGroup.Base,Qt.white)
cg.setColor(QColorGroup.Background,QColor(0,255,255))
cg.setColor(QColorGroup.Shadow,Qt.black)
cg.setColor(QColorGroup.Highlight,QColor(0,0,128))
cg.setColor(QColorGroup.HighlightedText,Qt.white)
cg.setColor(QColorGroup.Link,Qt.black)
cg.setColor(QColorGroup.LinkVisited,Qt.black)
pal.setActive(cg)
cg.setColor(QColorGroup.Foreground,Qt.black)
cg.setColor(QColorGroup.Button,QColor(192,192,192))
cg.setColor(QColorGroup.Light,Qt.white)
cg.setColor(QColorGroup.Midlight,QColor(220,220,220))
cg.setColor(QColorGroup.Dark,QColor(96,96,96))
cg.setColor(QColorGroup.Mid,QColor(128,128,128))
cg.setColor(QColorGroup.Text,Qt.black)
cg.setColor(QColorGroup.BrightText,Qt.white)
cg.setColor(QColorGroup.ButtonText,Qt.black)
cg.setColor(QColorGroup.Base,Qt.white)
cg.setColor(QColorGroup.Background,QColor(0,255,255))
cg.setColor(QColorGroup.Shadow,Qt.black)
cg.setColor(QColorGroup.Highlight,QColor(0,0,128))
cg.setColor(QColorGroup.HighlightedText,Qt.white)
cg.setColor(QColorGroup.Link,QColor(0,0,255))
cg.setColor(QColorGroup.LinkVisited,QColor(255,0,255))
pal.setInactive(cg)
cg.setColor(QColorGroup.Foreground,QColor(128,128,128))
cg.setColor(QColorGroup.Button,QColor(192,192,192))
cg.setColor(QColorGroup.Light,Qt.white)
cg.setColor(QColorGroup.Midlight,QColor(220,220,220))
cg.setColor(QColorGroup.Dark,QColor(96,96,96))
cg.setColor(QColorGroup.Mid,QColor(128,128,128))
cg.setColor(QColorGroup.Text,QColor(128,128,128))
cg.setColor(QColorGroup.BrightText,Qt.white)
cg.setColor(QColorGroup.ButtonText,QColor(128,128,128))
cg.setColor(QColorGroup.Base,Qt.white)
cg.setColor(QColorGroup.Background,QColor(0,255,255))
cg.setColor(QColorGroup.Shadow,Qt.black)
cg.setColor(QColorGroup.Highlight,QColor(0,0,128))
cg.setColor(QColorGroup.HighlightedText,Qt.white)
cg.setColor(QColorGroup.Link,QColor(0,0,255))
cg.setColor(QColorGroup.LinkVisited,QColor(255,0,255))
pal.setDisabled(cg)
self.textLabel1.setPalette(pal)
self.lineEdit2 = QLineEdit(self,"lineEdit2")
self.lineEdit2.setGeometry(QRect(40,420,310,21))
self.languageChange()
self.resize(QSize(866,656).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)
self.connect(self.pushButton2,SIGNAL("clicked()"),self.addMatrix)
self.connect(self.pushButton3,SIGNAL("clicked()"),self.addMem)
self.connect(self.pushButton5,SIGNAL("clicked()"),self.percent)
self.connect(self.lineEdit2,SIGNAL("returnPressed()"),self.intvec)
def languageChange(self):
self.setCaption(self.__tr("Form2"))
self.pushButton2.setText(self.__tr("Generar BD"))
self.pushButton3.setText(self.__tr("Memoria"))
#.........这里部分代码省略.........
示例5: Form2
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
class Form2(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)
if not name:
self.setName("Form2")
self.lineEdit2 = QLineEdit(self,"lineEdit2")
self.lineEdit2.setGeometry(QRect(40,420,310,21))
self.textLabel1 = QLabel(self,"textLabel1")
self.textLabel1.setGeometry(QRect(30,340,181,31))
self.textLabel1.setPaletteBackgroundColor(QColor(0,255,255))
pal = QPalette()
cg = QColorGroup()
cg.setColor(QColorGroup.Foreground,Qt.black)
cg.setColor(QColorGroup.Button,QColor(192,192,192))
cg.setColor(QColorGroup.Light,Qt.white)
cg.setColor(QColorGroup.Midlight,QColor(223,223,223))
cg.setColor(QColorGroup.Dark,QColor(96,96,96))
cg.setColor(QColorGroup.Mid,QColor(128,128,128))
cg.setColor(QColorGroup.Text,Qt.black)
cg.setColor(QColorGroup.BrightText,Qt.white)
cg.setColor(QColorGroup.ButtonText,Qt.black)
cg.setColor(QColorGroup.Base,Qt.white)
cg.setColor(QColorGroup.Background,QColor(0,255,255))
cg.setColor(QColorGroup.Shadow,Qt.black)
cg.setColor(QColorGroup.Highlight,QColor(0,0,128))
cg.setColor(QColorGroup.HighlightedText,Qt.white)
cg.setColor(QColorGroup.Link,Qt.black)
cg.setColor(QColorGroup.LinkVisited,Qt.black)
pal.setActive(cg)
cg.setColor(QColorGroup.Foreground,Qt.black)
cg.setColor(QColorGroup.Button,QColor(192,192,192))
cg.setColor(QColorGroup.Light,Qt.white)
cg.setColor(QColorGroup.Midlight,QColor(220,220,220))
cg.setColor(QColorGroup.Dark,QColor(96,96,96))
cg.setColor(QColorGroup.Mid,QColor(128,128,128))
cg.setColor(QColorGroup.Text,Qt.black)
cg.setColor(QColorGroup.BrightText,Qt.white)
cg.setColor(QColorGroup.ButtonText,Qt.black)
cg.setColor(QColorGroup.Base,Qt.white)
cg.setColor(QColorGroup.Background,QColor(0,255,255))
cg.setColor(QColorGroup.Shadow,Qt.black)
cg.setColor(QColorGroup.Highlight,QColor(0,0,128))
cg.setColor(QColorGroup.HighlightedText,Qt.white)
cg.setColor(QColorGroup.Link,QColor(0,0,255))
cg.setColor(QColorGroup.LinkVisited,QColor(255,0,255))
pal.setInactive(cg)
cg.setColor(QColorGroup.Foreground,QColor(128,128,128))
cg.setColor(QColorGroup.Button,QColor(192,192,192))
cg.setColor(QColorGroup.Light,Qt.white)
cg.setColor(QColorGroup.Midlight,QColor(220,220,220))
cg.setColor(QColorGroup.Dark,QColor(96,96,96))
cg.setColor(QColorGroup.Mid,QColor(128,128,128))
cg.setColor(QColorGroup.Text,QColor(128,128,128))
cg.setColor(QColorGroup.BrightText,Qt.white)
cg.setColor(QColorGroup.ButtonText,QColor(128,128,128))
cg.setColor(QColorGroup.Base,Qt.white)
cg.setColor(QColorGroup.Background,QColor(0,255,255))
cg.setColor(QColorGroup.Shadow,Qt.black)
cg.setColor(QColorGroup.Highlight,QColor(0,0,128))
cg.setColor(QColorGroup.HighlightedText,Qt.white)
cg.setColor(QColorGroup.Link,QColor(0,0,255))
cg.setColor(QColorGroup.LinkVisited,QColor(255,0,255))
pal.setDisabled(cg)
self.textLabel1.setPalette(pal)
self.pushButton2 = QPushButton(self,"pushButton2")
self.pushButton2.setGeometry(QRect(620,330,141,31))
self.pushButton3 = QPushButton(self,"pushButton3")
self.pushButton3.setGeometry(QRect(620,370,141,31))
self.table1 = QTable(self,"table1")
self.table1.setGeometry(QRect(30,20,800,310))
self.table1.setLineWidth(1)
self.table1.setNumRows(101)
self.table1.setNumCols(15)
self.languageChange()
self.resize(QSize(866,656).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)
self.connect(self.pushButton2,SIGNAL("clicked()"),self.addMatrix)
self.connect(self.pushButton3,SIGNAL("clicked()"),self.addMem)
def languageChange(self):
self.setCaption(self.__tr("Form2"))
self.textLabel1.setText(QString.null)
self.pushButton2.setText(self.__tr("Generar BD"))
self.pushButton3.setText(self.__tr("Memoria"))
def addMatrix(self):
filas = self.table1.numRows()
#.........这里部分代码省略.........
示例6: ChannelWidgetSettingsDialog
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
class ChannelWidgetSettingsDialog(QDialog):
value_display_widgets = { "LCD": QLCDNumber,
"label": QLabel,
"combo": QComboBox,
"editable": QLineEdit }
alignment_flags = { 'vleft': Qt.AlignLeft | Qt.AlignBottom,
'vright': Qt.AlignRight | Qt.AlignBottom,
'vcentre': Qt.AlignHCenter | Qt.AlignBottom,
'hleft': Qt.AlignLeft | Qt.AlignVCenter,
'hright': Qt.AlignRight | Qt.AlignVCenter,
'hcentre': Qt.AlignCenter }
def __init__(self, *args):
QDialog.__init__(self, *args)
self.setCaption("%s - channel properties" % str(self.name()))
self.innerbox = QSplitter(Qt.Horizontal, self)
grid = QGrid(2, self.innerbox)
grid.setSpacing(5)
grid.setMargin(5)
QLabel("Label", grid)
self.txtLabel = QLineEdit(grid)
QLabel("Label position", grid)
labelpos_group = QVButtonGroup(grid)
self.optLabelAbove = QRadioButton("above", labelpos_group)
self.optLabelLeft = QRadioButton("on the left", labelpos_group)
self.optLabelLeft.setChecked(True)
QLabel("Label alignment", grid)
labelalign_group = QHButtonGroup(grid)
self.optLabelAlignLeft = QRadioButton("left", labelalign_group)
self.optLabelAlignCenter = QRadioButton("centre", labelalign_group)
self.optLabelAlignRight = QRadioButton("right", labelalign_group)
self.optLabelAlignLeft.setChecked(True)
QLabel("Value display format", grid)
self.txtFormat = QLineEdit(grid)
QLabel("Value display style", grid)
self.lstChannelStyles = QComboBox(grid)
self.lstChannelStyles.insertStrList(["LCD", "label", "combo", "editable"])
QObject.connect(self.lstChannelStyles, SIGNAL('activated(int)'), self.lstChannelStylesChanged)
self.combopanel = QHBox(self.innerbox)
self.tblComboChoices = QTable(self.combopanel)
self.tblComboChoices.setNumCols(2)
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"]:
#.........这里部分代码省略.........
示例7: Grid
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
#.........这里部分代码省略.........
seleccion = tabla.selection(indiceseleccion)
if seleccion.leftCol()!=0 or seleccion.rightCol() < self.__idu.n_var()-1:
LOG.debug("Seleccionincorrecta:"+str(seleccion.leftCol())+","+str(seleccion.rightCol()))
from Driza.excepciones import SeleccionIncorrectaException
raise SeleccionIncorrectaException
def mostrar_t_reg(self):
"""Muestra el tab de casos"""
self.showPage(self.tab)
def mostrar_t_var(self):
"""Muestra el tab de variables"""
self.showPage(self.tab_2)
#Metodos privados
def __mostrar_t_var(self):
""" Representa la variable pos en la tabla de variables. Las propiedades de la variable las lee de los datos.
Si no se indica posicion, se entiende que se quiere rellenar toda la tabla
"""
LOG.debug("Actualizando tabla de variables completa")
if self.__nvar > (self.table2.numRows()-self.__idu.n_var()):
self.table2.setNumRows(self.__idu.n_var()+self.__nvar)
for fila in range(self.__idu.n_var(), self.table2.numRows()):
for columna in range(self.table2.numCols()):
self.table2.clearCell(fila, columna)
for indicevar in range(self.__idu.n_var()):
self.__mostrar_var(indicevar)
self.__mostrar_titulo_t_reg()
def __mostrar_var(self, pos):
"""Muestra una unica variable (fila) en la tabla segun el listado de variables"""
variable = self.__idu.var(pos)
self.table2.setText(pos, 0, str(variable.name()))
self.table2.setItem(pos, 1, self.__combotableitem())
self.table2.item(pos, 1).setCurrentItem(variable.tipo)
self.table2.setText(pos, 3, str(variable.descripcion))
self.table2.setText(pos, 2, str(variable.valorpordefecto))
self.table2.setItem(pos, 4, self.__botontableitem())
def __mostrar_t_reg(self):
""" Rellena la tabla de datos con los registros actuales
"""
if self.__nreg > (self.table1.numRows() - self.__idu.n_reg()):
self.table1.setNumRows(self.__idu.n_reg() + self.__nreg)
for i in range(self.__idu.n_reg()):
self.__mostrar_reg(i)
self.__mostrar_titulo_t_reg()
for i in range(self.__idu.n_reg(), self.table1.numRows()):
for j in range(self.table1.numCols()):
self.table1.clearCell(i, j)
for i in range(self.table1.numRows()):
for j in range(self.__idu.n_var(), self.table1.numCols()):
self.table1.clearCell(i, j)
self.__mostrar_lateral_t_reg()
def __mostrar_reg(self, pos):
"""Muestra un solo dato"""
if self.modoetiqueta:
for i in range(self.__idu.n_var()):
if hasattr(self.__idu[pos][i], "etiqueta"):
self.table1.setText(pos, i, self.__idu[pos][i].etiqueta())
else:
self.table1.setText(pos, i, str(self.__idu[pos][i]))
else:
for i in range(self.__idu.n_var()):
示例8: Canvasinfo
# 需要导入模块: from qttable import QTable [as 别名]
# 或者: from qttable.QTable import setText [as 别名]
class Canvasinfo(QWidget):
def __init__(self,parent = None,name = None,fl = 0):
QWidget.__init__(self,parent,name,fl)
if not name:
self.setName("Canvasinfo")
self.canvaslabels = QTable(self,"canvaslabels")
self.canvaslabels.setNumCols(2)
self.canvaslabels.horizontalHeader().setLabel(0,"X")
self.canvaslabels.horizontalHeader().setLabel(1,"Y")
self.canvaslabels.setNumRows(5)
for i in range (5):
self.canvaslabels.verticalHeader().setLabel(i,
QIconSet(QPixmap(sys.path[0]+"/larm_utilities/sprite%d.png" % (i + 1))),QString.null)
self.canvaslabels.setGeometry(QRect(0,20,300,128))
self.canvaslabels.setCursor(QCursor(13))
self.canvaslabels.setFocusPolicy(QTable.NoFocus)
self.canvaslabels.setFrameShape(QTable.StyledPanel)
self.canvaslabels.setResizePolicy(QTable.AutoOne)
self.canvaslabels.setReadOnly(1)
self.canvaslabels.setSelectionMode(QTable.NoSelection)
self.canvaslabels.setFocusStyle(QTable.FollowStyle)
self.label = QLabel(self,"label")
self.label.setGeometry(QRect(0,0,300,20))
self.label.setPaletteForegroundColor(QColor('gold'))
label_font = QFont(self.label.font())
label_font.setFamily("Pigiarniq Heavy")
self.label.setFont(label_font)
self.label.setAlignment(Qt.AlignCenter)
self.canvaslabels.setPaletteBackgroundColor(QColor(50, 50, 50))
self.canvaslabels.setPaletteForegroundColor(QColor('gold'))
self.canvaslabels.setColumnWidth(0, 132)
self.canvaslabels.setColumnWidth(1, 132)
self.canvaslabels.setShowGrid(False)
self.clearWState(Qt.WState_Polished)
self.connect(self,PYSIGNAL("showMachineLabel"),self.updateLabels)
self.connect(self,PYSIGNAL("hideMachineLabel"),self.deleteLabels)
def deleteLabels(self):
self.label.setText(QString())
for r in range(5):
for c in range(2):
self.canvaslabels.setText(r, c, QString())
def updateLabels(self,d):
#set label[0] as main label
self.label.setText(d[0])
#recurse through label[1] and set them
for r in range(len(d[1])):
for c in range(len(d[1][r])):
self.canvaslabels.setText(r, c, QString(d[1][r][c]))
def __tr(self,s,c = None):
return qApp.translate("Canvasinfo",s,c)