View Issue Details

IDProjectCategoryView StatusLast Update
0000424ascendcanvas-guipublic2011-03-15 23:08
Reporterjohn 
Assigned Togrivan 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.7 
Target Version0.9.8Fixed in Version0.9.8 
Summary0000424: Update canvas GUI to work with latest Gaphas
DescriptionLatest releases of Gaphas (the Python/Cairo canvas library) have made some significant API changes. We need to update our codebase so that it works with the latest Gaphas code.

We should also check, as part of this, what versions of Gaphas are included with the current distributions, and ensure that our code will be compatible with those if possible. Otherwise, consider including a local copy of Gaphas (and whatever dependencies) within our codebase.
Additional InformationGaphas code is here:
http://github.com/amolenaar/gaphas

See also PyPI.
TagsNo tags attached.

Relationships

Activities

john

2010-03-26 17:12

administrator   ~0000611

I think you can commmit your changes to this directly to trunk, if you like. Providing they're all within the pygtk/canvas directory and not outside that.

2010-04-06 18:21

 

a1.diff (7,692 bytes)
Index: connectortool.py
===================================================================
--- connectortool.py	(revision 2696)
+++ connectortool.py	(working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from gaphas.tool import HandleTool
 from blockconnecttool import BlockConnectTool
 from blockline import BlockLine
@@ -18,36 +19,39 @@
 		self._handle_tool = HandleTool()
 		self._handle_index_glued = 0
 		self._handle_index_dragged = 1
-		self._grabbed_handle = None
-		self._grabbed_item = None
+		self.grabbed_handle = None
+		self.grabbed_item = None
 		self._new_item = None
 
-	def on_button_press(self,context,event):
+	def on_button_press(self,event):
 		if event.button != 1:
 			return False
-
-		view = context.view
-		canvas = view.canvas
-		glueitem, glueport, gluepos = self.get_item_at_point(view, (event.x, event.y), list())
+		pass
+		'''
+		view = self.view.tool.view
+		glueitem, glueport = self.view.get_item_at_point((event.x, event.y))
 		if glueport and hasattr(glueport,"point"):
 			line = self._create_line(context,event.x, event.y)
 			canvas.get_matrix_i2c(line, calculate=True)
 			self._new_item = line
-			view.focused_item = line
-			del view.selected_items
+			self.view.focused_item = line
+			del self.view.selected_items
 			context.grab()
 
 			h_glue = line.handles()[self._handle_index_glued]
-			self.connect(view,line,h_glue, (event.x, event.y))
+			self.connect(self.view,line,h_glue, (event.x, event.y))
 
 			h_drag = line.handles()[self._handle_index_dragged]
 			self._handle_tool.grab_handle(line, h_drag)
-			self._grabbed_handle = h_drag
-			self._grabbed_item = line
+			self.grabbed_handle = h_drag
+			self.grabbed_item = line
 			
 			print "STARTED NEW CONNECTOR"
-			return True
+			return True'''
 
+	#def on_button_press(self,event):
+		#pass
+
 	def _create_line(self, context, x, y):
 		view = context.view
 		canvas = view.canvas
Index: blocktype.py
===================================================================
--- blocktype.py	(revision 2696)
+++ blocktype.py	(working copy)
@@ -106,4 +106,4 @@
 
 	#def get_dual_name(self, index):
 	#	return self.duals[index].get_text()
-	
\ No newline at end of file
+	
Index: blockport.py
===================================================================
--- blockport.py	(revision 2696)
+++ blockport.py	(working copy)
@@ -1,6 +1,7 @@
+# -*- coding: utf-8 -*-
 from gaphas.connector import PointPort
 from blockinstance import PortInstance
-from gaphas.connector import VariablePoint
+from gaphas.connector import Position
 from gaphas.solver import WEAK
 
 class BlockPort(PointPort):
@@ -11,6 +12,8 @@
 	"""
 	
 	def __init__(self, blockinstance, portname):
-		super(BlockPort,self).__init__(VariablePoint((0,0),strength=WEAK))
+		#super(BlockPort,self).__init__(VariablePoint((0,0),strength=WEAK))
+		#PointPort(Position(self._hm.pos))
+		super(BlockPort,self).__init__(Position((0,0)))
 		self.portinstance = blockinstance.ports[portname]
 
Index: contextmenutool.py
===================================================================
--- contextmenutool.py	(revision 2696)
+++ contextmenutool.py	(working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from gaphas.tool import Tool
 import pygtk
 pygtk.require('2.0') 
@@ -16,10 +17,11 @@
 	"""
 	def __init__(self):
 		pass
-
-	def on_button_press(self, context, event):
+			
+	def on_button_press(self, event):
+		context = self.view.tool
 		if event.button != 3:
-			context.ungrab()
+			context.ungrab(self.view.tool)
 			return False
 		if context.view.hovered_item:
 			menu = gtk.Menu()
@@ -46,7 +48,7 @@
 				menuinfo.set_sensitive(False)
 			menu.show_all()
 			menu.popup( None, None, None, event.button, event.time)
-			context.ungrab()
+			self.view.tool.ungrab(self.view.tool)
 			return True
 
 	def info(self,widget,window,context,item):
Index: blockitem.py
===================================================================
--- blockitem.py	(revision 2696)
+++ blockitem.py	(working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 
 from gaphas.constraint import LineConstraint, LessThanConstraint, EqualsConstraint, Constraint, _update, BalanceConstraint
 from gaphas.item import Line, SW, NE, NW, SE, Item, Handle
@@ -2,5 +3,6 @@
 from gaphas.util import *
-from gaphas.connector import PointPort, VariablePoint
+#from gaphas.connector import PointPort, VariablePoint
 from gaphas.solver import solvable, WEAK, NORMAL, STRONG, VERY_STRONG
-from gaphas.state import observed, reversible_method, reversible_pair, reversible_property, disable_dispatching
+from gaphas.state import observed, reversible_method, reversible_pair, reversible_property #disable_dispatching
+
 from gaphas.geometry import distance_rectangle_point
Index: gaphas-test.py
===================================================================
--- gaphas-test.py	(revision 2696)
+++ gaphas-test.py	(working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 import pygtk
 pygtk.require('2.0') 
 
@@ -6,12 +7,13 @@
 import cairo
 from gaphas import GtkView, View
 from gaphas.tool import HoverTool, PlacementTool, HandleTool, ToolChain
-from gaphas.tool import ItemTool, RubberbandTool
-
+from gaphas.tool import ItemTool, RubberbandTool, DefaultTool
+from blockcanvas import BlockCanvas
+from blockitem  import DefaultBlockItem
 from gaphas import painter
 #painter.DEBUG_DRAW_BOUNDING_BOX = True
 
-from port import *
+#from port import *
 
 def factory(view, cls):
     """
@@ -26,7 +28,7 @@
 
 def create_window(canvas, title, zoom=1.0):
     view = GtkView()
-    view.tool = DefaultExampleTool()
+    view.tool = DefaultTool()
 
     w = gtk.Window()
     w.set_title(title)
@@ -47,7 +49,7 @@
 
     def on_clicked(button, view):
         #view.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSSHAIR))
-        view.tool.grab(PlacementTool(factory(view, DefaultBlock), HandleTool(), 2))
+        view.tool.grab(PlacementTool(factory(view, DefaultBlockItem), HandleTool(), 2))
 
     b.connect('clicked', on_clicked, view)
     v.add(b)
Index: blocklist.py
===================================================================
--- blocklist.py	(revision 2696)
+++ blocklist.py	(working copy)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 from __future__ import with_statement
 import os, sys
 
@@ -127,7 +128,7 @@
 		
 from gaphas import GtkView, View
 from gaphas.tool import HoverTool, PlacementTool, HandleTool, ToolChain
-from gaphas.tool import LineSegmentTool
+#from gaphas.tool import LineSegmentTool
 from gaphas.tool import Tool, ItemTool, RubberbandTool
 from gaphas.painter import ItemPainter
 from blockconnecttool import BlockConnectTool
@@ -152,7 +153,7 @@
 	chain.append(BlockConnectTool()) # for connect/disconnect of lines
 	chain.append(ConnectorTool()) # for creating new lines by drag from Port
 	chain.append(ContextMenuTool()) # right-click
-	chain.append(LineSegmentTool()) # for moving line 'elbows'
+	#chain.append(LineSegmentTool()) # for moving line 'elbows'
 	chain.append(ItemTool())
 	chain.append(PanTool())
 	chain.append(ZoomTool())
@@ -367,6 +368,11 @@
 		tmenu.append(dbg)
 		dbg.show()
 		
+		con = gtk.ImageMenuItem('Connector', agr)
+		con.connect("activate",self.set_connector_tool)
+		tmenu.append(con)
+		con.show()
+
 		slv = gtk.ImageMenuItem(gtk.STOCK_EXECUTE, agr)
 		slv.connect("activate", self.run_canvas)
 		tmenu.append(slv)
@@ -524,7 +530,7 @@
 				self.view.canvas.add(bi)
 				return bi
 			return wrapper
-		self.view.tool.grab(PlacementTool(my_block_factory(), HandleTool(), 2))
+		self.view.tool.grab(PlacementTool(self.view,my_block_factory(), HandleTool(), 2))
 		self.status.push(0,"Selected '%s'..." % blocktype.type.getName())
 
 	def set_connector_tool(self):
a1.diff (7,692 bytes)

arijit

2010-04-06 18:25

developer   ~0000621

Last edited: 2010-04-06 18:26

a1.diff file contains the svn diff. The canvas now manages to run but the connecttool is not functioning properly. Rest all functionalities seem to work fine. We might need to change variable names according to the changes brought into gaphas.

2010-05-24 10:11

 

asc2.diff (2,913 bytes)
Index: connectortool.py
===================================================================
--- connectortool.py	(revision 2818)
+++ connectortool.py	(working copy)
@@ -26,12 +26,15 @@
 		self.motion_handle = None
 
 	def on_button_press(self,event):		
+		
 		if event.button != 1:
 			return False
 
 		glueitem,glueport,gluepos = self.view.get_port_at_point((event.x,event.y),distance = 10,exclude = [])
 		
-		if glueport:
+		if glueport and hasattr(glueport,"point"):
+			
+			#print "Conn.Tool L36\n: "glueitem,glueport,gluepos
 			self.line = self._create_line((event.x, event.y))
 			self._new_item = self.line
 			h_glue = self.line.handles()[self._handle_index_glued]
@@ -44,7 +47,7 @@
 			self.grabbed_handle = h_drag
 			self.grabbed_item = self.line
 			
-		return True
+			return True
 
 	def on_button_release(self,event):
 
Index: blockproperties.py
===================================================================
--- blockproperties.py	(revision 2818)
+++ blockproperties.py	(working copy)
@@ -142,17 +142,29 @@
 		
 		methodvbox = gtk.VBox(homogeneous=True)
 		methodframe = gtk.Frame("Enter your custom METHODs for the block below")
-		methodentry = gtksourceview.View()
-		methodentry.set_show_line_numbers(True) 
-		self.sb = gtksourceview.Buffer()
-		self.sb.set_highlight_matching_brackets(True)
-		self.sb.set_highlight_syntax(True)
-		self.sb.set_text(bi.usercode)
-		methodentry.set_buffer(self.sb)
+		
+		self.sourceviewView = gtksourceview.View()
+		self.sourceviewView.set_show_line_numbers(True) 
+		
+		self.sourceviewLangman = gtksourceview.language_manager_get_default()
+		
+		op = self.sourceviewLangman.get_search_path()
+		op.append(os.path.join('..','..','tools','gtksourceview-2.0'))
+		self.sourceviewLangman.set_search_path(op)
+		
+		self.sourceviewLang = self.sourceviewLangman.get_language('ascend')
+		
+		self.sourceviewBuff = gtksourceview.Buffer()
+		self.sourceviewBuff.set_language(self.sourceviewLang)
+		
+		self.sourceviewBuff.set_highlight_syntax(True)
+		self.sourceviewBuff.set_text(bi.usercode)
+		
+		self.sourceviewView.set_buffer(self.sourceviewBuff)
 		scrolled_window2 = gtk.ScrolledWindow()
 		scrolled_window2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 		label = gtk.Label("Custom Method")
-		methodframe.add(methodentry)
+		methodframe.add(self.sourceviewView)
 		scrolled_window2.add_with_viewport(methodframe)
 		self.notebook.append_page(scrolled_window2, label)
 		
@@ -228,9 +240,9 @@
 			item.blockinstance.name = self.pname.get_text()			
 			v.value = str(self.textbox[v.name].get_text())
 
-		startiter = self.sb.get_start_iter()
-		enditer = self.sb.get_end_iter()
-		usertext = self.sb.get_text(startiter, enditer)	
+		startiter = self.sourceviewBuff.get_start_iter()
+		enditer = self.sourceviewBuff.get_end_iter()
+		usertext = self.sourceviewBuff.get_text(startiter, enditer)	
 		if usertext == "" :
 			pass
 		else:	
asc2.diff (2,913 bytes)

john

2010-05-24 10:11

administrator   ~0000643

asc2.diff file from Grivan completes the repairs. Problem solved.

Issue History

Date Modified Username Field Change
2010-02-23 09:57 john New Issue
2010-03-23 18:24 john Target Version => 0.9.8
2010-03-26 17:11 john Status new => assigned
2010-03-26 17:11 john Assigned To => arijit
2010-03-26 17:12 john Note Added: 0000611
2010-04-06 18:21 arijit File Added: a1.diff
2010-04-06 18:25 arijit Note Added: 0000621
2010-04-06 18:26 arijit Note Edited: 0000621
2010-05-24 10:11 john File Added: asc2.diff
2010-05-24 10:11 john Note Added: 0000643
2010-05-24 10:12 john Assigned To arijit => grivan
2010-05-24 10:12 john Status assigned => resolved
2010-05-24 10:12 john Fixed in Version => SVN
2010-05-24 10:12 john Resolution open => fixed
2011-03-15 23:08 john Fixed in Version SVN => 0.9.8