import tkinter as tk from tkinter import ttk import os from datetime i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import tkinter as tk
from tkinter import ttk
import os
from datetime import datetime
VER = '0.2'+' build of '+ datetime.now().strftime('%d.%m.%Y')
def to_fr(txt_widget, frame_widget, but_widget):
txt_widget.grid_remove()
if frame_widget.grid_info() == {}:
frame_widget.grid(row=0, column=0)
else:
frame_widget.grid()
but_widget.configure(command = lambda:to_txt(txt, fr, per))
#~ print (but_widget.command)
def to_txt(txt_widget, frame_widget, but_widget):
frame_widget.grid_remove()
if txt_widget.grid_info() == {}:
txt_widget.grid(row=0, column=0)
else:
txt_widget.grid()
but_widget.configure(command = lambda:to_fr(txt, fr, per))
#~ print (but_widget.command)
def cheks(txt_chek, frame_widget):
pass
root = tk.Tk()
root.title(u'TxToDo | v'+VER)
root.geometry('200x350')
#~ root.tk.call('wm', 'iconbitmap', root._w, '-default', way_mod+'\\remprog.ico')
txt = tk.Text(root, wrap = tk.WORD,
state='normal', relief = 'groove')
fr = tk.Frame(root, height = 19, width = 62)
per = ttk.Button(root, text=u'Переход', command=lambda:to_fr(txt, fr, per))
filetxt = [i for i in open(os.path.join(os.path.dirname(__file__), 'txtodo.txt'), 'r')]
txtout = []
for i in filetxt:
p = i.expandtabs(4) #
it = len(p)-len(p.lstrip())
if i.lstrip()[0] != '[':
txtout.append(p[:it]+'[ ] '+p[it:])
else:
txtout.append(p)
print(txtout)
txt.insert(1.0, ''.join(txtout))
txt.grid(row=0, column=0, sticky='nsew')
per.grid(row=1, column=0, padx=10, pady=10)
root.mainloop()