Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- class Container(tk.Frame):
- def __init__(self, parent = None, priority = 3, bg = 'bisque'):
- self.inpList = []
- tk.Frame.__init__(self, parent)
- self.can = tk.Canvas(window, bg = 'aqua')
- self.f = tk.Frame(self.can, bg = bg, height = 200, width = 300)
- self.f.pack(in_ = self.can, fill = 'both', expand = True)
- self.f.propagate(False)
- self.b = tk.Button(self.f, text = 'add', command = lambda: self.add_task(priority))
- self.scb = tk.Scrollbar(self.can)
- self.can.create_window(4, 4, window = self.f)
- self.f.bind("<Configure>", self.on_frame)
- self.can.configure(yscrollcommand = self.scb.set)
- self.scb.configure(command = self.can.yview)
- self.scb.pack(side = 'right', fill = 'y')
- self.can.pack(fill = 'both', expand = True)
- self.b.pack(side = 'left', anchor = 's')
- self.s = tk.Button(self.f, text = 'print all', command = self.print_all)
- self.s.pack(side = 'left')
- self.t = None
- self.saveBtn = None
- def on_frame(self, event):
- self.can.configure(scrollregion = self.can.bbox('all'))
- def add_task(self, priority): # refer 1.2_text for implementation
- finished = False
- self.t = tk.Text(self.f)
- self.t.configure(height = 10, wrap = 'word')
- self.t.bind("<Return>", self.save_task)
- self.t.pack(fill = tk.X)
- def print_all(self):
- print(self.inpList)
- def save_task(self, event):
- td = self.t.get('current linestart', 'current lineend') # 1.0 end-1c
- self.inpList.append(td)
- def to_json(self):
- pass
- if __name__ == '__main__':
- window = tk.Tk()
- window.minsize(300, 600)
- p1 = Container(window, priority = 1)
- p2 = Container(window, bg = 'blue', priority = 2)
- p3 = Container(window, bg = 'red', priority = 3)
- window.mainloop()
Add Comment
Please, Sign In to add comment