# TypeError: 'NoneType' object is not callable

**URL:** https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030
**Category:** Support
**Tags:** python, module
**Created:** [January 4, 2023, 2:26pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030 "2023-01-04T14:26:18Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 4, 2023, 2:26pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/1 "2023-01-04T14:26:18Z")

</div>

Hey all,

I’m developing a module to Slicer and I’m facing some issues. One of the functionalities is to place a control point and get its coordinates through a button that calls a method. I put a `print` on the beggining of this method and it’s called right when I start the module, but when I place de control point and click the button it gives this error: `TypeError: 'NoneType' object is not callable`

```auto
def setup(self):
      
        ScriptedLoadableModuleWidget.setup(self)

        uiWidget = slicer.util.loadUI(self.resourcePath('UI/Module.ui'))
        self.layout.addWidget(uiWidget)
        self.ui = slicer.util.childWidgetVariables(uiWidget)

        markupsNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode")
        self.ui.PontoCentralButton.setCurrentNode(markupsNode)
        self.ui.PontoCentralButton.buttonsVisible=False
        self.ui.PontoCentralButton.placeButton().show()
        self.ui.PontoCentralButton.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceSingleMarkup

        uiWidget.setMRMLScene(slicer.mrmlScene)

# [...]

        # Buttons
        self.ui.CoordsButton.connect("clicked(bool)", self.logic.coordCentral(self.ui.MRMLNodeComboBox_frame.currentNode(),markupsNode))

```

```auto
def coordCentral(self, inputFrame, markupsNode):
        print("method called ")

```

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [January 4, 2023, 3:17pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/2 "2023-01-04T15:17:24Z")

</div>

My guess is that `self.ui.MRMLNodeComboBox_frame` is the NoneType object. Make sure your UI file has this object with this exact objectName of MRMLNodeComboBox\_frame and that you have saved this UI file (not unsaved changes).

---

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 4, 2023, 4:17pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/3 "2023-01-04T16:17:08Z")

</div>

Hi James, I checked that but it’s the exact same name. And the .ui file is saved too

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [January 4, 2023, 5:54pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/4 "2023-01-04T17:54:21Z")

</div>

I would suggest you do some continued debugging to find the NoneType object. Adding a print statement for `self.ui.MRMLNodeComboBox_frame` will help confirm if it is indeed an object or a NoneType.

---

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 5, 2023, 12:05pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/5 "2023-01-05T12:05:10Z")

</div>

I printed the `inputFrame` on `coordCentral`, where `inputFrame = self.ui.MRMLNodeComboBox_frame` and it returned this:

```auto
vtkMRMLViewNode (000001CC95966B90)
  ID: vtkMRMLViewNode1
  ClassName: vtkMRMLViewNode
  Name: View1
  Debug: false
  MTime: 227115
  Description: (none)
  SingletonTag: 1
  HideFromEditors: false
  Selectable: true
  Selected: false
  UndoEnabled: false
  Attributes:
    MappedInLayout:1
  Node references:
    InteractionNodeRef: (none)
    ParentLayoutNodeRef: (none)
  LayoutLabel: 1
  ViewGroup: 0
  Active: 0
  Visibility: 1
  BackgroundColor: (0.756863, 0.764706, 0.909804)
  BackgroundColor2: (0.454902, 0.470588, 0.745098)
  LayoutColor: (0.454902, 0.513725, 0.913725)
  OrientationMarkerType: none
  OrientationMarkerSize: medium
  RulerType: none
  RulerColor: white
   AxisLabels: L;R;P;A;I;S
  FieldOfView: 200
  LetterSize: 0.05
  BoxVisible: true
  BoxColor: (1, 0, 1)
  FiducialsVisible: true
  FiducialLabelsVisible: true
  AxisLabelsVisible: true
  AxisLabelsCameraDependent: true
  AnimationMode: Off
  ViewAxisMode: LookFrom
  SpinDegrees: 2
  AnimationMs: 5
  SpinDirection: YawLeft
  RotateDegrees: 5
  RockLength: 200
  RockCount: 0
  StereoType: NoStereo
  RenderMode: Perspective
  UseDepthPeeling: 1
  GPUMemorySize: 0
  AutoReleaseGraphicsResources: false
  ExpectedFPS: 8
  VolumeRenderingQuality: 1
  RaycastTechnique: 0
  VolumeRenderingSurfaceSmoothing: 0
  VolumeRenderingOversamplingFactor: 2
  Interacting: 0
  LinkedControl: 0

```

From `Description: (none)` it seems to be a NoneType right? But again the method was called right when the module started, before selecting the input node and placing the control point. So I’m guessing that’s why it’s NoneType.

Don’t know why this is happening.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [January 5, 2023, 12:20pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/6 "2023-01-05T12:20:07Z")

</div>

Please copy-paste the whole error message you get. Without it it is only possible to keep guessing around.

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [January 5, 2023, 12:35pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/7 "2023-01-05T12:35:35Z")

</div>

You seem to be using

```auto
self.ui.PontoCentralButton

```

and

```auto
self.ui.CoordsButton

```

in your example, which will probably not work …

---

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 5, 2023, 12:37pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/8 "2023-01-05T12:37:49Z")

</div>

I copied on the original qustion: `TypeError: 'NoneType' object is not callable`

There’s nothing else.

---

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 5, 2023, 12:47pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/9 "2023-01-05T12:47:27Z")

</div>

They are different things actually. I don’t know if that’s the most effiecient way because I’m new to Slicer but the idea is: the user place a control point trought the Markups Control Point button (`PontoCentralButton`), and when it’s placed they click on the “Coordenadas” button (`CoordsButton`), wich should call the method and get the coordinates of that control point.

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/3/236c59c254db88eb57b2cb4d0da63ae95fcb7102.png)

Hope this helps to give more context to the problem.

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [January 5, 2023, 1:20pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/10 "2023-01-05T13:20:39Z")

</div>

Please put your function into the YourExtensionWidget class, not into the YourExtensionLogic.

Connect it like:

```auto
      self.ui.toggleButton.connect('clicked(bool)', self.onToggleButton)

```

Hope that helps.

---

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 5, 2023, 1:35pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/11 "2023-01-05T13:35:24Z")

</div>

Unfortunately the same behavior happens ☹  
I made `onToggleButton` call the processing function on the Logic class too, but it didn’t work either.

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [January 5, 2023, 1:55pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/12 "2023-01-05T13:55:15Z")

</div>

Maybe you can print the coordinates of your markup [like described here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-volume-voxel-coordinates-from-markup-control-point-ras-coordinates) and avoid passing the view argument.

---

<div class="post-metadata">

### Author: ![LuisaDantas](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@LuisaDantas](https://discourse.slicer.org/u/LuisaDantas)
#### Post date: [January 5, 2023, 2:14pm UTC](https://discourse.slicer.org/t/typeerror-nonetype-object-is-not-callable/27030/13 "2023-01-05T14:14:46Z")

</div>

Great, I’ll try that and let you know if it works, thanks!
