From Vasilis.Vlachoudis at cern.ch Thu Mar 1 10:42:49 2018 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 1 Mar 2018 15:42:49 +0000 Subject: [Tkinter-discuss] clipboard and bytes In-Reply-To: <20180301001213.338b98c503e4c7dc73afac5e@web.de> References: <0BC70B5D93E054469872FFD0FE07220E01D003E49A@CERNXCHG53.cern.ch> <20180228204251.8597f08f59be517b00a7774a@web.de>, <20180301001213.338b98c503e4c7dc73afac5e@web.de> Message-ID: <0BC70B5D93E054469872FFD0FE07220E01D004060A@CERNXCHG53.cern.ch> Many thanks! I works within the same process. When I try to launch it twice, so I can have clipboard exchange between different processes I get the following exception: Traceback (most recent call last): File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__ return self.func(*args) File "foo.py", line 41, in paste res = root.tk.call(clip) _tkinter.TclError: invalid command name "139879786444744cp" I saw in the documentation that by default it uses the UTF8STRING as type I've tried to force it to type="STRING" but with no success ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de] Sent: Thursday, March 01, 2018 00:12 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] clipboard and bytes On Wed, 28 Feb 2018 20:42:51 +0100 Michael Lange wrote: (...) > So at least this primitive seems to work. Maybe you can use this > technique to achieve what you want. Or maybe this slightly modified example comes closer to what you are looking for: from tkinter import * root = Tk() def copy(string): def cp(): return string copyfunc = (root.register(cp)) return(copyfunc) root.clipboard_clear() root.clipboard_append(copy(b'foobar'), type='foo') def paste(ev): clip = root.clipboard_get(type='foo') res = root.tk.call(clip) print('->', res, type(res)) root.bind('', paste) root.mainloop() Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "... freedom ... is a worship word..." "It is our worship word too." -- Cloud William and Kirk, "The Omega Glory", stardate unknown _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss From Vasilis.Vlachoudis at cern.ch Thu Mar 1 11:13:37 2018 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 1 Mar 2018 16:13:37 +0000 Subject: [Tkinter-discuss] clipboard and bytes In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01D004060A@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01D003E49A@CERNXCHG53.cern.ch> <20180228204251.8597f08f59be517b00a7774a@web.de>, <20180301001213.338b98c503e4c7dc73afac5e@web.de>, <0BC70B5D93E054469872FFD0FE07220E01D004060A@CERNXCHG53.cern.ch> Message-ID: <0BC70B5D93E054469872FFD0FE07220E01D0040629@CERNXCHG53.cern.ch> I did something else. I've used the binascii.b2a_hex() and a2b_hex() functions to convert the bytes() to a hex string and the reverse (double in size, and a useless UTF-8 conversion, encode/decode) This way it works but not a clean approach, since I am copying in the clipboard binary data in a form of ascii. Is there a way to create a new mime format and advertise the format somehow in the clipboard? Vasilis ________________________________________ From: Vasilis Vlachoudis Sent: Thursday, March 01, 2018 16:42 To: Michael Lange; tkinter-discuss at python.org Subject: RE: [Tkinter-discuss] clipboard and bytes Many thanks! I works within the same process. When I try to launch it twice, so I can have clipboard exchange between different processes I get the following exception: Traceback (most recent call last): File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__ return self.func(*args) File "foo.py", line 41, in paste res = root.tk.call(clip) _tkinter.TclError: invalid command name "139879786444744cp" I saw in the documentation that by default it uses the UTF8STRING as type I've tried to force it to type="STRING" but with no success ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de] Sent: Thursday, March 01, 2018 00:12 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] clipboard and bytes On Wed, 28 Feb 2018 20:42:51 +0100 Michael Lange wrote: (...) > So at least this primitive seems to work. Maybe you can use this > technique to achieve what you want. Or maybe this slightly modified example comes closer to what you are looking for: from tkinter import * root = Tk() def copy(string): def cp(): return string copyfunc = (root.register(cp)) return(copyfunc) root.clipboard_clear() root.clipboard_append(copy(b'foobar'), type='foo') def paste(ev): clip = root.clipboard_get(type='foo') res = root.tk.call(clip) print('->', res, type(res)) root.bind('', paste) root.mainloop() Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "... freedom ... is a worship word..." "It is our worship word too." -- Cloud William and Kirk, "The Omega Glory", stardate unknown _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss From Vasilis.Vlachoudis at cern.ch Thu Mar 1 14:49:31 2018 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 1 Mar 2018 19:49:31 +0000 Subject: [Tkinter-discuss] clipboard and bytes In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01D0040629@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01D003E49A@CERNXCHG53.cern.ch> <20180228204251.8597f08f59be517b00a7774a@web.de>, <20180301001213.338b98c503e4c7dc73afac5e@web.de>, <0BC70B5D93E054469872FFD0FE07220E01D004060A@CERNXCHG53.cern.ch>, <0BC70B5D93E054469872FFD0FE07220E01D0040629@CERNXCHG53.cern.ch> Message-ID: <0BC70B5D93E054469872FFD0FE07220E01D00408CB@CERNXCHG53.cern.ch> I've been reading and debugging a bit what firefox is doing and how the selection is treated. I couldn't find anywhere how to handle binary data, but firefox when you copy an image it creates customs mime types like image/png that contain the data in a form '0x39 0xf7 0xb8 0x8f 0xff ...' Now I don't know if it is tk/tcl or _tkinter that makes this interpretation or the data are really ascii written in hex format, but I think even like this it can work for me. An interesting feature is the selection_get(type='TARGETS') which returns all possible mime/formats available. V. ________________________________________ From: Vasilis Vlachoudis Sent: Thursday, March 01, 2018 17:13 To: Michael Lange; tkinter-discuss at python.org Subject: RE: [Tkinter-discuss] clipboard and bytes I did something else. I've used the binascii.b2a_hex() and a2b_hex() functions to convert the bytes() to a hex string and the reverse (double in size, and a useless UTF-8 conversion, encode/decode) This way it works but not a clean approach, since I am copying in the clipboard binary data in a form of ascii. Is there a way to create a new mime format and advertise the format somehow in the clipboard? Vasilis ________________________________________ From: Vasilis Vlachoudis Sent: Thursday, March 01, 2018 16:42 To: Michael Lange; tkinter-discuss at python.org Subject: RE: [Tkinter-discuss] clipboard and bytes Many thanks! I works within the same process. When I try to launch it twice, so I can have clipboard exchange between different processes I get the following exception: Traceback (most recent call last): File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__ return self.func(*args) File "foo.py", line 41, in paste res = root.tk.call(clip) _tkinter.TclError: invalid command name "139879786444744cp" I saw in the documentation that by default it uses the UTF8STRING as type I've tried to force it to type="STRING" but with no success ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de] Sent: Thursday, March 01, 2018 00:12 To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] clipboard and bytes On Wed, 28 Feb 2018 20:42:51 +0100 Michael Lange wrote: (...) > So at least this primitive seems to work. Maybe you can use this > technique to achieve what you want. Or maybe this slightly modified example comes closer to what you are looking for: from tkinter import * root = Tk() def copy(string): def cp(): return string copyfunc = (root.register(cp)) return(copyfunc) root.clipboard_clear() root.clipboard_append(copy(b'foobar'), type='foo') def paste(ev): clip = root.clipboard_get(type='foo') res = root.tk.call(clip) print('->', res, type(res)) root.bind('', paste) root.mainloop() Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "... freedom ... is a worship word..." "It is our worship word too." -- Cloud William and Kirk, "The Omega Glory", stardate unknown _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss From klappnase at web.de Fri Mar 2 04:22:49 2018 From: klappnase at web.de (Michael Lange) Date: Fri, 2 Mar 2018 10:22:49 +0100 Subject: [Tkinter-discuss] clipboard and bytes In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01D004060A@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01D003E49A@CERNXCHG53.cern.ch> <20180228204251.8597f08f59be517b00a7774a@web.de> <20180301001213.338b98c503e4c7dc73afac5e@web.de> <0BC70B5D93E054469872FFD0FE07220E01D004060A@CERNXCHG53.cern.ch> Message-ID: <20180302102249.1a6ea8d6ffae764ae4d093ee@web.de> Hi, Vasilis Vlachoudis wrote: > I works within the same process. > When I try to launch it twice, so I can have clipboard exchange between > different processes > > I get the following exception: > Traceback (most recent call last): > File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__ > return self.func(*args) > File "foo.py", line 41, in paste > res = root.tk.call(clip) > _tkinter.TclError: invalid command name "139879786444744cp" oh sure, I did not think about *that* :) This is not going to work of course with two separate program instances. > I did something else. > I've used the binascii.b2a_hex() and a2b_hex() functions > to convert the bytes() to a hex string and the reverse (double in size, > and a useless UTF-8 conversion, encode/decode) > This way it works but not a clean approach, > since I am copying in the clipboard binary data in a form of ascii. Actually I believe, if you got it working, that it is probably the most "clean" approach, at least as long as you stay within Tk; I guess that other software might only receive "junk data" from the clipboard, though. > Is there a way to create a new mime format and advertise > the format somehow in the clipboard? Quoting "man clipboard" again: " Type specifies the form in which the selection is to be returned (the desired ``target'' for conversion, in ICCCM terminology), and should be an atom name such as STRING or FILE_NAME; see the Inter-Client Communication Conventions Manual for complete details. Type defaults to STRING. The format argument specifies the representation that should be used to transmit the selection to the requester (the second column of Table 2 of the ICCCM), and defaults to STRING.(...) The format argument is needed only for compatibility with clipboard requesters that do not use Tk. If the Tk toolkit is being used to retrieve the CLIPBOARD selection then the value is converted back to a string at the requesting end, so format is irrelevant." So I guess that the answer is probably "yes" here, but it sounds to me like a non-trivial task that might require a considerable amount of extra-investigation. > I've been reading and debugging a bit what firefox is doing and how the > selection is treated. I couldn't find anywhere how to handle binary > data, but firefox when you copy an image it creates customs mime types > like image/png that contain the data in a form '0x39 0xf7 0xb8 0x8f > 0xff ...' Probably they are doing something of that ICCCM compliant things, but I really don't know anything about that. > Now I don't know if it is tk/tcl or _tkinter that makes this > interpretation or the data are really ascii written in hex format, but > I think even like this it can work for me. I think it is surely tcl/tk that does it, tkinter only calls tk's clipboard commands. However tkinter in some situations *might* do some "mangling" to the data that tk returns (e.g. in the example from my previous post, when the "embedded" helper func would return a list, self.tk.call() would turn this into a tuple). Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8 From rikudou__sennin at live.com Sat Mar 3 16:13:54 2018 From: rikudou__sennin at live.com (adil gourinda) Date: Sat, 3 Mar 2018 21:13:54 +0000 Subject: [Tkinter-discuss] PanedWindow widget Message-ID: I) If you type in IDLE: ========== import tkinter print(help(tkinter.PanedWindow.paneconfigure)) ========== you get: ========== paneconfigure(self, tagOrId, cnf=None, **kw) ========== I have two questions: -Does "tagOrId" is the equivalent of "window" in TCL? -What is "cnf" parameter which is present in all Tkinter classes and methods? II) If you type in IDLE: ========== import tkinter print(help(tkinter.PanedWindow.sash_coord)) ========== you get: ========== sash_coord(self, index) Return the current x and y pair for the sash given by index. Index must be an integer between 0 and 1 less than the number of panes in the panedwindow. The coordinates given are those of the top left corner of the region containing the sash. + --------------------------------------------------------------- | pathName sash dragto index x y This command computes the | difference between the given coordinates and the coordinates | given to the last sash coord command for the given sash. It then | moves that sash the computed difference. The return value is the | empty string. + --------------------------------------------------------------- ========== This output return the description of two Tcl commands (pathName sash coord index and pathName sash dragto index x y) in one Tkinter methods, is it an error? Thanks for your attention -------------- next part -------------- An HTML attachment was scrubbed... URL: From storchaka at gmail.com Sun Mar 4 04:15:15 2018 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sun, 4 Mar 2018 11:15:15 +0200 Subject: [Tkinter-discuss] PanedWindow widget In-Reply-To: References: Message-ID: 03.03.18 23:13, adil gourinda ????: > print(help(tkinter.PanedWindow.paneconfigure)) print() is not needed here. help() itself prints the description. > I have two questions: > -Does "tagOrId" is the equivalent of "window" in TCL? Yes, it is. > -What is "cnf" parameter which is present in all Tkinter classes and > methods? A dict of options. You can specify options either as keyword arguments paneconfigure(wnd, height=200, width=100) or as a dict (if you have a variable set of options). options = {} options['height'] = 200 options['width'] = 100 paneconfigure(wnd, options) or even combine both ways paneconfigure(wnd, options, padx=10, pady=5) In modern Python this parameter mostly redundant since you can pass a variable number of keyword arguments as **options. paneconfigure(wnd, **options, padx=10, pady=5) > This output return the description of two Tcl commands (pathName *sash > coord* index and pathName *sash dragto* index x y) in one? Tkinter > methods, is it an error? This looks like a bug. Please open an issue on https://bugs.python.org/. From mkiever at web.de Sun Mar 4 16:28:16 2018 From: mkiever at web.de (mkiever at web.de) Date: Sun, 04 Mar 2018 21:28:16 -0000 Subject: [Tkinter-discuss] =?utf-8?q?PanedWindow_widget?= Message-ID: <0MI5ze-1epr5c0JeI-003tO9@smtp.web.de> Just tried: Adding the function definition of sash_dragto to tkinter/__init__.py is sufficient to make it work. I just don't understand how it is supposed to be used in combination with sash_mark. Perhaps, I have to try this in tcl to understand. Serhiy Storchaka : >03.03.18 23:13, adil gourinda ????: > >> This output return the description of two Tcl commands (pathName *sash >> coord* index and pathName *sash dragto* index x y) in one? Tkinter >> methods, is it an error? > >This looks like a bug. Please open an issue on https://bugs.python.org/. From rikudou__sennin at outlook.com Sun Mar 4 18:26:56 2018 From: rikudou__sennin at outlook.com (adil gourinda) Date: Sun, 4 Mar 2018 23:26:56 +0000 Subject: [Tkinter-discuss] configure command Message-ID: [cid:132f79be-dacf-4e7a-b0b1-94f5411d267b] By this picture I tried to explain the translation of "configure" command from Tcl to Python configure() method. For the (1) and (3) cases the python's syntax is clear. But for the (2) case where in Tcl I need to write only the option's name without value, what is its equivalent in Python (when the parameter's name is an argument)?; I tried the syntax in the picture and it works but what make things more difficult is when there is another parameter before "option" (ex :PanedWindow.paneconfigure). Thanks for your attention -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Tk configure command to Tkinter configure() method.jpg Type: image/jpeg Size: 50083 bytes Desc: Tk configure command to Tkinter configure() method.jpg URL: From klappnase at web.de Mon Mar 5 17:41:17 2018 From: klappnase at web.de (Michael Lange) Date: Mon, 5 Mar 2018 23:41:17 +0100 Subject: [Tkinter-discuss] configure command In-Reply-To: References: Message-ID: <20180305234117.393d00a18e7df358395bba18@web.de> Hi, On Sun, 4 Mar 2018 23:26:56 +0000 adil gourinda wrote: > [cid:132f79be-dacf-4e7a-b0b1-94f5411d267b] > By this picture I tried to explain the translation of "configure" > command from Tcl to Python configure() method. > > For the (1) and (3) cases the python's syntax is clear. > > But for the (2) case where in Tcl I need to write only the option's > name without value, what is its equivalent in Python (when the > parameter's name is an argument)?; I tried the syntax in the picture > and it works but what make things more difficult is when there is > another parameter before "option" (ex :PanedWindow.paneconfigure). > > Thanks for your attention actually that is quite straightforward, as a little toying around reveals: First a simple example in Tcl: $ wish % panedwindow .pw .pw % pack .pw % text .pw.t .pw.t % .pw add .pw.t % .pw paneconfigure .pw.t -width -width {} {} {} {} % Now the same in Python: $ python Python 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Tkinter import * >>> root = Tk() >>> pw = PanedWindow(root) >>> pw.pack() >>> t = Text(pw) >>> pw.add(t) >>> pw.paneconfigure(t, 'width') ('width', '', '', '', '') >>> So you see, the paneconfigure command works exactly the same in Python as it does in Tcl. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Dismissed. That's a Star Fleet expression for, "Get out." -- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud" From mark at markroseman.com Mon Mar 5 11:23:34 2018 From: mark at markroseman.com (Mark Roseman) Date: Mon, 5 Mar 2018 08:23:34 -0800 Subject: [Tkinter-discuss] configure command In-Reply-To: References: Message-ID: <6BBF331A-6B3F-4CAA-A86C-083424EAB2F1@markroseman.com> The method ?paneconfigure? is not the same as ?configure?, so you shouldn?t try to shoe-horn it into your diagram. Sure, it behaves similarly, but it?s a different command, rather than some ?magic? that?s part of regular configure. I hope you?re using the information in the TkDocs tutorial to guide you in terms of translating between languages. Mark > On Mar 4, 2018, at 3:26 PM, adil gourinda wrote: > > > By this picture I tried to explain the translation of "configure" command from Tcl to Python configure() method. > > For the (1) and (3) cases the python's syntax is clear. > > But for the (2) case where in Tcl I need to write only the option's name without value, what is its equivalent in Python (when the parameter's name is an argument)?; I tried the syntax in the picture and it works but what make things more difficult is when there is another parameter before "option" (ex :PanedWindow.paneconfigure). > > Thanks for your attention > _______________________________________________ > 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 rikudou__sennin at live.com Tue Mar 6 11:31:23 2018 From: rikudou__sennin at live.com (adil gourinda) Date: Tue, 6 Mar 2018 16:31:23 +0000 Subject: [Tkinter-discuss] configure command In-Reply-To: <20180305234117.393d00a18e7df358395bba18@web.de> References: , <20180305234117.393d00a18e7df358395bba18@web.de> Message-ID: In your example, is "width" a positional argument or a positional-keyword argument (and if it is what is the parameter's name) ? Thanks ________________________________ From: Tkinter-discuss on behalf of Michael Lange Sent: Monday, March 5, 2018 10:41 PM To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] configure command Hi, On Sun, 4 Mar 2018 23:26:56 +0000 adil gourinda wrote: > [cid:132f79be-dacf-4e7a-b0b1-94f5411d267b] > By this picture I tried to explain the translation of "configure" > command from Tcl to Python configure() method. > > For the (1) and (3) cases the python's syntax is clear. > > But for the (2) case where in Tcl I need to write only the option's > name without value, what is its equivalent in Python (when the > parameter's name is an argument)?; I tried the syntax in the picture > and it works but what make things more difficult is when there is > another parameter before "option" (ex :PanedWindow.paneconfigure). > > Thanks for your attention actually that is quite straightforward, as a little toying around reveals: First a simple example in Tcl: $ wish % panedwindow .pw .pw % pack .pw % text .pw.t .pw.t % .pw add .pw.t % .pw paneconfigure .pw.t -width -width {} {} {} {} % Now the same in Python: $ python Python 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Tkinter import * >>> root = Tk() >>> pw = PanedWindow(root) >>> pw.pack() >>> t = Text(pw) >>> pw.add(t) >>> pw.paneconfigure(t, 'width') ('width', '', '', '', '') >>> So you see, the paneconfigure command works exactly the same in Python as it does in Tcl. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Dismissed. That's a Star Fleet expression for, "Get out." -- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud" _______________________________________________ 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 klappnase at web.de Tue Mar 6 15:46:27 2018 From: klappnase at web.de (Michael Lange) Date: Tue, 6 Mar 2018 21:46:27 +0100 Subject: [Tkinter-discuss] configure command In-Reply-To: References: <20180305234117.393d00a18e7df358395bba18@web.de> Message-ID: <20180306214627.1bb43013e7d62fee44fe6d9e@web.de> Hi, On Tue, 6 Mar 2018 16:31:23 +0000 adil gourinda wrote: > In your example, is "width" a positional argument or a > positional-keyword argument (and if it is what is the parameter's > name) ? Not sure what you mean by that; I would tend to say the parameter's name is "width" ;) At https://www.tcl.tk/man/tcl8.4/TkCmd/panedwindow.htm#M33 this is explained in more detail. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Earth -- mother of the most beautiful women in the universe. -- Apollo, "Who Mourns for Adonais?" stardate 3468.1 From namnguyen at verily.com Tue Mar 6 12:57:01 2018 From: namnguyen at verily.com (Nam Nguyen) Date: Tue, 6 Mar 2018 09:57:01 -0800 Subject: [Tkinter-discuss] Fixed ratio split screen geometry manager Message-ID: Hi, I'm looking for a fixed ratio 2-pane geometry manager. I tried PanedWindow but it does not have any option for me to specify the ratio of the children. What I'm looking for is a geometry manager/container that splits its space into two for the children. The children can grow only in their own spaces. The children can come and go, but the parent container should maintain that 2-pane split with the same ratio. Where should I look into? Thanks! Nam -------------- next part -------------- An HTML attachment was scrubbed... URL: From namnguyen at google.com Tue Mar 6 13:48:35 2018 From: namnguyen at google.com (Nam Nguyen) Date: Tue, 6 Mar 2018 10:48:35 -0800 Subject: [Tkinter-discuss] Fixed ratio split screen geometry manager Message-ID: Hi, I'm looking for a fixed ratio 2-pane geometry manager. I tried PanedWindow but it does not have any option for me to specify the ratio of the children. What I'm looking for is a geometry manager/container that splits its space into two for the children. The children can grow only in their own spaces. The children can come and go, but the parent container should maintain that 2-pane split with the same ratio. Where should I look into? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From klappnase at web.de Tue Mar 6 19:30:50 2018 From: klappnase at web.de (Michael Lange) Date: Wed, 7 Mar 2018 01:30:50 +0100 Subject: [Tkinter-discuss] Fixed ratio split screen geometry manager In-Reply-To: References: Message-ID: <20180307013050.503cba0457ad16f819f50704@web.de> Hi, On Tue, 6 Mar 2018 09:57:01 -0800 Nam Nguyen wrote: > Hi, > > I'm looking for a fixed ratio 2-pane geometry manager. > > I tried PanedWindow but it does not have any option for me to specify > the ratio of the children. > > What I'm looking for is a geometry manager/container that splits its > space into two for the children. The children can grow only in their > own spaces. The children can come and go, but the parent container > should maintain that 2-pane split with the same ratio. > > Where should I look into? in case you do not need the PanedWindow's resize handle, you might want to have a look at the Grid geometry manager's uniform and weight options to the grid_columnconfigure() and grid_rowconfigure() commands. Another option might be to have a look at the Place geometry manager, especially the relheight and relwidth options. Using for example relheight=0.5 will make the widget always occupy 50% of the parent widget's height. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. The sight of death frightens them [Earthers]. -- Kras the Klingon, "Friday's Child", stardate 3497.2 From rikudou__sennin at live.com Wed Mar 7 08:46:40 2018 From: rikudou__sennin at live.com (adil gourinda) Date: Wed, 7 Mar 2018 13:46:40 +0000 Subject: [Tkinter-discuss] configure command In-Reply-To: <20180306214627.1bb43013e7d62fee44fe6d9e@web.de> References: <20180305234117.393d00a18e7df358395bba18@web.de> , <20180306214627.1bb43013e7d62fee44fe6d9e@web.de> Message-ID: For the last time, what is the parameter's name that accepts option's name as a string: instance.configure(?!?!="option") I hope I was clear this time. Thanks ________________________________ From: Tkinter-discuss on behalf of Michael Lange Sent: Tuesday, March 6, 2018 8:46 PM To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] configure command Hi, On Tue, 6 Mar 2018 16:31:23 +0000 adil gourinda wrote: > In your example, is "width" a positional argument or a > positional-keyword argument (and if it is what is the parameter's > name) ? Not sure what you mean by that; I would tend to say the parameter's name is "width" ;) At https://www.tcl.tk/man/tcl8.4/TkCmd/panedwindow.htm#M33 this is explained in more detail. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Earth -- mother of the most beautiful women in the universe. -- Apollo, "Who Mourns for Adonais?" stardate 3468.1 _______________________________________________ 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 bryan.oakley at gmail.com Wed Mar 7 11:49:03 2018 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Wed, 7 Mar 2018 10:49:03 -0600 Subject: [Tkinter-discuss] configure command In-Reply-To: References: <20180305234117.393d00a18e7df358395bba18@web.de> <20180306214627.1bb43013e7d62fee44fe6d9e@web.de> Message-ID: > > For the last time, what is the parameter's name that accepts option's name > as a string: The tk documentation calls this "option". In python it doesn't have a literal name. If you need to refer to it in documentation you could use "argument" or "the only argument" or "the first positional argument". For example: "if you call the configure method with a single argument (eg: label_widget.configure("text")), it will return ..." On Wed, Mar 7, 2018 at 7:46 AM, adil gourinda wrote: > For the last time, what is the parameter's name that accepts option's name > as a string: > > instance*.configure(*?!?!="option"*)* > > I hope I was clear this time. > > Thanks > ------------------------------ > *From:* Tkinter-discuss python.org> on behalf of Michael Lange > *Sent:* Tuesday, March 6, 2018 8:46 PM > *To:* tkinter-discuss at python.org > *Subject:* Re: [Tkinter-discuss] configure command > > Hi, > > On Tue, 6 Mar 2018 16:31:23 +0000 > adil gourinda wrote: > > > In your example, is "width" a positional argument or a > > positional-keyword argument (and if it is what is the parameter's > > name) ? > > Not sure what you mean by that; I would tend to say the parameter's name > is "width" ;) > > At > https://www.tcl.tk/man/tcl8.4/TkCmd/panedwindow.htm#M33 > this is explained in more detail. > > Regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Earth -- mother of the most beautiful women in the universe. > -- Apollo, "Who Mourns for Adonais?" stardate 3468.1 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss > > _______________________________________________ > 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 klappnase at web.de Wed Mar 7 17:14:24 2018 From: klappnase at web.de (Michael Lange) Date: Wed, 7 Mar 2018 23:14:24 +0100 Subject: [Tkinter-discuss] configure command In-Reply-To: References: <20180305234117.393d00a18e7df358395bba18@web.de> <20180306214627.1bb43013e7d62fee44fe6d9e@web.de> Message-ID: <20180307231424.c5e7a3163aaf9aff097bbe56@web.de> Hi, On Wed, 7 Mar 2018 13:46:40 +0000 adil gourinda wrote: > For the last time, what is the parameter's name that accepts option's > name as a string: > > instance.configure(?!?!="option") > > I hope I was clear this time. ok, I got it now :) As Brian pointed out, there is no literal parameter name here in Python, however (to make things a bit more confusing :) technically speaking you can use "cnf" as keyword-parameter here (although "cnf" is usually supposed to be a {"option":"value"} dict), so e.g.: >>> widget.configure('bd') ('borderwidth', 'borderWidth', 'BorderWidth', , 0) is equal to >>> widget.configure(cnf='bd') ('borderwidth', 'borderWidth', 'BorderWidth', , 0) Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You can't evaluate a man by logic alone. -- McCoy, "I, Mudd", stardate 4513.3 From rikudou__sennin at outlook.com Sun Mar 11 09:26:37 2018 From: rikudou__sennin at outlook.com (adil gourinda) Date: Sun, 11 Mar 2018 13:26:37 +0000 Subject: [Tkinter-discuss] Fixed ratio split screen geometry manager In-Reply-To: References: Message-ID: I suggest to use place() geometry manager ________________________________ From: Tkinter-discuss on behalf of Nam Nguyen via Tkinter-discuss Sent: Tuesday, March 6, 2018 6:48:35 PM To: tkinter-discuss at python.org Subject: [Tkinter-discuss] Fixed ratio split screen geometry manager Hi, I'm looking for a fixed ratio 2-pane geometry manager. I tried PanedWindow but it does not have any option for me to specify the ratio of the children. What I'm looking for is a geometry manager/container that splits its space into two for the children. The children can grow only in their own spaces. The children can come and go, but the parent container should maintain that 2-pane split with the same ratio. Where should I look into? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From namnguyen at verily.com Thu Mar 15 17:41:02 2018 From: namnguyen at verily.com (Nam Nguyen) Date: Thu, 15 Mar 2018 14:41:02 -0700 Subject: [Tkinter-discuss] Inherit styles from parent widgets Message-ID: Hi list, Is there any way to inherit common options from parent widgets? Tk Themed widgets allow me to define a hierarchy of styles on different types of widgets. For example, I can have TButton, or Derived.TButton. What I'm asking is if I have a frame with red background color, I would love for all frames (or button, or any widget making use of the background option) placed in that frame to also inherit its redness unless a style has been specified. I guess (but am not sure) that this is similar to Cascade Style Sheet. Thanks! Nam -------------- next part -------------- An HTML attachment was scrubbed... URL: From namnguyen at google.com Mon Mar 26 15:12:31 2018 From: namnguyen at google.com (Nam Nguyen) Date: Mon, 26 Mar 2018 12:12:31 -0700 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread Message-ID: Hi, The adage often goes something like this: Do all GUI actions in a GUI thread (usually main thread), do I/O in different threads. While it is a good wisdom to apply blanketly, I'm curious about bad outcome from not following that advice. Other than the obvious blocking nature of the event loop, which is why we need threads to work with it, is there any other downside from directly creating, modifying, or destroying Tk objects (such as widgets, variables) in non-GUI threads? Thanks! Nam -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From bryan.oakley at gmail.com Mon Mar 26 15:40:53 2018 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Mon, 26 Mar 2018 14:40:53 -0500 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: References: Message-ID: I think that part of the problem arises due to the fact that the tk library used by tkinter might not have been compiled with thread support. It's an explicit option required during the compile stage (--enable-threads). If you don't have a tk library compiled with thread support, then modifying tkinter objects from other threads can have typical thread-safety issues. Someone a while ago created a thread-safe version of tkinter called mttkinter. The README for that project has this to say: Although tkinter is technically thread-safe (assuming Tk is built with > --enable-threads), practically speaking there are still problems when used > in multithreaded Python applications. The problems stem from the fact that > the _tkinter module attempts to gain control of the main thread via a > polling technique when processing calls from other threads. If it succeeds, > all is well. If it fails (i.e., after a timeout), the application receives > an exception with the message: RuntimeError: main thread is not in main > loop. There is no way to tell when this might happen, so calling Tk > routines from multiple threads seems to be problematic at best. Even with thread support, there appears to be bad interactions between the global interpreter lock (GIL) of python, and the underlying tcl interpreter used by Tkinter. Donal Fellows is one of the maintainers of the tcl core, and he provided additional information in this stackoverflow answer: http://stackoverflow.com/a/38767665/7432 In that post he wrote: Each Tcl interpreter object (i.e., the context that knows how to run a Tcl > procedure) can only be safely used from the OS thread that creates it. This > is because Tcl doesn't use a global interpreter lock like Python, and > instead makes extensive use of thread-specific data to reduce the number of > locks required internally. (Well-written Tcl code can take advantage of > this to scale up very large on suitable hardware.) > Because of this, you must make sure that you only ever run Tcl commands or > Tkinter operations from a single thread; I trust Donal on this subject. On Mon, Mar 26, 2018 at 2:12 PM, Nam Nguyen via Tkinter-discuss < tkinter-discuss at python.org> wrote: > Hi, > > The adage often goes something like this: > > Do all GUI actions in a GUI thread (usually main thread), do I/O in > different threads. > > While it is a good wisdom to apply blanketly, I'm curious about bad > outcome from not following that advice. Other than the obvious blocking > nature of the event loop, which is why we need threads to work with it, is > there any other downside from directly creating, modifying, or destroying > Tk objects (such as widgets, variables) in non-GUI threads? > > Thanks! > Nam > > _______________________________________________ > 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 namnguyen at google.com Mon Mar 26 15:54:20 2018 From: namnguyen at google.com (Nam Nguyen) Date: Mon, 26 Mar 2018 12:54:20 -0700 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: References: Message-ID: On Mon, Mar 26, 2018 at 12:40 PM, Bryan Oakley wrote: > I think that part of the problem arises due to the fact that the tk > library used by tkinter might not have been compiled with thread support. > It's an explicit option required during the compile stage > (--enable-threads). If you don't have a tk library compiled with thread > support, then modifying tkinter objects from other threads can have typical > thread-safety issues. > > Someone a while ago created a thread-safe version of tkinter called > mttkinter. The README for that project has this to say: > > Although tkinter is technically thread-safe (assuming Tk is built with >> --enable-threads), practically speaking there are still problems when used >> in multithreaded Python applications. The problems stem from the fact that >> the _tkinter module attempts to gain control of the main thread via a >> polling technique when processing calls from other threads. If it succeeds, >> all is well. If it fails (i.e., after a timeout), the application receives >> an exception with the message: RuntimeError: main thread is not in main >> loop. There is no way to tell when this might happen, so calling Tk >> routines from multiple threads seems to be problematic at best. > > > > Even with thread support, there appears to be bad interactions between the > global interpreter lock (GIL) of python, and the underlying tcl interpreter > used by Tkinter. Donal Fellows is one of the maintainers of the tcl core, > and he provided additional information in this stackoverflow answer: > http://stackoverflow.com/a/38767665/7432 > > In that post he wrote: > > Each Tcl interpreter object (i.e., the context that knows how to run a Tcl >> procedure) can only be safely used from the OS thread that creates it. This >> is because Tcl doesn't use a global interpreter lock like Python, and >> instead makes extensive use of thread-specific data to reduce the number of >> locks required internally. (Well-written Tcl code can take advantage of >> this to scale up very large on suitable hardware.) >> > > > Because of this, you must make sure that you only ever run Tcl commands or >> Tkinter operations from a single thread; > > This is where my confusion comes from, actually ;). Python is single threaded (from the OS point of view). When I create the TCL interpreter, it is also created in the same thread that runs the Python interpreter. So regardless of how many Python threads (threading module), they all should belong to this same OS thread, should they not? ? > > I trust Donal on this subject. > > > On Mon, Mar 26, 2018 at 2:12 PM, Nam Nguyen via Tkinter-discuss < > tkinter-discuss at python.org> wrote: > >> Hi, >> >> The adage often goes something like this: >> >> Do all GUI actions in a GUI thread (usually main thread), do I/O in >> different threads. >> >> While it is a good wisdom to apply blanketly, I'm curious about bad >> outcome from not following that advice. Other than the obvious blocking >> nature of the event loop, which is why we need threads to work with it, is >> there any other downside from directly creating, modifying, or destroying >> Tk objects (such as widgets, variables) in non-GUI threads? >> >> Thanks! >> Nam >> >> _______________________________________________ >> 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From klappnase at web.de Mon Mar 26 17:22:33 2018 From: klappnase at web.de (Michael Lange) Date: Mon, 26 Mar 2018 23:22:33 +0200 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: References: Message-ID: <20180326232233.456e43a217c6a02ca6626cd2@web.de> Hi, On Mon, 26 Mar 2018 12:54:20 -0700 Nam Nguyen via Tkinter-discuss wrote: > This is where my confusion comes from, actually ;). Python is single > threaded (from the OS point of view). When I create the TCL > interpreter, it is also created in the same thread that runs the Python > interpreter. So regardless of how many Python threads (threading > module), they all should belong to this same OS thread, should they not? I am not an expert on this, but I don't think so. At least here when I run a Tkinter app using threads (on linux) I see three threads in top, each with a different pid. And I am quite sure that I have seen strange things happen, iirc seemingly unpredictable, when the rule of thumb "run Tk only from the main thread and don't touch it from any child thread" was not observed. Some times such code *seemed* to work though, which I believe makes it even more dangerous, since it seems you can never know what (and when) will hit you. So my recommendation is to just either stick with that "rule of thumb" or else try the aforementioned thread-safe tkinter version. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. On my planet, to rest is to rest -- to cease using energy. To me, it is quite illogical to run up and down on green grass, using energy, instead of saving it. -- Spock, "Shore Leave", stardate 3025.2 From namnguyen at google.com Mon Mar 26 17:41:28 2018 From: namnguyen at google.com (Nam Nguyen) Date: Mon, 26 Mar 2018 14:41:28 -0700 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: <20180326232233.456e43a217c6a02ca6626cd2@web.de> References: <20180326232233.456e43a217c6a02ca6626cd2@web.de> Message-ID: On this note, is setting/getting variables (StringVar, IntVar etc) considered GUI action? Why, or why not? Thanks! Nam On Mon, Mar 26, 2018 at 2:22 PM, Michael Lange wrote: > Hi, > > On Mon, 26 Mar 2018 12:54:20 -0700 > Nam Nguyen via Tkinter-discuss wrote: > > > This is where my confusion comes from, actually ;). Python is single > > threaded (from the OS point of view). When I create the TCL > > interpreter, it is also created in the same thread that runs the Python > > interpreter. So regardless of how many Python threads (threading > > module), they all should belong to this same OS thread, should they not? > > I am not an expert on this, but I don't think so. At least here when I > run a Tkinter app using threads (on linux) I see three threads in top, > each with a different pid. > And I am quite sure that I have seen strange things happen, iirc seemingly > unpredictable, when the rule of thumb "run Tk only from the main thread > and don't touch it from any child thread" was not observed. Some times > such code *seemed* to work though, which I believe makes it even more > dangerous, since it seems you can never know what (and when) will hit you. > So my recommendation is to just either stick with that "rule of thumb" or > else try the aforementioned thread-safe tkinter version. > > Best regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > On my planet, to rest is to rest -- to cease using energy. To me, it > is quite illogical to run up and down on green grass, using energy, > instead of saving it. > -- Spock, "Shore Leave", stardate 3025.2 > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From bryan.oakley at gmail.com Mon Mar 26 18:37:45 2018 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Mon, 26 Mar 2018 17:37:45 -0500 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: References: <20180326232233.456e43a217c6a02ca6626cd2@web.de> Message-ID: I don't know with absolute certainty, but I would say that getting/setting variables is considered a "GUI action". Earlier I quoted Donal Fellows as saying "you must make sure that you only ever run Tcl commands or Tkinter operations from a single thread". Getting or setting a variable requires running a tcl command. On Mon, Mar 26, 2018 at 4:41 PM, Nam Nguyen via Tkinter-discuss < tkinter-discuss at python.org> wrote: > On this note, is setting/getting variables (StringVar, IntVar etc) > considered GUI action? Why, or why not? > Thanks! > Nam > > On Mon, Mar 26, 2018 at 2:22 PM, Michael Lange wrote: > >> Hi, >> >> On Mon, 26 Mar 2018 12:54:20 -0700 >> Nam Nguyen via Tkinter-discuss wrote: >> >> > This is where my confusion comes from, actually ;). Python is single >> > threaded (from the OS point of view). When I create the TCL >> > interpreter, it is also created in the same thread that runs the Python >> > interpreter. So regardless of how many Python threads (threading >> > module), they all should belong to this same OS thread, should they not? >> >> I am not an expert on this, but I don't think so. At least here when I >> run a Tkinter app using threads (on linux) I see three threads in top, >> each with a different pid. >> And I am quite sure that I have seen strange things happen, iirc seemingly >> unpredictable, when the rule of thumb "run Tk only from the main thread >> and don't touch it from any child thread" was not observed. Some times >> such code *seemed* to work though, which I believe makes it even more >> dangerous, since it seems you can never know what (and when) will hit you. >> So my recommendation is to just either stick with that "rule of thumb" or >> else try the aforementioned thread-safe tkinter version. >> >> Best regards >> >> Michael >> >> .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. >> >> On my planet, to rest is to rest -- to cease using energy. To me, it >> is quite illogical to run up and down on green grass, using energy, >> instead of saving it. >> -- Spock, "Shore Leave", stardate 3025.2 >> > > > _______________________________________________ > 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 klappnase at web.de Mon Mar 26 19:02:47 2018 From: klappnase at web.de (Michael Lange) Date: Tue, 27 Mar 2018 01:02:47 +0200 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: References: <20180326232233.456e43a217c6a02ca6626cd2@web.de> Message-ID: <20180327010247.106a3a036f753b9171d7c7e1@web.de> Hi, On Mon, 26 Mar 2018 14:41:28 -0700 Nam Nguyen wrote: > On this note, is setting/getting variables (StringVar, IntVar etc) > considered GUI action? Why, or why not? > Thanks! > Nam as Brian already pointed out, when setting/getting those varaible's values Tcl commands are involved. A less technical but (maybe) more obvious explanation may be that setting the variable value may change directly for example the string displayed in a Label widget. Considering this I believe it is rather evident that it actually is gui action. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You go slow, be gentle. It's no one-way street -- you know how you feel and that's all. It's how the girl feels too. Don't press. If the girl feels anything for you at all, you'll know. -- Kirk, "Charlie X", stardate 1535.8 From namnguyen at google.com Mon Mar 26 22:49:09 2018 From: namnguyen at google.com (Nam Nguyen) Date: Mon, 26 Mar 2018 19:49:09 -0700 Subject: [Tkinter-discuss] Revisiting the adage of GUI thread In-Reply-To: <20180327010247.106a3a036f753b9171d7c7e1@web.de> References: <20180326232233.456e43a217c6a02ca6626cd2@web.de> <20180327010247.106a3a036f753b9171d7c7e1@web.de> Message-ID: Thank you for the discussions, everyone! I had figured this to be the case while reading Tcl sources. Your confirmations were very helpful. I guess the point in short is anything that touches the Tcl interpreter should be done in the same thread (threading module thread) the interpreter has been started in or risk hitting hard-to-debug problem. Thanks! Nam On Mon, Mar 26, 2018 at 4:02 PM, Michael Lange wrote: > Hi, > > On Mon, 26 Mar 2018 14:41:28 -0700 > Nam Nguyen wrote: > > > On this note, is setting/getting variables (StringVar, IntVar etc) > > considered GUI action? Why, or why not? > > Thanks! > > Nam > > as Brian already pointed out, when setting/getting those varaible's > values Tcl commands are involved. A less technical but (maybe) more > obvious explanation may be that setting the variable value may change > directly for example the string displayed in a Label widget. Considering > this I believe it is rather evident that it actually is gui action. > > Best regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > You go slow, be gentle. It's no one-way street -- you know how you > feel and that's all. It's how the girl feels too. Don't press. If > the girl feels anything for you at all, you'll know. > -- Kirk, "Charlie X", stardate 1535.8 > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From msa01 at bitflipper.ca Tue Mar 27 07:54:35 2018 From: msa01 at bitflipper.ca (Cam Farnell) Date: Tue, 27 Mar 2018 08:54:35 -0300 Subject: [Tkinter-discuss] Help related to tkinter on Mac In-Reply-To: References: <20180326232233.456e43a217c6a02ca6626cd2@web.de> <20180327010247.106a3a036f753b9171d7c7e1@web.de> Message-ID: Hello All, I've developed a simple flowcharting program in Python 2.7 + Tkinter which I am about to release as open source. All the development was done on an Xubuntu box so it works under Linux and, thanks to the magic of VirtualBox, I've tried it successfully under a couple of version of Windows. Under Macs it is more problematic. What I've found so far is: - If you run it under the Python 2.7 that comes with the machine then you get a message about it not finding a config file, which is normal for first-time startup, but then it hangs without even starting the GUI and there is no way to interrupt it to see what is going on. - If you run it under Python 2.7 which was installed with the package manager "brew" (https://brew.sh/) then it works. Neither of the people who tried if for me on their Macs know much about Python, and I certainly don't know much about Macs. Therefore I'm hoping that someone on this list who has a Mac and knows something about Python might be willing to give it a try. Based on that I could make changes or at least update the web site to let Mac users know what the situation is. The web site with information and the download link is: http://www.retroflow.ca Many thanks Cam Farnell Halifax, NS, Canada From namnguyen at google.com Tue Mar 27 11:29:06 2018 From: namnguyen at google.com (Nam Nguyen) Date: Tue, 27 Mar 2018 08:29:06 -0700 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? Message-ID: Hi list, I have several ttk.Frames belonging to the same parent (master, but I try not to use that word) that are swapped in and out depending on some external event. What I observe so far is there is some flickering every time a frame is swapped out and another swapped in. I have tried using both place and pack geometry managers. Do you have any tip/trick to eliminate this flickering? Thanks! Nam -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From namnguyen at google.com Tue Mar 27 15:57:39 2018 From: namnguyen at google.com (Nam Nguyen) Date: Tue, 27 Mar 2018 12:57:39 -0700 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: References: Message-ID: A simple reprod code: import tkinter as tk from tkinter import font root = tk.Tk() root.minsize(1280, 800) root.bind('', lambda _: root.quit()) my_font = font.Font(root, 'Sans 128 bold') f_1 = tk.Frame(root) tk.Button(f_1, text='Frame 1', font=my_font).pack( expand=True, fill=tk.BOTH) f_2 = tk.Frame(root) tk.Button(f_2, text='Frame 2'[::-1], font=my_font).pack( expand=True, fill=tk.BOTH) f_1.pack(expand=True, fill=tk.BOTH) current = f_1 def flip(): global current current.pack_forget() if current is f_1: current = f_2 else: current = f_1 current.pack(expand=True, fill=tk.BOTH) root.after(1000, flip) root.after(1000, flip) root.mainloop() Nam On Tue, Mar 27, 2018 at 8:29 AM, Nam Nguyen wrote: > Hi list, > > I have several ttk.Frames belonging to the same parent (master, but I try > not to use that word) that are swapped in and out depending on some > external event. > > What I observe so far is there is some flickering every time a frame is > swapped out and another swapped in. I have tried using both place and pack > geometry managers. > > Do you have any tip/trick to eliminate this flickering? > > Thanks! > Nam > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From bryan.oakley at gmail.com Tue Mar 27 16:17:15 2018 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Tue, 27 Mar 2018 15:17:15 -0500 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: References: Message-ID: I don't see any flicker when I run that. On Tue, Mar 27, 2018 at 2:57 PM, Nam Nguyen via Tkinter-discuss < tkinter-discuss at python.org> wrote: > A simple reprod code: > > import tkinter as tk > from tkinter import font > > > root = tk.Tk() > root.minsize(1280, 800) > root.bind('', lambda _: root.quit()) > > my_font = font.Font(root, 'Sans 128 bold') > f_1 = tk.Frame(root) > tk.Button(f_1, text='Frame 1', font=my_font).pack( > expand=True, fill=tk.BOTH) > f_2 = tk.Frame(root) > tk.Button(f_2, text='Frame 2'[::-1], font=my_font).pack( > expand=True, fill=tk.BOTH) > > f_1.pack(expand=True, fill=tk.BOTH) > current = f_1 > > def flip(): > global current > current.pack_forget() > if current is f_1: > current = f_2 > else: > current = f_1 > current.pack(expand=True, fill=tk.BOTH) > root.after(1000, flip) > > root.after(1000, flip) > root.mainloop() > > Nam > > On Tue, Mar 27, 2018 at 8:29 AM, Nam Nguyen wrote: > >> Hi list, >> >> I have several ttk.Frames belonging to the same parent (master, but I try >> not to use that word) that are swapped in and out depending on some >> external event. >> >> What I observe so far is there is some flickering every time a frame is >> swapped out and another swapped in. I have tried using both place and pack >> geometry managers. >> >> Do you have any tip/trick to eliminate this flickering? >> >> Thanks! >> Nam >> > > > _______________________________________________ > 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 namnguyen at google.com Tue Mar 27 16:27:06 2018 From: namnguyen at google.com (Nam Nguyen) Date: Tue, 27 Mar 2018 13:27:06 -0700 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: References: Message-ID: I'm running i3-wm on Debian and this code tends to flicks more when I have my mouse over the buttons. Nam On Tue, Mar 27, 2018 at 1:17 PM, Bryan Oakley wrote: > I don't see any flicker when I run that. > > On Tue, Mar 27, 2018 at 2:57 PM, Nam Nguyen via Tkinter-discuss < > tkinter-discuss at python.org> wrote: > >> A simple reprod code: >> >> import tkinter as tk >> from tkinter import font >> >> >> root = tk.Tk() >> root.minsize(1280, 800) >> root.bind('', lambda _: root.quit()) >> >> my_font = font.Font(root, 'Sans 128 bold') >> f_1 = tk.Frame(root) >> tk.Button(f_1, text='Frame 1', font=my_font).pack( >> expand=True, fill=tk.BOTH) >> f_2 = tk.Frame(root) >> tk.Button(f_2, text='Frame 2'[::-1], font=my_font).pack( >> expand=True, fill=tk.BOTH) >> >> f_1.pack(expand=True, fill=tk.BOTH) >> current = f_1 >> >> def flip(): >> global current >> current.pack_forget() >> if current is f_1: >> current = f_2 >> else: >> current = f_1 >> current.pack(expand=True, fill=tk.BOTH) >> root.after(1000, flip) >> >> root.after(1000, flip) >> root.mainloop() >> >> Nam >> >> On Tue, Mar 27, 2018 at 8:29 AM, Nam Nguyen wrote: >> >>> Hi list, >>> >>> I have several ttk.Frames belonging to the same parent (master, but I >>> try not to use that word) that are swapped in and out depending on some >>> external event. >>> >>> What I observe so far is there is some flickering every time a frame is >>> swapped out and another swapped in. I have tried using both place and pack >>> geometry managers. >>> >>> Do you have any tip/trick to eliminate this flickering? >>> >>> Thanks! >>> Nam >>> >> >> >> _______________________________________________ >> 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From klappnase at web.de Tue Mar 27 17:24:54 2018 From: klappnase at web.de (Michael Lange) Date: Tue, 27 Mar 2018 23:24:54 +0200 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: References: Message-ID: <20180327232454.59f48f763746d2fcdad4a4ab@web.de> Hi, On Tue, 27 Mar 2018 13:27:06 -0700 Nam Nguyen via Tkinter-discuss wrote: > I'm running i3-wm on Debian and this code tends to flicks more when I > have my mouse over the buttons. > Nam I see some flicker here, too. The additional flicker when the mouse hovers over the window is apparently due to the event that occurs after the widget was packed, which switches the button's background to the activebackground color. The (here rather tiny) flicker with the mouse outside the window is maybe only due to the time Tk needs to redraw the window. This effect can be observed more closely when you set the background color of one button for example to "red" and to "green" for the other. You will get much more flicker all of a sudden. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Witch! Witch! They'll burn ya! -- Hag, "Tomorrow is Yesterday", stardate unknown From mark at markroseman.com Tue Mar 27 17:57:30 2018 From: mark at markroseman.com (Mark Roseman) Date: Tue, 27 Mar 2018 14:57:30 -0700 Subject: [Tkinter-discuss] Help related to tkinter on Mac In-Reply-To: References: <20180326232233.456e43a217c6a02ca6626cd2@web.de> <20180327010247.106a3a036f753b9171d7c7e1@web.de> Message-ID: Hi Cam, I tried it on my system and it actually worked. I?m guessing it?s because I have a newer version of Tk installed than the system one. Have your testers download Tcl/Tk from here, install it, and see what happens. https://www.activestate.com/activetcl/downloads Mark > On Mar 27, 2018, at 4:54 AM, Cam Farnell wrote: > > Hello All, > > I've developed a simple flowcharting program in Python 2.7 + Tkinter which I am about to release as open source. All the development was done on an Xubuntu box so it works under Linux and, thanks to the magic of VirtualBox, I've tried it successfully under a couple of version of Windows. Under Macs it is more problematic. What I've found so far is: > > - If you run it under the Python 2.7 that comes with the machine then you get a message about it not finding a config file, which is normal for first-time startup, but then it hangs without even starting the GUI and there is no way to interrupt it to see what is going on. > > - If you run it under Python 2.7 which was installed with the package manager "brew" (https://brew.sh/) then it works. > > Neither of the people who tried if for me on their Macs know much about Python, and I certainly don't know much about Macs. > > Therefore I'm hoping that someone on this list who has a Mac and knows something about Python might be willing to give it a try. Based on that I could make changes or at least update the web site to let Mac users know what the situation is. > > The web site with information and the download link is: > > http://www.retroflow.ca > > Many thanks > > Cam Farnell > Halifax, NS, Canada > > _______________________________________________ > 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 namnguyen at google.com Tue Mar 27 21:18:50 2018 From: namnguyen at google.com (Nam Nguyen) Date: Wed, 28 Mar 2018 01:18:50 +0000 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: <20180327232454.59f48f763746d2fcdad4a4ab@web.de> References: <20180327232454.59f48f763746d2fcdad4a4ab@web.de> Message-ID: Is my code out of whack or is it "standard" enough to your seasoned eyes? Is there any guess as to a fix to this flickering, be it with my code, or Tk itself? Thanks! Nam On Tue, Mar 27, 2018, 2:24 PM Michael Lange wrote: > Hi, > > On Tue, 27 Mar 2018 13:27:06 -0700 > Nam Nguyen via Tkinter-discuss wrote: > > > I'm running i3-wm on Debian and this code tends to flicks more when I > > have my mouse over the buttons. > > Nam > > I see some flicker here, too. The additional flicker when the mouse > hovers over the window is apparently due to the event that occurs > after the widget was packed, which switches the button's background to > the activebackground color. The (here rather tiny) flicker with the mouse > outside the window is maybe only due to the time Tk needs to redraw the > window. > This effect can be observed more closely when you set the background > color of one button for example to "red" and to "green" for the other. > You will get much more flicker all of a sudden. > > Best regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Witch! Witch! They'll burn ya! > -- Hag, "Tomorrow is Yesterday", stardate unknown > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From klappnase at web.de Wed Mar 28 05:42:53 2018 From: klappnase at web.de (Michael Lange) Date: Wed, 28 Mar 2018 11:42:53 +0200 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: References: <20180327232454.59f48f763746d2fcdad4a4ab@web.de> Message-ID: <20180328114253.a140bc676172d27f218a99ba@web.de> Hi, On Wed, 28 Mar 2018 01:18:50 +0000 Nam Nguyen wrote: > Is my code out of whack or is it "standard" enough to your seasoned > eyes? Is there any guess as to a fix to this flickering, be it with my > code, or Tk itself? of course you could address the "mouse over widget" issue with something like b1 = tk.Button(f_1, text='Frame 1', font=my_font) b1.pack(expand=True, fill=tk.BOTH) bg = b1.cget('background') b1.configure(activebackground=bg) f_2 = tk.Frame(root) tk.Button(f_2, text='Frame 2'[::-1], font=my_font, activebackground=bg).pack( expand=True, fill=tk.BOTH) For the flicker that remains, I don't think there is much one can do about it. If my assumption that it comes simply from the redrawing operation is correct, I am afraid that there is no remedy (at least none that I am aware of). Here it is barely visible but this might depend on the speed of the system. When Brian says that he does not notice any flicker at all, that might just be because his machine is faster than mine. Of course there is still a chance that I have been missing something. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Our way is peace. -- Septimus, the Son Worshiper, "Bread and Circuses", stardate 4040.7. From namnguyen at google.com Wed Mar 28 16:07:54 2018 From: namnguyen at google.com (Nam Nguyen) Date: Wed, 28 Mar 2018 13:07:54 -0700 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: <20180328114253.a140bc676172d27f218a99ba@web.de> References: <20180327232454.59f48f763746d2fcdad4a4ab@web.de> <20180328114253.a140bc676172d27f218a99ba@web.de> Message-ID: This happens in Tcl/Tk too. I'll follow up with the Tk folks and come back if there's any fix or workaround. #!/usr/bin/env tclsh package require Tk bind . {} {destroy .} wm minsize . 1280 800 frame .f_1 button .f_1.b -text {Frame 1} -command {destroy .} pack .f_1.b -expand true -fill both frame .f_2 button .f_2.b -text {2 emarF} -command {destroy .} pack .f_2.b -expand true -fill both set current 1 set delay 500 proc flip {} { global current global delay pack forget ".f_$current" if {$current == 1} then { set current 2 } else { set current 1 } pack ".f_$current" -expand true -fill both after $delay {flip} } pack ".f_$current" -expand true -fill both after $delay {flip} On Wed, Mar 28, 2018 at 2:42 AM, Michael Lange wrote: > Hi, > > On Wed, 28 Mar 2018 01:18:50 +0000 > Nam Nguyen wrote: > > > Is my code out of whack or is it "standard" enough to your seasoned > > eyes? Is there any guess as to a fix to this flickering, be it with my > > code, or Tk itself? > > of course you could address the "mouse over widget" issue with something > like > > b1 = tk.Button(f_1, text='Frame 1', font=my_font) > b1.pack(expand=True, fill=tk.BOTH) > bg = b1.cget('background') > b1.configure(activebackground=bg) > f_2 = tk.Frame(root) > tk.Button(f_2, text='Frame 2'[::-1], font=my_font, > activebackground=bg).pack( expand=True, fill=tk.BOTH) > > For the flicker that remains, I don't think there is much one can do > about it. If my assumption that it comes simply from the redrawing > operation is correct, I am afraid that there is no remedy (at least none > that I am aware of). Here it is barely visible but this might depend on > the speed of the system. When Brian says that he does not notice any > flicker at all, that might just be because his machine is faster than > mine. Of course there is still a chance that I have been missing > something. > > Best regards > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Our way is peace. > -- Septimus, the Son Worshiper, "Bread and Circuses", > stardate 4040.7. > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: From klappnase at web.de Wed Mar 28 19:06:18 2018 From: klappnase at web.de (Michael Lange) Date: Thu, 29 Mar 2018 01:06:18 +0200 Subject: [Tkinter-discuss] How to eliminate flickers when swapping frames? In-Reply-To: References: <20180327232454.59f48f763746d2fcdad4a4ab@web.de> <20180328114253.a140bc676172d27f218a99ba@web.de> Message-ID: <20180329010618.e65dccd26308b7914bdb120d@web.de> Hi, On Wed, 28 Mar 2018 13:07:54 -0700 Nam Nguyen wrote: > This happens in Tcl/Tk too. I'll follow up with the Tk folks and come > back if there's any fix or workaround. Sure, I never doubted that it has nothing particularly to do with Tkinter. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. This cultural mystique surrounding the biological function -- you realize humans are overly preoccupied with the subject. -- Kelinda the Kelvan, "By Any Other Name", stardate 4658.9 From c.buhtz at posteo.jp Thu Mar 29 19:15:59 2018 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Fri, 30 Mar 2018 01:15:59 +0200 Subject: [Tkinter-discuss] real and platform independent maximizing a window Message-ID: <40C0wz4M4Mz9rxM@submission02.posteo.de> When looking around about the question how to "maximize a window" with Tkinter there are two approaches. 1. Using wm_state('-zoomed', True). Problem: Not working on all platforms. e. g. "-zoomed" is not allowed on Debian unstable with XFCE on Python3.6 Tkinter 8.6 2. Compute the screen resolution or maxsize() and set it manually. This doesn't work also. The size doesn't fit exact and the "maximize" button on the top right corner is still available - should be transformed to a "normal size" button because the current state is "maximized". Isn't there a platform independent way to real(!) maximize a window with Tkinter? If not is there a ticket in the bug tracker about it? From klappnase at web.de Fri Mar 30 15:40:04 2018 From: klappnase at web.de (Michael Lange) Date: Fri, 30 Mar 2018 21:40:04 +0200 Subject: [Tkinter-discuss] real and platform independent maximizing a window In-Reply-To: <40C0wz4M4Mz9rxM@submission02.posteo.de> References: <40C0wz4M4Mz9rxM@submission02.posteo.de> Message-ID: <20180330214004.eeb9b8a2b594dfb754476f5c@web.de> Hi, On Fri, 30 Mar 2018 01:15:59 +0200 wrote: > When looking around about the question how to "maximize a window" with > Tkinter there are two approaches. > > 1. > Using wm_state('-zoomed', True). > Problem: Not working on all platforms. e. g. "-zoomed" is not allowed > on Debian unstable with XFCE on Python3.6 Tkinter 8.6 > > 2. > Compute the screen resolution or maxsize() and set it manually. This > doesn't work also. The size doesn't fit exact and the "maximize" button > on the top right corner is still available - should be transformed to a > "normal size" button because the current state is "maximized". > > Isn't there a platform independent way to real(!) maximize a window > with Tkinter? If not is there a ticket in the bug tracker about it? unless I missed some recent development, there is no such way. I don't think this a bug, but rather a "missing feature" in Tk (if one wants to put it that way). Maybe one major problem here is that usually you don't really want a maximized window to occupy the entire screen, but only the part of the screen that is not covered by system panels. With X11 there are plenty of WMs / DEs to deal with, and it is most likely hard to satisfy them all. But I don't know for sure, that is just a guess. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Military secrets are the most fleeting of all. -- Spock, "The Enterprise Incident", stardate 5027.4