Пример #1
0
 def draw(self):
     """Shows the BPMN in a new window"""
     root = Tk()
     app = BPMN_Draw(root, self)
     root.mainloop()
     del app
     del root
Пример #2
0
    def get_popup_menu(self, velem, elem):
        popup_menu = BPMN_Draw.get_popup_menu(self, velem, elem)

        if velem is None:
            popup_menu.add_command(label="New activity", command=self._new_activity())
            popup_menu.add_command(label="New event",    command=self._new_event())
            popup_menu.add_command(label="New gateway",  command=self._new_gateway())
            popup_menu.add_command(label="New pool",     command=self._new_pool())
            return popup_menu

        if velem.type == "shape":
            popup_menu.add_separator()
            popup_menu.add_command(label="Change name", command=self._change_element_name(elem))
            if isinstance(elem, mbpmn.BPMN_Element):
                popup_menu.add_command(label="Add connection", command=self._add_edge(velem))
                if isinstance(elem, mbpmn.Gateway):
                    subtype_menu = Menu(popup_menu.menu, tearoff=0)
                    if elem.subtype != "exclusive":
                        subtype_menu.add_command(label="Exclusive gateway", command=self._change_element_subtype(elem, "exclusive"))
                    if elem.subtype != "inclusive":
                        subtype_menu.add_command(label="Inclusive gateway", command=self._change_element_subtype(elem, "inclusive"))
                    if elem.subtype != "parallel":
                        subtype_menu.add_command(label="Parallel gateway",  command=self._change_element_subtype(elem, "parallel"))
                    popup_menu.add_cascade(label="Change subtype to", menu=subtype_menu)
                if isinstance(elem, mbpmn.Event):
                    subtype_menu = Menu(popup_menu.menu, tearoff=0)
                    if elem.subtype != "intermediate":
                        subtype_menu.add_command(label="Intermediate event", command=self._change_element_subtype(elem, "intermediate"))
                    if elem.subtype != "start":
                        subtype_menu.add_command(label="Start event", command=self._change_element_subtype(elem, "start"))
                    if elem.subtype != "end":
                        subtype_menu.add_command(label="End event", command=self._change_element_subtype(elem, "end"))
                    popup_menu.add_cascade(label="Change subtype to", menu=subtype_menu)
                popup_menu.add_command(label="Delete "+elem.type, command=self._del_elem(elem))
            if isinstance(elem, mbpmn.Pool):
                popup_menu.add_command(label="New lane",    command=self._new_lane(elem))
                popup_menu.add_command(label="Delete pool", command=self._del_pool(elem))
            if isinstance(elem, mbpmn.Lane):
                popup_menu.add_command(label="New activity", command=self._new_activity(elem))
                popup_menu.add_command(label="New event",    command=self._new_event(elem))
                popup_menu.add_command(label="New gateway",  command=self._new_gateway(elem))
                popup_menu.add_command(label="Delete lane",  command=self._del_lane(elem))

        if velem.type == "edge":
            popup_menu.add_command(label="Delete edge", command=self._del_edge(velem))

        return popup_menu
Пример #3
0
    def __init__(self, master, bpmn, cases):
        # cases is a list of cases, where a case is a list in the format:
        # (event object, start time, end time)
        BPMN_Draw.__init__(self, master, bpmn)
        master.wm_title("BPMN Simulation")
        self.cases = cases

        self.toggle_lock()

        frame = Frame(master)

        vcmd = (master.register(self._num_entry_validate),
                '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')

        self.case_text = Label(frame, text="Steps:")
        self.case_text.grid(row=0, column=0, sticky=W+E+N+S)

        self.num_entry = Spinbox(frame, increment=1, from_=1, to=maxint, validate='all', validatecommand=vcmd)
        self.num_entry.grid(row=0, column=1, sticky=W+E+N+S)

        self.increm_options = ["seconds", "minutes", "hours", "days"]
        self.increm_var = StringVar()
        self.increm_var.set(self.increm_options[0])
        self.increm_sel = OptionMenu(frame, self.increm_var, *self.increm_options)
        self.increm_sel.grid(row=0, column=2, sticky=W+N+E+S)

        img_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "graphics")

        self.prev_but = Button(frame, command=self.on_prev_button)
        self.prev_but.grid(row=0, column=3, sticky=W+E+N+S)
        self.prev_img = PhotoImage(file=os.path.join(img_dir, "skip-backward.gif"))
        self.prev_but.config(image=self.prev_img, width=24, height=24)

        self.play_but = Button(frame, command=self.on_play_button)
        self.play_but.grid(row=0, column=4, sticky=W+E+N+S)
        self.play_img = PhotoImage(file=os.path.join(img_dir, "play.gif"))
        self.play_but.config(image=self.play_img, width=24, height=24)
        self.pause_img = PhotoImage(file=os.path.join(img_dir, "pause.gif"))

        self.stop_but = Button(frame, command=self.on_stop_button)
        self.stop_but.grid(row=0, column=5, sticky=W+E+N+S)
        self.stop_img = PhotoImage(file=os.path.join(img_dir, "stop.gif"))
        self.stop_but.config(image=self.stop_img, width=24, height=24)

        self.next_but = Button(frame, command=self.on_next_button)
        self.next_but.grid(row=0, column=6, sticky=W+E+N+S)
        self.next_img = PhotoImage(file=os.path.join(img_dir, "skip-forward.gif"))
        self.next_but.config(image=self.next_img, width=24, height=24)

        self.case_text = Label(frame, text="Case:")
        self.case_text.grid(row=0, column=7, sticky=W+E+N+S)

        self.case_options = range(1, len(self.cases)+1)
        self.case_var = StringVar()
        self.case_var.set(self.case_options[0])
        self.case_sel = OptionMenu(frame, self.case_var, *self.case_options)
        self.case_sel.grid(row=0, column=8, sticky=W+E+N+S)

        frame.pack(anchor=W)

        frame2 = Frame(master)

        self.currt_lab = Label(frame2, text="Current time:")
        self.currt_lab.grid(row=0, column=0, sticky=W+N+S)

        self.currt_var = StringVar()
        self.currt = Label(frame2, textvariable=self.currt_var)
        self.currt.grid(row=0, column=1, sticky=W+N+S)

        frame2.pack(anchor=W)

        self.case_var.trace("w", self.on_case_change)

        self.simulating = "stop"
        self.last_tick  = datetime.now()
        self.anim_tick  = datetime.now()
        self.animations = {}
Пример #4
0
 def __init__(self, master, bpmn):
     BPMN_Draw.__init__(self, master, bpmn)
     master.wm_title("BPMN Edition")
Пример #5
0
    def get_popup_menu(self, velem, elem):
        popup_menu = BPMN_Draw.get_popup_menu(self, velem, elem)

        if velem is None:
            popup_menu.add_command(label="New activity",
                                   command=self._new_activity())
            popup_menu.add_command(label="New event",
                                   command=self._new_event())
            popup_menu.add_command(label="New gateway",
                                   command=self._new_gateway())
            popup_menu.add_command(label="New pool", command=self._new_pool())
            return popup_menu

        if velem.type == "shape":
            popup_menu.add_separator()
            popup_menu.add_command(label="Change name",
                                   command=self._change_element_name(elem))
            if isinstance(elem, mbpmn.BPMN_Element):
                popup_menu.add_command(label="Add connection",
                                       command=self._add_edge(velem))
                if isinstance(elem, mbpmn.Gateway):
                    subtype_menu = Menu(popup_menu.menu, tearoff=0)
                    if elem.subtype != "exclusive":
                        subtype_menu.add_command(
                            label="Exclusive gateway",
                            command=self._change_element_subtype(
                                elem, "exclusive"))
                    if elem.subtype != "inclusive":
                        subtype_menu.add_command(
                            label="Inclusive gateway",
                            command=self._change_element_subtype(
                                elem, "inclusive"))
                    if elem.subtype != "parallel":
                        subtype_menu.add_command(
                            label="Parallel gateway",
                            command=self._change_element_subtype(
                                elem, "parallel"))
                    popup_menu.add_cascade(label="Change subtype to",
                                           menu=subtype_menu)
                if isinstance(elem, mbpmn.Event):
                    subtype_menu = Menu(popup_menu.menu, tearoff=0)
                    if elem.subtype != "intermediate":
                        subtype_menu.add_command(
                            label="Intermediate event",
                            command=self._change_element_subtype(
                                elem, "intermediate"))
                    if elem.subtype != "start":
                        subtype_menu.add_command(
                            label="Start event",
                            command=self._change_element_subtype(
                                elem, "start"))
                    if elem.subtype != "end":
                        subtype_menu.add_command(
                            label="End event",
                            command=self._change_element_subtype(elem, "end"))
                    popup_menu.add_cascade(label="Change subtype to",
                                           menu=subtype_menu)
                popup_menu.add_command(label="Delete " + elem.type,
                                       command=self._del_elem(elem))
            if isinstance(elem, mbpmn.Pool):
                popup_menu.add_command(label="New lane",
                                       command=self._new_lane(elem))
                popup_menu.add_command(label="Delete pool",
                                       command=self._del_pool(elem))
            if isinstance(elem, mbpmn.Lane):
                popup_menu.add_command(label="New activity",
                                       command=self._new_activity(elem))
                popup_menu.add_command(label="New event",
                                       command=self._new_event(elem))
                popup_menu.add_command(label="New gateway",
                                       command=self._new_gateway(elem))
                popup_menu.add_command(label="Delete lane",
                                       command=self._del_lane(elem))

        if velem.type == "edge":
            popup_menu.add_command(label="Delete edge",
                                   command=self._del_edge(velem))

        return popup_menu
Пример #6
0
 def __init__(self, master, bpmn):
     BPMN_Draw.__init__(self, master, bpmn)
     master.wm_title("BPMN Edition")
Пример #7
0
    def __init__(self, master, bpmn, cases):
        # cases is a list of cases, where a case is a list in the format:
        # (event object, start time, end time)
        BPMN_Draw.__init__(self, master, bpmn)
        master.wm_title("BPMN Simulation")
        self.cases = cases

        self.toggle_lock()

        frame = Frame(master)

        vcmd = (master.register(self._num_entry_validate), '%d', '%i', '%P',
                '%s', '%S', '%v', '%V', '%W')

        self.case_text = Label(frame, text="Steps:")
        self.case_text.grid(row=0, column=0, sticky=W + E + N + S)

        self.num_entry = Spinbox(frame,
                                 increment=1,
                                 from_=1,
                                 to=maxint,
                                 validate='all',
                                 validatecommand=vcmd)
        self.num_entry.grid(row=0, column=1, sticky=W + E + N + S)

        self.increm_options = ["seconds", "minutes", "hours", "days"]
        self.increm_var = StringVar()
        self.increm_var.set(self.increm_options[0])
        self.increm_sel = OptionMenu(frame, self.increm_var,
                                     *self.increm_options)
        self.increm_sel.grid(row=0, column=2, sticky=W + N + E + S)

        img_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               "graphics")

        self.prev_but = Button(frame, command=self.on_prev_button)
        self.prev_but.grid(row=0, column=3, sticky=W + E + N + S)
        self.prev_img = PhotoImage(
            file=os.path.join(img_dir, "skip-backward.gif"))
        self.prev_but.config(image=self.prev_img, width=24, height=24)

        self.play_but = Button(frame, command=self.on_play_button)
        self.play_but.grid(row=0, column=4, sticky=W + E + N + S)
        self.play_img = PhotoImage(file=os.path.join(img_dir, "play.gif"))
        self.play_but.config(image=self.play_img, width=24, height=24)
        self.pause_img = PhotoImage(file=os.path.join(img_dir, "pause.gif"))

        self.stop_but = Button(frame, command=self.on_stop_button)
        self.stop_but.grid(row=0, column=5, sticky=W + E + N + S)
        self.stop_img = PhotoImage(file=os.path.join(img_dir, "stop.gif"))
        self.stop_but.config(image=self.stop_img, width=24, height=24)

        self.next_but = Button(frame, command=self.on_next_button)
        self.next_but.grid(row=0, column=6, sticky=W + E + N + S)
        self.next_img = PhotoImage(
            file=os.path.join(img_dir, "skip-forward.gif"))
        self.next_but.config(image=self.next_img, width=24, height=24)

        self.case_text = Label(frame, text="Case:")
        self.case_text.grid(row=0, column=7, sticky=W + E + N + S)

        self.case_options = range(1, len(self.cases) + 1)
        self.case_var = StringVar()
        self.case_var.set(self.case_options[0])
        self.case_sel = OptionMenu(frame, self.case_var, *self.case_options)
        self.case_sel.grid(row=0, column=8, sticky=W + E + N + S)

        frame.pack(anchor=W)

        frame2 = Frame(master)

        self.currt_lab = Label(frame2, text="Current time:")
        self.currt_lab.grid(row=0, column=0, sticky=W + N + S)

        self.currt_var = StringVar()
        self.currt = Label(frame2, textvariable=self.currt_var)
        self.currt.grid(row=0, column=1, sticky=W + N + S)

        frame2.pack(anchor=W)

        self.case_var.trace("w", self.on_case_change)

        self.simulating = "stop"
        self.last_tick = datetime.now()
        self.anim_tick = datetime.now()
        self.animations = {}