'Add event on Layer border - vue leaflet
How can I add an event to the polygon border, if the user clicks inside the polygon it should do nothing, but if the user clicks on the border it should trigger some event, is it possible?
Solution 1:[1]
import matplotlib
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import tkinter as tk
from shapely.geometry import Polygon
import matplotlib.pyplot as plt
from tkinter import ttk as ttk
matplotlib.use('TkAgg')
root = tk.Tk()
root.title('Section Analysis')
root.geometry('700x400')
root.state('zoomed')
polygon1 = Polygon([[0, 0], [1, 0], [1, 1], [0, 0]])
x,y = polygon1.exterior.xy
fig = Figure(figsize=(8,6), dpi=100)
rects1 = fig.add_subplot(111).plot(x,y,color ='tab:blue',picker=True, pickradius=5)
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.draw()
canvas.get_tk_widget().pack(side=tk.RIGHT)
def onpick(event):
thisline = event.artist
xdata = thisline.get_xdata()
ydata = thisline.get_ydata()
ind = event.ind
points = tuple(zip(xdata[ind], ydata[ind]))
print('onpick points:', points)
fig.canvas.mpl_connect('pick_event', onpick)
root.mainloop()
Solution 2:[2]
Did you try to remove sudo?
However, since you have to run each 30 minutes you can also considered to:
- scheduling directly in python using
schedule - using a python library to write your CronTab file
- running on a more isolated enviroment using docker and schedule with crontab the docker run
- finally, if you have access to it, you can consider also using cronjob on a k8s cluster et similia
Solution 3:[3]
You're attempting to execute the script with sudo, but cron can't prompt you for the password. Since this is root's crontab, you shouldn't need to use sudo.
If you must use sudo in cron, you need to designate those commands to be passwordless through /etc/sudoers. Something along these lines should work.
opc ALL=(root) NOPASSWD: /home/opc/python_scripts/main.py
Solution 4:[4]
So I do not know what the problem was but I solved it.
How:
previously as I had mentioned in my question that I had tried the above two questions separately.
- Now what I did was, implemented the given answer of Calling a python script from shell script cron in which i only used this part of the answer :
#!/usr/bin/env bash
dirName=`dirname $0`
baseName=`basename $0`
arg1=$1
arg2=$2
cd ${dirName} && python ./room_wise.py arg1 arg2
- from the second question Shell Script: Execute a python program from within a shell script, i used João Víctor answer method 2 and replace python with python3.
I do not completely understand what the problem was but yeah when I used both of these solutions together then it started working. Also as other people have mentioned in this post, do not use sudo if you are using root's crontab and otherwise as well as it can lead to authorization issues. This solved it so, if anyone has a better understanding then do add your answers as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SW84 |
| Solution 2 | Dabr |
| Solution 3 | |
| Solution 4 | aditya_sharma |
