本文要实现的是在按下两个按钮,分别打印两句话
步骤1:先通过Extension Wizard建立出scripted模块

将模块的名字命名为Test
步骤2:找到名为Test.py的文件
将里面的代码修改成下面这样
import logging
import os
import vtk
import slicer
from slicer.ScriptedLoadableModule import *
from slicer.util import VTKObservationMixin
class Test(ScriptedLoadableModule):
"""Uses ScriptedLoadableModule base class, available at:
https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
"""
def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
self.parent.title = "Test" # TODO: make this more human readable by adding spaces
self.parent.categories = ["Examples"] # TODO: set categories (folders where the module shows up in the module selector)
self.parent.dependencies = [] # TODO: add here list of module names that this module requires
self.parent.contributors = ["John Doe (AnyWare Corp.)"] # TODO: replace with "Firstname Lastname (Organization)"
# TODO: update with short description of the module and a link to online module documentation
self.parent

本文介绍如何在Slicer模块中添加两个按钮,并设置点击事件来打印消息,包括创建scripted模块、修改Python代码及实现界面布局的具体步骤。
最低0.47元/天 解锁文章
2199






