def generateWidget( self, idGDT, ContainerOfData ):
self.idGDT = idGDT
self.ContainerOfData = ContainerOfData
self.checkBox = QtGui.QCheckBox(self.Text)
self.checkBox.setChecked(True)
global checkBoxState
checkBoxState = True
hbox = QtGui.QHBoxLayout()
hbox.addWidget(self.checkBox)
hbox.addStretch(1)
self.checkBox.stateChanged.connect(self.updateState)
return hbox
python类QHBoxLayout()的实例源码
def setupUi(self, type_widget):
type_widget.setObjectName("type_widget")
type_widget.resize(248, 78)
self.horizontalLayout_2 = QtGui.QHBoxLayout(type_widget)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.type_icon = QtGui.QLabel(type_widget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.type_icon.sizePolicy().hasHeightForWidth())
self.type_icon.setSizePolicy(sizePolicy)
self.type_icon.setObjectName("type_icon")
self.horizontalLayout_2.addWidget(self.type_icon)
spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.line = QtGui.QFrame(type_widget)
self.line.setFrameShape(QtGui.QFrame.VLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
self.horizontalLayout_2.addWidget(self.line)
spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.type_label = QtGui.QLabel(type_widget)
font = QtGui.QFont()
font.setFamily("Cantarell")
font.setPointSize(10)
font.setWeight(75)
font.setBold(True)
self.type_label.setFont(font)
self.type_label.setObjectName("type_label")
self.horizontalLayout_2.addWidget(self.type_label)
self.retranslateUi(type_widget)
QtCore.QMetaObject.connectSlotsByName(type_widget)
def setupUi(self):
self.setAutoFillBackground(True)
hLayout = QtGui.QHBoxLayout(self)
self.setLayout(hLayout)
self.taskNameWidget = QtGui.QLineEdit(self.task.name)
self.priorityWidget = PriorityWidget()
self.priorityWidget.setValue(self.task.priority)
self.statusWidget = StatusWidgetBar()
self.statusWidget.setCurrentIndex(self.task.status)
self.deleteWidget = DeleteWidget('delete')
hLayout.addWidget(self.taskNameWidget)
hLayout.addWidget(self.priorityWidget)
hLayout.addWidget(self.statusWidget)
hLayout.addWidget(self.deleteWidget)
def setupUI(self):
mainLayout = QtGui.QVBoxLayout()
self.setLayout(mainLayout)
self.buttonLayout = QtGui.QHBoxLayout()
self.msg = QtGui.QLabel()
self.addTaskButton = QtGui.QPushButton('Add Task')
self.addTaskButton.setToolTip('Add a new task to the list')
self.sortButton = QtGui.QPushButton('Reverse Sorting')
self.sortButton.setCheckable(True)
self.sortButton.setToolTip('Push to sort so highest priorities are at the top,\notherwise lowest will be at the top.')
self.helpButton = QtGui.QPushButton('?')
self.helpButton.setMaximumWidth(30)
self.helpButton.setFlat(True)
self.helpButton.setToolTip(self.__helpText())
self.hideButton = QtGui.QPushButton('Hide Finished Tasks')
self.hideButton.setCheckable(True)
self.hideButton.setToolTip('Hide finished tasks to keep the list tidy')
self.clipboardButton = QtGui.QPushButton('Copy To Clipboard')
self.clipboardButton.setToolTip('Push to copy current task info to cliboard for pasting into emails or other text documents.\nHandy to keep those coordinators happy.')
self.buttonLayout.addWidget(self.addTaskButton)
self.buttonLayout.addWidget(self.sortButton)
self.buttonLayout.addWidget(self.hideButton)
self.buttonLayout.addWidget(self.clipboardButton)
self.buttonLayout.addSpacing(20)
self.buttonLayout.addWidget(self.helpButton)
self.layout().addWidget(self.msg)
self.layout().addLayout(self.buttonLayout)
self.taskContainer = QtGui.QWidget()
self.scrollArea = QtGui.QScrollArea()
self.scrollArea.setWidget(self.taskContainer)
self.layout().addWidget(self.scrollArea)
self.createTaskWidgets()
self.update()
def __init__(self, templateData, parcelationData, axis, correlationTable, colorTable, selectedColor):
super(SliceViewer, self).__init__()
self.template = templateData
self.regionId = None
self.parcelation = parcelationData
self.axis = axis
self.CommunityMode = False
self.correlationTable = correlationTable
self.colorTable= colorTable
self.selectedColor = selectedColor
self.displayedSlice = 0
self.QImage = []
scalefactor = 350
self.scaleFactor = int(math.ceil(scalefactor / self.parcelation.shape[0]))
numColors = self.parcelation.max()
self.clut = np.zeros(numColors, dtype=np.uint32)
for i in range(numColors):
r, g, b = colorsys.hls_to_rgb(float(i) / float(numColors), 0.5, 1.0)
self.clut[i] = (255 << 24 | int(255*r) << 16 | int(255*g) << 8 | int(255*b))
slice_view_layout = QtGui.QHBoxLayout()
self.setLayout(slice_view_layout)
slider = QtGui.QSlider()
slider.setRange(0, self.template.shape[self.axis]-1)
slider.valueChanged.connect(self.setDisplayedSlice)
slider.sliderReleased.connect(self.handleSliderRelease)
slider.setValue(self.displayedSlice)
slice_view_layout.addWidget(slider)
self.label = QtGui.QLabel()
self.updateSliceLabel()
slice_view_layout.addWidget(self.label)
def __init__(self, parent=None, win=None, current_class=None, class_analysis=None):
super(XrefDialogClass, self).__init__(parent)
self.current_class = current_class
self.class_analysis = class_analysis
title = "Xrefs for the class %s" % current_class
self.setWindowTitle(title)
xrefs_list = []
ref_kind_map = {0:"Class instanciation", 1:"Class reference"}
xrefs_from = class_analysis.get_xref_from()
for ref_class in xrefs_from:
for ref_kind, ref_method in xrefs_from[ref_class]:
xrefs_list.append(('From', ref_kind_map[ref_kind], ref_method, ref_class.get_vm_class()))
xrefs_to = class_analysis.get_xref_to()
for ref_class in xrefs_to:
for ref_kind, ref_method in xrefs_to[ref_class]:
xrefs_list.append(('To', ref_kind_map[ref_kind], ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list, headers=["Origin", "Kind", "Method"])
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def __init__(self, parent=None, win=None, current_class=None, class_analysis=None, method_analysis=None):
super(XrefDialogMethod, self).__init__(parent)
self.current_class = current_class
self.class_analysis = class_analysis
self.method_analysis = method_analysis
title = "Xrefs for the method %s" % self.method_analysis.method
self.setWindowTitle(title)
xrefs_list = []
xrefs_from = self.method_analysis.get_xref_from()
for ref_class, ref_method in xrefs_from:
xrefs_list.append(('From', ref_method, ref_class.get_vm_class()))
xrefs_to = self.method_analysis.get_xref_to()
for ref_class, ref_method in xrefs_to:
xrefs_list.append(('To', ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list)
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def __init__(self, parent=None, win=None, current_class=None, class_analysis=None, field_analysis=None):
super(XrefDialogField, self).__init__(parent)
self.current_class = current_class
self.class_analysis = class_analysis
self.field_analysis = field_analysis
title = "Xrefs for the field %s" % self.field_analysis.field
self.setWindowTitle(title)
xrefs_list = []
xrefs_read = self.field_analysis.get_xref_read()
for ref_class, ref_method in xrefs_read:
xrefs_list.append(('Read', ref_method, ref_class.get_vm_class()))
xrefs_write = self.field_analysis.get_xref_write()
for ref_class, ref_method in xrefs_write:
xrefs_list.append(('Write', ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list)
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def __init__(self, parent=None, win=None, string_analysis=None):
super(XrefDialogString, self).__init__(parent)
self.string_analysis = string_analysis
title = "Xrefs for the string %s" % self.string_analysis.value
self.setWindowTitle(title)
xrefs_list = []
xrefs_from = self.string_analysis.get_xref_from()
for ref_class, ref_method in xrefs_from:
xrefs_list.append(('From', ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list)
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def __init__(self, parent=None, win=None, current_class=None, class_analysis=None):
super(XrefDialogClass, self).__init__(parent)
self.current_class = current_class
self.class_analysis = class_analysis
title = "Xrefs for the class %s" % current_class
self.setWindowTitle(title)
xrefs_list = []
ref_kind_map = {0:"Class instanciation", 1:"Class reference"}
xrefs_from = class_analysis.get_xref_from()
for ref_class in xrefs_from:
for ref_kind, ref_method in xrefs_from[ref_class]:
xrefs_list.append(('From', ref_kind_map[ref_kind], ref_method, ref_class.get_vm_class()))
xrefs_to = class_analysis.get_xref_to()
for ref_class in xrefs_to:
for ref_kind, ref_method in xrefs_to[ref_class]:
xrefs_list.append(('To', ref_kind_map[ref_kind], ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list, headers=["Origin", "Kind", "Method"])
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def __init__(self, parent=None, win=None, current_class=None, class_analysis=None, field_analysis=None):
super(XrefDialogField, self).__init__(parent)
self.current_class = current_class
self.class_analysis = class_analysis
self.field_analysis = field_analysis
title = "Xrefs for the field %s" % self.field_analysis.field
self.setWindowTitle(title)
xrefs_list = []
xrefs_read = self.field_analysis.get_xref_read()
for ref_class, ref_method in xrefs_read:
xrefs_list.append(('Read', ref_method, ref_class.get_vm_class()))
xrefs_write = self.field_analysis.get_xref_write()
for ref_class, ref_method in xrefs_write:
xrefs_list.append(('Write', ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list)
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def __init__(self, parent=None, win=None, string_analysis=None):
super(XrefDialogString, self).__init__(parent)
self.string_analysis = string_analysis
title = "Xrefs for the string %s" % self.string_analysis.value
self.setWindowTitle(title)
xrefs_list = []
xrefs_from = self.string_analysis.get_xref_from()
for ref_class, ref_method in xrefs_from:
xrefs_list.append(('From', ref_method, ref_class.get_vm_class()))
closeButton = QtGui.QPushButton("Close")
closeButton.clicked.connect(self.close)
xreflayout = QtGui.QGridLayout()
xrefwin = XrefListView(self, win=win, xrefs=xrefs_list)
xreflayout.addWidget(xrefwin, 0, 0)
buttonsLayout = QtGui.QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(xreflayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
def create_directory_choose(self):
group_box = QtGui.QGroupBox('An awesome web project called:')
title_hbox = QHBoxLayout()
title_hbox.setContentsMargins(10, 10, 10, 10)
win_icon = self.create_icon_box('window_icon', 'Window Icon')
exe_icon = self.create_icon_box('exe_icon', 'Exe Icon')
mac_icon = self.create_icon_box('mac_icon', 'Mac Icon')
self.title_label = QtGui.QLabel('TBD')
self.title_label.setStyleSheet('font-size:20px; font-weight:bold;')
title_hbox.addWidget(self.title_label)
title_hbox.addWidget(QtGui.QLabel())
title_hbox.addWidget(win_icon)
title_hbox.addWidget(exe_icon)
title_hbox.addWidget(mac_icon)
vlayout = QtGui.QVBoxLayout()
vlayout.setSpacing(5)
vlayout.setContentsMargins(10, 5, 10, 5)
vlayout.addLayout(title_hbox)
#vlayout.addLayout(input_layout)
#vlayout.addLayout(output_layout)
group_box.setLayout(vlayout)
return group_box
def create_text_input_with_file_setting(self, name):
hlayout = QtGui.QHBoxLayout()
setting = self.get_setting(name)
text = QtGui.QLineEdit()
text.setObjectName(setting.name)
button = QtGui.QPushButton('...')
button.setMaximumWidth(30)
button.setMaximumHeight(26)
button.clicked.connect(self.call_with_object('get_file', button,
text, setting))
if setting.value:
text.setText(setting.value)
text.setStatusTip(setting.description)
text.setToolTip(setting.description)
text.textChanged.connect(self.call_with_object('setting_changed',
text, setting))
hlayout.addWidget(text)
hlayout.addWidget(button)
return hlayout
def create_color_setting(self, name):
hlayout = QtGui.QHBoxLayout()
setting = self.get_setting(name)
color_disp = ColorDisplay(setting.value or setting.default_value)
color_disp.setObjectName(setting.name)
color_disp.setContentsMargins(5, 5, 5, 5)
button = QtGui.QPushButton('Choose...')
button.setMaximumWidth(100)
button.setMaximumHeight(26)
button.clicked.connect(self.call_with_object('get_color', button,
color_disp,
setting.value or setting.default_value,
setting))
if setting.value:
color_disp.setColor(setting.value)
color_disp.setStatusTip(setting.description)
color_disp.setToolTip(setting.description)
color_disp.colorChanged.connect(self.call_with_object('setting_changed',
color_disp, setting))
hlayout.addWidget(color_disp)
hlayout.addWidget(button)
return hlayout
def create_text_input_with_folder_setting(self, name):
hlayout = QtGui.QHBoxLayout()
setting = self.get_setting(name)
text = QtGui.QLineEdit()
text.setObjectName(setting.name)
button = QtGui.QPushButton('...')
button.setMaximumWidth(30)
button.setMaximumHeight(26)
button.clicked.connect(self.call_with_object('get_folder', button,
text, setting))
if setting.value:
text.setText(setting.value)
text.setStatusTip(setting.description)
text.setToolTip(setting.description)
text.textChanged.connect(self.call_with_object('setting_changed',
text, setting))
hlayout.addWidget(text)
hlayout.addWidget(button)
return hlayout
def create_list_setting(self, name):
hlayout = QtGui.QHBoxLayout()
setting = self.get_setting(name)
button = None
if setting.button:
button = QtGui.QPushButton(setting.button)
button.clicked.connect(lambda: setting.button_callback(button))
combo = QtGui.QComboBox()
combo.setObjectName(setting.name)
combo.currentIndexChanged.connect(self.call_with_object('setting_changed',
combo, setting))
combo.editTextChanged.connect(self.call_with_object('setting_changed',
combo, setting))
combo.setStatusTip(setting.description)
combo.setToolTip(setting.description)
for val in setting.values:
combo.addItem(val)
default_index = combo.findText(setting.default_value)
if default_index != -1:
combo.setCurrentIndex(default_index)
hlayout.addWidget(QtGui.QLabel())
hlayout.addWidget(combo)
if button:
hlayout.addWidget(button)
return hlayout
def initUI(self):
self._layout = QtGui.QGridLayout(None)
self.setLayout(self._layout)
self._layout.setContentsMargins(0,5,0,5)
self._layout.setSpacing(0)
self._topBar = QtGui.QFrame()
self._topBarLayout = QtGui.QHBoxLayout(self._topBar)
self._refreshProgression = QtGui.QProgressBar()
self._refreshProgression.setMinimum(0)
self._refreshProgression.setMaximum(100)
self._refreshProgression.setValue(10)
self._refreshButton = QtGui.QPushButton("Refresh")
self._filterLabel = QtGui.QLabel("Filter :")
self._filterField = QtGui.QLineEdit()
self._topBarLayout.addWidget(self._refreshProgression)
self._topBarLayout.addWidget(self._refreshButton)
self._topBarLayout.addWidget(self._filterLabel)
self._topBarLayout.addWidget(self._filterField)
self.generateJobList()
self._layout.addWidget(self._topBar)
self._layout.addWidget(self._jobList)
self._autoRefresh = JobListAutoRefresh(self,self._refreshProgression)
#autoRefresh.run()
self._refreshButton.clicked.connect(self.startRefresh)
def initUI(self):
# Define Layout
self._layout = QtGui.QHBoxLayout()
self._layout.setContentsMargins(0,0,0,0)
self._layout.setSpacing(5)
self.setLayout(self._layout)
# Create Elements
self._label = QtGui.QPushButton(self._parameter.label())
self._field = QtGui.QLineEdit(str(self._parameter.value()))
self._slider = ParameterSlider()
self._layout.addWidget(self._label)
self._layout.addWidget(self._field)
self._layout.addWidget(self._slider)
def initUI(self):
self._mainLayout = QtGui.QHBoxLayout(self)
self.setLayout(self._mainLayout)
self.parmTypeList = ParameterTypeList(self)
self.parmTempList = ParameterTemplateList(self)
self._mainLayout.addWidget(self.parmTypeList)
self._mainLayout.addWidget(self.parmTempList)