i'm trying to implement my own edit menu using Tkinter,
my cut and copy methods,... seems to work fine but I'm having allot of trouble getting my paste method to work. will someone please help?
(((its kinda ugly i know, but i'm still new to programming and i'm more focused on getting it
to work right. later I'll go back and really clean up my code and oop practice. )))
app
app
are both entry widgets
app[ # ]
app[ # ]
app[ # ]
are lists of entry widgets
def _copy(self):
app=self.app
if app.select_present():
if app.focus_get():
app.clipboard_clear()
app.clipboard_append( app.selection_get() )
elif app.select_present():
if app.focus_get():
app.clipboard_clear()
app.clipboard_append( app.selection_get() )
else:
i = 0
for i in range(200):
app.clipboard_clear()
app.clipboard_clear()
app.clipboard_clear()
if app.select_present():
if app.focus_get():
app.clipboard_append(
app.selection_get() )
elif app.select_present():
if app.focus_get():
app.clipboard_append(
app.selection_get() )
elif app.select_present():
if app.focus_get():
app.clipboard_append(
app.selection_get() )
#####################################################################################
def _cut(self):
app=self.app
x=0
if app.select_present():
if app.focus_get():
app.clipboard_clear()
app.clipboard_append( app.selection_get() )
app.delete(SEL_FIRST,SEL_LAST)
elif app.select_present():
if app.focus_get():
app.clipboard_clear()
app.clipboard_append( app.selection_get() )
app.delete(SEL_FIRST,SEL_LAST)
else:
i = 0
for i in range(200):
app.clipboard_clear()
app.clipboard_clear()
app.clipboard_clear()
if app.select_present():
if app.focus_get():
app.clipboard_append(
app.selection_get() )
app.delete(SEL_FIRST,SEL_LAST)
elif app.select_present():
if app.focus_get():
app.clipboard_append(
app.selection_get() )
app.delete(SEL_FIRST,SEL_LAST)
elif app.select_present():
if app.focus_get():
app.clipboard_append(
app.selection_get() )
app.delete(SEL_FIRST,SEL_LAST)
##########################################################
def _paste(self):
if app.focus_get():
app.insert(INSERT, app.clipboard_get())
if app.focus_get():
app.insert(INSERT, app.clipboard_get())
...
...
...
<<<< this _paste method doesn't work, it always sets the focus to app
no mater where i paste at. How do I query where the insertion point is?
please someone help me. I've been going through Tkinter tutorials for over a week now, but i can not find a solution and i feel like its one of those really simple things that just keeps aluding me.
thanks.