from PySide.QtCore import Slot
from PySide import QtGui, QtCore
class Output(object):
def __init__(self, physical_type):
''' '''
self.layout.addWidget(self.group_box, 1)
def run(self):
self.tabs.addTab(self.__genTable(), "None")
form_layout = QtGui.QFormLayout(self.group_box)
form_layout.addWidget(self.tabs)
return self.layout
def __genTable(self, rows = 4, columns = 2):
table_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
table_view.
setSelectionBehavior( QtGui.
QTableView.
SelectItems )
table_view.horizontalHeader().sectionDoubleClicked.connect(self.changeHorizontalHeader)
return table_view
def changeHorizontalHeader(self, index):
model = self.tabs.currentWidget()
oldHeader = model.horizontalHeaderItem(index).text()
'Change header label for column {}'.format(index),
'Header:',
oldHeader)
if ok:
self.tabs.currentWidget().setText(newHeader)
from PySide.QtCore import Slot
from PySide import QtGui, QtCore
class Output(object):
def __init__(self, physical_type):
''' '''
self.group_box = QtGui.QGroupBox('Output')
self.layout = QtGui.QVBoxLayout()
self.layout.addWidget(self.group_box, 1)
self.tabs = QtGui.QTabWidget()
def run(self):
self.tabs.addTab(self.__genTable(), "None")
form_layout = QtGui.QFormLayout(self.group_box)
form_layout.addWidget(self.tabs)
return self.layout
def __genTable(self, rows = 4, columns = 2):
table_view = QtGui.QTableWidget(rows,columns)
table_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
table_view.setSelectionBehavior( QtGui.QTableView.SelectItems )
table_view.horizontalHeader().sectionDoubleClicked.connect(self.changeHorizontalHeader)
return table_view
def changeHorizontalHeader(self, index):
model = self.tabs.currentWidget()
oldHeader = model.horizontalHeaderItem(index).text()
newHeader, ok = QtGui.QInputDialog.getText(QtGui.QInputDialog(),
'Change header label for column {}'.format(index),
'Header:',
QtGui.QLineEdit.Normal,
oldHeader)
if ok:
self.tabs.currentWidget().setText(newHeader)
To copy to clipboard, switch view to plain text mode
Bookmarks