Beispiel #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()
Beispiel #2
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)