Пример #1
0
    def init_gui(self):
        self.draw_area = DrawArea(self.sub_frame)
        self.pallete = HeaderFrame(self.sub_frame, 'Palette')
        self.pallete.close = self.hide_pallete

        self.draw_area.grid(row=0,
                            column=0,
                            rowspan=4,
                            columnspan=3,
                            sticky=(tk.N, tk.S, tk.W, tk.E))
        self.pallete.grid(row=0,
                          column=3,
                          rowspan=4,
                          columnspan=1,
                          sticky=(tk.N, tk.S, tk.W, tk.E))

        self.fields = Section(self.pallete.sub_frame,
                              text='Fields',
                              relief="raised",
                              borderwidth=1)
        self.fields.pack(fill="x", pady=2, padx=2, anchor="ne")

        self.constructs = Section(self.pallete.sub_frame,
                                  text='Constructs',
                                  relief="raised",
                                  borderwidth=1)
        self.constructs.pack(fill="x", expand=1, pady=2, padx=2, anchor="ne")

        for r in range(4):
            self.sub_frame.rowconfigure(r, weight=1)
        for c in range(4):
            self.sub_frame.columnconfigure(c, weight=1)

        self.init_fields()
        self.init_constructs()
Пример #2
0
    def __init__(self, parent, path, text):
        HeaderFrame.__init__(self, parent, text)
        self.root = parent
        self.tree = ttk.Treeview(self.sub_frame)

        ttk.Style().configure(".", font=('Helvetica', 12), foreground="")

        ysb = ttk.Scrollbar(self, orient='vertical', command=self.tree.yview)
        xsb = ttk.Scrollbar(self, orient='horizontal', command=self.tree.xview)
        self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)
        self.tree.heading('#0', text=path, anchor='w')

        abspath = os.path.abspath(path)
        root_node = self.tree.insert('', 'end', text='Workspace', open=True)
        self.process_directory(root_node, abspath)

        self.tree.pack(fill='both', expand=1)
Пример #3
0
    def attach(self, canvas, x=10, y=10):
        if canvas is self.canvas:
            self.canvas.coords(self.id, x, y)
            return
        if self.canvas:
            self.detach()
        if not canvas:
            return zxx

        if self.label is not None:
            self.label.destroy()

        if 'S' in self.name and self.is_copy:
            label = StartField(canvas, self.ba, 'Start')
        elif 'Field' in self.name and self.is_copy:
            label = Variable(canvas, self.ba, 'Field')
        elif 'Reference List' in self.name and self.is_copy:
            label = ReferenceList(canvas, self.ba, 'Reference List')
        elif 'E' in self.name and self.is_copy:
            label = HeaderFrame(canvas, 'End')
        elif 'Packet Info' in self.name and self.is_copy:
            label = PacketInfo(canvas, self.ba, 'Packet')

        elif 'rect' in self.shape:
            label = tk.Label(canvas,
                             text=self.name,
                             borderwidth=2,
                             relief="raised",
                             padx=10,
                             pady=10)
        elif 'circular' in self.shape:
            label = CircularButton(canvas, 50, 50, 'grey', self.name)
        elif 'rhombus' in self.shape:
            label = RhombusButton(canvas, 300, 150, 'grey')
        else:
            label = ArrowButton(canvas, 200, 150, 'black')
            self.arrow = True

        id = canvas.create_window(x, y, window=label, anchor="nw")

        self.canvas = canvas
        self.label = label
        self.id = id
        if not self.is_copy:
            label.bind("<ButtonPress>", self.press)
        if self.is_copy:
            label.bind("<ButtonPress>", self.press_copy)
Пример #4
0
 def __init__(self, parent, root, text):
     ''' Constructor '''
     HeaderFrame.__init__(self, parent, text)
     self.parent = parent
     self.root = root
     self.init_gui()
Пример #5
0
 def __init__(self, parent, text):
     HeaderFrame.__init__(self, parent, text)
     self.root = parent
     self.init_gui()
Пример #6
0
class BuildingArea(HeaderFrame):
    def __init__(self, parent, text):
        HeaderFrame.__init__(self, parent, text)
        self.root = parent
        self.init_gui()

    def init_gui(self):
        self.draw_area = DrawArea(self.sub_frame)
        self.pallete = HeaderFrame(self.sub_frame, 'Palette')
        self.pallete.close = self.hide_pallete

        self.draw_area.grid(row=0,
                            column=0,
                            rowspan=4,
                            columnspan=3,
                            sticky=(tk.N, tk.S, tk.W, tk.E))
        self.pallete.grid(row=0,
                          column=3,
                          rowspan=4,
                          columnspan=1,
                          sticky=(tk.N, tk.S, tk.W, tk.E))

        self.fields = Section(self.pallete.sub_frame,
                              text='Fields',
                              relief="raised",
                              borderwidth=1)
        self.fields.pack(fill="x", pady=2, padx=2, anchor="ne")

        self.constructs = Section(self.pallete.sub_frame,
                                  text='Constructs',
                                  relief="raised",
                                  borderwidth=1)
        self.constructs.pack(fill="x", expand=1, pady=2, padx=2, anchor="ne")

        for r in range(4):
            self.sub_frame.rowconfigure(r, weight=1)
        for c in range(4):
            self.sub_frame.columnconfigure(c, weight=1)

        self.init_fields()
        self.init_constructs()

    def init_fields(self):
        self.icons = [
            Icon("S",
                 shape='circular',
                 command=self.start_field_popup,
                 ba=self),
            Icon("Field (Var size)", command=self.var_popup, ba=self),
            Icon("Reference List", command=self.ref_popup, ba=self),
            Icon("E", shape='circular', ba=self),
            Icon("Packet Info.", command=self.pack_popup, ba=self)
        ]

        for i in range(2):
            y = i * 80 + 30
            self.icons[i].attach(self.fields.canvas, y=y)
            self.icons[i + 3].attach(self.fields.canvas, x=350, y=y)

        y = 3 * 80 + 30
        self.icons[2].attach(self.fields.canvas, y=y)

    def var_popup(self):
        pass

    def start_field_popup(self):
        #self.start_win = tk.Toplevel(self.root) # Set parent
        #StartField(self.start_win, self)
        pass

    def ref_popup(self):
        pass

    def pack_popup(self):
        pass

    def init_constructs(self):
        self.constructs.canvas.destroy()

        self.decision = DndFrame(self.constructs.sub_frame,
                                 "Decision",
                                 height=200)
        self.expression = Icon("Expression", shape='rhombus')
        self.expression.attach(self.decision.canvas)
        self.decision.pack(fill="x", expand=1)

        self.connector = DndFrame(self.constructs.sub_frame,
                                  text="Connector",
                                  height=200)
        self.arrow = Icon("Constructor", shape='arrow')
        self.arrow.attach(self.connector.canvas)
        self.connector.pack(fill="x", expand=0)

        self.expression = DndFrame(self.constructs.sub_frame,
                                   text="Expression")
        self.expression.pack(fill="x", expand=0)

        self.relational = DndFrame(self.expression, text="Relational Operator")
        self.relational.pack(fill="x", expand=0)

        self.rel_icons = [
            Icon("<"),
            Icon(">"),
            Icon("<="),
            Icon(">="),
            Icon("=="),
            Icon("~=")
        ]
        for i in range(6):
            x = i * 100 + 10
            self.rel_icons[i].attach(self.relational.canvas, x=x)

        self.logical = DndFrame(self.expression, text="Logical Operator")
        self.logical.pack(fill="x", expand=0)

        self.log_icons = [
            Icon("And"),
            Icon("Or"),
            Icon("Not"),
        ]

        for i in range(3):
            x = i * 150 + 10
            self.log_icons[i].attach(self.logical.canvas, x=x)

        self.operand = Icon("Operand")
        self.operand.attach(self.expression.canvas)

    def hide_pallete(self):
        self.pallete.forget_grid()

    def show_pallete(self):
        self.pallete.grid(row=0,
                          column=3,
                          rowspan=4,
                          columnspan=1,
                          sticky=(tk.N, tk.S, tk.W, tk.E))

    def close(self):
        self.grid_forget()

    def show_build(self):
        self.grid(row=1,
                  column=2,
                  rowspan=15,
                  columnspan=8,
                  sticky=(tk.N, tk.S, tk.W, tk.E))