Re: {Possible_Spam} Re: {Possible_Spam} tkinter text editor
-- Original Message --- From: Gigs [EMAIL PROTECTED] To: John McMonagle [EMAIL PROTECTED] Sent: Sat, 10 Mar 2007 15:13:20 +0100 Subject: {Possible_Spam} Re: {Possible_Spam} tkinter text editor John McMonagle wrote: Gigs_ wrote: I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected Bind the Button1-ButtonRelease event to a function which checks the length of the SEL tag of the text widget. If it is zero length, disable the appropriate menu entries, if it is non-zero, enable the appropriate menu entries. Simple example: from Tkinter import * root = Tk() textWidget = Text(root) textWidget.pack() def onButton1Release(event): if len(textWidget.tag_ranges(SEL)) == 0: print 'No text selected. Disable appropriate menu entries' else: print 'Some text selected. Enable appropriate menu entries' textWidget.bind('Button1-ButtonRelease', onButton1Release) root.mainloop() thx, but what i dont know is how to change state on menu item. I dont know how to access that menu item later. I know on button like B = Button(root) B.pack() and later i change with B.config(blabla) but on menu i have more items like M = Menu(root) i.add_command(label='one', command=show1) i.add_command(label='two', command=show2) M.add_cascade(label='File', menu=i) how to change item: 'two' Use the entry config method of the Menu widget: i.entryconfig('one', state=DISABLED) Here is some recommended reading: http://www.pythonware.com/library/tkinter/introduction/x5841-methods.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text editor
Gigs_ wrote: I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected Btw it is cut copy ... in edit menu -- http://mail.python.org/mailman/listinfo/python-list
tkinter text editor
I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text editor
On Friday 09 March 2007 12:04, Gigs_ wrote: Gigs_ wrote: I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected Btw it is cut copy ... in edit menu state = 'diabled' ## no change allowed ## to Text Wiget state = 'normal' ## default for Text Wiget jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text editor
jim-on-linux wrote: On Friday 09 March 2007 12:04, Gigs_ wrote: Gigs_ wrote: I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected Btw it is cut copy ... in edit menu state = 'diabled' ## no change allowed ## to Text Wiget state = 'normal' ## default for Text Wiget jim-on-linux http:\\www.inqvista.com yes man but i want to make that when there is no selected text this menu items go DISABLED and when text is selected this menu items go NORMAL -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text editor
Gigs_ wrote: jim-on-linux wrote: On Friday 09 March 2007 12:04, Gigs_ wrote: Gigs_ wrote: I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected Btw it is cut copy ... in edit menu state = 'diabled' ## no change allowed ## to Text Wiget state = 'normal' ## default for Text Wiget jim-on-linux http:\\www.inqvista.com yes man but i want to make that when there is no selected text this menu items go DISABLED and when text is selected this menu items go NORMAL You have to methodically determine on an event by event basis what is going to cause selection and what isn't, then update the menus accordingly. It takes a lot of testing. An alternative is polling whether text is selected at the moment but is a waste of CPU cycles and is unnecessary. Best is to let the system clipboard handle copy-paste as it was designed to do. You are opening a can of worms trying to micromanage your application. James -- http://mail.python.org/mailman/listinfo/python-list
Re: {Possible_Spam} tkinter text editor
Gigs_ wrote: I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected Bind the Button1-ButtonRelease event to a function which checks the length of the SEL tag of the text widget. If it is zero length, disable the appropriate menu entries, if it is non-zero, enable the appropriate menu entries. Simple example: from Tkinter import * root = Tk() textWidget = Text(root) textWidget.pack() def onButton1Release(event): if len(textWidget.tag_ranges(SEL)) == 0: print 'No text selected. Disable appropriate menu entries' else: print 'Some text selected. Enable appropriate menu entries' textWidget.bind('Button1-ButtonRelease', onButton1Release) root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list