Пример #1
0
  def add_widgets(self, instructions):
    if self.processingCollapsibleButton is not None:
      self.processingCollapsibleButton.deleteLater()
    self.processingCollapsibleButton = ctk.ctkCollapsibleButton()
    self.processingCollapsibleButton.text = "Processing"
    self.layout.addWidget(self.processingCollapsibleButton)

    self.processingFormLayout = qt.QFormLayout(self.processingCollapsibleButton)

    # Add vertical spacer
    self.layout.addStretch(1)

    self.widgets = []

    for instruction in instructions:
      if instruction['type'] == 'volume':
        volume = ScalarVolumeWidget(destination=instruction['destination'])
        self.widgets.append(volume)
        self.processingFormLayout.addRow('{} Volume: '.format(instruction['destination']), volume)

      if instruction['type'] == 'fiducials':
        fiducial = MarkupsFiducialWidget(destination=instruction['destination'])
        self.widgets.append(fiducial)
        self.processingFormLayout.addRow('{} Fiducials: '.format(instruction['destination']), fiducial)

      if instruction['type'] == 'slider':
        slider = SliderWidget(
          destination=instruction['destination'],
          minimum=instruction['minimum'],
          maximum=instruction['maximum']
        )
        self.widgets.append(slider)
        self.processingFormLayout.addRow('{} Slider: '.format(instruction['destination']), slider)

      if instruction['type'] == 'checkbox':
        checkbox = CheckboxWidget(
          destination=instruction['destination'],
          text=instruction['text']
        )
        self.widgets.append(checkbox)
        self.processingFormLayout.addRow('{} Checkbox: '.format(instruction['destination']), checkbox)

      if instruction['type'] == 'radiobutton':
        radiobox = RadioButtonWidget(
          destination=instruction['destination'],
          options=instruction['options']
        )
        self.widgets.append(radiobox)
        self.processingFormLayout.addRow('{} Options: '.format(instruction['text']), radiobox)

    self.applyButton = add_button('Process', 'Run the algorithm', enabled=True)

    self.processingFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
Пример #2
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.predictionUrl = ''
        self.interfaceUrl = ''
        self.clearToSendMsg = False
        # Instantiate and connect widgets ...

        #
        # LOGO area
        #
        logoCollapsibleButton = collapsible_button('Info')

        self.layout.addWidget(logoCollapsibleButton)
        self.logolayout = qt.QFormLayout(logoCollapsibleButton)

        self.logolabel, _ = \
            add_image(os.path.join(os.path.split(os.path.realpath(__file__))[0], "Resources/Icons/TOMAAT_INFO.png"))

        self.logolayout.addRow(self.logolabel)

        #
        # Direct Connection area
        #
        directConnectionCollapsibleButton = collapsible_button(
            'Direct Connection')
        self.layout.addWidget(directConnectionCollapsibleButton)
        self.directConnectionLayout = qt.QFormLayout(
            directConnectionCollapsibleButton)

        self.urlBoxDirectConnection = add_textbox("https://localhost:9000")

        self.urlBoxButton = add_button(text='Confirm',
                                       tooltip_text='Confirm entry',
                                       click_function=self.select_from_textbox,
                                       enabled=True)

        self.directConnectionLayout.addRow("Server URL: ",
                                           self.urlBoxDirectConnection)

        self.directConnectionLayout.addRow(self.urlBoxButton)

        directConnectionCollapsibleButton.collapsed = True

        #
        # Managed Connection area
        #
        managedConenctionCollapsibleButton = collapsible_button(
            'Public Server List')
        self.layout.addWidget(managedConenctionCollapsibleButton)

        self.managedConnectionLayout = qt.QFormLayout(
            managedConenctionCollapsibleButton)

        self.urlBoxManagedConnection = add_textbox(
            "http://tomaat.cloud:8001/discover")

        self.managedConnectionLayout.addRow("Discovery Server URL: ",
                                            self.urlBoxManagedConnection)

        self.serviceTree = qt.QTreeWidget()
        self.serviceTree.setHeaderLabel('Available services')
        self.serviceTree.itemSelectionChanged.connect(self.select_from_tree)

        self.discoverServicesButton = add_button(
            "Discover Services",
            "Discover available segmentation services on the net.",
            self.onDiscoverButton, True)

        self.serviceDescription = add_label('')

        self.managedConnectionLayout.addRow(self.discoverServicesButton)

        self.managedConnectionLayout.addRow(self.serviceTree)

        self.managedConnectionLayout.addRow(self.serviceDescription)

        self.processingCollapsibleButton = None