示例#1
0
 def star(self,
          location,
          radius,
          points=5,
          color="black",
          fill=True,
          lineWidth=None,
          lineDash=None,
          **other_args):
     "Draw a star."
     s = clean_dict(
         location=location,
         radius=radius,
         points=points,
         color=color,
         fill=fill,
         lineDash=lineDash,
         lineWidth=lineWidth,
     )
     if lineWidth:
         s["lineWidth"] = lineWidth
     s.update(other_args)
     name = self.check_name(s, "star")
     self.call_method("star", s)
     return self.wrap_name(name)
示例#2
0
 def arrow(self,
           location1,
           location2,
           head_length,
           color="black",
           lineWidth=None,
           lineDash=None,
           head_angle=45,
           head_offset=0,
           symmetric=False,
           **other_args):
     "Draw an arrow."
     s = clean_dict(location1=location1,
                    location2=location2,
                    color=color,
                    lineDash=lineDash,
                    head_length=head_length,
                    head_angle=head_angle,
                    head_offset=head_offset,
                    symmetric=symmetric)
     if lineWidth:
         s["lineWidth"] = lineWidth
     s.update(other_args)
     name = self.check_name(s, "arrow")
     self.call_method("arrow", s)
     return self.wrap_name(name)
示例#3
0
def graph(
        network_json=None,
        canvas_size=500,
        info_height=150,
        selector_size=90,
        sidebar_size=150,
        gap=10,
        min_color="#00f",
        min_threshold_color="#aaa",
        max_threshold_color="#bbb",
        max_color="orange",
        default_layout="grid",  # or "relax" or "skeleton"
        separator_radius=6,
        link_radius=1,
        min_change=1,
        undo_limit=10,
        font="normal 10px Arial",  # default node font
        color="#999",  # default node font
        shape="text",  # or "circle", "rect"
        radius=4,  # radius for circle or rect
        background=None,  # default node background
        src_font=None,  # overrides for src nodes
        src_color=None,
        src_background=None,
        src_shape=None,
        src_radius=None,
        **other_attributes):
    s = clean_dict(
        network_json=network_json,
        canvas_size=canvas_size,
        info_height=info_height,
        selector_size=selector_size,
        sidebar_size=sidebar_size,
        gap=gap,
        min_color=min_color,
        min_threshold_color=min_threshold_color,
        max_threshold_color=max_threshold_color,
        max_color=max_color,
        default_layout=default_layout,  # or "relax" or "skeleton"
        separator_radius=separator_radius,
        link_radius=link_radius,
        min_change=min_change,
        undo_limit=undo_limit,
        font=font,
        color=color,
        background=background,
        shape=shape,
        radius=radius,
        src_font=src_font,
        src_color=src_color,
        src_background=src_background,
        src_shape=src_shape,
        src_radius=src_radius,
    )
    s.update(other_attributes)
    return Network_Widget(s)
示例#4
0
 def edge(self,
          source_name,
          destination_name,
          weight=1,
          color=None,
          lineWidth=None,
          lineDash=None,
          **other_args):
     s = clean_dict(color=color, lineWidth=lineWidth, lineDash=lineDash)
     s.update(other_args)
     self.element.d_network.edge(source_name, destination_name, weight, s)
示例#5
0
 def circle(self,
            location,
            r,
            color="black",
            fill=True,
            method_name="circle",
            **other_args):
     "Draw a circle or arc on the canvas frame."
     s = clean_dict(location=location, r=r, color=color, fill=fill)
     s.update(other_args)
     name = self.check_name(s, method_name)
     self.call_method(method_name, s)
     return self.wrap_name(name)
示例#6
0
 def line(self,
          location1,
          location2,
          color="black",
          lineWidth=None,
          method_name="line",
          **other_args):
     "Draw a line segment on the canvas frame."
     s = clean_dict(location1=location1,
                    location2=location2,
                    color=color,
                    lineWidth=lineWidth)
     s.update(other_args)
     name = self.check_name(s, method_name)
     self.call_method(method_name, s)
     return self.wrap_name(name)
示例#7
0
 def node(self,
          node_name,
          color=None,
          background=None,
          font=None,
          position=None,
          **other_args):
     if position is not None:
         if type(position) is not dict:
             (x, y) = position
             position = {"x": x, "y": y}
     s = clean_dict(color=color,
                    background=background,
                    font=font,
                    position=position)
     s.update(other_args)
     self.element.d_network.node(node_name, s)
示例#8
0
 def polygon(self,
             locations,
             color="black",
             close=True,
             fill=True,
             **other_args):
     "Draw a polygon or polyline on the canvas frame"
     # convert tuples to lists automagically
     lpoints = []
     for p in locations:
         if type(p) != dict:
             p = list(p)
         lpoints.append(p)
     s = clean_dict(locations=lpoints, color=color, close=close, fill=fill)
     s.update(other_args)
     name = self.check_name(s, "polygon")
     self.call_method("polygon", s)
     return self.wrap_name(name)
示例#9
0
 def rect(self,
          location,
          w,
          h,
          color="black",
          degrees=0,
          fill=True,
          method_name="rect",
          **other_args):
     "Draw a rectangle on the canvas frame."
     s = clean_dict(location=location,
                    w=w,
                    h=h,
                    color=color,
                    degrees=degrees,
                    fill=fill)
     s.update(other_args)
     name = self.check_name(s, method_name)
     self.call_method(method_name, s)
     return self.wrap_name(name)
示例#10
0
 def text(self,
          location,
          text,
          color="black",
          degrees=0,
          align="left",
          font=None,
          **other_args):
     "Draw some text on the canvas frame."
     s = clean_dict(location=location,
                    text=text,
                    color=color,
                    degrees=degrees,
                    align=align)
     if font:
         s["font"] = font
     s.update(other_args)
     name = self.check_name(s, "text")
     self.call_method("text", s)
     return self.wrap_name(name)