requirements_counter = IntVar()
requirements_counter.set(1)

Button(mainframe, text="Add", command=add_requirement).grid(column=2, row=9, sticky=(N,W))

#text area
#txt_frm = Frame(mainframe, width=200, height=100) #larger
txt_frm = Frame(mainframe, width=500, height=100) #smaller
txt_frm.pack(fill="both", expand=True)

#for a smaller frame
txt_frm.pack_propagate(0)

txt_frm.grid(column=0, columnspan= 2, row=9, sticky=(W,E))
# ensure a consistent GUI size
txt_frm.grid_propagate(False)
# implement stretchability
txt_frm.grid_rowconfigure(0, weight=1)
txt_frm.grid_columnconfigure(0, weight=1)

# create a Text widget
t = Text(txt_frm, borderwidth=3, relief="sunken")
t.config(font=("consolas", 12), undo=True, wrap='word')
t.grid(row=0, column=0, sticky="nsew", padx=2, pady=2)

# create a Scrollbar and associate it with txt
scrollb = Scrollbar(txt_frm, command=t.yview)
scrollb.grid(row=0, column=1, sticky='nsew')
t['yscrollcommand'] = scrollb.set

t.pack()
Пример #2
0
    def __init__(self,
                 master,
                 xml=None,
                 heading_text=None,
                 heading_anchor=None,
                 padding=None,
                 cursor=None,
                 takefocus=None,
                 style=None,
                 width=1000,
                 height=1000):
        Frame.__init__(self,
                       master,
                       class_="XML_Viewer",
                       width=width,
                       height=height)
        Frame.grid_propagate(self, False)
        self._vsb = Scrollbar(self, orient=VERTICAL)
        self._hsb = Scrollbar(self, orient=HORIZONTAL)

        kwargs = {}
        kwargs["yscrollcommand"] = lambda f, l: autoscroll(self._vsb, f, l)
        kwargs["xscrollcommand"] = lambda f, l: autoscroll(self._hsb, f, l)

        if style is not None:
            kwargs["style"] = style

        if padding is not None:
            kwargs["padding"] = padding

        if cursor is not None:
            kwargs["cursor"] = cursor

        if takefocus is not None:
            kwargs["takefocus"] = takefocus

        self._treeview = Treeview(self, **kwargs)

        if heading_text is not None:
            if heading_anchor is not None:
                self._treeview.heading("#0",
                                       text=heading_text,
                                       anchor=heading_anchor)
            else:
                self._treeview.heading("#0", text=heading_text)

        self._treeview.bind("<<TreeviewOpen>>", self._on_open)
        self._treeview.bind("<<TreeviewClose>>", self._on_close)

        # Without this line, horizontal scrolling doesn't work properly.
        self._treeview.column("#0", stretch=True, minwidth=100)

        self._vsb['command'] = self._treeview.yview
        self._hsb['command'] = self._treeview.xview

        self._treeview.grid(column=0, row=0, sticky=N + S + W + E)
        self._vsb.grid(column=1, row=0, sticky=N + S)
        self._hsb.grid(column=0, row=1, sticky=E + W)

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self._element_tree = None
        self._item_ID_to_element = {}

        if xml is not None:
            self.parse_xml(xml)