From emmanueladeiza29 at gmail.com Tue Aug 1 05:36:08 2017 From: emmanueladeiza29 at gmail.com (Emmanuel Adeiza) Date: Tue, 1 Aug 2017 10:36:08 +0100 Subject: [Tkinter-discuss] Problem on Notebook Widget Message-ID: i am currently working on a project(using tkinter) that uses the Notebook widget and has an area that serves as an editor but when i click on 'new file' it does open it in a new tab but does not show the tab, the previous tab that i was on before clicking 'new file' is still the one on display... i need it to automatically display the new tab instead of me having to click on it before i see the tab this is the source code for that: def new(self,filename1='Untitled'): global content_text filename=filename1 tab_frame=Frame(myNote,height=600, width=1350, background='#113147208', borderwidth=1, relief= FLAT) line_number_bar = Text(tab_frame, width=2, padx=2, takefocus=True, border=0, background='tan', state='disabled', wrap='none', cursor = 'dotbox') line_number_bar.pack(side='left', fill='y') content_text = Text(tab_frame, wrap='word', background='AntiqueWhite3') content_text.pack(expand='yes', fill='both') scroll_bar = Scrollbar(content_text, cursor = 'dotbox') content_text.configure(yscrollcommand=scroll_bar.set) scroll_bar.config(command=content_text.yview) scroll_bar.pack(side='right', fill='y') --------------------------------------------------------------------------------------------------------------------- thanks in advance it's my first time using this platform -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Aug 5 12:36:20 2017 From: klappnase at web.de (Michael Lange) Date: Sat, 5 Aug 2017 18:36:20 +0200 Subject: [Tkinter-discuss] Problem on Notebook Widget In-Reply-To: References: Message-ID: <20170805183620.0f808a284b77d62a8c4f2ee8@web.de> Hi Emmanuel, On Tue, 1 Aug 2017 10:36:08 +0100 Emmanuel Adeiza wrote: > i am currently working on a project(using tkinter) that uses the > Notebook widget and has an area that serves as an editor but when i > click on 'new file' it does open it in a new tab but does not show the > tab, the previous tab that i was on before clicking 'new file' is still > the one on display... i need it to automatically display the new tab > instead of me having to click on it before i see the tab > this is the source code for that: > def new(self,filename1='Untitled'): > global content_text > filename=filename1 > tab_frame=Frame(myNote,height=600, width=1350, > background='#113147208', borderwidth=1, relief= FLAT) > line_number_bar = Text(tab_frame, width=2, padx=2, > takefocus=True, border=0, background='tan', state='disabled', > wrap='none', cursor = 'dotbox') > line_number_bar.pack(side='left', fill='y') > content_text = Text(tab_frame, wrap='word', > background='AntiqueWhite3') > content_text.pack(expand='yes', fill='both') > scroll_bar = Scrollbar(content_text, cursor = 'dotbox') > content_text.configure(yscrollcommand=scroll_bar.set) > scroll_bar.config(command=content_text.yview) > scroll_bar.pack(side='right', fill='y') you need to explicitely add the newly created Frame as a new "slave" to the Notebook, then you can tell the Notebook to select the newly created tab, like this: myNote.add(tab_frame, text=filename1) myNote.select(myNote.index('end')-1) # or: myNote.select( # tab_frame) Hre you can find a complete reference of the Notebook widget (and other Tkinter widgets as well :) http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Notebook.html I hope this helps! Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. I'm a soldier, not a diplomat. I can only tell the truth. -- Kirk, "Errand of Mercy", stardate 3198.9 From li.beinan at gmail.com Mon Aug 7 04:56:46 2017 From: li.beinan at gmail.com (Beinan Li) Date: Mon, 7 Aug 2017 16:56:46 +0800 Subject: [Tkinter-discuss] pack(fill=Y) not working as expected Message-ID: Hello Tkinter, I was following a book example code as following: import Tkinter as tk root = tk.Tk() tk.Button(root, text="A").pack(side=tk.LEFT, expand=tk.YES, fill=tk.Y) tk.Button(root, text="B").pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH) tk.Button(root, text="C").pack(side=tk.RIGHT, expand=tk.YES, fill=tk.NONE, anchor = tk.NE) tk.Button(root, text="D").pack(side=tk.LEFT, expand=tk.NO, fill=tk.Y) tk.Button(root, text="E").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) tk.Button(root, text="G").pack(side=tk.BOTTOM, expand=tk.YES, fill=tk.Y) tk.Button(root, text="H").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) tk.Button(root, text="I").pack(side=tk.RIGHT, expand=tk.NO) tk.Button(root, text="J").pack(anchor=tk.SE) root.mainloop() I was expecting to get the result in the attached expected.png, but got what shows in got.png. It seems that the fill option does not work as expected. I tried with Python 2.7.13 on macOS Sierra. What am I missing here? Thanks, Beinan -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: expected.png Type: image/png Size: 16424 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: got.png Type: image/png Size: 65697 bytes Desc: not available URL: From li.beinan at gmail.com Mon Aug 7 05:25:12 2017 From: li.beinan at gmail.com (Beinan Li) Date: Mon, 7 Aug 2017 17:25:12 +0800 Subject: [Tkinter-discuss] pack(fill=Y) not working as expected In-Reply-To: References: Message-ID: I found that the problem applies to Button, but not Label. Using root = tk.Tk() tk.Label(root, text="A", bg='green').pack(side=tk.LEFT, expand=tk.YES, fill=tk.Y) # align to the left-edge, tk.Label(root, text="B", bg='red').pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH) tk.Label(root, text="C", bg='blue').pack(side=tk.RIGHT, expand=tk.YES, fill=tk.NONE, anchor=tk.NE) tk.Label(root, text="D", bg='yellow').pack(side=tk.LEFT, expand=tk.NO, fill=tk.Y) tk.Label(root, text="E", bg='purple').pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) tk.Label(root, text="F", bg='pink').pack(side=tk.TOP, expand=tk.NO, fill=tk.NONE) tk.Label(root, text="G", bg='green').pack(side=tk.BOTTOM, expand=tk.YES, fill=tk.Y) tk.Label(root, text="H", bg='red').pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) tk.Label(root, text="I", bg='blue').pack(side=tk.RIGHT, expand=tk.NO) tk.Label(root, text="J", bg='yellow').pack(anchor=tk.SE) root.mainloop() I managed to get label.png as attached. Note that I forgot to add the button "F" in my previous example, but that's a trivial mistake that does not affect my point. Does it mean that currently Buttons cannot fill vertically no matter what? Thanks, Beinan On Mon, Aug 7, 2017 at 4:56 PM, Beinan Li wrote: > Hello Tkinter, > > I was following a book example code as following: > > import Tkinter as tk > root = tk.Tk() > tk.Button(root, text="A").pack(side=tk.LEFT, expand=tk.YES, fill=tk.Y) > tk.Button(root, text="B").pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH) > tk.Button(root, text="C").pack(side=tk.RIGHT, expand=tk.YES, fill=tk.NONE, > anchor = tk.NE) > tk.Button(root, text="D").pack(side=tk.LEFT, expand=tk.NO, fill=tk.Y) > tk.Button(root, text="E").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) > tk.Button(root, text="G").pack(side=tk.BOTTOM, expand=tk.YES, fill=tk.Y) > tk.Button(root, text="H").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) > tk.Button(root, text="I").pack(side=tk.RIGHT, expand=tk.NO) > tk.Button(root, text="J").pack(anchor=tk.SE) > root.mainloop() > > I was expecting to get the result in the attached expected.png, > but got what shows in got.png. > > It seems that the fill option does not work as expected. > I tried with Python 2.7.13 on macOS Sierra. > > What am I missing here? > > Thanks, > Beinan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: label.png Type: image/png Size: 79860 bytes Desc: not available URL: From bryan.oakley at gmail.com Mon Aug 7 18:56:09 2017 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Mon, 7 Aug 2017 17:56:09 -0500 Subject: [Tkinter-discuss] pack(fill=Y) not working as expected In-Reply-To: References: Message-ID: On OSX, buttons will not grow vertically. That platform has strict requirements about the look of buttons. On Mon, Aug 7, 2017 at 4:25 AM, Beinan Li wrote: > I found that the problem applies to Button, but not Label. > > Using > > root = tk.Tk() > tk.Label(root, text="A", bg='green').pack(side=tk.LEFT, expand=tk.YES, > fill=tk.Y) # align to the left-edge, > tk.Label(root, text="B", bg='red').pack(side=tk.TOP, expand=tk.YES, > fill=tk.BOTH) > tk.Label(root, text="C", bg='blue').pack(side=tk.RIGHT, expand=tk.YES, > fill=tk.NONE, anchor=tk.NE) > tk.Label(root, text="D", bg='yellow').pack(side=tk.LEFT, expand=tk.NO, > fill=tk.Y) > tk.Label(root, text="E", bg='purple').pack(side=tk.TOP, expand=tk.NO, > fill=tk.BOTH) > tk.Label(root, text="F", bg='pink').pack(side=tk.TOP, expand=tk.NO, > fill=tk.NONE) > tk.Label(root, text="G", bg='green').pack(side=tk.BOTTOM, expand=tk.YES, > fill=tk.Y) > tk.Label(root, text="H", bg='red').pack(side=tk.TOP, expand=tk.NO, > fill=tk.BOTH) > tk.Label(root, text="I", bg='blue').pack(side=tk.RIGHT, expand=tk.NO) > tk.Label(root, text="J", bg='yellow').pack(anchor=tk.SE) > root.mainloop() > > I managed to get label.png as attached. > > Note that I forgot to add the button "F" in my previous example, but > that's a trivial mistake that does not affect my point. > > Does it mean that currently Buttons cannot fill vertically no matter what? > > Thanks, > Beinan > > > On Mon, Aug 7, 2017 at 4:56 PM, Beinan Li wrote: > >> Hello Tkinter, >> >> I was following a book example code as following: >> >> import Tkinter as tk >> root = tk.Tk() >> tk.Button(root, text="A").pack(side=tk.LEFT, expand=tk.YES, fill=tk.Y) >> tk.Button(root, text="B").pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH) >> tk.Button(root, text="C").pack(side=tk.RIGHT, expand=tk.YES, >> fill=tk.NONE, anchor = tk.NE) >> tk.Button(root, text="D").pack(side=tk.LEFT, expand=tk.NO, fill=tk.Y) >> tk.Button(root, text="E").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) >> tk.Button(root, text="G").pack(side=tk.BOTTOM, expand=tk.YES, fill=tk.Y) >> tk.Button(root, text="H").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH) >> tk.Button(root, text="I").pack(side=tk.RIGHT, expand=tk.NO) >> tk.Button(root, text="J").pack(anchor=tk.SE) >> root.mainloop() >> >> I was expecting to get the result in the attached expected.png, >> but got what shows in got.png. >> >> It seems that the fill option does not work as expected. >> I tried with Python 2.7.13 on macOS Sierra. >> >> What am I missing here? >> >> Thanks, >> Beinan >> >> > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Vasilis.Vlachoudis at cern.ch Thu Aug 24 10:04:15 2017 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 24 Aug 2017 14:04:15 +0000 Subject: [Tkinter-discuss] Drag n drop from another application Message-ID: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch> Hi All, is there a way to catch a drop signal from KDE, GNOME, etc.. e.g. dragging a file from the file browser in x11 to an application with Tkinter Thanks in advance Vasilis From klappnase at web.de Thu Aug 24 17:26:32 2017 From: klappnase at web.de (Michael Lange) Date: Thu, 24 Aug 2017 23:26:32 +0200 Subject: [Tkinter-discuss] Drag n drop from another application In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch> Message-ID: <20170824232632.d6349907fa2872e015481672@web.de> Hi Vasilis, On Thu, 24 Aug 2017 14:04:15 +0000 Vasilis Vlachoudis wrote: > Hi All, > > is there a way to catch a drop signal from KDE, GNOME, etc.. > e.g. dragging a file from the file browser in x11 to an application > with Tkinter the tkdnd Tk extension can do that. I wrote a Tkinter wrapper for tkdnd some time ago ( http://tkinterdnd.sourceforge.net/ ), the version available there however is buggy and works only partially. I have a much improved version here that I wanted to upload as soon as I find the time to run a few more tests and update the docs, if you would like to try that one I could send it to you off-list. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Superior ability breeds superior ambition. -- Spock, "Space Seed", stardate 3141.9 From klappnase at web.de Fri Aug 25 05:34:33 2017 From: klappnase at web.de (Michael Lange) Date: Fri, 25 Aug 2017 11:34:33 +0200 Subject: [Tkinter-discuss] Drag n drop from another application In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01CFEEB324@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch> <20170824232632.d6349907fa2872e015481672@web.de> <0BC70B5D93E054469872FFD0FE07220E01CFEEB324@CERNXCHG53.cern.ch> Message-ID: <20170825113433.c557c2134d1a08b6d5fa7ba2@web.de> Hi Vasilis, On Fri, 25 Aug 2017 08:21:03 +0000 Vasilis Vlachoudis wrote: > Thank you Michael, > > is this the same with the Tkdnd.py module inside tkinter, or it is an > extension of it? no, Tkdnd.py is pure Tkinter code and can only handle dnd within one Tkinter program. For "real" dnd you will need tkdnd. BTW, iirc there is a problem with tkdnd-2.6 (which is still the version included with debian and probably other linux/unix systems). I am not 100% sure, but I believe drops would only work if the drop target is a direct child of the toplevel window, which has been fixed with tkdnd-2.8. I never really used tkdnd in a real application, so it's a little hard to remember exactly, it was something like this. With tkdnd-2.8 also dragging from Tkinter to the file manager should work, so if you want to use it, it might be a good idea to upgrade (although a number of X11 file managers I tested behaved differently, some accepted the drops from Tk, others wouldn't and pcmanfm always crashed :) You can find the latest version at https://sourceforge.net/projects/tkdnd/files/ , compiling should be rather easy, here a simple ./configure && make && make install did the job. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Most legends have their basis in facts. -- Kirk, "And The Children Shall Lead", stardate 5029.5 From Vasilis.Vlachoudis at cern.ch Fri Aug 25 04:21:03 2017 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Fri, 25 Aug 2017 08:21:03 +0000 Subject: [Tkinter-discuss] Drag n drop from another application In-Reply-To: <20170824232632.d6349907fa2872e015481672@web.de> References: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch>, <20170824232632.d6349907fa2872e015481672@web.de> Message-ID: <0BC70B5D93E054469872FFD0FE07220E01CFEEB324@CERNXCHG53.cern.ch> Thank you Michael, is this the same with the Tkdnd.py module inside tkinter, or it is an extension of it? V. ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de] Sent: Thursday, August 24, 2017 23:26 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Drag n drop from another application Hi Vasilis, On Thu, 24 Aug 2017 14:04:15 +0000 Vasilis Vlachoudis wrote: > Hi All, > > is there a way to catch a drop signal from KDE, GNOME, etc.. > e.g. dragging a file from the file browser in x11 to an application > with Tkinter the tkdnd Tk extension can do that. I wrote a Tkinter wrapper for tkdnd some time ago ( http://tkinterdnd.sourceforge.net/ ), the version available there however is buggy and works only partially. I have a much improved version here that I wanted to upload as soon as I find the time to run a few more tests and update the docs, if you would like to try that one I could send it to you off-list. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Superior ability breeds superior ambition. -- Spock, "Space Seed", stardate 3141.9 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss From Vasilis.Vlachoudis at cern.ch Fri Aug 25 10:29:34 2017 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Fri, 25 Aug 2017 14:29:34 +0000 Subject: [Tkinter-discuss] Drag n drop from another application In-Reply-To: <20170825113433.c557c2134d1a08b6d5fa7ba2@web.de> References: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch> <20170824232632.d6349907fa2872e015481672@web.de> <0BC70B5D93E054469872FFD0FE07220E01CFEEB324@CERNXCHG53.cern.ch>, <20170825113433.c557c2134d1a08b6d5fa7ba2@web.de> Message-ID: <0BC70B5D93E054469872FFD0FE07220E01CFEEBA1E@CERNXCHG53.cern.ch> Great thanks. I will give it a try. Best Vasilis ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de] Sent: Friday, August 25, 2017 11:34 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Drag n drop from another application Hi Vasilis, On Fri, 25 Aug 2017 08:21:03 +0000 Vasilis Vlachoudis wrote: > Thank you Michael, > > is this the same with the Tkdnd.py module inside tkinter, or it is an > extension of it? no, Tkdnd.py is pure Tkinter code and can only handle dnd within one Tkinter program. For "real" dnd you will need tkdnd. BTW, iirc there is a problem with tkdnd-2.6 (which is still the version included with debian and probably other linux/unix systems). I am not 100% sure, but I believe drops would only work if the drop target is a direct child of the toplevel window, which has been fixed with tkdnd-2.8. I never really used tkdnd in a real application, so it's a little hard to remember exactly, it was something like this. With tkdnd-2.8 also dragging from Tkinter to the file manager should work, so if you want to use it, it might be a good idea to upgrade (although a number of X11 file managers I tested behaved differently, some accepted the drops from Tk, others wouldn't and pcmanfm always crashed :) You can find the latest version at https://sourceforge.net/projects/tkdnd/files/ , compiling should be rather easy, here a simple ./configure && make && make install did the job. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Most legends have their basis in facts. -- Kirk, "And The Children Shall Lead", stardate 5029.5 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss From klappnase at web.de Fri Aug 25 17:27:59 2017 From: klappnase at web.de (Michael Lange) Date: Fri, 25 Aug 2017 23:27:59 +0200 Subject: [Tkinter-discuss] Drag n drop from another application In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01CFEEBA1E@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01CFEEA44B@CERNXCHG53.cern.ch> <20170824232632.d6349907fa2872e015481672@web.de> <0BC70B5D93E054469872FFD0FE07220E01CFEEB324@CERNXCHG53.cern.ch> <20170825113433.c557c2134d1a08b6d5fa7ba2@web.de> <0BC70B5D93E054469872FFD0FE07220E01CFEEBA1E@CERNXCHG53.cern.ch> Message-ID: <20170825232759.2baa4a581424582960b85925@web.de> Hi Vasilis, On Fri, 25 Aug 2017 14:29:34 +0000 Vasilis Vlachoudis wrote: > Great thanks. > I will give it a try. I finally uploaded the new version 0.3 of TkinterDnD2, this version now works with both Python2 and Python3. I also added a few new (hopefully helpful) demo scripts. I think I had to change the API to fix some bugs (although at the moment I cannot remember the details :) , so if you already downloaded v. 0.1 you are probably better off replacing it. I did a brief test with the demos here, as far as I can see everything seems to work ok. If you still find a bug, please report it here, then I will try to fix it asap. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. No one may kill a man. Not for any purpose. It cannot be condoned. -- Kirk, "Spock's Brain", stardate 5431.6