Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving Visualea to Python 3 / Qt5 or Qt6 #6

Merged
merged 27 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bad3c6f
Update setup.cfg
Wilgawox Jul 26, 2021
996f588
2to3 + setup.cfg updated
Jul 26, 2021
2c15f47
Resolved .qrc bug and partial QT5/Pyside2 changes. Corrected import p…
Jul 28, 2021
e135c9d
Minor bugs fixed and take back the change QtGui to QtWidgets
Aug 3, 2021
f1da4bf
Completed the last commit
Aug 3, 2021
f7413ef
End of stage commit
Aug 13, 2021
9174530
End of stage commit n.2
Aug 13, 2021
963e29c
Remove egg-info and fix setup.py. Add also a gitignore file.
pradal Jan 17, 2023
26d218e
Merge branch 'thib' into visualea
pradal Jan 17, 2023
addc3c8
Rm __pycache__
pradal Jan 17, 2023
07d99c6
Fix Qt interface from QtGui to QtWidgets
pradal Jan 17, 2023
fda9fef
Fix the Networkx example
pradal Jan 17, 2023
4048ab7
Fix problem of events
pradal Jan 17, 2023
5daa263
WIP: QtGui to QtWidget
Jan 18, 2023
fcb8a78
Fix a bug frm 2to3 conversion: filter was not the std function but a …
pradal Jan 18, 2023
6d9c943
WIP QtGui forgot
Jan 19, 2023
6e5d0f0
WIP, class arguments order, now node and edge working
Jan 20, 2023
79c82b8
Update metaclass
pradal Jan 23, 2023
10d1478
Fix python 2 to Python 3 division error
pradal Jan 25, 2023
8b3bce5
fixed: zoom with mouse wheel
Jan 26, 2023
8687000
fixed: zoom with mouse wheel x-y direction
Jan 26, 2023
a73820a
Fix scaling view with touchpad
pradal Jan 30, 2023
e92b4fd
vpltk to qtpy, still one vpltk.qt.compat
Feb 3, 2023
f017ca6
WIP, get rid of vpltk
Feb 7, 2023
1c32d25
del vpltk reference
Feb 7, 2023
bf4e024
Update setup and version info
pradal Feb 9, 2023
6c364bc
Update conda packagnig information
pradal Feb 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Python files
*.py[cod]

# C extensions
*.so
*.dll
*.dylib

# Compiled Static libraries
*.lai
*.la
*.a

# Compiled Object files
*.os

# Packages
*.egg
*.egg-info
dist
build
build-scons
eggs
.eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
__pycache__
*.pth
*.bak

# Installer logs
pip-log.txt
.amlog
.sconsign.dblite

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Designer files
*visualea/src/visualea/ui_*

# Translations
*.mo

# Vim files
*.swp
*.*~

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.settings
.idea

# svn
.svn

# temporary files
*._icon.png

# Mac dirs
.DS_Store
13 changes: 7 additions & 6 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
{% set version = "2.0.1" %}
{% set data = load_setup_py_data() %}

package:
name: openalea.grapheditor
version: {{ version }}
version: {{ data.get('version') }}

source:
path: ..

build:
noarch: python
preserve_egg_dir: True
number: 0
script: python setup.py install --prefix=$PREFIX
script: {{PYTHON}} setup.py install

requirements:
build:
- openalea.deploy
run:
- openalea.deploy
- openalea.core
- openalea.vpltk
- qtpy

test:
imports:
- openalea.grapheditor

about:
home: http://github.com/openalea/visualea
home: {{ data.get('url') }}
license: Cecill-c License
summary: GraphEditor package for OpenAlea.
summary: {{ data.get('description') }}

8 changes: 4 additions & 4 deletions examples/networkx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
master_doc = 'index'

# General information about the project.
project = u'NetworkX GraphEditor Strategy'
copyright = u'2010, Daniel Barbeau'
project = 'NetworkX GraphEditor Strategy'
copyright = '2010, Daniel Barbeau'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -172,8 +172,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'NetworkXGraphEditorStrategy.tex', u'NetworkX GraphEditor Strategy Documentation',
u'Daniel Barbeau', 'manual'),
('index', 'NetworkXGraphEditorStrategy.tex', 'NetworkX GraphEditor Strategy Documentation',
'Daniel Barbeau', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
43 changes: 24 additions & 19 deletions examples/networkx/__init__.py → examples/networkx/nx_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
them.
"""

import weakref
import networkx as nx

from functools import cmp_to_key

from openalea.grapheditor.all import Observed, GraphAdapterBase
import weakref

def cmp(a, b):
return (id(a) > id(b)) - (id(a) < id(b))

class NxObservedVertex(Observed):

Expand All @@ -23,18 +28,18 @@ def notify_position(self, pos):
self.notify_listeners(("metadata_changed", "position", pos))

def notify_update(self, **kwargs):
for k, v in kwargs.iteritems():
for k, v in kwargs.items():
self.notify_listeners(("metadata_changed", k, v))

pos = self.g().node[self]["position"]
pos = self.g().nodes[self]["position"]
self.notify_position(pos)

def __setitem__(self, key, value):
self.g().node[self][key] = value
self.g().nodes[self][key] = value
self.notify_update()

def __getitem__(self, key):
return self.g().node[self][key]
return self.g().nodes[self][key]

class NXObservedGraph( GraphAdapterBase, Observed ):
"""An adapter to networkx.Graph"""
Expand All @@ -55,7 +60,7 @@ def add_vertex(self, vertex, **kwargs):
if "position" not in kwargs :
kwargs["position"] = [0., 0.]
else:
kwargs["position"] = map(float, kwargs["position"])
kwargs["position"] = list(map(float, kwargs["position"]))
if "color" not in kwargs :
kwargs["color"] = QtGui.QColor(0, 0, 0)

Expand All @@ -71,7 +76,7 @@ def remove_vertex(self, vertex):

def add_edge(self, src_vertex, tgt_vertex, **kwargs):
edge = [src_vertex, tgt_vertex]
edge.sort(lambda x, y: cmp(id(x), id(y)))
edge.sort(key=cmp_to_key(cmp))
edge = tuple(edge)
if self.graph.has_edge(*edge):
return
Expand All @@ -81,7 +86,7 @@ def add_edge(self, src_vertex, tgt_vertex, **kwargs):

def remove_edge(self, src_vertex, tgt_vertex):
edge = [src_vertex, tgt_vertex]
edge.sort(lambda x, y: cmp(id(x), id(y)))
edge.sort(key=cmp_to_key(cmp))
edge = tuple(edge)
self.graph.remove_edge(edge[0], edge[1])
self.notify_listeners(("edge_removed", ("default",edge)))
Expand All @@ -92,17 +97,17 @@ def remove_edges(self, edges):
# -- not in the adapter interface (yet): --
def set_vertex_data(self, vertex, **kwargs):
if vertex in self.graph:
for k, v in kwargs.iteritems():
self.graph.node[vertex][k]=v
for k, v in kwargs.items():
self.graph.nodes[vertex][k]=v

def set_edge_data(self, edge_proxy, **kwargs):
#nothing right now"
#nothing right now
pass

#------------------------
# -- the graph qt view --
#------------------------
from PyQt4 import QtGui, QtCore
from qtpy import QtGui, QtCore, QtWidgets
from openalea.grapheditor.qt import (Vertex, View, mixin_method,
QtGraphStrategyMaker,
DefaultGraphicalEdge,
Expand All @@ -112,16 +117,16 @@ def set_edge_data(self, edge_proxy, **kwargs):

class GraphicalNode( DefaultGraphicalVertex ):
def initialise_from_model(self):
self.setPos(QtCore.QPointF(*self.graph().graph.node[self.vertex()]["position"]))
color = self.graph().graph.node[self.vertex()]["color"]
self.setPos(QtCore.QPointF(*self.graph().graph.nodes[self.vertex()]["position"]))
color = self.graph().graph.nodes[self.vertex()]["color"]
brush = QtGui.QBrush(color)
self.setBrush(brush)

def store_view_data(self, **kwargs):
self.graph().set_vertex_data(self.vertex(), **kwargs)

def get_view_data(self, key):
return self.graph().graph.node[self.vertex()][key]
return self.graph().graph.nodes[self.vertex()][key]

class GraphicalView( View ):
def __init__(self, parent):
Expand Down Expand Up @@ -157,10 +162,10 @@ def removeElement(self, event):
"floating-default":DefaultGraphicalFloatingEdge} )

#THE APPLICATION'S MAIN WINDOW
class MainWindow(QtGui.QMainWindow):
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
""" """
QtGui.QMainWindow.__init__(self, parent)
QtWidgets.QMainWindow.__init__(self, parent)

self.setMinimumSize(800,600)

Expand All @@ -181,9 +186,9 @@ def __init__(self, parent=None):

if __name__=="__main__":

instance = QtGui.QApplication.instance()
instance = QtWidgets.QApplication.instance()
if instance is None :
app = QtGui.QApplication([])
app = QtWidgets.QApplication([])
else :
app = instance

Expand Down
15 changes: 0 additions & 15 deletions metainfo.ini

This file was deleted.

49 changes: 0 additions & 49 deletions setup.cfg

This file was deleted.

23 changes: 16 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@

from setuptools import setup, find_packages

from openalea.deploy.metainfo import read_metainfo
name = "OpenAlea.GraphEditor"
description= "GraphEditor package for OpenAlea."
long_description= "An generic GGUI API for viewing and interacting with various sorts of graphs."
authors = "Daniel Barbeau, Christophe Pradal"
authors_email = "[email protected]"
url = "https://github.com/openalea/grapheditor"
license = "Cecill-C"

metadata = read_metainfo('metainfo.ini', verbose=True)
for key,value in metadata.iteritems():
exec("%s = '%s'" % (key, value))

# find version number in src/openalea/core/version.py
_version = {}
with open("src/openalea/core/version.py") as fp:
exec(fp.read(), _version)
version = _version["__version__"]

namespace = 'openalea'
packages=find_packages('src')
Expand All @@ -19,7 +28,7 @@
setup_requires = ['openalea.deploy']
install_requires = []
# web sites where to find eggs
dependency_links = ['http://openalea.gforge.inria.fr/pi']
dependency_links = []

# setup function call
#
Expand All @@ -40,8 +49,8 @@
package_dir= package_dir,

# Namespace packages creation by deploy
namespace_packages=[namespace],
create_namespaces=True,
#namespace_packages=[namespace],
#create_namespaces=True,

zip_safe=False,

Expand Down
Loading