I am creating a Plugin, where on addFeature button, first user will get a dialog box to select the type of feature user wants to draw. On the basis of users choice, other editing constraints will get activated as defined for a layer. Currently I am able to create a dialog box with radio buttons for users selection and things are working correctly for first run, if user is following below steps in order.
- Start editing (Toggle Editing)
- Add Feature button
- Dialog box for users choice
- Editing by the user as per applied constraints
- Stop Editing (Toggle Editing)
The above steps are working fine for first run, but if user starts another editing session, then the dialog box is getting for 2 times and so on for further sessions.
While working on this, I found layer.editingStarted.connect(function), this signal is getting continued even after complete execution of function. I tried to disconnect this but not able to do it.
How can I disconnect the same or is there any other workaround for this problem?
My Code and Dialog box are attached for reference.
lyr=self.iface.activeLayer()
lyr.editingStarted.connect(lambda:fiber_add_feature(db,lyr))
def fiber_add_feature(self,db,vlyr):
if vlyr.name()=="Fiber Cable":
iface.actionAddFeature().triggered.connect(lambda: self.fiber_route_type(db,vlyr))
def fiber_route_type(self,db,lyr):
if lyr.name()=="Fiber Cable":
self.route_dlg=FiberRouteTypeDialog()
self.duct_require_dlg=DuctRequirementDialog()
if lyr.isEditable():
ar="Aerial"
ugr="Under Ground Route"
Duct_presnt=True
self.route_dlg.show()
route_result = self.route_dlg.exec_()
if route_result:
if self.route_dlg.ar_rb.isChecked():
fiber = fiberEditTool(self.canvas, self.iface,db,ar, not(Duct_presnt))
self.canvas.setMapTool(fiber)
elif self.route_dlg.ugr_rb.isChecked():
self.duct_require_dlg.show()
duct_result = self.duct_require_dlg.exec_()
if duct_result:
if self.duct_require_dlg.cb_duct.isChecked():
fiber = fiberEditTool(self.canvas, self.iface,db,ugr,Duct_presnt)
self.canvas.setMapTool(fiber)
elif self.duct_require_dlg.cb_wo_duct.isChecked():
fiber = fiberEditTool(self.canvas, self.iface,db,ugr,not(Duct_presnt))
self.canvas.setMapTool(fiber)
iface.actionAddFeature().triggered.connect(...)
line in theinitGui()
of your plugin? Or perhaps just discard the 2nd and 3rd lines of your script above?