]>
vault307.fbx.one Git - mu_code.git/blob - checkListfromList.py
3 from tkinter
import ttk
8 entries
=[] # updated by user
14 window
.title((datetime
.date
.today()).strftime("%B"))
15 window
.minsize(width
=240, height
=50)
16 window
.maxsize(width
=240,height
=365)
17 window
.resizable(width
=True,height
=True)
18 window
.columnconfigure(0,weight
=1)
19 window
.columnconfigure(1,weight
=1)
22 uframe
=tk
.Frame(window
) #entry widget, add and delete button
23 uframe
.columnconfigure(0,weight
=1)
24 uframe
.columnconfigure(1,weight
=1)
25 uframe
.grid(row
=0,column
=0,columnspan
=2,sticky
='nsew')
27 scrollframe
=tk
.Frame(window
, height
=283, width
=240)
28 scrollframe
.grid_columnconfigure(0,weight
=1)
29 scrollframe
.grid_rowconfigure(0,weight
=1)
30 scrollframe
.grid(row
=1,column
=0,sticky
='nsew')
31 scrollframe
.grid_propagate(0)
33 kanvas
=tk
.Canvas(scrollframe
)
34 rScroll
=ttk
.Scrollbar(scrollframe
,orient
='vertical',
36 rScroll
.grid(row
=0,column
=1,sticky
='ns')
37 kanvas
.configure(yscrollcommand
=rScroll
.set,borderwidth
=0,
39 kanvas
.configure(scrollregion
=kanvas
.bbox('all'))
40 kanvas
.grid(row
=0,column
=0,sticky
='nsew')
42 rframe
=tk
.Frame(kanvas
) # buttons created from input
43 kanvas
.create_window((0,0),window
=rframe
,anchor
='nw')
44 rframe
.columnconfigure(0, minsize
=225)
47 # reset/configure inner frame (rframe) to be scrollregion
48 def updateScrollRegion(kanvas
):
49 kanvas
.update_idletasks()
50 kanvas
.configure(scrollregion
=kanvas
.bbox('all'))
53 def MouseWheelHandler(event
):
55 if event
.num
==5 or event
.delta
==-120:
57 if event
.num
==4 or event
.delta
==120:
59 kanvas
.yview_scroll(direction
,'units')
60 window
.bind("<MouseWheel>",MouseWheelHandler
)
61 window
.bind("<Button-4>",MouseWheelHandler
)
62 window
.bind("<Button-5>",MouseWheelHandler
)
64 rframe
.bind("<Configure>", lambda event
, kanvas
=kanvas
: updateScrollRegion(kanvas
))
70 style
.theme_use('default')
71 style
.configure('todo.TButton',foreground
='blue4',
72 background
='medium purple')
73 style
.map('todo.TButton',
74 foreground
=[('pressed','maroon'),('disabled','medium purple')],
75 background
=[('active','slate blue'),('disabled','blue4')])
76 style2
.configure('admin.TButton',forgeground
='deep pink',
77 background
='MediumPurple4')
78 style2
.map('admin.TButton',
79 foreground
=[('pressed','DeepPink2'),('focus','hot pink'),('!focus','deep pink')],
80 background
=[('active','DeepPink4'),('focus','MediumOrchid4')])
81 style3
.configure('admin.TEntry',forgeground
='deep pink',
82 fieldbackground
='MediumPurple4')
83 style3
.map('admin.TEntry',
84 foreground
=[('focus','hot pink'),('!focus','deep pink')],
85 fieldbackground
=[('active','DeepPink4'),('focus','MediumOrchid4')])
87 content
=tk
.StringVar()
94 entries
.append(cOntent
)
98 btn
=ttk
.Button(rframe
,text
=entry
,style
='todo.TButton',
99 command
=lambda :done())
100 btn
.grid(row
=(count
),column
=0,sticky
='ew')
101 if btn
['text'].endswith(" DONE"):
102 btn
['state']='disabled'
104 for children
in rframe
.winfo_children():
105 if children
.winfo_class() =='TButton':
106 if children
not in buttons
:
109 updateScrollRegion(kanvas
)
110 kanvas
.yview('moveto',1)
113 btn
.configure(text
=btn
['text']+" DONE",state
='disabled')
119 btn
['state']='normal'
120 btn
['text']=re
.sub(remove
,'',(btn
['text']))
124 for button
in buttons
:
125 saveData
.append(button
['text'])
127 shelfFile
=shelve
.open('/home/Jimmy/mu_code/savedButtons')
128 shelfFile
['saveData']=saveData
134 shelfFile
=shelve
.open('/home/Jimmy/mu_code/savedButtons')
135 saveData
=shelfFile
['saveData']
136 for item
in saveData
:
142 for button
in buttons
:
143 entries
.append(button
['text'])
145 new
=tk
.Toplevel(window
)
147 new
.minsize(width
=240, height
=50)
148 new
.resizable(width
=True,height
=True)
149 new
.columnconfigure(0,weight
=1)
150 new
.columnconfigure(1,weight
=1)
151 new
.transient(window
)
154 newFrame
=tk
.Frame(new
)
155 newFrame
.columnconfigure(0,weight
=1)
156 newFrame
.grid(row
=0,column
=0,columnspan
=2,sticky
='nsew')
158 # listbox with vertical(y) scroll
159 lb
=tk
.Listbox(newFrame
,bg
='peach puff',fg
='DeepPink2',
160 selectbackground
='maroon3',selectforeground
='DarkOrchid4')
161 lb
.grid(column
=0,row
=0, columnspan
=2,sticky
='nsew')
162 yScroll
=ttk
.Scrollbar(new
, orient
='vertical')
163 yScroll
.grid(column
=2, row
=0, sticky
='ns')
164 yScroll
['command']=lb
.yview
165 lb
.configure(yscrollcommand
=yScroll
.set)
167 reMove
=ttk
.Button(newFrame
,text
='remove',style
='admin.TButton',
168 command
=lambda :remove())
169 reMove
.grid(column
=0,row
=1,sticky
='ew')
171 for entry
in entries
:
172 lb
.insert(tk
.END
,entry
)
175 rmvdTxt
=lb
.get(tk
.ANCHOR
)
177 entries
.remove(rmvdTxt
)
180 for button
in buttons
:
181 if button
['text']==rmvdTxt
:
182 buttons
.remove(button
)
184 for button
in buttons
:
185 entries
.append(button
['text'])
186 for entry
in entries
:
190 for widget
in rframe
.winfo_children():
199 inPut
=ttk
.Entry(uframe
,textvariable
=content
,style
='admin.TEntry')
200 inPut
.grid(row
=0,column
=0,columnspan
=2,sticky
='ew')
203 inPut
.bind('<Return>',hitenter
)
204 aDd
=ttk
.Button(uframe
,text
='add',command
=add
,style
='admin.TButton')
205 aDd
.grid(row
=1,column
=0,sticky
='nsew')
207 deLete
=ttk
.Button(uframe
,text
='delete',
208 command
=delete
,style
='admin.TButton')
209 deLete
.grid(row
=1,column
=1,sticky
='nsew')
211 # make menu bar and drop down items
212 menubar
=tk
.Menu(window
, background
='SlateBlue2',
213 activebackground
='slate blue',disabledforeground
='blue4')
214 optionsmenu
=tk
.Menu(window
,tearoff
=0)
215 optionsmenu
.add_command(background
='SlateBlue2',
216 activebackground
='slate blue',label
='reset ALL',command
=lambda x
=buttons
:reset(x
))
217 optionsmenu
.add_command(background
='SlateBlue2',
218 activebackground
='slate blue',label
='load',command
=load
)
219 optionsmenu
.add_command(background
='SlateBlue2',
220 activebackground
='slate blue',label
='save',command
=save
)
221 optionsmenu
.add_command(background
='SlateBlue2',
222 activebackground
='slate blue',label
='exit',command
=window
.destroy
)
223 menubar
.add_cascade(label
='options',menu
=optionsmenu
)
224 datemenu
=tk
.Menu(window
,tearoff
=0)
225 menubar
.add_cascade(label
=((datetime
.date
.today()).strftime("%d-%m-%Y")),
226 state
='disabled',menu
=datemenu
)
227 window
.config(background
='medium purple',menu
=menubar
)