本文整理汇总了Python中vtk.qt4.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QVTKRenderWindowInteractor.setSizePolicy方法的具体用法?Python QVTKRenderWindowInteractor.setSizePolicy怎么用?Python QVTKRenderWindowInteractor.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk.qt4.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor
的用法示例。
在下文中一共展示了QVTKRenderWindowInteractor.setSizePolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AppWindow
# 需要导入模块: from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor [as 别名]
# 或者: from vtk.qt4.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor import setSizePolicy [as 别名]
class AppWindow(QtGui.QMainWindow):
def __init__(self, parent):
self.parent = parent
self.queue = Queue.Queue()
self.processThread = ProcessingThread(self.queue)
#self.processThread = threading.Thread(target=self.consumer.run())
self.processThread.start()
self.fileLoader = DicomLoader(self, "file")
self.folderLoader = DicomLoader(self, "series")
self.importSrc()
self.initGUI()
self.initToolbar()
self.initConnections()
def importSrc(self):
# will be shown as errors in pyCharm
pass
def exit(self):
self.close()
def initConnections(self):
self.connect(self.ui.actionLoad, QtCore.SIGNAL("triggered()"), self.loadSingleFile)
self.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.exit)
def initGUI(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setWindowTitle("Simple Dicom Viewer")
#self.dicomReader = vtk.vtkDICOMImageReader()
#self.dicomReader = vtkgdcm.vtkGDCMImageReader()
self.show()
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.ui.numpyLayout.addWidget(self.toolbar)
self.ui.numpyLayout.addWidget(self.canvas)
self.vtkWidget = QVTKRenderWindowInteractor(self.ui.imageFrame)
self.vtkWidget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
#self.ui.imageLayout.removeWidget(self.ui.dicomSlider)
self.ui.imageLayout.addWidget(self.vtkWidget)
#self.ui.imageLayout.addWidget(self.ui.dicomSlider)
self.disableSlider()
self.viewer= vtk.vtkImageViewer()
#self.viewer.SetupInteractor(MyInteractor())
self.vtkWidget.GetRenderWindow().AddRenderer(self.viewer.GetRenderer())
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
#self.iren.SetRenderWindow(self.vtkWidget.GetRenderWindow())
self.drag = False
self.measuring = False
self.iren.AddObserver("LeftButtonPressEvent", self.leftClick)
self.iren.AddObserver("LeftButtonReleaseEvent", self.leftRelease)
self.iren.AddObserver("EnterEvent", self.mouseEntered)
self.iren.AddObserver("LeaveEvent", self.mouseLeft)
self.iren.AddObserver("MouseMoveEvent", self.mouseMoved)
def mouseMoved(self, *args):
if self.drag:
self.temp = args[0].GetEventPosition()
print(self.temp)
print(self.begin)
self.drawLine([self.begin, self.temp])
return
time.sleep(0.1)
#print(args[0].GetEventPosition())
def mouseEntered(self, *args):
self.drag = False
print("Entered")
def mouseLeft(self, *args):
self.drag = False
print("Left")
def leftClick(self, *args):
if self.measuring:
if self.drag == False:
self.drag = True
self.begin = args[0].GetEventPosition()
print(self.begin)
print(self.drag)
else:
self.drag = False
self.end = args[0].GetEventPosition()
self.drawLine([self.begin, self.end])
self.printDistance(self.dist)
def leftRelease(self, *args):
#self.drag = False
#.........这里部分代码省略.........
示例2: Ui_MainWindow
# 需要导入模块: from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor [as 别名]
# 或者: from vtk.qt4.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor import setSizePolicy [as 别名]
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(790, 571)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.gridlayout = QtGui.QGridLayout(self.centralWidget)
self.gridlayout.setObjectName("gridlayout")
self.splitter_2 = QtGui.QSplitter(self.centralWidget)
self.splitter_2.setOrientation(QtCore.Qt.Horizontal)
self.splitter_2.setObjectName("splitter_2")
self.splitter = QtGui.QSplitter(self.splitter_2)
self.splitter.setOrientation(QtCore.Qt.Vertical)
self.splitter.setObjectName("splitter")
self.listWidget = QtGui.QListWidget(self.splitter)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.listWidget.sizePolicy().hasHeightForWidth())
self.listWidget.setSizePolicy(sizePolicy)
self.listWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.listWidget.setSelectionRectVisible(False)
self.listWidget.setObjectName("listWidget")
self.tabWidget = QtGui.QTabWidget(self.splitter)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(5)
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
self.tabWidget.setSizePolicy(sizePolicy)
self.tabWidget.setTabShape(QtGui.QTabWidget.Rounded)
self.tabWidget.setObjectName("tabWidget")
self.tab = QtGui.QWidget()
self.tab.setObjectName("tab")
self.hSlider_basisIndex = QtGui.QSlider(self.tab)
self.hSlider_basisIndex.setGeometry(QtCore.QRect(10, 160, 160, 22))
self.hSlider_basisIndex.setMaximum(10)
self.hSlider_basisIndex.setOrientation(QtCore.Qt.Horizontal)
self.hSlider_basisIndex.setObjectName("hSlider_basisIndex")
self.label_basisIndex = QtGui.QLabel(self.tab)
self.label_basisIndex.setGeometry(QtCore.QRect(10, 140, 161, 17))
self.label_basisIndex.setObjectName("label_basisIndex")
self.spinBox_basisIndex = QtGui.QSpinBox(self.tab)
self.spinBox_basisIndex.setGeometry(QtCore.QRect(180, 150, 63, 27))
self.spinBox_basisIndex.setReadOnly(True)
self.spinBox_basisIndex.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)
self.spinBox_basisIndex.setObjectName("spinBox_basisIndex")
self.label_level = QtGui.QLabel(self.tab)
self.label_level.setGeometry(QtCore.QRect(10, 10, 171, 17))
self.label_level.setObjectName("label_level")
self.spinBox_level = QtGui.QSpinBox(self.tab)
self.spinBox_level.setGeometry(QtCore.QRect(180, 20, 63, 27))
self.spinBox_level.setReadOnly(True)
self.spinBox_level.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)
self.spinBox_level.setObjectName("spinBox_level")
self.hSlider_level = QtGui.QSlider(self.tab)
self.hSlider_level.setGeometry(QtCore.QRect(10, 30, 160, 22))
self.hSlider_level.setOrientation(QtCore.Qt.Horizontal)
self.hSlider_level.setObjectName("hSlider_level")
self.label_cutoff = QtGui.QLabel(self.tab)
self.label_cutoff.setGeometry(QtCore.QRect(10, 64, 221, 17))
self.label_cutoff.setObjectName("label_cutoff")
self.lineEdit_cutoff = QtGui.QLineEdit(self.tab)
self.lineEdit_cutoff.setGeometry(QtCore.QRect(10, 84, 91, 22))
self.lineEdit_cutoff.setLayoutDirection(QtCore.Qt.RightToLeft)
self.lineEdit_cutoff.setObjectName("lineEdit_cutoff")
self.label_cutoff_minmax = QtGui.QLabel(self.tab)
self.label_cutoff_minmax.setGeometry(QtCore.QRect(110, 90, 121, 17))
font = QtGui.QFont()
font.setPointSize(11)
self.label_cutoff_minmax.setFont(font)
self.label_cutoff_minmax.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label_cutoff_minmax.setObjectName("label_cutoff_minmax")
self.line = QtGui.QFrame(self.tab)
self.line.setGeometry(QtCore.QRect(10, 110, 231, 16))
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
self.label_basisCutoff_minmax = QtGui.QLabel(self.tab)
self.label_basisCutoff_minmax.setGeometry(QtCore.QRect(110, 221, 121, 17))
font = QtGui.QFont()
font.setPointSize(11)
self.label_basisCutoff_minmax.setFont(font)
self.label_basisCutoff_minmax.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label_basisCutoff_minmax.setObjectName("label_basisCutoff_minmax")
self.label_basisCutoff = QtGui.QLabel(self.tab)
self.label_basisCutoff.setGeometry(QtCore.QRect(10, 195, 221, 17))
self.label_basisCutoff.setObjectName("label_basisCutoff")
self.lineEdit_basisCutoff = QtGui.QLineEdit(self.tab)
self.lineEdit_basisCutoff.setGeometry(QtCore.QRect(10, 215, 91, 22))
self.lineEdit_basisCutoff.setLayoutDirection(QtCore.Qt.RightToLeft)
self.lineEdit_basisCutoff.setObjectName("lineEdit_basisCutoff")
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtGui.QWidget()
self.tab_2.setObjectName("tab_2")
self.tabWidget.addTab(self.tab_2, "")
self.vtkWidget = QVTKRenderWindowInteractor(self.splitter_2)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(10)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.vtkWidget.sizePolicy().hasHeightForWidth())
#.........这里部分代码省略.........
示例3: QVTKRenderWindowInteractor
# 需要导入模块: from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor [as 别名]
# 或者: from vtk.qt4.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor import setSizePolicy [as 别名]
tool2.toggled.connect(editSwc)
toolbar1.addAction(tool2)
tool3 = QtGui.QAction(toolbar1)
tool3_icon = QtGui.QIcon()
tool3_icon.addFile(r'G:\sulei\workplace\TraceTool\Resource\Science.png')
tool3.setIcon(tool3_icon)
tool3.triggered.connect(changeLineWidth)
toolbar1.addAction(tool3)
mainwin.addToolBar(toolbar1)
mainwin.setMenuBar(menubar1)
mainwin_location = QtCore.QRect(600, 300, 400, 400)
mainwin.setMaximumSize(400, 400)
mainwin.setGeometry(mainwin_location)
central_widget = QtGui.QWidget(mainwin)
mainwin.setCentralWidget(central_widget)
layout1 = QtGui.QHBoxLayout()
central_widget.setLayout(layout1)
vtk_widget = QVTKRenderWindowInteractor(central_widget)
vtk_widget.setMinimumSize(50, 50)
layout1.addWidget(vtk_widget)
vtk_widget.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
ren = vtk.vtkRenderer()
style1 = SwcEditStyle()
iren = vtk_widget.GetRenderWindow().GetInteractor()
iren.SetInteractorStyle(style1)
vtk_widget.Initialize()
vtk_widget.Start()
mainwin.show()
sys.exit(app.exec_())