Terry, thank you for the explanation. I have already created a branch and a 
pull request just for the zoom problem, so I will create a separate branch 
for the layout problem. But next time I will follow your advice :)

Pavel

On Sunday, March 12, 2017 at 2:13:59 AM UTC+1, Pavel Balashov wrote:
>
> Hello,
>
> recently I have started to use Leo editor for outlining my university 
> projects and I like it a lot. Also I was really excited about one of its 
> plugins, graphcanvas.py, and its ability to automatically layout nodes in 
> the graph. I had several problems with this plugin, but was able to fix 
> them by modifing the code a bit.
>
> 1) Leo crashed after choosing any type of layout
>
> I have installed a pydot package (this one: 
> https://pypi.python.org/pypi/pydot, version 1.2.3) via pip and confirmend 
> that it worked with my Python 3.5.2 installation.
>
> But when I tried to apply PyDot "neato" layout, Leo crashed with the 
> following exception:
>
> Traceback (most recent call last):
>   File "/home/nodex/Software/Leo/leo/plugins/graphcanvas.py", line 725, in 
> <lambda>
>     ('neato', lambda: self.layout('neato')),
>   File "/home/nodex/Software/Leo/leo/plugins/graphcanvas.py", line 798, in 
> layout
>     x,y,width,height = map(float, G.get_bb().strip('"').split(','))
> AttributeError: 'list' object has no attribute 'get_bb'
>
> It is line 798 in the graphcanvas.py file. I have some experience with 
> debugging Python projects, so after some time I found out why G.get_bb() 
> caused Leo to crash - during execution of that line, variable G is a list 
> of Dot objects (more specifically, it contains a single Dot object), so it 
> is impossible to invoke get_bb() from it. So I have modified that line:
>
> # G.get_bb() -> G[0].get_bb()
> x,y,width,height = map(float, G[0].get_bb().strip('"').split(','))
>
> Also another choice forced me to change line 790 because of the same 
> reason:
>
> # G.get_node() -> G[0].get_node()
> lst = G[0].get_node(''.join(['"', i.gnx, '"']))
>
> This changes fixed both problems.
>
> This problem may be caused by my choice of pydot package (there are 
> several other pydot packages in PyPi).
>
> 2) Leo crashed after holding Ctrl and scrolling up (zooming) in the Graph 
> pane
>
> Traceback (most recent call last):
>   File "/home/nodex/Software/Leo/leo/plugins/graphcanvas.py", line 209, in 
> wheelEvent
>     scale = 1.+0.1*(event.delta() / 120)
> AttributeError: 'QWheelEvent' object has no attribute 'delta'
>
>
> It is line 209 in the graphcanvas.py file. After some debugging and 
> googling I have found out, that I am using PyQt 5.5.1 and in Qt 5 delta() 
> method of QWheelEvent class is depracated and replaced by angleDelta() 
> method.
>
> PyQt4.8: http://doc.qt.io/qt-4.8/qwheelevent.html#delta
> PyQt5: http://doc.qt.io/qt-5/qwheelevent.html#angleDelta
>
> So I have changed this line:
>
> # event.delta() -> event.angleDelta().y()
> scale = 1. + 0.1 * (event.angleDelta().y() / 120)
>
> And that fixed the zooming problem.
>
>
>
>
> If these changes are ok, then I would like to contribute them to the 
> project. But I have never contributed to any open source projects, so if 
> someone could guide me through this process, I would really appreciate it :)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to