rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
dom_extensions.setAttributes( self.top, (("width", str(x2-x1+20)), ("height", str(y2-y1+20)))) | w = px_to_mm_txt( x2 -x1 +2*border_size) h = px_to_mm_txt( y2 -y1 +2*border_size) bx2, by2 = x2-x1+2*border_size, y2-y1+2*border_size dom_extensions.setAttributes( self.top, (("width", w), ("height", h), ("viewBox",'0 0 %d %d' % ( bx2, by2)))) | def construct_dom_tree( self, top_levels): """constructs the SVG dom from all top_levels""" self._id = 0 doc = self.document self.top = dom_extensions.elementUnder( doc, "svg", attributes=(("xmlns", "http://www.w3.org/2000/svg"), ("version", "1.0"))) if self.full_size: sx = self.paper.get_paper_property( 'size_x') sy =... |
(('style', 'stroke: ('font-size', '12pt'), | (('font-size', '12pt'), | def construct_dom_tree( self, top_levels): """constructs the SVG dom from all top_levels""" self._id = 0 doc = self.document self.top = dom_extensions.elementUnder( doc, "svg", attributes=(("xmlns", "http://www.w3.org/2000/svg"), ("version", "1.0"))) if self.full_size: sx = self.paper.get_paper_property( 'size_x') sy =... |
('stroke-width', '1pt'), | def construct_dom_tree( self, top_levels): """constructs the SVG dom from all top_levels""" self._id = 0 doc = self.document self.top = dom_extensions.elementUnder( doc, "svg", attributes=(("xmlns", "http://www.w3.org/2000/svg"), ("version", "1.0"))) if self.full_size: sx = self.paper.get_paper_property( 'size_x') sy =... | |
self.group.setAttribute( 'transform', 'translate('+str(-x1+10)+', '+str(-y1+10)+')') | self.group.setAttribute( 'transform', 'translate(%d,%d)' % (-x1+border_size, -y1+border_size)) | def construct_dom_tree( self, top_levels): """constructs the SVG dom from all top_levels""" self._id = 0 doc = self.document self.top = dom_extensions.elementUnder( doc, "svg", attributes=(("xmlns", "http://www.w3.org/2000/svg"), ("version", "1.0"))) if self.full_size: sx = self.paper.get_paper_property( 'size_x') sy =... |
if b.line_width != 1.0 or b.line_color != ' line_width = (b.type == 'b') and b.wedge_width or b.type != 'w' and b.line_width or 1.0 l_group = dom_extensions.elementUnder( self.group, 'g', (( 'stroke-width', str( line_width)), ( 'stroke', b.line_color))) else: l_group = self.group | line_width = (b.type == 'b') and b.wedge_width or b.type != 'w' and b.line_width or 1.0 l_group = dom_extensions.elementUnder( self.group, 'g', (( 'stroke-width', str( line_width)), ( 'stroke', b.line_color))) | def add_bond( self, b): """adds bond item to SVG document""" if b.line_width != 1.0 or b.line_color != '#000' or b.type == 'b': line_width = (b.type == 'b') and b.wedge_width or b.type != 'w' and b.line_width or 1.0 l_group = dom_extensions.elementUnder( self.group, 'g', (( 'stroke-width', str( line_width)), ( 'stroke'... |
( 'stroke', t.line_color), | def add_text( self, t): """adds text item to SVG document""" item = t.item x1, y1 = t.get_xy() x, y, x2, y2 = self.paper.bbox( item) dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', t.area_color), ( 'stroke', t.area_color))) y... | |
( 'stroke', a.line_color), | def add_atom( self, a): """adds atom item to SVG document""" if a.show: item = a.selector x1, y1 = a.get_xy() x, y, x2, y2 = self.paper.bbox( item) #if os.name == 'nt': # x += 2 #nasty hack to improve results on win machines (they have larger fonts?!?) # x2 -= 2 dom_extensions.elementUnder( self.group, 'rect', (( 'x... | |
self.load_CDML( file, replace=1) | ret = self.load_CDML( file, replace=1) if not ret: sys.stderr.write( " !! failed, will not proceed.") return | def process_batch( self, opts, files=None): import time f = None t = None o = None for opt in opts: if opt[0] == '-f': f = opt[1] elif opt[0] == '-t': t = opt[1] elif opt[0] == '-o': o = opt[1] elif opt[0] == '-l': if not files: files = [] file_list = opt[1] file_file = open( file_list, 'r') for name in [l.strip() for... |
b.read_standard_values( old_standard=old_standard) | b.read_standard_values( self.standard, old_standard=old_standard) | def apply_current_standard( self, objects=[], old_standard=None, template_mode=0): """if no objects are given all are used, if old_standard is given only the values that have changed are applied; in template mode no changes of paper format are made""" if not template_mode: self.create_background() objs = objects or sel... |
a.read_standard_values( old_standard=old_standard) | a.read_standard_values( self.standard, old_standard=old_standard) | def apply_current_standard( self, objects=[], old_standard=None, template_mode=0): """if no objects are given all are used, if old_standard is given only the values that have changed are applied; in template mode no changes of paper format are made""" if not template_mode: self.create_background() objs = objects or sel... |
m.read_standard_values( old_standard=old_standard) | m.read_standard_values( self.standard, old_standard=old_standard) | def apply_current_standard( self, objects=[], old_standard=None, template_mode=0): """if no objects are given all are used, if old_standard is given only the values that have changed are applied; in template mode no changes of paper format are made""" if not template_mode: self.create_background() objs = objects or sel... |
scaleMenu.add( 'command', label=_('Swap'), command = self.paper.lower_selected_to_bottom, accelerator='(C-o s)') | scaleMenu.add( 'command', label=_('Swap on stack'), command = self.paper.swap_selected_on_stack, accelerator='(C-o s)') | def initialize( self): Pmw.initialise( self) import pixmaps if os.name == 'posix': try: self.option_add( "*font", ("-adobe-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*")) except: print "cannot init default font" else: self.option_add( "*font", ("Helvetica",10,"normal")) self.title( "BKchem") self.stat= StringVar() sel... |
x1, y1, x2, y2 = map( round, [x1, y1, x2, y2]) | def _draw_w1( self): x1, y1 = self.atom1.get_xy() x2, y2 = self.atom2.get_xy() x1, y1, x2, y2 = map( round, [x1, y1, x2, y2]) # main item x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) self.item = self.paper.create_polygon( (x1, y1, x0, y0, 2*x2-x0, 2*y2-y0), tags=('bond',), outline=self.line_c... | |
x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) self.item = self.paper.create_polygon( (x1, y1, x0, y0, 2*x2-x0, 2*y2-y0), tags=('bond',), outline=self.line_color, fill=self.line_color, joinstyle="miter") | self.item = self._draw_wedge( (x1,y1,x2,y2), self.bond_width) | def _draw_w1( self): x1, y1 = self.atom1.get_xy() x2, y2 = self.atom2.get_xy() x1, y1, x2, y2 = map( round, [x1, y1, x2, y2]) # main item x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) self.item = self.paper.create_polygon( (x1, y1, x0, y0, 2*x2-x0, 2*y2-y0), tags=('bond',), outline=self.line_c... |
if self.focused and (self.focused.object_type == 'arrow' or self.focused.object_type == 'polygon'): | if self.focused and (self.focused.object_type == 'arrow' or self.focused.object_type == 'polygon' or self.focused.object_type == "polyline"): | def mouse_drag( self, event): if not self._dragging: # drag threshhold dx = event.x-self._startx dy = event.y-self._starty self._move_sofar += math.sqrt( dx**2 + dy**2) if self._move_sofar <= 1.0: return |
self.bind( "<MouseWheel>", lambda e: self.yview( "scroll", -misc.signum( e.delta), "units")) | def set_bindings( self): if not Store.app.in_batch_mode: self.bind( "<B1-Motion>", self._drag1) self.bind( "<ButtonRelease-1>", self._release1) self.bind( "<Shift-B1-Motion>", self._drag1) self.bind( "<Button-1>", lambda e: self._pressed1( e, mod=[])) self.bind( "<Shift-Button-1>", lambda e: self._pressed1( e, mod=['sh... | |
return | coords = self.transformer.transform_4( self.paper.coords( item)) outline = self.paper.itemcget( item, 'outline') fill = self.paper.itemcget( item, 'fill') width = self.convert( float( self.paper.itemcget( item, 'width'))) x1, y1, x2, y2 = coords w = x2 - x1 h = y2 - y1 self.context.save() self.context.translate( x1+w/2... | def _draw_oval( self, item): return |
tr = transform3d() tr.set_move( -x0, 0, 0) tr.set_rotation_y( math.pi) tr.set_move( x0, 0, 0) | tr = transform() tr.set_move( -x0, 0) tr.set_scaling_xy( -1, 1) tr.set_move( x0, 0) | def swap_sides_of_selected( self, mode="vertical"): """mirrors the selected things, vertical uses y-axis as a mirror plane, horizontal x-axis""" # locate all selected containers, filter them to be unique to_align, unique = self.selected_to_unique_containers() self.unselect_all() # check if there is anything to align if... |
tr = transform3d() tr.set_move( 0, -y0, 0) tr.set_rotation_x( math.pi) tr.set_move( 0, y0, 0) | tr = transform() tr.set_move( 0, -y0) tr.set_scaling_xy( 1, -1) tr.set_move( 0, y0) | def swap_sides_of_selected( self, mode="vertical"): """mirrors the selected things, vertical uses y-axis as a mirror plane, horizontal x-axis""" # locate all selected containers, filter them to be unique to_align, unique = self.selected_to_unique_containers() self.unselect_all() # check if there is anything to align if... |
invert_coords( self.molecule) def invert_coords( molecule, tr=None): if not tr: ys = [a.y for a in molecule.vertices] center_y = (max( ys) + min( ys)) / 2.0 tr = transform.transform() tr.set_move( 0, -center_y) tr.set_scaling_xy( 1, -1) tr.set_move( 0, center_y) molecule.transform( tr) return tr | def write_to_file( self, name): if type( name) == types.StringType: file = open( name, 'w') else: file = name oasa_bridge.write_molfile( self.molecule, file) | |
if b.type == 'h': | if b.type in 'hd': | def add_bond( self, b, page): """adds bond item to page""" s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color), stroke_width=Screen.px_to_cm( b.line_width)) style_name = self.get_appropriate_style_name( s) l_group = page # items to export if b.type == 'h': items = b.items else: if b.cente... |
if b.type in 'nh': | if b.type in 'nhd': | def add_bond( self, b, page): """adds bond item to page""" s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color), stroke_width=Screen.px_to_cm( b.line_width)) style_name = self.get_appropriate_style_name( s) l_group = page # items to export if b.type == 'h': items = b.items else: if b.cente... |
elif b.type == 'h': for i in items: for p in i: coords = map( Screen.px_to_cm, self.paper.coords( p)) self.create_oo_line( coords, page, style_name) | def add_bond( self, b, page): """adds bond item to page""" s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color), stroke_width=Screen.px_to_cm( b.line_width)) style_name = self.get_appropriate_style_name( s) l_group = page # items to export if b.type == 'h': items = b.items else: if b.cente... | |
for name,m in a.marks.iteritems(): | for m in a.marks: | def add_atom( self, a, page): """adds atom to document""" if a.show: coords = map( Screen.px_to_cm, self.paper.coords( a.selector)) # we need to use negative padding of the text because oo puts too much space above # and under text dy = abs( coords[3]-coords[1]) ptop = -0.25*dy pbot = -0.2*dy gr_style = graphics_style(... |
elif name == 'biradical': | elif name in ('biradical','dotted_electronpair'): | def add_atom( self, a, page): """adds atom to document""" if a.show: coords = map( Screen.px_to_cm, self.paper.coords( a.selector)) # we need to use negative padding of the text because oo puts too much space above # and under text dy = abs( coords[3]-coords[1]) ptop = -0.25*dy pbot = -0.2*dy gr_style = graphics_style(... |
if o.items.index( i) == 0: | if self.paper.type( i) == "oval": | def add_plus_mark( self, o, page): s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color), fill_color=self.paper.any_color_to_rgb_string( o.atom.area_color), stroke_width=Screen.px_to_cm( 1)) style_name = self.get_appropriate_style_name( s) for i in o.items: if o.items.index( i) == 0: x... |
else: | for i in o.items: if self.paper.type( i) == "line": | def add_plus_mark( self, o, page): s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color), fill_color=self.paper.any_color_to_rgb_string( o.atom.area_color), stroke_width=Screen.px_to_cm( 1)) style_name = self.get_appropriate_style_name( s) for i in o.items: if o.items.index( i) == 0: x... |
if o.items.index( i) == 1: coords[0] += 0 coords[2] += -1 elif o.items.index( i) == 2: coords[1] += 0 coords[3] += -1 | def add_plus_mark( self, o, page): s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color), fill_color=self.paper.any_color_to_rgb_string( o.atom.area_color), stroke_width=Screen.px_to_cm( 1)) style_name = self.get_appropriate_style_name( s) for i in o.items: if o.items.index( i) == 0: x... | |
( 'draw:textarea-horizontal-align','left'), | ( 'draw:textarea-horizontal-align','middle'), | def to_dom( self, doc): style = doc.createElement( 'style:style') dom_extensions.setAttributes( style, (('style:family', self.family), ('style:name', self.name), ('style:parent-style-name','standard'))) pad_top = "%scm" % self.padding_top pad_bot = "%scm" % self.padding_bottom prop = dom_extensions.elementUnder( style,... |
if 'bond_width' in self.__dict__: | if hasattr( self, 'bond_width'): | def read_standard_values( self, standard, old_standard=None): meta_enabled.read_standard_values( self, standard, old_standard=old_standard) # wedge width if not old_standard or (standard.wedge_width != old_standard.wedge_width): self.wedge_width = Screen.any_to_px( standard.wedge_width) # line width if not old_standard... |
if o.object_type == 'arrow' or o.object_type == 'polygon': | if o.object_type in ('arrow','polygon','polyline'): | def select( self, items): "adds an object to the list of other selected objects and calls their select() method" for o in items: if o.object_type == 'arrow' or o.object_type == 'polygon': # we cannot allow arrows or polygons to be selected because selection of arrow and its points # doubles some actions (moving etc.) a... |
area_colored.meta__undo_properties | area_colored.meta__undo_properties +\ ("xml_ftext",) | def lift( self): if self.selector: self.paper.lift( self.selector) if self.item: self.paper.lift( self.item) |
self.bind( "<Button-1>", self._n_pressed1) self.bind( "<Shift-Button-1>", self._s_pressed1) | def set_bindings( self): if not Store.app.in_batch_mode: self.bind( "<B1-Motion>", self._drag1) self.bind( "<ButtonRelease-1>", self._release1) self.bind( "<Button-1>", self._n_pressed1) self.bind( "<Shift-Button-1>", self._s_pressed1) self.bind( "<Shift-B1-Motion>", self._drag1) self.bind( "<Delete>", self.key_pressed... | |
def _s_pressed1( self, event): "button 1 with shift" | def _pressed1( self, event, mod=None): "button 1" | def _s_pressed1( self, event): "button 1 with shift" event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) Store.app.mode.mouse_down( event, modifiers=['shift']) |
Store.app.mode.mouse_down( event, modifiers=['shift']) def _n_pressed1( self, event): "button 1 without anything" event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) Store.app.mode.mouse_down( event) | Store.app.mode.mouse_down( event, modifiers=mod) | def _s_pressed1( self, event): "button 1 with shift" event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) Store.app.mode.mouse_down( event, modifiers=['shift']) |
a = map( self.id_to_object, b) a = [i for i in a if i not in self._do_not_focus] | id_objs = [(x, self.id_to_object( x)) for x in b] a = [i for i in id_objs if i[1] not in self._do_not_focus] | def _move( self, event): event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) |
a = a[-1] else: a = None | fid, fobj = a[-1] else: fid, fobj = None, None | def _move( self, event): event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) |
if a and a != self.__in: self.__in = a | if fobj and (fobj != self.__in or (misc.isinstance_of_one( fobj, self.classes_with_per_item_reselection) and self.__in_id != fid)): self.__in = fobj self.__in_id = fid | def _move( self, event): event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) |
elif not a and self.__in: | elif not fobj and self.__in: | def _move( self, event): event.x = self.canvasx( event.x) event.y = self.canvasy( event.y) |
return self.canvas.list_bbox( [i.item for i in self.items]) | bbox = list( self.canvas.list_bbox( [i.item for i in self.items if not i.ignore_y])) for i in self.items: if i.ignore_y: x1, y1, x2, y2 = self.canvas.bbox( i.item) bbox[0] = min( (bbox[0], x1)) bbox[2] = max( (bbox[2], x2)) if y1 < bbox[1]: bbox[1] -= 2 return bbox | def bbox( self): """returns the bounding box of the object as a list of [x1,y1,x2,y2]""" return self.canvas.list_bbox( [i.item for i in self.items]) |
self.ignore_y = False | def __init__( self, text, attrs=None): self.text = text self.attrs = attrs or Set() self.item = None self.dx = 0 | |
Store.app.paper.new_polyline( [x1+0.1*abs(y2-y1), y1, x1, y1, x1, y2, x1+0.1*abs(y2-y1), y2]).draw() Store.app.paper.new_polyline( [x2-0.1*abs(y2-y1), y1, x2, y1, x2, y2, x2-0.1*abs(y2-y1), y2]).draw() | dx = 0.05*math.sqrt( (y2-y1)**2 + (x2-x1)**2) Store.app.paper.new_polyline( [x1+dx, y1, x1, y1, x1, y2, x1+dx, y2]).draw() Store.app.paper.new_polyline( [x2-dx, y1, x2, y1, x2, y2, x2-dx, y2]).draw() | def _end_of_empty_drag( self, x1, y1, x2, y2): Store.app.paper.new_polyline( [x1+0.1*abs(y2-y1), y1, x1, y1, x1, y2, x1+0.1*abs(y2-y1), y2]).draw() |
else: self.bond_width = None | def read_package( self, package): b = ['no', 'yes'] type = package.getAttribute( 'type') if type: self.type = type[0] self.order = int( type[1]) else: self.type = 'n' self.order = 1 # implied if package.getAttribute( 'bond_width'): self.bond_width = float( package.getAttribute( 'bond_width')) * self.paper.real_to_scree... | |
area_colored.__init__( self) | def __init__( self, paper, coords=(), package=None, width=1): vector_graphics_item.__init__( self, paper, coords=coords, package=package, width=width) area_colored.__init__( self) del self.coords # polygon does use points for storage of coord information if not package: self.points = [] for i in range( 0, len( coords),... | |
line_colored.__init__( self) | def __init__( self, paper, coords=(), package=None, width=1): vector_graphics_item.__init__( self, paper, coords=coords, package=package, width=width) line_colored.__init__( self) del self.coords # polygon does use points for storage of coord information if not package: self.points = [] for i in range( 0, len( coords),... | |
'molecule', 'line_color','double_length_ratio', 'wedge_width') | 'molecule', 'line_color','double_length_ratio', 'wedge_width', 'order') | def transform( self, tr): x, y = tr.transform_xy( self.x, self.y) self.move_to( x, y, dont_move_marks=1) for m in self.marks.values(): if m: m.transform( tr) |
if b.type <= 3: if not (b.type == 2 and b.center): coords = reduce( operator.add, [o.get_xy() for o in b.get_atoms()]) coords = map( self.paper.px_to_cm, coords) self.create_oo_line( coords, page, style_name) if b.second: coords = map( self.paper.px_to_cm, self.paper.coords( b.second)) self.create_oo_line( coords, page... | if b.type == 'h': items = b.items else: if b.center: if not b.order == 2: print "shit!" items = [] else: items = [b.item] items += b.second items += b.third if b.type in 'nbh': for i in items: | def add_bond( self, b, page): """adds bond item to page""" s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color), stroke_width=self.paper.px_to_cm( b.line_width)) style_name = self.get_appropriate_style_name( s) l_group = page if b.type <= 3: if not (b.type == 2 and b.center): coords = redu... |
point_array = [] maxX, maxY, minX, minY = None,None,None,None for p in a.points: x,y = map( self.paper.px_to_cm, p.get_xy()) if not maxX or x > maxX: maxX = x if not minX or x < minX: minX = x if not maxY or y > maxY: maxY = y if not minY or y < minY: minY = y point_array.append( (x,y)) points = "" for (x,y) in point_a... | points = [map( self.paper.px_to_cm, p.get_xy()) for p in a.points] self.create_oo_polyline( points, page, style_name) | def add_arrow( self, a, page): end_pin, start_pin = None,None if a.pin==1 or a.pin==3: end_pin = 1 if a.pin==2 or a.pin==3: start_pin = 1 s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( a.line_color), marker_end=end_pin, marker_start=start_pin, stroke_width=self.paper.px_to_cm( a.line_width)) style... |
import pixmaps | def change_mode( self, tag): import pixmaps self.paper.switch_to_mode( tag) if self.subbuttons: for butts in self.subbuttons: butts.deleteall() m = self.paper.mode for i in range( len( m.submodes)): if i >= len( self.subbuttons): self.subbuttons.append( Pmw.RadioSelect( self.subFrame, buttontype = 'button', selectmode ... | |
if i >= len( self.subbuttons): self.subbuttons.append( Pmw.RadioSelect( self.subFrame, buttontype = 'button', selectmode = 'single', orient = 'horizontal', command = self.change_submode, hull_borderwidth = 0, padx = 0, pady = 0, hull_relief = 'ridge', )) if i % 2: self.subbuttons[i].pack( side=LEFT, padx=10) else: self... | self.subbuttons.append( Pmw.RadioSelect( self.subFrame, buttontype = 'button', selectmode = 'single', orient = 'horizontal', command = self.change_submode, hull_borderwidth = 0, padx = 0, pady = 0, hull_relief = 'ridge', )) if i % 2: self.subbuttons[i].pack( side=LEFT, padx=10) else: self.subbuttons[i].pack( side=LEFT) | def change_mode( self, tag): import pixmaps self.paper.switch_to_mode( tag) if self.subbuttons: for butts in self.subbuttons: butts.deleteall() m = self.paper.mode for i in range( len( m.submodes)): if i >= len( self.subbuttons): self.subbuttons.append( Pmw.RadioSelect( self.subFrame, buttontype = 'button', selectmode ... |
self.second = None self.third = None | self.second = [] self.third = [] | def __init__( self, paper, atoms=(), package=None, molecule=None, type='s', order=1): self.type = type self.order = order meta_enabled.__init__( self, paper) self.item = None self.second = None self.third = None self.items = [] self.molecule = molecule if atoms: self.atom1, self.atom2 = atoms self.selector = None |
if self.type in ('w','h'): | if self.type in 'whab': | def read_standard_values( self, old_standard=None): meta_enabled.read_standard_values( self, old_standard=old_standard) # wedge width or ... if self.type in ('w','h'): if not old_standard or (self.paper.standard.wedge_width != old_standard.wedge_width): self.bond_width = self.paper.any_to_px( self.paper.standard.wedge_... |
self.bond_width = self.paper.any_to_px( self.paper.standard.wedge_width) else: if not old_standard or (self.paper.standard.bond_width != old_standard.bond_width): if 'bond_width' in self.__dict__: self.bond_width = misc.signum( self.bond_width) *self.paper.any_to_px( self.paper.standard.bond_width) else: self.bond_wid... | self.line_width = self.paper.any_to_px( self.paper.standard.wedge_width) else: if not old_standard or (self.paper.standard.line_width != old_standard.line_width): self.line_width = self.paper.any_to_px( self.paper.standard.line_width) | def read_standard_values( self, old_standard=None): meta_enabled.read_standard_values( self, old_standard=old_standard) # wedge width or ... if self.type in ('w','h'): if not old_standard or (self.paper.standard.wedge_width != old_standard.wedge_width): self.bond_width = self.paper.any_to_px( self.paper.standard.wedge_... |
if not old_standard or (self.paper.standard.line_width != old_standard.line_width): self.line_width = self.paper.any_to_px( self.paper.standard.line_width) | if not old_standard or (self.paper.standard.bond_width != old_standard.bond_width): if 'bond_width' in self.__dict__: self.bond_width = misc.signum( self.bond_width) * self.paper.any_to_px( self.paper.standard.bond_width) else: self.bond_width = self.paper.any_to_px( self.paper.standard.bond_width) | def read_standard_values( self, old_standard=None): meta_enabled.read_standard_values( self, old_standard=old_standard) # wedge width or ... if self.type in ('w','h'): if not old_standard or (self.paper.standard.wedge_width != old_standard.wedge_width): self.bond_width = self.paper.any_to_px( self.paper.standard.wedge_... |
self.second = self.third = None | self.second = self.third = [] | def _draw_n1( self): x1, y1 = self.atom1.get_xy() x2, y2 = self.atom2.get_xy() # main item self.item = self.paper.create_line( (x1, y1, x2, y2), tags=('bond',), width=self.line_width, fill=self.line_color, capstyle="round") # draw helper items self.second = self.third = None self.paper.register_id( self.item, self) ret... |
self.second = self.paper.create_line( x-_k*dx, y-_k*dy, x0+_k*dx, y0+_k*dy, width=self.line_width, fill=self.line_color) | self.second = [self.paper.create_line( x-_k*dx, y-_k*dy, x0+_k*dx, y0+_k*dy, width=self.line_width, fill=self.line_color)] | def _draw_n2( self): x1,y1,x2,y2 = self._draw_n1() if self.center == None or self.bond_width == None: self._decide_distance_and_center() d = self.bond_width # double if self.center: self.paper.itemconfig( self.item, fill='') d = int( round( d/3)) x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, d) # shortening of... |
self.third = self.paper.create_line( 2*x1-x, 2*y1-y, 2*x2-x0, 2*y2-y0, width=self.line_width, fill=self.line_color) | self.third = [self.paper.create_line( 2*x1-x, 2*y1-y, 2*x2-x0, 2*y2-y0, width=self.line_width, fill=self.line_color)] | def _draw_n2( self): x1,y1,x2,y2 = self._draw_n1() if self.center == None or self.bond_width == None: self._decide_distance_and_center() d = self.bond_width # double if self.center: self.paper.itemconfig( self.item, fill='') d = int( round( d/3)) x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, d) # shortening of... |
if self.center == None or self.bond_width == None: | if self.bond_width == None: | def _draw_n3( self): x1,y1,x2,y2 = self._draw_n1() if self.center == None or self.bond_width == None: self._decide_distance_and_center() d = self.bond_width _k = (1-self.double_length_ratio)/2 x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, d*3/4) dx = x-x0 dy = y-y0 self.second = self.paper.create_line( x-_k*dx... |
self.second = self.paper.create_line( x-_k*dx, y-_k*dy, x0+_k*dx, y0+_k*dy, width=self.line_width, fill=self.line_color) self.third = self.paper.create_line( 2*x1-x-_k*dx, 2*y1-y-_k*dy, 2*x2-x0+_k*dx, 2*y2-y0+_k*dy, width=self.line_width, fill=self.line_color) | self.second = [self.paper.create_line( x-_k*dx, y-_k*dy, x0+_k*dx, y0+_k*dy, width=self.line_width, fill=self.line_color)] self.third = [self.paper.create_line( 2*x1-x-_k*dx, 2*y1-y-_k*dy, 2*x2-x0+_k*dx, 2*y2-y0+_k*dy, width=self.line_width, fill=self.line_color)] | def _draw_n3( self): x1,y1,x2,y2 = self._draw_n1() if self.center == None or self.bond_width == None: self._decide_distance_and_center() d = self.bond_width _k = (1-self.double_length_ratio)/2 x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, d*3/4) dx = x-x0 dy = y-y0 self.second = self.paper.create_line( x-_k*dx... |
x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) | x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, width) | def _draw_h1( self): x1,y1,x2,y2 = self._draw_n1() # main item self.paper.itemconfig( self.item, fill='') # the small lines step_size = 5 x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) d = sqrt( (x1-x2)**2 + (y1-y2)**2) # length of the bond dx1 = -(x1 - x0)/d dy1 = -(y1 - y0)/d dx2 = -(x1 -2*x2... |
coords = map( round, coords) | def _draw_h1( self): x1,y1,x2,y2 = self._draw_n1() # main item self.paper.itemconfig( self.item, fill='') # the small lines step_size = 5 x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) d = sqrt( (x1-x2)**2 + (y1-y2)**2) # length of the bond dx1 = -(x1 - x0)/d dy1 = -(y1 - y0)/d dx2 = -(x1 -2*x2... | |
self.items.append( self.paper.create_line( coords, width=self.line_width, fill=self.line_color)) | items.append( self.paper.create_line( coords, width=self.line_width, fill=self.line_color)) return items | def _draw_h1( self): x1,y1,x2,y2 = self._draw_n1() # main item self.paper.itemconfig( self.item, fill='') # the small lines step_size = 5 x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, self.bond_width) d = sqrt( (x1-x2)**2 + (y1-y2)**2) # length of the bond dx1 = -(x1 - x0)/d dy1 = -(y1 - y0)/d dx2 = -(x1 -2*x2... |
self.item = self._draw_wedge( (x1,y1,x2,y2), self.bond_width) | self.item = self._draw_wedge( (x1,y1,x2,y2), self.line_width) self.paper.addtag_withtag( "bond", self.item) | def _draw_w1( self): x1, y1 = self.atom1.get_xy() x2, y2 = self.atom2.get_xy() #x1, y1, x2, y2 = map( round, [x1, y1, x2, y2]) # main item self.item = self._draw_wedge( (x1,y1,x2,y2), self.bond_width) # draw helper items self.second = self.third = None self.paper.register_id( self.item, self) |
self.second = self.third = None | self.second = self.third = [] | def _draw_w1( self): x1, y1 = self.atom1.get_xy() x2, y2 = self.atom2.get_xy() #x1, y1, x2, y2 = map( round, [x1, y1, x2, y2]) # main item self.item = self._draw_wedge( (x1,y1,x2,y2), self.bond_width) # draw helper items self.second = self.third = None self.paper.register_id( self.item, self) |
return self.paper.create_polygon( (x1, y1, x0, y0, 2*x2-x0, 2*y2-y0), tags=('bond',), outline=self.line_color, fill=self.line_color, joinstyle="miter") | return self.paper.create_polygon( (x1, y1, x0, y0, 2*x2-x0, 2*y2-y0), outline=self.line_color, fill=self.line_color, joinstyle="miter") def _draw_a1( self): x1, y1 = self.atom1.get_xy() x2, y2 = self.atom2.get_xy() self.item = self._draw_adder( (x1,y1,x2,y2), self.line_width) self.paper.addtag_withtag( "bond", self... | def _draw_wedge( self, coords, width): """returns the polygon item""" x1, y1, x2, y2 = coords # main item x, y, x0, y0 = geometry.find_parallel( x1, y1, x2, y2, width) return self.paper.create_polygon( (x1, y1, x0, y0, 2*x2-x0, 2*y2-y0), tags=('bond',), outline=self.line_color, fill=self.line_color, joinstyle="miter") |
if self.second: self.paper.delete( self.second) self.second = None if self.third: self.paper.delete( self.third) self.third = None | [self.paper.delete( i) for i in self.second] self.second = [] [self.paper.delete( i) for i in self.third] self.third = [] | def simple_redraw( self): """very fast redraw that draws only a simple line instead of the bond, used in 3d rotation only (as for bkchem 0.5.0)""" if self.second: self.paper.delete( self.second) self.second = None if self.third: self.paper.delete( self.third) self.third = None if self.items: map( self.paper.delete, sel... |
if self.type == 'n': items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] | items = [self.item] + self.second + self.third if self.type in 'nab': | def focus( self): if self.type == 'n': items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width+2) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width+2) for item in self.items] elif ... |
[self.paper.itemconfig( item, width = self.line_width+2) for item in self.items] | self.paper.itemconfig( self.item, fill="black") | def focus( self): if self.type == 'n': items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width+2) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width+2) for item in self.items] elif ... |
self.paper.itemconfigure( self.item, fill='white') | if self.center: items.remove( self.item) [self.paper.itemconfigure( item, fill='white') for item in items] | def focus( self): if self.type == 'n': items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width+2) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width+2) for item in self.items] elif ... |
if self.type == 'n': | items = [self.item] + self.second + self.third if self.type in 'nab': | def unfocus( self): if self.type == 'n': if not self.item: return items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width) for it... |
items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] | def unfocus( self): if self.type == 'n': if not self.item: return items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width) for it... | |
[self.paper.itemconfig( item, width = self.line_width) for item in self.items] | self.paper.itemconfig( self.item, fill = "") | def unfocus( self): if self.type == 'n': if not self.item: return items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width) for it... |
self.paper.itemconfigure( self.item, fill=self.line_color) | if self.center: items.remove( self.item) [self.paper.itemconfigure( item, fill=self.line_color) for item in items] | def unfocus( self): if self.type == 'n': if not self.item: return items = [self.item] if self.second: items += [self.second] if self.third: items += [self.third] [self.paper.itemconfig( item, width = self.line_width) for item in items] elif self.type == 'h': [self.paper.itemconfig( item, width = self.line_width) for it... |
b = [self.item] if self.second: b.append( self.second) if self.third: b.append( self.third) if self.selector: b.append( self.selector) if self.items: b.extend( self.items) [self.paper.move( o, dx, dy) for o in b] | items = [self.item] + self.second + self.third + self.items [self.paper.move( o, dx, dy) for o in items] | def move( self, dx, dy): """moves object with his selector (when present)""" #self.redraw() # changed for speed, reduces time needed to move objects to 1/2 b = [self.item] if self.second: b.append( self.second) if self.third: b.append( self.third) if self.selector: b.append( self.selector) if self.items: b.extend( sel... |
items = [] | items = [self.item] + self.second + self.third + self.items | def delete( self): self.unselect() items = [] if self.item: items += [self.item] self.paper.unregister_id( self.item) self.item = None if self.second: items += [self.second] self.second = None if self.third: items += [self.third] self.third = None if self.items: items.extend( self.items) self.items = [] map( self.paper... |
items += [self.item] | def delete( self): self.unselect() items = [] if self.item: items += [self.item] self.paper.unregister_id( self.item) self.item = None if self.second: items += [self.second] self.second = None if self.third: items += [self.third] self.third = None if self.items: items.extend( self.items) self.items = [] map( self.paper... | |
self.item = None if self.second: items += [self.second] self.second = None if self.third: items += [self.third] self.third = None if self.items: items.extend( self.items) self.items = [] | self.item = None self.second = [] self.third = [] self.items = [] | def delete( self): self.unselect() items = [] if self.item: items += [self.item] self.paper.unregister_id( self.item) self.item = None if self.second: items += [self.second] self.second = None if self.third: items += [self.third] self.third = None if self.items: items.extend( self.items) self.items = [] map( self.paper... |
self.item = None | def delete( self): self.unselect() items = [] if self.item: items += [self.item] self.paper.unregister_id( self.item) self.item = None if self.second: items += [self.second] self.second = None if self.third: items += [self.third] self.third = None if self.items: items.extend( self.items) self.items = [] map( self.paper... | |
if self.order != 1 or self.type in 'wha': | if self.order != 1: | def get_package( self, doc): b = ['no', 'yes'] bnd = doc.createElement('bond') dom_extensions.setAttributes( bnd, (('type', "%s%d" % (self.type, self.order)), ('width', str( self.line_width)), ('start', self.atom1.get_cdml_id()), ('end', self.atom2.get_cdml_id()), ('double_ratio', str( self.double_length_ratio)))) if s... |
return (x02-x01)/(x12-x11), (y02-y01/y12-y02) | return (x02-x01)/(x12-x11), (y02-y01)/(y12-y11) | def get_scaling_xy( self): """computes the scaling for 'x' and 'y' separately""" x01, y01, x02, y02 = [0, 0, 100, 100] x11, y11, x12, y12 = self.transform_4( (x01, y01, x02, y02)) return (x02-x01)/(x12-x11), (y02-y01/y12-y02) |
return self.molecule | return self.arrow | def _get_parent( self): return self.molecule |
point_drawable.__init__( self) text_like.__init__( self) area_colored.__init__( self) | def __init__( self, paper, xy=(), text='', package=None): meta_enabled.__init__( self, paper) point_drawable.__init__( self) text_like.__init__( self) area_colored.__init__( self) self.selector = None self._selected = 0 self.ftext = None if xy: self.set_xy( xy[0], xy[1]) self.set_text( text) self.item = None if packag... | |
self.subbuttons[i].pack( side=LEFT) | if i % 2: self.subbuttons[i].pack( side=LEFT, padx=10) else: self.subbuttons[i].pack( side=LEFT) | def change_mode( self, tag): import pixmaps self.paper.switch_to_mode( tag) if self.subbuttons: for butts in self.subbuttons: butts.deleteall() m = self.paper.mode for i in range( len( m.submodes)): if i >= len( self.subbuttons): self.subbuttons.append( Pmw.RadioSelect( self.subFrame, buttontype = 'button', selectmode ... |
('share/bkchem/images', ['images/logo.ppm']), | ('share/bkchem/images', ['images/logo.ppm','images/icon.ico','images/icon.png']), | def strip_path( path): if path.startswith( strip): new = path.replace( strip, "", 1) return new else: return path |
self.app.paper.select( [self.focused]) name = self.app.editPool.activate( text = self.focused.get_text()) if name and not dom_extensions.isOnlyTags( name): self.app.paper.set_name_to_selected( name) self.app.paper.add_bindings() | self.app.paper.signal_to_app( _("The text mode can no longer be used to edit atoms, use atom mode.")) | def mouse_click( self, event): if not self.focused: name = self.app.editPool.activate() if not name: return name = unicode( name).encode( 'utf-8') ## catch not well-formed text try: xml.sax.parseString( "<a>%s</a>" % name, xml.sax.ContentHandler()) except xml.sax.SAXParseException: name = xml.sax.saxutils.escape( name)... |
self.app.paper.set_name_to_selected( name) | self.app.paper.set_name_to_selected( name, interpret=self.app.editPool.interpret) | def mouse_click( self, event): if not self.focused: name = self.app.editPool.activate() if not name: return name = unicode( name).encode( 'utf-8') ## catch not well-formed text try: xml.sax.parseString( "<a>%s</a>" % name, xml.sax.ContentHandler()) except xml.sax.SAXParseException: name = xml.sax.saxutils.escape( name)... |
v = self.get_free_valency() | v = self.free_valency | def get_text( self): if not self.show: return self.name elif self.show: ret = self.name # hydrogens if self.show_hydrogens: v = self.get_free_valency() if v: h = 'H' else: h = '' if v > 1: h += '%d' % v if self.pos == 'center-last': ret = h + ret else: ret = ret + h # charge if self.charge: ch = '' if abs( self.charge)... |
v = self.get_free_valency() | v = self.free_valency | def get_ftext( self): ret = self.name # hydrogens if self.show_hydrogens: v = self.get_free_valency() if v: h = 'H' else: h = '' if v > 1: h += '<sub>%d</sub>' % v if self.pos == 'center-last': ret = h + ret else: ret = ret + h # charge if self.charge -self.get_charge_from_marks(): ch = '' if abs( self.charge) > 1: ch ... |
free_val = self.get_free_valency() if free_val > 0: ret['H'] = free_val return ret | if self.free_valency > 0: ret['H'] = self.free_valency return re | def get_formula_dict( self): """returns formula as dictionary that can be passed to functions in periodic_table""" ret = PT.formula_dict( self.name) free_val = self.get_free_valency() if free_val > 0: ret['H'] = free_val return ret |
fv = self.get_free_valency( strict=1) | fv = self.free_valency | def set_valency_from_name( self): for val in PT.periodic_table[ self.name]['valency']: self.valency = val try: fv = self.get_free_valency( strict=1) except: return # this happens on read if fv >= 0: return |
if already_there: | if already_there and len( [o for o in self.selected if o.object_type != 'mark']): | def __init__( self, selected, **kw): Tkinter.Menu.__init__( self, Store.app, tearoff=0, **kw) self.selected = selected self.changes_made = 0 already_there = [] self.configurable = {} # this is similar to configurable but is prepared on init to take dynamic things into account for obj_type in configurable.keys(): if typ... |
if i: self.add_separator() self.add_command( label=_("Properties"), command=Store.app.paper.config_selected) | if len( [o for o in self.selected if o.object_type != 'mark']): if i: self.add_separator() self.add_command( label=_("Properties"), command=Store.app.paper.config_selected) | def __init__( self, selected, **kw): Tkinter.Menu.__init__( self, Store.app, tearoff=0, **kw) self.selected = selected self.changes_made = 0 already_there = [] self.configurable = {} # this is similar to configurable but is prepared on init to take dynamic things into account for obj_type in configurable.keys(): if typ... |
( 'textLength', "%dpx" % (x2-x-2)))) | ( 'textLength', "%dpx" % (x2-x)))) | def add_text( self, t): """adds text item to SVG document""" item = t.item x1, y1 = t.get_xy() x, y, x2, y2 = self.paper.bbox( item) dom_extensions.elementUnder( self.group, 'rect', (( 'x', str( x)), ( 'y', str( y)), ( 'width', str( x2-x)), ( 'height', str( y2-y)), ( 'fill', t.area_color), ( 'stroke', t.area_color))) y... |
( 'textLength', "%dpx" % (x2-x-2)))) | ( 'textLength', "%dpx" % (x2-x)))) | def add_atom( self, a): """adds atom item to SVG document""" if a.show: item = a.selector x1, y1 = a.get_xy() x, y, x2, y2 = self.paper.bbox( item) if os.name == 'nt': x += 2 #nasty hack to improve results on win machines (they have larger fonts?!?) x2 -= 2 dom_extensions.elementUnder( self.group, 'rect', (( 'x', str(... |
other.id = self.id | pass | def copy_settings( self, other): """copies settings of self to other, does not check if other is capable of receiving it""" other.id = self.id |
replace_minus_button.pack( anchor='w', padx=5, pady=5) | def draw( self): paper_frame = Tkinter.Frame( self.dialog.interior(), bd=2, relief="groove") paper_frame.pack( padx=10, pady=10, anchor="n", fill="x") | |
replace_minus_button.pack( anchor='w', padx=10, pady=10) | def draw( self): self.pages = Pmw.NoteBook( self.body) self.pages.pack( anchor='w', pady=0, padx=0, fill='both', expand=1) # COMMON common_page = self.pages.add( _('Common')) # use real minus ? replace_minus_button = Tkinter.Checkbutton( common_page, text=_('Use real minus chracter (instead of hyphen)?'), variable=self... | |
self.area_color = pack.getAttribute( 'area_color') or self.area_color self.line_color = pack.getAttribute( 'line_color') or self.line_color | for attr in ("area_color", "line_color"): if pack.getAttributeNode( attr): setattr( self, attr, pack.getAttribute( 'area_color')) | def read_package( self, pack): """reads the dom element pack and sets internal state according to it""" self.coords = self.paper.real_to_screen_coords( map( Screen.any_to_px, dom_extensions.getAttributes( pack, ['x1', 'y1', 'x2', 'y2']))) self.area_color = pack.getAttribute( 'area_color') or self.area_color self.line_c... |
self.area_color = pack.getAttribute( 'area_color') or self.area_color self.line_color = pack.getAttribute( 'line_color') or self.line_color | for attr in ("area_color", "line_color"): if pack.getAttributeNode( attr): setattr( self, attr, pack.getAttribute( 'area_color')) | def read_package( self, pack): """reads the dom element pack and sets internal state according to it""" self.coords = self.paper.real_to_screen_coords( map( Screen.any_to_px, dom_extensions.getAttributes( pack, ['x1', 'y1', 'x2', 'y2']))) |
self.area_color = pack.getAttribute( 'area_color') or self.area_color self.line_color = pack.getAttribute( 'line_color') or self.line_color | for attr in ("area_color", "line_color"): if pack.getAttributeNode( attr): setattr( self, attr, pack.getAttribute( 'area_color')) | def read_package( self, pack): """reads the dom element pack and sets internal state according to it""" self.points = [] for p in pack.getElementsByTagName( 'point'): self.points.append( classes.point( self.paper, arrow=self, package=p)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.