Beispiel #1
0
def main():
    root = Tk()
    sizex = 800
    sizey = 600
    posx = 100
    posy = 100
    root.wm_geometry("%dx%d+%d+%d" % (sizex, sizey, posx, posy))

    root.grid()
    root.rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)

    myframe = Frame(root, relief=GROOVE, bd=1)
    myframe.grid(row=0, column=0, sticky="NESW")

    myframe.rowconfigure(0, weight=1)
    myframe.columnconfigure(0, weight=1)
    myframe.columnconfigure(1, weight=0)

    canvas = Canvas(myframe)
    canvas.grid(row=0, column=0, sticky="NESW")

    frame = Frame(canvas)
    myscrollbar = Scrollbar(myframe, orient="vertical", command=canvas.yview)
    myscrollbar.grid(row=0, column=1, sticky="NESW")
    canvas.configure(yscrollcommand=myscrollbar.set)

    canvas.create_window((0, 0), window=frame, anchor='nw')
    frame.bind("<Configure>", lambda e, c=canvas: myfunction(c, e))
    data(frame)
    root.mainloop()
Beispiel #2
0
    def __init__(self, root, *args, **kw):
        GUIDialog.__init__(self, master=root, *args, **kw)
        self.qom_type_var = root.qom_type_var

        self.title(_("Device Tree"))
        self.grid()

        self.columnconfigure(0, weight=1, minsize=300)
        self.columnconfigure(2, weight=1, minsize=100)
        self.rowconfigure(0, weight=1)

        geom = "+" + str(int(root.winfo_rootx())) \
             + "+" + str(int(root.winfo_rooty()))
        self.geometry(geom)

        self.focus()

        self.device_tree = dt = VarTreeview(self, selectmode="browse")
        dt["columns"] = "Macros"

        dt.heading("#0", text=_("Devices"))
        dt.heading("Macros", text=_("Macros"))

        dt.bind("<ButtonPress-1>", self.on_b1_press_dt)

        dt.grid(row=0, column=0, sticky="NEWS")

        add_scrollbars_native(self, dt)

        column_fr = Frame(self, borderwidth=0)
        column_fr.grid(row=0, column=2, rowspan=2, sticky="SEWN")
        column_fr.columnconfigure(0, weight=1)
        column_fr.rowconfigure(0, weight=1)
        column_fr.rowconfigure(1, weight=1, minsize=100)

        fr_at = VarLabelFrame(column_fr, text=_("Architecture filter"))
        fr_at.grid(row=0, column=0, sticky="SEWN")

        self.fr_qt = VarLabelFrame(column_fr, text=_("Select QOM type"))
        self.fr_qt.grid(row=1, column=0, sticky="SEWN")

        self.add_button = VarButton(column_fr,
                                    text=_("Select"),
                                    command=self.on_select_qom_type)
        self.add_button.grid(row=2, column=0, sticky="EW")
        self.add_button.config(state="disabled")

        qtype_dt = self.qtype_dt = qvd_get(
            root.mach.project.build_path,
            version=root.mach.project.target_version).qvc.device_tree

        arch_buttons = Frame(fr_at, borderwidth=0)
        arch_buttons.pack(fill="x")

        arch_buttons.columnconfigure(0, weight=1, minsize=60)
        arch_buttons.columnconfigure(1, weight=1, minsize=60)
        arch_buttons.columnconfigure(2, weight=1, minsize=60)

        bt_all_arches = VarButton(arch_buttons,
                                  text=_("All"),
                                  command=self.select_arches)
        bt_all_arches.grid(row=0, column=0, sticky="EW")

        bt_none_arches = VarButton(arch_buttons,
                                   text=_("None"),
                                   command=self.deselect_arches)
        bt_none_arches.grid(row=0, column=1, sticky="EW")

        bt_invert_arches = VarButton(arch_buttons,
                                     text=_("Invert"),
                                     command=self.invert_arches)
        bt_invert_arches.grid(row=0, column=2, sticky="EW")

        if not qtype_dt.arches:
            bt_all_arches.config(state="disabled")
            bt_none_arches.config(state="disabled")
            bt_invert_arches.config(state="disabled")

        arch_selector_outer = Frame(fr_at, borderwidth=0)
        arch_selector_outer.pack(fill="both", anchor="w")
        arch_selector, scrolltag = add_scrollbars_with_tags(
            arch_selector_outer, GUIFrame)

        ac = self.arches_checkbox = []
        for a in sorted(list(qtype_dt.arches)):
            v = IntVar()
            c = Checkbutton(arch_selector,
                text = a,
                variable = v,
                command = lambda arch = a, var = v: \
                    self.on_toggle_arch(arch, var)
            )

            c.pack(expand=1, anchor="w")
            c.bindtags((scrolltag, ) + c.bindtags())
            c.select()
            ac.append(c)

        # key: item
        # value: ItemDesc
        self.detached_items = {}
        self.all_items = {}

        self.disabled_arches = set()

        self.qom_create_tree("", qtype_dt.children)