From gerard.roger.laine at free.fr Wed Dec 7 20:36:00 2016 From: gerard.roger.laine at free.fr (gerard.roger.laine at free.fr) Date: Wed, 7 Dec 2016 18:36:00 -0700 (MST) Subject: [Tkinter-discuss] Control position of Tkinter common dialogs? In-Reply-To: <1288039508.11440.1401892311@webmail.messagingengine.com> References: <1288039508.11440.1401892311@webmail.messagingengine.com> Message-ID: <1481160960407-5204895.post@n6.nabble.com> All common dialogs appear to ignore the optional parent = parameter It seems it is because your code invoke the winfo_root() before the grid manager finish is calculations. and this command return a Null decimal string. According to Tk manual "https://www.tcl.tk/man/tcl8.4/TkCmd/winfo.htm#M52" If you need the true width immediately after creating a widget, invoke update to force the geometry manager to arrange it, or use winfo reqwidth to get the window's requested width instead of its actual width. This code works perfectly self.update() self.geometry("+%d+%d" % (self.parent.winfo_rootx()+50, self.parent.winfo_rooty()+50 ) ) -- View this message in context: http://python.6.x6.nabble.com/Control-position-of-Tkinter-common-dialogs-tp1978712p5204895.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From adickman at us.ibm.com Thu Dec 8 13:00:50 2016 From: adickman at us.ibm.com (Alan L Dickman) Date: Thu, 8 Dec 2016 11:00:50 -0700 Subject: [Tkinter-discuss] Learning Python/Tkinter and struggling with the text object Message-ID: Thanks in advance for any help! I'm just learning Python and Tkinter. Can anyone suggest why this program does not insert 'some text' into text box t1 when the start button is clicked? No errors are thrown when I run the program in PyCharm from tkinter import * class Window(Frame): t1 = [] def __init__(self, master=None) Frame.__init__(self, master) self.master = master self.master.title("My Title") StartButton = Button(self, text="Start", command=self.start, bg= '#006ba6', fg="white") StartButton.grid(row=0, columnspan=3, sticky=(N, S, W, E)) Label(self, text="Your Name").grid(row=1, sticky=(N, S, W, E)) t1 = Text(self, height=2) t1.grid(row=1, column=1, sticky=(N, S, W, E)) self.t1.insert( 0, 'some text') quitButton = Button(self, text="Quit", command=self.client_quit, bg='#006ba6', fg="white") quitButton.grid(row=5, columnspan=3, sticky=(N, S, W, E)) self.grid(sticky=(N, S, W, E)) def start(self): self.t1.insert(0, 'some text') def client_quit(self): exit() root = Tk() root.geometry() app = Window(root) root.mainloop() Alan Dickman IBM Cloud Technical Sales Specialist, Process Transformation North America Public Sector Email: adickman at us.ibm.com Mobile: +1 303 324 9353 Find me on: LinkedIn -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 19179 bytes Desc: not available URL: From robertvstepp at gmail.com Fri Dec 9 10:58:48 2016 From: robertvstepp at gmail.com (boB Stepp) Date: Fri, 9 Dec 2016 09:58:48 -0600 Subject: [Tkinter-discuss] Learning Python/Tkinter and struggling with the text object In-Reply-To: References: Message-ID: On Thu, Dec 8, 2016 at 12:00 PM, Alan L Dickman wrote: > > Thanks in advance for any help! I'm just learning Python and Tkinter. Can anyone suggest why this program does not insert 'some text' into text box t1 when the start button is clicked? No errors are thrown when I run the program in PyCharm I think your issue is that your list "t1" is not doing anything for you. Inside your __init__ method, "t1" and "self.t1" are not referring to the same thing. Your Text widget is bound to "t1", not the list. I am a relative newbie in tkinter, but apparently "0" is not an allowed index. "insert" inserts before the given index, which in your case needs to be "END". > > from tkinter import * > > class Window(Frame): > t1 = [] I don't see what this is doing. It will not be the same as t1 in your method below. > def __init__(self, master=None) > Frame.__init__(self, master) > self.master = master > self.master.title("My Title") > StartButton = Button(self, text="Start", command=self.start, bg='#006ba6', fg="white") > StartButton.grid(row=0, columnspan=3, sticky=(N, S, W, E)) > Label(self, text="Your Name").grid(row=1, sticky=(N, S, W, E)) > t1 = Text(self, height=2) > t1.grid(row=1, column=1, sticky=(N, S, W, E)) > self.t1.insert( 0, 'some text') This needs to drop the "self" and use an appropriate index. It should be: "t1.insert(END, 'some text')". > quitButton = Button(self, text="Quit", command=self.client_quit, bg='#006ba6', fg="white") > quitButton.grid(row=5, columnspan=3, sticky=(N, S, W, E)) > self.grid(sticky=(N, S, W, E)) > > def start(self): > self.t1.insert(0, 'some text') > > def client_quit(self): > exit() > > root = Tk() > root.geometry() > app = Window(root) > root.mainloop() > HTH! boB From klappnase at web.de Fri Dec 9 11:02:05 2016 From: klappnase at web.de (Michael Lange) Date: Fri, 9 Dec 2016 17:02:05 +0100 Subject: [Tkinter-discuss] Control position of Tkinter common dialogs? In-Reply-To: <1481160960407-5204895.post@n6.nabble.com> References: <1288039508.11440.1401892311@webmail.messagingengine.com> <1481160960407-5204895.post@n6.nabble.com> Message-ID: <20161209170205.fa2fe8af045de3cf2e8319d2@web.de> Hi, On Wed, 7 Dec 2016 18:36:00 -0700 (MST) "gerard.roger.laine at free.fr" wrote: > All common dialogs appear to ignore the optional parent = parameter > > It seems it is because your code invoke the winfo_root() before the grid > manager finish is calculations. > and this command return a Null decimal string. (...) I am a bit confused about this, which dialogs do you mean exactly? Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Sometimes a man will tell his bartender things he'll never tell his doctor. -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), stardate unknown. From klappnase at web.de Fri Dec 9 10:55:31 2016 From: klappnase at web.de (Michael Lange) Date: Fri, 9 Dec 2016 16:55:31 +0100 Subject: [Tkinter-discuss] Learning Python/Tkinter and struggling with the text object In-Reply-To: References: Message-ID: <20161209165531.c79dffc8cf8804e0b78a5535@web.de> Hi, On Thu, 8 Dec 2016 11:00:50 -0700 "Alan L Dickman" wrote: > Thanks in advance for any help! I'm just learning Python and Tkinter. > Can anyone suggest why this program does not insert 'some text' into > text box t1 when the start button is clicked? No errors are thrown when > I run the program in PyCharm > > from tkinter import * > > class Window(Frame): > t1 = [] > def __init__(self, master=None) > Frame.__init__(self, master) > self.master = master > self.master.title("My Title") > StartButton = Button(self, text="Start", command=self.start, bg= > '#006ba6', fg="white") > StartButton.grid(row=0, columnspan=3, sticky=(N, S, W, E)) > Label(self, text="Your Name").grid(row=1, sticky=(N, S, W, E)) > t1 = Text(self, height=2) > t1.grid(row=1, column=1, sticky=(N, S, W, E)) > self.t1.insert( 0, 'some text') > quitButton = Button(self, text="Quit", > command=self.client_quit, bg='#006ba6', fg="white") > quitButton.grid(row=5, columnspan=3, sticky=(N, S, W, E)) > self.grid(sticky=(N, S, W, E)) > > def start(self): > self.t1.insert(0, 'some text') (...) there are various problems here: You do self.t1.insert( 0, 'some text') , your text widget however is "t1", self.t1 is an empty list, so your list after the button press will look like ['some text', 'some text'] . Next, if you try to insert a string into a text widget, you need to specify the index with a construct like "line.character", so if you want to insert something at the start of the first line, use 1.0 instead of 0, otherwise a TclError will be thrown, as in: >>> text.insert(0, 'foo') Traceback (most recent call last): File "", line 1, in File "Tkinter.py", line 3236, in insert self.tk.call((self._w, 'insert', index, chars) + args) _tkinter.TclError: bad text index "0" Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Immortality consists largely of boredom. -- Zefrem Cochrane, "Metamorphosis", stardate 3219.8 From klappnase at web.de Fri Dec 9 13:25:12 2016 From: klappnase at web.de (Michael Lange) Date: Fri, 9 Dec 2016 19:25:12 +0100 Subject: [Tkinter-discuss] Learning Python/Tkinter and struggling with the text object In-Reply-To: References: <20161209165531.c79dffc8cf8804e0b78a5535@web.de> Message-ID: <20161209192512.5af66ec4af5d64e356fb0d89@web.de> Hi, On Fri, 9 Dec 2016 10:50:45 -0700 "Alan L Dickman" wrote: > Michael - This is just one example. I've tried so many version of this > program. Some run but don't update the t1 text window. Others throw an > error trying to access t1. For example, the version below throws an > error at t1.grid(). It seems like there must be a simple answer but I > have found no good examples on the internet. > > What would you change so that text is inserted into t1 when the start > button is clicked? > > from tkinter import * > > class Window(Frame): > t1 = Text() the way you initialize the Text widget here effectiveley makes it into self.t1 , so you will get an error when you try to grid() the widget, because there is no t1. You will get the same error when the start() function is called. To make sure the code works as expected, you need to take care that the widget is properly referenced, so it can be accessed later. The way to go is something like: def __init__(self, master=None): Frame.__init__(self, master) self.t1 = Text() self.t1.grid() (...) def start(self): print('I am here') self.t1.insert(END, 'some text') Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "Can you imagine how life could be improved if we could do away with jealousy, greed, hate ..." "It can also be improved by eliminating love, tenderness, sentiment -- the other side of the coin" -- Dr. Roger Corby and Kirk, "What are Little Girls Made Of?", stardate 2712.4 From james.simon.pascoe at gmail.com Wed Dec 21 09:54:19 2016 From: james.simon.pascoe at gmail.com (James Pascoe) Date: Wed, 21 Dec 2016 14:54:19 +0000 Subject: [Tkinter-discuss] Unit Testing Tkinter App Message-ID: Hi Everybody, I like Tkinter a lot and am using it to create Gui driven Python tools for my company. I was wondering if somebody could give me a current answer on what the best way of writing unit tests is for Tkinter programs? I am looking for a programmatic approach that I can automate at git commit time. I looked at dogtail and PyUseCase? Are these tools current? What does everybody else do? Apologies for asking a question that I am sure has been asked several times before, but I can't seem to find a good recent answer. Thank you very much for the help, James -------------- next part -------------- An HTML attachment was scrubbed... URL: From adickman at us.ibm.com Wed Dec 21 10:12:52 2016 From: adickman at us.ibm.com (Alan L Dickman) Date: Wed, 21 Dec 2016 15:12:52 +0000 Subject: [Tkinter-discuss] Putting a Smartphone veneer over a tkinter user interface Message-ID: An HTML attachment was scrubbed... URL: From inq1Ltd at inqvista.com Thu Dec 22 14:44:16 2016 From: inq1Ltd at inqvista.com (inq1Ltd) Date: Thu, 22 Dec 2016 14:44:16 -0500 Subject: [Tkinter-discuss] Putting a Smartphone veneer over a tkinter user interface In-Reply-To: References: Message-ID: <1971128.i7F1otxGoc@inqvista-001> On Wednesday, December 21, 2016 03:12:52 PM Alan L Dickman wrote: > Has anyone out there wrapped a smartphone image around a tkinter user > interface? If you did, how did you do it. If not, please share your ideas > for how one might do this. THANKS IN ADVANCE! > Alan Dickman > IBM Cloud Technical Sales Specialist, Process Transformation > North America Public Sector > Phone: 1-303-324-9353, 1-303-886-2744 > email: adickman at us.ibm.com > LinkedIn: alandickman Alan, What are the extensions of the images you are asking about? Some smart phone images I receive are jpg. If you go to my website, inqvista.com, and scroll thru the Image Management Link you can see a few images that are png's but others are available for tkinter, jim for inqVista