From amit.finkler at gmail.com Tue Apr 1 15:05:43 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Tue, 01 Apr 2008 16:05:43 +0300 Subject: [Tkinter-discuss] thread module Message-ID: <47F23327.7040202@gmail.com> Hi, Following a previous post of mine (http://mail.python.org/pipermail/tkinter-discuss/2008-March/001320.html), I finally managed to start a new thread using the thread module. This new thread is started by clicking on a button on my Tkinter GUI and it just continuously plots a graph using matplotlib. Now, however, a new problem arises - how does one close the thread??? The function this thread starts has a Ctrl-C Exception which works fine if the thread module is not used. Now, however, pressing Ctrl-C does nothing. The thread has a life of its own!!! Your help will be greatly appreciated. Amit. From timj at tolisgroup.com Tue Apr 1 17:26:32 2008 From: timj at tolisgroup.com (Tim Jones) Date: Tue, 1 Apr 2008 08:26:32 -0700 Subject: [Tkinter-discuss] thread module In-Reply-To: <47F23327.7040202@gmail.com> References: <47F23327.7040202@gmail.com> Message-ID: <0BEE9516-E036-4209-BC3C-F9BB8002E34E@tolisgroup.com> On Apr 1, 2008, at 6:05 AM, Amit Finkler wrote: > Hi, > > Following a previous post of mine (http://mail.python.org/pipermail/ > tkinter-discuss/2008-March/001320.html), I finally managed to start > a new thread using the thread module. This new thread is started by > clicking on a button on my Tkinter GUI and it just continuously > plots a graph using matplotlib. > > Now, however, a new problem arises - how does one close the > thread??? The function this thread starts has a Ctrl-C Exception > which works fine if the thread module is not used. Now, however, > pressing Ctrl-C does nothing. The thread has a life of its own!!! > > Your help will be greatly appreciated. The simplest solution is to set a global flag "QuitThread" and set it to False while running. Then, allow the user to click a button and then set the value to True. In the thread, check the value of the variable and exit if it's True. HTH, Tim From longorh at npt.nuwc.navy.mil Tue Apr 1 18:53:32 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Tue, 1 Apr 2008 09:53:32 -0700 (PDT) Subject: [Tkinter-discuss] lower() in class Misc Message-ID: <16418727.post@talk.nabble.com> Don't know if this is the place to report this. Not really a bug, however, method lower() is defined twice in class Misc in the module Tkinter.py. Both definitions are identical. -- View this message in context: http://www.nabble.com/lower%28%29-in-class-Misc-tp16418727p16418727.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From longorh at npt.nuwc.navy.mil Tue Apr 1 19:22:24 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Tue, 1 Apr 2008 10:22:24 -0700 (PDT) Subject: [Tkinter-discuss] New Full Tkinter document editor widget --suggestions, comments, etc. In-Reply-To: References: <003301c88e1a$eea60250$6501a8c0@aristotle> <47e491110803251533g5b6d4a8eide043e034437df38@mail.gmail.com> Message-ID: <16419433.post@talk.nabble.com> I've actually been considering WCK as a platform for future development (What I've done so far I consider to be experimental). I've read your article (Fredrik Lundh's, Using Event Trackers to Simplify Tool Implementation) and really think this is a solution for implementing the addition of new kinds of objects. I've recently written a very small plugin framework which automatically loads all plugins in a path. As the plugin classes are instantiated, they are provided with access to the Model, view widget and a notebook widget (for inserting a custom GUI if applicable). With StyledText, I'm leaning towards a design in which a plugin may also include a pluggable controller. In this way, plugins will be used to add lists, tables, images and other sorts of objects to StyledText. I will periodically update the StyledWidget in the Tkinter wiki as I more towards a final implementation. Thanks for your comments. Fredrik Lundh wrote: > > Michael O'Donnell wrote: > >> But I find that as you get more ambitious, better to use a Canvas widget >> instead of a Text widget, which is pretty inflexible. Using a Canvas, you >> need to do a lot more work (splitting text into lines, positioning lines >> on the >> canvas, etc.), but you can do almost anything you can think of with a >> Canvas. > > on the other hand, the overhead might kill you if you switch to a > Canvas. the Text widget is highly optimized for text rendering, after > all. > > (I'd use a WCK widget if I were you guys, but that's me ;-) > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/New-Full-Tkinter-document-editor-widget----suggestions%2C-comments%2C-etc.-tp16266693p16419433.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From amit.finkler at gmail.com Wed Apr 2 09:41:05 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Wed, 02 Apr 2008 10:41:05 +0300 Subject: [Tkinter-discuss] thread module In-Reply-To: <0BEE9516-E036-4209-BC3C-F9BB8002E34E@tolisgroup.com> References: <47F23327.7040202@gmail.com> <0BEE9516-E036-4209-BC3C-F9BB8002E34E@tolisgroup.com> Message-ID: <47F33891.2040609@gmail.com> Tim Jones wrote: > On Apr 1, 2008, at 6:05 AM, Amit Finkler wrote: > >> Hi, >> >> Following a previous post of mine (http://mail.python.org/pipermail/ >> tkinter-discuss/2008-March/001320.html), I finally managed to start >> a new thread using the thread module. This new thread is started by >> clicking on a button on my Tkinter GUI and it just continuously >> plots a graph using matplotlib. >> >> Now, however, a new problem arises - how does one close the >> thread??? The function this thread starts has a Ctrl-C Exception >> which works fine if the thread module is not used. Now, however, >> pressing Ctrl-C does nothing. The thread has a life of its own!!! >> >> Your help will be greatly appreciated. >> > > The simplest solution is to set a global flag "QuitThread" and set it > to False while running. Then, allow the user to click a button and > then set the value to True. In the thread, check the value of the > variable and exit if it's True. > > HTH, > Tim > Thanks for the tip. It seems like a reasonable solution. One question remains: after I set the flag to be true, how do I exit the thread? I tried to check whether the flag is true and then execute thread.exit(). Nothing happened, though. The graph continued on plotting and obviously the thread kept on running. Thanks, Amit. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080402/d3c3f470/attachment.htm From amit.finkler at gmail.com Wed Apr 2 09:58:22 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Wed, 02 Apr 2008 10:58:22 +0300 Subject: [Tkinter-discuss] thread module In-Reply-To: <0BEE9516-E036-4209-BC3C-F9BB8002E34E@tolisgroup.com> References: <47F23327.7040202@gmail.com> <0BEE9516-E036-4209-BC3C-F9BB8002E34E@tolisgroup.com> Message-ID: <47F33C9E.8080504@gmail.com> Tim Jones wrote: > On Apr 1, 2008, at 6:05 AM, Amit Finkler wrote: > >> Hi, >> >> Following a previous post of mine (http://mail.python.org/pipermail/ >> tkinter-discuss/2008-March/001320.html), I finally managed to start >> a new thread using the thread module. This new thread is started by >> clicking on a button on my Tkinter GUI and it just continuously >> plots a graph using matplotlib. >> >> Now, however, a new problem arises - how does one close the >> thread??? The function this thread starts has a Ctrl-C Exception >> which works fine if the thread module is not used. Now, however, >> pressing Ctrl-C does nothing. The thread has a life of its own!!! >> >> Your help will be greatly appreciated. >> > > The simplest solution is to set a global flag "QuitThread" and set it > to False while running. Then, allow the user to click a button and > then set the value to True. In the thread, check the value of the > variable and exit if it's True. > > HTH, > Tim > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > I may have messed up a bit the entire point of global variables, but here goes: 1. I created a global variable named "QuitThread" on my main module. 2. I initially set it to "False". 3. When clicking on the "Run" button of my GUI (defined in the main module), a new thread starts using start_new_thread, where QuitThread is one of the variables in its tuple. 4. This new thread runs a function from a second module. In this module I also added "import thread". 5. This function runs a loop in which it checks every iteration whether QuitThread is True or False. 6. If it is True, it executes "thread.exit()". 7. Nothing happens. The thread continues on running. Hope there is enough information for you to be able to help me :-) Cheers, Amit. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080402/0514ad21/attachment.htm From mkieverpy at tlink.de Wed Apr 2 13:59:39 2008 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Wed, 02 Apr 2008 11:59:39 -0000 Subject: [Tkinter-discuss] lower() in class Misc Message-ID: <20080402104749.046CCD485@mail.terralink.de> Hi Ron, >Don't know if this is the place to report this. Not really a bug, however, >method lower() is defined twice in class Misc in the module Tkinter.py. >Both definitions are identical. right place would have been here: http://bugs.python.org/ I created a corresponding entry with a patch which removes the first Misc.lower: http://bugs.python.org/issue2535# Cheers, ------------------------------------------------------------------------------ Matthias Kievernagel Software development mkiever/at/web/dot/de http://mkiever.home.tlink.de ------------------------------------------------------------------------------ From costas_air at yahoo.co.uk Thu Apr 3 20:53:27 2008 From: costas_air at yahoo.co.uk (Costas N) Date: Thu, 3 Apr 2008 18:53:27 +0000 (GMT) Subject: [Tkinter-discuss] OptionMenu and Keyboard Message-ID: <381668.39508.qm@web28205.mail.ukl.yahoo.com> Hi all, I have the same problem as Mr Vasilis has. Does any of you know the answer. Regards Costas __________________________________________________________ Sent from Yahoo! Mail. A Smarter Inbox http://uk.docs.yahoo.com/nowyoucan.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080403/a1eb71d5/attachment.htm From costas_air at yahoo.co.uk Thu Apr 3 20:53:27 2008 From: costas_air at yahoo.co.uk (Costas N) Date: Thu, 3 Apr 2008 18:53:27 +0000 (GMT) Subject: [Tkinter-discuss] OptionMenu and Keyboard Message-ID: <381668.39508.qm@web28205.mail.ukl.yahoo.com> Hi all, I have the same problem as Mr Vasilis has. Does any of you know the answer. Regards Costas __________________________________________________________ Sent from Yahoo! Mail. A Smarter Inbox http://uk.docs.yahoo.com/nowyoucan.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080403/a1eb71d5/attachment-0001.htm From david.giesen at kodak.com Sat Apr 5 12:27:59 2008 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Sat, 5 Apr 2008 06:27:59 -0400 Subject: [Tkinter-discuss] David J. Giesen/505633/EKC is out of the office. Message-ID: I will be out of the office starting 04/04/2008 and will not return until 04/14/2008. I will respond to your message as soon as possible when I return. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080405/61af69a9/attachment.htm From Vasilis.Vlachoudis at cern.ch Sat Apr 5 14:13:14 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Sat, 5 Apr 2008 14:13:14 +0200 Subject: [Tkinter-discuss] OptionMenu and Keyboard In-Reply-To: <381668.39508.qm@web28205.mail.ukl.yahoo.com> References: <381668.39508.qm@web28205.mail.ukl.yahoo.com> Message-ID: <2AACD4EB2F123248A064A23843B3A173CFA931@cernxchg47.cern.ch> Hi Costas, I never found a solution to the problem, but also when the list was getting too long, bigger than the screen height it was impossible to select an item. For this reason I?ve created a ComboBox, you can find it along with other useful classes that I?ve made and/or collected from the web on the http://www.fluka.org/flair program I?ve made. Maybe also you can find much better implementations of ComboBoxes in tix or pmw. Cheers Vasilis From: tkinter-discuss-bounces at python.org [mailto:tkinter-discuss-bounces at python.org] On Behalf Of Costas N Sent: Thursday, 03 April 2008 20:53 To: tkinter-discuss at python.org; tkinter-discuss at python.org Subject: [Tkinter-discuss] OptionMenu and Keyboard Hi all, I have the same problem as Mr Vasilis has. Does any of you know the answer. Regards Costas ________________________________ Yahoo! for Good helps you make a difference -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080405/caa769ad/attachment.htm From mkieverpy at tlink.de Sat Apr 5 17:24:00 2008 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Sat, 05 Apr 2008 15:24:00 -0000 Subject: [Tkinter-discuss] thread module Message-ID: <20080405150520.DFB37BBF9@mail.terralink.de> Hi Amit, >1. I created a global variable named "QuitThread" on my main module. >2. I initially set it to "False". >3. When clicking on the "Run" button of my GUI (defined in the main >module), a new thread starts using start_new_thread, where QuitThread is >one of the variables in its tuple. This sounds wrong. You don't need QuitThread as a parameter to start_new_thread. >4. This new thread runs a function from a second module. In this >module I also added "import thread". >5. This function runs a loop in which it checks every iteration >whether QuitThread is True or False. >6. If it is True, it executes "thread.exit()". >7. Nothing happens. The thread continues on running. has your problem been solved in the mean time? If not two things to check/try: - thread.exit works by throwing an exception. Make sure you don't catch it by accident. - Print/log value of QuitThread on every access in both threads. Cheers, ------------------------------------------------------------------------------ Matthias Kievernagel Software development mkiever/at/web/dot/de http://mkiever.home.tlink.de ------------------------------------------------------------------------------ From skanemupp at yahoo.se Sat Apr 5 02:28:43 2008 From: skanemupp at yahoo.se (globalrev) Date: Fri, 4 Apr 2008 17:28:43 -0700 (PDT) Subject: [Tkinter-discuss] How to make all the buttons the same size? Message-ID: <16507347.post@talk.nabble.com> Buttons shrink to fit the symbol/text u put on it. well i dont want that it looks ugly. how do i set the same size for all the buttons? i thought it was row/columnspan at first but it doesnt seem to work. [code] #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self, text="1", state=DISABLED) self.btnDisplay.grid(row=0, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="2", state=DISABLED) self.btnDisplay.grid(row=0, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="3", state=DISABLED) self.btnDisplay.grid(row=0, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="+", state=DISABLED) self.btnDisplay.grid(row=0, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="4", state=DISABLED) self.btnDisplay.grid(row=1, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", state=DISABLED) self.btnDisplay.grid(row=1, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="6", state=DISABLED) self.btnDisplay.grid(row=1, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="-", state=DISABLED) self.btnDisplay.grid(row=1, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="7", state=DISABLED) self.btnDisplay.grid(row=2, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", state=DISABLED) self.btnDisplay.grid(row=2, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="9", state=DISABLED) self.btnDisplay.grid(row=2, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="*", state=DISABLED) self.btnDisplay.grid(row=2, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="0", state=DISABLED) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="C", state=DISABLED) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="r", state=DISABLED) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="/", state=DISABLED) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) #def Display(self): if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() [/code] -- View this message in context: http://www.nabble.com/How-to-make-all-the-buttons-the-same-size--tp16507347p16507347.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From skanemupp at yahoo.se Sat Apr 5 02:44:17 2008 From: skanemupp at yahoo.se (globalrev) Date: Fri, 4 Apr 2008 17:44:17 -0700 (PDT) Subject: [Tkinter-discuss] Buttonwidget, problem with callback-function!? Message-ID: <16508071.post@talk.nabble.com> in the following program i want "1" to appear in the upper "entry" when i click the button "1". so i will replace state=DISBALED with command=self.Display(xbtn) or command=Display(xbtn). Display being a function that takes the pressed buttons "value" and so outputs in the first entry the corresponding integer or arithmetic. ive tried this but i dont get ti to work. is Display some sort of predefined function that im f***ing around with? 2nd code is the implementation of the Display-funcand corresponding errormessages. what is the problem here? #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self, text="1", state=DISABLED) self.btnDisplay.grid(row=0, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="2", state=DISABLED) self.btnDisplay.grid(row=0, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="3", state=DISABLED) self.btnDisplay.grid(row=0, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="+", state=DISABLED) self.btnDisplay.grid(row=0, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="4", state=DISABLED) self.btnDisplay.grid(row=1, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", state=DISABLED) self.btnDisplay.grid(row=1, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="6", state=DISABLED) self.btnDisplay.grid(row=1, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="-", state=DISABLED) self.btnDisplay.grid(row=1, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="7", state=DISABLED) self.btnDisplay.grid(row=2, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", state=DISABLED) self.btnDisplay.grid(row=2, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="9", state=DISABLED) self.btnDisplay.grid(row=2, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="*", state=DISABLED) self.btnDisplay.grid(row=2, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="0", state=DISABLED) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="C", state=DISABLED) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="r", state=DISABLED) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="/", state=DISABLED) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) #def Display(self): if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): #self.pack_propagate(0) self.enText = Entry(self) self.enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) self.enText = Entry(self) self.enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) self.btnDisplay = Button(self, text="1", command=Display('1')) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="2", state=DISABLED) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="3", state=DISABLED) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="+", state=DISABLED) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="4", state=DISABLED) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", state=DISABLED) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="6", state=DISABLED) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="-", state=DISABLED) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="7", state=DISABLED) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", state=DISABLED) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="9", state=DISABLED) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="*", state=DISABLED) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="0", state=DISABLED) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="C", state=DISABLED) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="r", state=DISABLED) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="/", state=DISABLED) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) #self.btnDisplay.pack(fill=BOTH, expand=1) def Display(xbtn): if xbtn==1: print 1 if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() command=self.Display(xbtn) Traceback (most recent call last): File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 87, in guiFrame = GUIFramework() File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 20, in __init__ self.CreateWidgets() File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 33, in CreateWidgets self.btnDisplay = Button(self, text="1", command=self.Display('1')) TypeError: Display() takes exactly 1 argument (2 given) command=Display(xbtn) Traceback (most recent call last): File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 87, in guiFrame = GUIFramework() File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 20, in __init__ self.CreateWidgets() File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 33, in CreateWidgets self.btnDisplay = Button(self, text="1", command=Display('1')) NameError: global name 'Display' is not defined -- View this message in context: http://www.nabble.com/Buttonwidget%2C-problem-with-callback-function%21--tp16508071p16508071.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From amit.finkler at gmail.com Sun Apr 6 15:45:12 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Sun, 06 Apr 2008 16:45:12 +0300 Subject: [Tkinter-discuss] thread module In-Reply-To: <20080405150520.DFB37BBF9@mail.terralink.de> References: <20080405150520.DFB37BBF9@mail.terralink.de> Message-ID: <47F8D3E8.6060900@gmail.com> Hi all, mkieverpy at tlink.de wrote: > Hi Amit, > > >> 1. I created a global variable named "QuitThread" on my main module. >> 2. I initially set it to "False". >> 3. When clicking on the "Run" button of my GUI (defined in the main >> module), a new thread starts using start_new_thread, where QuitThread is >> one of the variables in its tuple. >> > > This sounds wrong. You don't need QuitThread as a parameter to > start_new_thread. > > Fixed that. No errors yet. >> 4. This new thread runs a function from a second module. In this >> module I also added "import thread". >> 5. This function runs a loop in which it checks every iteration >> whether QuitThread is True or False. >> 6. If it is True, it executes "thread.exit()". >> 7. Nothing happens. The thread continues on running. >> > > has your problem been solved in the mean time? > If not two things to check/try: > - thread.exit works by throwing an exception. Make sure you don't > catch it by accident. > In my function (in the second module), the loops runs in a "try:" and I added the following exception: except QuitThread == 1: thread.exit() Now, it crashes with the following error message NameError: global name 'QuitThread' is not defined and it points to the above exception as the source of the error. This is strange, since QuitThread is definitely defined as a global variable in the main module. > - Print/log value of QuitThread on every access in both threads. > By the way, it *doesn't* crash when I comment out the "print QuitThread" line inside the loop. Thanks for you help, Amit. > > Cheers, > ------------------------------------------------------------------------------ > Matthias Kievernagel Software development > mkiever/at/web/dot/de http://mkiever.home.tlink.de > ------------------------------------------------------------------------------ > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080406/cdc0291b/attachment.htm From mfranklin1 at gatwick.westerngeco.slb.com Mon Apr 7 09:22:39 2008 From: mfranklin1 at gatwick.westerngeco.slb.com (Martin Franklin) Date: Mon, 07 Apr 2008 08:22:39 +0100 Subject: [Tkinter-discuss] Buttonwidget, problem with callback-function!? In-Reply-To: <16508071.post@talk.nabble.com> References: <16508071.post@talk.nabble.com> Message-ID: <47F9CBBF.4070406@gatwick.westerngeco.slb.com> globalrev wrote: > in the following program i want "1" to appear in the upper "entry" when i > click the button "1". > > so i will replace state=DISBALED with command=self.Display(xbtn) or > command=Display(xbtn). Display being a function that takes the pressed > buttons "value" and so outputs in the first entry the corresponding integer > or arithmetic. > ive tried this but i dont get ti to work. > > is Display some sort of predefined function that im f***ing around with? > > 2nd code is the implementation of the Display-funcand corresponding > errormessages. > > > what is the problem here? > > > > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self,master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > def CreateWidgets(self): > > self.btnDisplay = Button(self, text="1", state=DISABLED) > self.btnDisplay.grid(row=0, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="2", state=DISABLED) > self.btnDisplay.grid(row=0, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="3", state=DISABLED) > self.btnDisplay.grid(row=0, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="+", state=DISABLED) > self.btnDisplay.grid(row=0, column=3, padx=5, pady=5) > > self.btnDisplay = Button(self, text="4", state=DISABLED) > self.btnDisplay.grid(row=1, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="5", state=DISABLED) > self.btnDisplay.grid(row=1, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="6", state=DISABLED) > self.btnDisplay.grid(row=1, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="-", state=DISABLED) > self.btnDisplay.grid(row=1, column=3, padx=5, pady=5) > > self.btnDisplay = Button(self, text="7", state=DISABLED) > self.btnDisplay.grid(row=2, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", state=DISABLED) > self.btnDisplay.grid(row=2, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="9", state=DISABLED) > self.btnDisplay.grid(row=2, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="*", state=DISABLED) > self.btnDisplay.grid(row=2, column=3, padx=5, pady=5) > > self.btnDisplay = Button(self, text="0", state=DISABLED) > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="C", state=DISABLED) > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="r", state=DISABLED) > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="/", state=DISABLED) > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > #def Display(self): > > > if __name__ == "__main__": > guiFrame = GUIFramework() > guiFrame.mainloop() > > > > > > > > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self,master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > def CreateWidgets(self): > > #self.pack_propagate(0) > > self.enText = Entry(self) > self.enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) > > self.enText = Entry(self) > self.enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="1", command=Display('1')) > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="2", state=DISABLED) > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="3", state=DISABLED) > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="+", state=DISABLED) > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > self.btnDisplay = Button(self, text="4", state=DISABLED) > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="5", state=DISABLED) > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="6", state=DISABLED) > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="-", state=DISABLED) > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > self.btnDisplay = Button(self, text="7", state=DISABLED) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", state=DISABLED) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="9", state=DISABLED) > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="*", state=DISABLED) > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > self.btnDisplay = Button(self, text="0", state=DISABLED) > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="C", state=DISABLED) > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > self.btnDisplay = Button(self, text="r", state=DISABLED) > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > self.btnDisplay = Button(self, text="/", state=DISABLED) > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > #self.btnDisplay.pack(fill=BOTH, expand=1) > > def Display(xbtn): > if xbtn==1: > print 1 > > if __name__ == "__main__": > guiFrame = GUIFramework() > guiFrame.mainloop() > > > > > > command=self.Display(xbtn) > > Traceback (most recent call last): > File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 87, in > > guiFrame = GUIFramework() > File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 20, in > __init__ > self.CreateWidgets() > File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 33, in > CreateWidgets > self.btnDisplay = Button(self, text="1", command=self.Display('1')) > TypeError: Display() takes exactly 1 argument (2 given) > > > command=Display(xbtn) > > Traceback (most recent call last): > File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 87, in > > guiFrame = GUIFramework() > File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 20, in > __init__ > self.CreateWidgets() > File "C:/Users/saftarn/Desktop/guiexperiments/defdonka.py", line 33, in > CreateWidgets > self.btnDisplay = Button(self, text="1", command=Display('1')) > NameError: global name 'Display' is not defined Display is a method so should have self as first argument def Display(self, xbtn): ... also when you assign it to the button command it needs to be self.Display you have another problem here though, you are calling the method as you create the button... rather than calling the method when the button is pressed quick example: def number1call(): print "Number 1 pressed" number1 = Button(parent, text = "1", width = 3, command=number1call) number1.pack() Note I do not call number1call when I assign it to the buttons command calling this function is done when the button is pressed. Cheers Martin -- signature file not found, must be something I ate From mfranklin1 at gatwick.westerngeco.slb.com Mon Apr 7 09:15:44 2008 From: mfranklin1 at gatwick.westerngeco.slb.com (Martin Franklin) Date: Mon, 07 Apr 2008 08:15:44 +0100 Subject: [Tkinter-discuss] How to make all the buttons the same size? In-Reply-To: <16507347.post@talk.nabble.com> References: <16507347.post@talk.nabble.com> Message-ID: <47F9CA20.8000809@gatwick.westerngeco.slb.com> globalrev wrote: > Buttons shrink to fit the symbol/text u put on it. well i dont want that it > looks ugly. how do i set the same size for all the buttons? > i thought it was row/columnspan at first but it doesnt seem to work. I normally use button width like so: b = Button(frame, text = "1", width = 3) -- signature file not found, must be something I ate From darr_low at yahoo.com Tue Apr 8 07:08:04 2008 From: darr_low at yahoo.com (Snakey) Date: Mon, 7 Apr 2008 22:08:04 -0700 (PDT) Subject: [Tkinter-discuss] How to automatically run some code upon GUI startup? Message-ID: <16547636.post@talk.nabble.com> I have created a simple Tkinter GUI. I have a function that needs to be executed automatically upon launching the GUI application. How can it be done? -- View this message in context: http://www.nabble.com/How-to-automatically-run-some-code-upon-GUI-startup--tp16547636p16547636.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From fredrik at pythonware.com Tue Apr 8 19:01:25 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 08 Apr 2008 19:01:25 +0200 Subject: [Tkinter-discuss] How to automatically run some code upon GUI startup? In-Reply-To: <16547636.post@talk.nabble.com> References: <16547636.post@talk.nabble.com> Message-ID: Snakey wrote: > I have created a simple Tkinter GUI. I have a function that needs to be > executed automatically upon launching the GUI application. How can it be > done? how about calling it from the script that creates the GUI, before you enter the mainloop? my_function() root.mainloop() if you want to call it when the GUI is up and running, you can use the "wait_visibility" method on the root widget: root.wait_visibility() # run event loop until window appears my_function() root.mainloop() another approach is to use the "after_idle" method: root.after_idle(my_function) root.mainloop() From Vasilis.Vlachoudis at cern.ch Tue Apr 8 22:49:46 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Tue, 8 Apr 2008 22:49:46 +0200 Subject: [Tkinter-discuss] Mulitple root windows Message-ID: <2AACD4EB2F123248A064A23843B3A173CFAA44@cernxchg47.cern.ch> In my application I wanted to have a help window which is responsive at all times even if a dialog issues a grab_set. I solved the problem by starting the Help window as a second root window with Tk().Now my program is like the following, and in fact if I get the grab from a dialog in rootmain the roothelp remains unaffected. What happens with Tkinter and Tk in this case? Which mainloop should I call (now I calling the main one and everything works in linux)? rootmain = Tk() roothelp = Tk() ... # create frames etc... ... rootmain.mainloop() Cheers Vasilis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080408/a682439d/attachment.htm From timj at tolisgroup.com Tue Apr 8 23:48:40 2008 From: timj at tolisgroup.com (Tim Jones) Date: Tue, 8 Apr 2008 14:48:40 -0700 Subject: [Tkinter-discuss] Mulitple root windows In-Reply-To: <2AACD4EB2F123248A064A23843B3A173CFAA44@cernxchg47.cern.ch> References: <2AACD4EB2F123248A064A23843B3A173CFAA44@cernxchg47.cern.ch> Message-ID: <1F052CC9-4837-4F87-B948-E9495860FC65@tolisgroup.com> On Apr 8, 2008, at 1:49 PM, Vasilis Vlachoudis wrote: > In my application I wanted to have a help window which is > responsive at all times even if a dialog issues a grab_set. > > I solved the problem by starting the Help window as a second root > window with Tk().Now my program is like the following, and in fact > if I get the grab from a dialog in rootmain the roothelp remains > unaffected. What happens with Tkinter and Tk in this case? Which > mainloop should I call (now I calling the main one and everything > works in linux)? > What you're currently doing should work, but have you considered creating your Help tool as a second application and starting it when the user asks for Help? Tim From darr_low at yahoo.com Wed Apr 9 03:56:46 2008 From: darr_low at yahoo.com (Snakey) Date: Tue, 8 Apr 2008 18:56:46 -0700 (PDT) Subject: [Tkinter-discuss] How to automatically run some code upon GUI startup? In-Reply-To: References: <16547636.post@talk.nabble.com> Message-ID: <16577829.post@talk.nabble.com> snakey wrote: > > Hi Fredrik, > Thanks for the suggestion. Let me try it now. I guess I need a deeper > understanding of this mainloop() thing. I am still unclear about how the > whole GUI concept of mainloop() works. > Fredrik Lundh wrote: > > Snakey wrote: > >> I have created a simple Tkinter GUI. I have a function that needs to be >> executed automatically upon launching the GUI application. How can it be >> done? > > how about calling it from the script that creates the GUI, before you > enter the mainloop? > > my_function() > root.mainloop() > > if you want to call it when the GUI is up and running, you can use the > "wait_visibility" method on the root widget: > > root.wait_visibility() # run event loop until window appears > my_function() > root.mainloop() > > another approach is to use the "after_idle" method: > > root.after_idle(my_function) > root.mainloop() > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/How-to-automatically-run-some-code-upon-GUI-startup--tp16547636p16577829.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Vasilis.Vlachoudis at cern.ch Wed Apr 9 15:47:37 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Wed, 9 Apr 2008 15:47:37 +0200 Subject: [Tkinter-discuss] Mulitple root windows In-Reply-To: <1F052CC9-4837-4F87-B948-E9495860FC65@tolisgroup.com> References: <2AACD4EB2F123248A064A23843B3A173CFAA44@cernxchg47.cern.ch> <1F052CC9-4837-4F87-B948-E9495860FC65@tolisgroup.com> Message-ID: <47FCC8F9.5030107@cern.ch> > What you're currently doing should work, but have you considered > creating your Help tool as a second application and starting it when > the user asks for Help? > > Tim > > Indeed it was my first approach, but I couldn't find an easy way of communicating in a platform independed way between the two applications. So I decided to include help inside the main application. V. -------------- next part -------------- A non-text attachment was scrubbed... Name: Vasilis_Vlachoudis.vcf Type: text/x-vcard Size: 312 bytes Desc: not available Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080409/4cb57a84/attachment.vcf From asolway at seas.upenn.edu Thu Apr 10 17:45:40 2008 From: asolway at seas.upenn.edu (Alec Solway) Date: Thu, 10 Apr 2008 11:45:40 -0400 Subject: [Tkinter-discuss] Main loop / Scheduling Message-ID: <20080410114540.o0hdq7e8p340o40k@webmail.seas.upenn.edu> Hi all, I'm debugging an existing application which uses Tkinter. Having not worked much with the library... please bear with me. In general, how is invocation of the event handler/dispatcher scheduled? The application in question is a Tcl/Tk library written in C; a Python interface using Tkinter sits on top of it. It seems to start the main loop implicitly by creating a Tkinter.Tk object (is this true of how the loop gets started?). The underlying C library schedules a task to run at a set interval with Tcl_CreateTimerHandler(...). If I'm not running any code outside of this framework, all is good. However, if I run anything in Python-space (say, just a really long loop that prints numbers, for testing), invocation of the scheduled task is delayed until this other task is done. My questions then are: (1) Is this an inherit problem with how things in general are set up? Is everything running under a single thread? (2) If not, is it possible to bump up the priority of the Tcl/Tk main loop and have it preempt Python space more often (or at all!), or conversely, downgrade the priority of the Python space process? (3) If option 2 fails, are there other alternatives anyone can think of to have these two things co-operate? Thanks for your help. From fredrik at pythonware.com Thu Apr 10 20:04:38 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 10 Apr 2008 20:04:38 +0200 Subject: [Tkinter-discuss] Main loop / Scheduling In-Reply-To: <20080410114540.o0hdq7e8p340o40k@webmail.seas.upenn.edu> References: <20080410114540.o0hdq7e8p340o40k@webmail.seas.upenn.edu> Message-ID: Alec Solway wrote: > (1) Is this an inherit problem with how things in general are set up? > Is everything running under a single thread? yes. From asolway at seas.upenn.edu Thu Apr 10 20:51:17 2008 From: asolway at seas.upenn.edu (Alec Solway) Date: Thu, 10 Apr 2008 14:51:17 -0400 Subject: [Tkinter-discuss] Main loop / Scheduling In-Reply-To: References: <20080410114540.o0hdq7e8p340o40k@webmail.seas.upenn.edu> Message-ID: <20080410145117.kc1vlojvi8wcoks0@webmail.seas.upenn.edu> If so, then why does the following work? What actually calls bar() below? foo = Tk() def bar(): print "bar" foo.after(1000, bar) # Drop back to prompt with 'after#0' response <1000ms> bar Quoting Fredrik Lundh : > Alec Solway wrote: > >> (1) Is this an inherit problem with how things in general are set up? >> Is everything running under a single thread? > > yes. > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > From fredrik at pythonware.com Thu Apr 10 21:26:24 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 10 Apr 2008 21:26:24 +0200 Subject: [Tkinter-discuss] Main loop / Scheduling In-Reply-To: <20080410145117.kc1vlojvi8wcoks0@webmail.seas.upenn.edu> References: <20080410114540.o0hdq7e8p340o40k@webmail.seas.upenn.edu> <20080410145117.kc1vlojvi8wcoks0@webmail.seas.upenn.edu> Message-ID: Alec Solway wrote: > If so, then why does the following work? What actually calls bar() below? > > foo = Tk() > def bar(): > print "bar" > foo.after(1000, bar) > # Drop back to prompt with 'after#0' response drop back to prompt? are you running this in interactive mode? the CPython interactive mode provides a "background event loop" that keeps Tkinter's event loop running. this is useful when tinkering when UI stuff from the command line, but is nothing you can rely on for code that you run outside the interactive mode. (you cannot rely on it in interactive mode either; it only works on Unix if you're using the readline library, and only works on Windows if you don't type anything into the window. as soon as you touch the keyboard, the event loop is terminate). to solve your problem, use an ordinary Python thread, and use a Queue object to pass results from the background thread to the main Tkinter thread. From darr_low at yahoo.com Fri Apr 11 04:29:14 2008 From: darr_low at yahoo.com (Snakey) Date: Thu, 10 Apr 2008 19:29:14 -0700 (PDT) Subject: [Tkinter-discuss] How to catch when the root window closes? In-Reply-To: References: Message-ID: <16623951.post@talk.nabble.com> would think that the root window is exited by using the "X" windows close button? If this is the case, you can bind the window manager event WM_DELETE_WINDOW to a handler. Try this: root = Tk() ... ... some other codes # -------------------------- # to bind the window manager's CLOSE event to a fn # -------------------------- root.protocol( "WM_DELETE_WINDOW", my_function ) # so when the user press the "x" button, my_function is executed. Write watever code you need in my_function(), and at the end of # the function, you can execute root.destroy to close the application. inhahe wrote: > > I tried doing root.bind("",onquit) > but i don't get why onquit is called *18* times when I exit the app. > what's the ideal way to execute something *once* when the app is exited? > Thanks, > inhahe > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/How-to-catch-when-the-root-window-closes--tp16290559p16623951.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From darr_low at yahoo.com Fri Apr 11 04:42:04 2008 From: darr_low at yahoo.com (Snakey) Date: Thu, 10 Apr 2008 19:42:04 -0700 (PDT) Subject: [Tkinter-discuss] Open a Dos prompt(cmd.exe) using a GUI, thus allowing user to execute batchfile Message-ID: <16624069.post@talk.nabble.com> I have created a GUI which has a button that when pressed, opens a Dos prompt box. I am using os.system( '.somepath...\.\cmd.exe' ). In this dos box, the user can run watever application he wants eg. execute a batchfile or run dos commands. 1. I need the GUI to monitor this dos box such that when the user closes the box, the GUI is aware of this action. 2. I need the GUI to monitor this dos box, such that when the user executes a batchfle in the dos prompt box, and the batchfile ends, the GUI is also aware. Is there someway the GUI can monitor the status of the dos box? -- View this message in context: http://www.nabble.com/Open-a-Dos-prompt%28cmd.exe%29-using-a-GUI%2C-thus-allowing-user-to-execute-batchfile-tp16624069p16624069.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ron.longo at cox.net Mon Apr 14 00:28:27 2008 From: ron.longo at cox.net (Ron Provost) Date: Sun, 13 Apr 2008 18:28:27 -0400 Subject: [Tkinter-discuss] A "Fixed" Tk Text widget Message-ID: <001d01c89db5$b245cf20$6501a8c0@aristotle> I have just completed and uploaded to the Tkinter wiki a "Fixed" version of the Tk Text widget called EnhancedText. This new widget (subclassed from Text) is intended to fix some of the quirks of the Text widget involving cursor movement. Namely, in Text, the cursor moves by paragraph rather than display-line when using the Up and Down arrow keys and it jumps to the beginning and end of a paragraph when using the 'Home' and 'End' keys. EnhancedText rewrites all the event handling of the Text widget. With EnhancedText, Up, Down, Home and End now move according to display lines rather than Paragraphs. This widget can be found here http://tkinter.unpythonic.net/wiki/EnhancedText. Thanks for any comments, bug reports, etc. Ron Longo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080413/8f8290ab/attachment.htm From darr_low at yahoo.com Mon Apr 14 15:36:03 2008 From: darr_low at yahoo.com (Snakey) Date: Mon, 14 Apr 2008 06:36:03 -0700 (PDT) Subject: [Tkinter-discuss] How to detech change of variable state in Tk? Message-ID: <16677661.post@talk.nabble.com> I have written a Tk GUI that upon pressing a button, will launch a subprocess to open a dos-box "cmd.exe". I need the GUI to monitor the returncode of this subprocess, so that when the dos box closes with return code 0, a subroutine can be executed to handle this event. BUT while the dos box is open, the GUI must still monitor all other events in mainloop() ( ie. GUI cannot hang ). snipplet of code: >>> import subprocess s= subprocess.Popen( 'cmd.exe' ) # s.poll() ??? -- View this message in context: http://www.nabble.com/How-to-detech-change-of-variable-state-in-Tk--tp16677661p16677661.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alix.zhang at gmail.com Mon Apr 14 17:21:08 2008 From: alix.zhang at gmail.com (chenguang Zhang) Date: Mon, 14 Apr 2008 23:21:08 +0800 Subject: [Tkinter-discuss] How can mouse read canvas's object's info? Message-ID: <63becf890804140821v343134d4le5f2456befbdf3f0@mail.gmail.com> Suppose there are several points on my canvas, each corresponds to a data of the form [point index, point's x coordanate, point's y coordinate], all these points are created by the following sentence, for point in self.data: #self.data is a point list and has the form [point1, point2, ...] self.drawing.create_oval(point[1]-2, point[2]-2, point[1]+2, point[2]+2,fill='black',tags='Toselect') #self.drawing is a Canvas self.drawing.tag_bind('Toselect', '', self.mouseEnter) and the following is the self.mouseEnter function: def mouseEnter(self,event): self.CoordinateShow.configure(text='point:'+str(event.x)+','+str(event.y)) #self.CoordinateShow is a Label to show the point's information I want to show the related information of the point when my mouse moves upon them... The KEY problem is: How can the mouse read out that point's OWN information, such as the point's index, x and y coordinate, and even the point's color. You see, the mouse's function here accually works on its own x and y coordinates(event.x and event.y), not the point's value. (now the self.mouseEnter function don't manipulate color, but my future work will have to handle this...) Thanks Very Much! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080414/31968f88/attachment.htm From jmcmonagle at velseis.com.au Tue Apr 15 01:10:10 2008 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Tue, 15 Apr 2008 09:10:10 +1000 Subject: [Tkinter-discuss] How can mouse read canvas's object's info? In-Reply-To: <63becf890804140821v343134d4le5f2456befbdf3f0@mail.gmail.com> References: <63becf890804140821v343134d4le5f2456befbdf3f0@mail.gmail.com> Message-ID: <4803E452.4050609@velseis.com.au> chenguang Zhang wrote: > Suppose there are several points on my canvas, each corresponds to a > data of the form [point index, point's x coordanate, point's y > coordinate], all these points are > created by the following sentence, > > for point in self.data: > #self.data is a point list and has the form [point1, point2, ...] > self.drawing.create_oval(point[1]-2, point[2]-2, point[1]+2, > > point[2]+2,fill='black',tags='Toselect') > #self.drawing is a Canvas > self.drawing.tag_bind('Toselect', '', self.mouseEnter) > > and the following is the self.mouseEnter function: > > def mouseEnter(self,event): > > self.CoordinateShow.configure(text='point:'+str(event.x)+','+str(event.y)) > #self.CoordinateShow is a Label to show the point's information > > I want to show the related information of the point when my mouse moves > upon them... > The KEY problem is: How can the mouse read out that point's OWN > information, such as the point's index, x and y coordinate, and even the > point's color. You see, the mouse's function here accually works on its > own x and y coordinates(event.x and event.y), not the point's value. > (now the self.mouseEnter function don't manipulate color, but my future > work will have to handle this...) > You need to convert the screen coordinate to your canvas coordinate. Replace event.x and event.y with self.drawing.canvasx(event.x) and self.drawing.canvasy(event.y) respectively. Regards, John From darr_low at yahoo.com Tue Apr 15 11:29:13 2008 From: darr_low at yahoo.com (Snakey) Date: Tue, 15 Apr 2008 02:29:13 -0700 (PDT) Subject: [Tkinter-discuss] Open a Dos prompt(cmd.exe) using a GUI, thus allowing user to execute batchfile In-Reply-To: <16624069.post@talk.nabble.com> References: <16624069.post@talk.nabble.com> Message-ID: <16698300.post@talk.nabble.com> I have found a way using subprocess.popen( 'cmd.exe' ). This will spawn a new process that does not hang the mainloop of the parent process. However, I also need to redirect everything the user types in the dos box back to be processed by my GUI, without hanging the GUI when the piping is taking place. Can this be done?? I tried >>> s = subprocess.popen( 'cmd.exe', stdout=subprocess.PIPE ) # when the new process ends, I do the following: out = s.stdout.readlines() # i do some string action on out Snakey wrote: > > I have created a GUI which has a button that when pressed, opens a Dos > prompt box. I am using os.system( '.somepath...\.\cmd.exe' ). In this > dos box, the user can run watever application he wants eg. execute a > batchfile or run dos commands. > > 1. I need the GUI to monitor this dos box such that when the user closes > the box, the GUI is aware of this action. > > 2. I need the GUI to monitor this dos box, such that when the user > executes a batchfle in the dos prompt box, and the batchfile ends, the GUI > is also aware. > > Is there someway the GUI can monitor the status of the dos box? > > > -- View this message in context: http://www.nabble.com/Open-a-Dos-prompt%28cmd.exe%29-using-a-GUI%2C-thus-allowing-user-to-execute-batchfile-tp16624069p16698300.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Vasilis.Vlachoudis at cern.ch Tue Apr 15 14:30:43 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Tue, 15 Apr 2008 14:30:43 +0200 Subject: [Tkinter-discuss] FocusOut on a popup widget Message-ID: <48049FF3.9030702@cern.ch> Dear all, in my application I have developed a small widget class "InPlaceEdit" to allow the user to edit in place the content of an item from a listbox. The class is creating a temporary popup Entry() (or overridden with any other widget) and placing it exactly on the coordinates of the listbox item to edit. Now my problem is the following. I am binding the so when the user clicks outside the widget, to destroy the widget and replace the value in the listbox. But, if the user clicks on a button, then the program first executes the command of the button and then it sends the event to the InPlaceEdit, with an end result that the content is updated after the command is executed. The same happens also with Menu entries. What should I bind to get a notification that I will lose the focus (or something similar) before executing the command of the button? Vasilis #=============================================================================== # Class to edit in place the contents of a listbox #=============================================================================== class InPlaceEdit: def __init__(self, listbox, item=ACTIVE, value=None): # Return value self.value = None # Result self.item = item # Find active try: self.active = listbox.index(self.item) except: return self.listbox = listbox # Create and set value self.frame = Frame(listbox, relief=None) self.createWidget() self.set(value) self.defaultBinds() # Bindings self.frame.bind("", self.focusOut) self.frame.bind("", self.cancel) self.listbox.bind("", self.resize) # Show and wait to be destroyed self.resize() self.frame.wait_window() # ---------------------------------------------------------------------- # Override method if another widget is requested # ---------------------------------------------------------------------- def createWidget(self): self.edit = Entry(self.frame, background="White") self.edit.pack(expand=YES, fill=BOTH) self.edit.focus_set() # ---------------------------------------------------------------------- # Set default bindings # ---------------------------------------------------------------------- def defaultBinds(self): try: self.edit.bind("", self.ok) self.edit.bind("", self.cancel) except AttributeError: pass # ---------------------------------------------------------------------- def resize(self, event=None): x, y, w, h = self.listbox.bbox(self.item) w = self.listbox.winfo_width() h += 2 try: self.frame.place(in_=self.listbox, x=x-1, y=y-1, width=w, height=h, bordermode=OUTSIDE) self.frame.update_idletasks() except TclError: pass # ---------------------------------------------------------------------- # Override method to set the value # ---------------------------------------------------------------------- def set(self, value): if value is None: value = self.listbox.get(self.item) self.edit.delete(0, END) self.edit.insert(0, value) self.edit.selection_range(0, END) # ---------------------------------------------------------------------- # Override method to get the value # ---------------------------------------------------------------------- def get(self): return self.edit.get() # ---------------------------------------------------------------------- def ok(self, event=None): self.value = self.get() self.frame.unbind('') self.frame.place_forget() self.frame.destroy() self.listbox.focus_set() act = self.listbox.index(ACTIVE) sel = self.listbox.selection_includes(self.active) self.listbox.delete(self.active) self.listbox.insert(self.active, self.value) if sel: self.listbox.selection_set(self.active) self.listbox.activate(act) return "break" # ---------------------------------------------------------------------- def focusOut(self, event=None): self.ok() # ---------------------------------------------------------------------- def cancel(self, event=None): self.frame.place_forget() self.frame.destroy() self.listbox.focus_set() return "break" -------------- next part -------------- A non-text attachment was scrubbed... Name: Vasilis_Vlachoudis.vcf Type: text/x-vcard Size: 312 bytes Desc: Vasilis_Vlachoudis.vcf Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080415/3edaa4bf/attachment.vcf From amit.finkler at gmail.com Tue Apr 15 16:20:21 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Tue, 15 Apr 2008 17:20:21 +0300 Subject: [Tkinter-discuss] running a command with input from a widget Message-ID: <4804B9A5.5060605@gmail.com> Hi, I created a function which has the following format, def setrange_rod(heater_range): """ Set heater range (0,1,2,3) to Lakeshore 330 """ lakeshore = devices.getDeviceByAddress(int(LakeAdr.get())) lakeshore.setrange(heater_range) Never mind right now what the first line in the function does. It is suffice to say that it creates the lakeshore class and that if I call it from the console with the .setrange(heater_range), it works (heater_range in my case is either 0, 1, 2 or 3) I'm trying to call it from a Menu widget heater = Menu( win3 , tearoff = 0 ) set_range_rod = Menu( heater, tearoff = 0 ) set_range_rod.add_command( label = "OFF", command = setrange_rod(0)) set_range_rod.add_command( label = "LOW", command = setrange_rod(1)) set_range_rod.add_command( label = "MEDIUM", command = setrange_rod(2)) set_range_rod.add_command( label = "HIGH", command = setrange_rod(3)) heater.add_cascade(label = "Rod", menu = set_range_rod) win3.config( menu=heater ) When I import the module, it automatically sets itself on the last option ("HIGH") and I cannot change it by choosing one of the other options in the menu. Does this happen because I wrote a "command = setrange(specific_value)"? If I use the same code but with a inputless function, i.e., "command = setrange_rod", assuming the setrange_rod is an inputless function - everything works fine. Hence my question. I apologize if my code is a bit messy, but I'm in the stages of renovations in the main code (aren't we always?). If you want, I can send it in its full glory, but then I think that decent programmers would start vomiting... :-) Any help or suggestions will be appreciated. Amit. From mtasic85 at gmail.com Tue Apr 15 12:51:15 2008 From: mtasic85 at gmail.com (mtasic85) Date: Tue, 15 Apr 2008 03:51:15 -0700 (PDT) Subject: [Tkinter-discuss] PyGTK to Tkinter wrapper Message-ID: <16699347.post@talk.nabble.com> Hi everyone, With all due respect to Tkinter and PyGTK developers, the starting idea was to make PyGTK code compatible with pygtk2tk without changing anything else except importing modules. The obvious use of pygtk2tk is having PyGTK code without having PyGTK installed. And the sweetest fact is that Tkinter is included by default in Python. This wrapper isn't completed, and it's in an early stage, so it'll require additional effort to be done, soon :) Currently, it supports following classes/widgets: GObject, Object, Widget, Container, Bin, Window, Box, HBox, VBox, Table, Button, ToggleButton, CheckButton, RadioButton, Label, and Entry. Basic examples from PyGTK tutorial are also included, and everything should work simply by running them without any installation, and modifications. Only parts which are modified in examples are parts where are import's statements at the beginning of source code. http://code.google.com/p/pygtk2tk/ http://code.google.com/p/pygtk2tk/ Anyone who would like to contribute is welcome! -- View this message in context: http://www.nabble.com/PyGTK-to-Tkinter-wrapper-tp16699347p16699347.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From amit.finkler at gmail.com Wed Apr 16 07:50:49 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Tue, 15 Apr 2008 22:50:49 -0700 (PDT) Subject: [Tkinter-discuss] running a command with input from a widget In-Reply-To: <4804B9A5.5060605@gmail.com> References: <4804B9A5.5060605@gmail.com> Message-ID: <16716882.post@talk.nabble.com> Amit Finkler wrote: > > > > set_range_rod.add_command( label = "OFF", command = setrange_rod(0)) > > > After searching the 'net a bit, I found the solution: a lambda wrapper (note the year...) http://mail.python.org/pipermail/python-list/2000-August/046867.html This calls for another question: How long do you think it is reasonable to search the 'net for a solution before bothering mailing lists with a problem which has a simple and known solution? Amit. -- View this message in context: http://www.nabble.com/running-a-command-with-input-from-a-widget-tp16703386p16716882.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From solaris_1234 at yahoo.com Sat Apr 19 18:56:09 2008 From: solaris_1234 at yahoo.com (solaris_1234) Date: Sat, 19 Apr 2008 09:56:09 -0700 (PDT) Subject: [Tkinter-discuss] Newbie's Scrollbar question Message-ID: <887993.87791.qm@web54406.mail.yahoo.com> Is there a way to get a Scrollbar widget to control two widgets? I would like to do something like: ... self.textbox1 = Text(self.myc, yscrollbarcommand=self.scrollbar1.set) self.textbox2 = Text(self.myc, yscrollbarcommand=self.scrollbar1.set) self.scrollbar1.config(command=self.textbox1.yview) self.scrollbar1.config(command=self.textbox2.yview) .... I understand the second self.scrollbar1.config is the only valid binding for scrollbar1. Any hints on how to do this ? Thanks, tkinter newbie --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080419/05141059/attachment.htm From msa01 at bitflipper.ca Sun Apr 20 16:10:14 2008 From: msa01 at bitflipper.ca (Cam Farnell) Date: Sun, 20 Apr 2008 11:10:14 -0300 Subject: [Tkinter-discuss] Newbie's Scrollbar question In-Reply-To: <887993.87791.qm@web54406.mail.yahoo.com> References: <887993.87791.qm@web54406.mail.yahoo.com> Message-ID: <480B4EC6.9060903@bitflipper.ca> I had to do this recently where one scroll bar needed to control two canvases. The trick is to create a function which accepts info from the scrollbar and then propagates it to the widgets to be scrolled. Some snippets from my code: hscroll = Scrollbar(FF,orient=HORIZONTAL,command=Propagator) def Propagator(*Args): """ Propagate position commands to more than one canvas. """ for C in MyCanvases: C.xview(*Args) Where "MyCanvases" is a list of the objects (in my case, Canvases) which need to scroll in response to changes in the scroll bar. Hope this helps Cam solaris_1234 wrote: > Is there a way to get a Scrollbar widget to control two widgets? > > I would like to do something like: > ... > self.textbox1 = Text(self.myc, yscrollbarcommand=self.scrollbar1.set) > self.textbox2 = Text(self.myc, yscrollbarcommand=self.scrollbar1.set) > self.scrollbar1.config(command=self.textbox1.yview) > self.scrollbar1.config(command=self.textbox2.yview) > .... > > I understand the second self.scrollbar1.config is the only valid binding > for scrollbar1. > > Any hints on how to do this ? > > Thanks, > > tkinter newbie From longorh at npt.nuwc.navy.mil Wed Apr 23 15:08:07 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Wed, 23 Apr 2008 06:08:07 -0700 (PDT) Subject: [Tkinter-discuss] Text widget tag_bind(), can't get it to work. Message-ID: <16834587.post@talk.nabble.com> I'm trying to catch a keypress event in a tagged region of text. According to the documentation this should work, however, my callback never gets called. Here's some test code: from Tkinter import * def typed( event=None ): print 'typed' def moved( event=None ): print 'moved' root = Tk() text = Text( root ) text.pack() text.insert( '1.0', '0123456789012345678901234567890' ) text.tag_add( 'try', '1.10', '1.19' ) text.tag_bind( 'try', '', typed ) text.tag_bind( 'try', '', moved ) root.mainloop( ) So, my moved function gets called whenever the mouse enters and moves within the tagged region. However, if I have the insert cursor in the tagged region and press any key, my typed function never gets called. Am I doing this incorrectly? Am I misunderstanding how this is supposed to work? Thanks, Ron -- View this message in context: http://www.nabble.com/Text-widget-tag_bind%28%29%2C-can%27t-get-it-to-work.-tp16834587p16834587.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alix.zhang at gmail.com Thu Apr 24 15:06:50 2008 From: alix.zhang at gmail.com (chenguang Zhang) Date: Thu, 24 Apr 2008 21:06:50 +0800 Subject: [Tkinter-discuss] How to get PyopenGL work with Tkinter(as part of python 2.5)? Message-ID: <63becf890804240606n24818370qd36f29302e5b6a96@mail.gmail.com> I think this must be an old question, but I still raise it for I can't bear any more failures. I'm really frustrated when the error message as the following pops up again and again... "Traceback (most recent call last): File "poly.py", line 14, in from OpenGL.Tk import * File "D:\Python25\lib\site-packages\pyopengl-3.0.0b1.0001- py2.5.egg\OpenGL\Tk\__init__.py", line 87, in _default_root.tk.call('package', 'require', 'Togl') _tkinter.TclError: can't find package Togl" I guess togl is not a must for the cooperation of PyopenGL and Tkinter, but just a guess. Could anyone help me out? My question can be summarized into a twofold one: a.Can pyopengl work with tkinter(as part of Python 2.5) without involving togl? How? (an sample code or useful link would be greatly appreciated) if the answer to question a is "NOT", then... b.How can I fix the error:"_tkinter.TclError: can't find package Togl"? Any help would be appreciated! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattx_13 at hotmail.com Thu Apr 24 12:15:57 2008 From: mattx_13 at hotmail.com (AbsoluteMatt) Date: Thu, 24 Apr 2008 03:15:57 -0700 (PDT) Subject: [Tkinter-discuss] Dynamic output of "DOS" command in tkinter Message-ID: <16849178.post@talk.nabble.com> Hi Guys, This is my first post here and my first time developing a tkinter app - so please go easy:-) I have to say I have found it really nice so far, but am struggling on one point. What I want to be able to do is take a system command and "pipe" it to a scrollable window, however I would like it to follow the execution of the command dynamically. The command that I am running is not one that will execute in a few seconds allowing me to send the result to a scrollable window - which I understand how to do. The link below shows an example of someone doing this: http://mail.python.org/pipermail/python-list/2004-September/281344.html What I am actually doing is running an oracle IMP command and would like to follow the imported tables/rows etc from the app Any suggestion about how to display in this way do this would be much appreciated. Many Thanks, Matt -- View this message in context: http://www.nabble.com/Dynamic-output-of-%22DOS%22-command-in-tkinter-tp16849178p16849178.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From leegold at fastmail.fm Fri Apr 25 05:39:05 2008 From: leegold at fastmail.fm (leegold) Date: Thu, 24 Apr 2008 23:39:05 -0400 Subject: [Tkinter-discuss] Listbox selection persistence Message-ID: <1209094745.15024.1249783713@webmail.messagingengine.com> Hi, I guess there's something basic I need to know. Given the code below if I press the button and p and q is highlighted then close the window I get: Output: >>> dddd [] ('15', '16') dddd [] But the x does not seem to persist outside of the def selected() block. I want the final last button press to persist so I can use those indexes for further processing. What am I missing here? Thanks. import sys, string, Tkinter from Tkinter import * root=Tkinter.Tk() frame=Tkinter.Frame(root) listbox=Listbox(frame, height=27,selectmode=MULTIPLE, font=('courier', 12)) listbox.pack(side=LEFT,fill=BOTH, expand=1) choices=map(chr, range(97, 123)) for item in choices: listbox.insert(END, item) frame.pack(fill=BOTH, expand=1) def selected(): x = listbox.curselection() print x zz='dddd' btn = Button(root, text = "Click for values", command = selected) btn.pack() #test print zz print x root.mainloop() #test print zz print x From mfranklin1 at gatwick.westerngeco.slb.com Fri Apr 25 08:48:31 2008 From: mfranklin1 at gatwick.westerngeco.slb.com (Martin Franklin) Date: Fri, 25 Apr 2008 07:48:31 +0100 Subject: [Tkinter-discuss] Dynamic output of "DOS" command in tkinter In-Reply-To: <0JZU0000RHWQBI@eurmta01.london.eur.slb.com> References: <0JZU0000RHWQBI@eurmta01.london.eur.slb.com> Message-ID: <48117EBF.5090905@gatwick.westerngeco.slb.com> AbsoluteMatt wrote: > Hi Guys, > > This is my first post here and my first time developing a tkinter app - so > please go easy:-) I have to say I have found it really nice so far, but am > struggling on one point. > > What I want to be able to do is take a system command and "pipe" it to a > scrollable window, however I would like it to follow the execution of the > command dynamically. The command that I am running is not one that will > execute in a few seconds allowing me to send the result to a scrollable > window - which I understand how to do. > The link below shows an example of someone doing this: > http://mail.python.org/pipermail/python-list/2004-September/281344.html > > What I am actually doing is running an oracle IMP command and would like to > follow the imported tables/rows etc from the app > > Any suggestion about how to display in this way do this would be much > appreciated. > > Many Thanks, > > Matt > > Hi Matt, this is not so much a tkinter problem, more a subprocess / popen thing :) I've done this in the past with a simple while 1: loop... proc = os.popen("imp big_oracle_xport_file.exp") while 1: line = proc.readline() if not line: break textBox.write(line) of course this will block and wait for the command to write another line to stdout... I'm sure there are better ways to do this by now, its been a while since I looked at the popen family (subprocess module now too I think...?) in any case the main python list would be my next stop after I checked the python doc's for popen, subprocess, command etc etc :) Cheers Martin -- signature file not found, must be something I ate From mattx_13 at hotmail.com Fri Apr 25 10:57:44 2008 From: mattx_13 at hotmail.com (AbsoluteMatt) Date: Fri, 25 Apr 2008 01:57:44 -0700 (PDT) Subject: [Tkinter-discuss] Dynamic output of "DOS" command in tkinter In-Reply-To: <48117EBF.5090905@gatwick.westerngeco.slb.com> References: <16849178.post@talk.nabble.com> <48117EBF.5090905@gatwick.westerngeco.slb.com> Message-ID: <16893325.post@talk.nabble.com> Hi Martin, Thanks for your reply, I actually started trying to do this with popen, but didn't pursue it as I wasn't sure that it would work this way. Now that you have confirmed that it can be done like this, I will continue on this path (and will read up on subprocess etc as well :-)). Thinking about it my question would have probably sat better in a python forum, but I got the answer/direction I needed so no regrets. Cheers, Matt Martin Franklin wrote: > > AbsoluteMatt wrote: >> Hi Guys, >> >> This is my first post here and my first time developing a tkinter app - >> so >> please go easy:-) I have to say I have found it really nice so far, but >> am >> struggling on one point. >> >> What I want to be able to do is take a system command and "pipe" it to a >> scrollable window, however I would like it to follow the execution of the >> command dynamically. The command that I am running is not one that will >> execute in a few seconds allowing me to send the result to a scrollable >> window - which I understand how to do. >> The link below shows an example of someone doing this: >> http://mail.python.org/pipermail/python-list/2004-September/281344.html >> >> What I am actually doing is running an oracle IMP command and would like >> to >> follow the imported tables/rows etc from the app >> >> Any suggestion about how to display in this way do this would be much >> appreciated. >> >> Many Thanks, >> >> Matt >> >> > > Hi Matt, > > this is not so much a tkinter problem, more a subprocess / popen thing :) > > I've done this in the past with a simple while 1: loop... > > > proc = os.popen("imp big_oracle_xport_file.exp") > > while 1: > line = proc.readline() > if not line: > break > textBox.write(line) > > of course this will block and wait for the command to write another line > to stdout... I'm sure there are better ways to do this by now, its been > a while since I looked at the popen family (subprocess module now too I > think...?) in any case the main python list would be my next stop after > I checked the python doc's for popen, subprocess, command etc etc :) > > Cheers > Martin > > -- > signature file not found, must be something I ate > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/Dynamic-output-of-%22DOS%22-command-in-tkinter-tp16849178p16893325.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.