From amit.finkler at gmail.com Wed Mar 5 17:09:46 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Wed, 05 Mar 2008 18:09:46 +0200 Subject: [Tkinter-discuss] Windows inaccessible while a module is running Message-ID: <47CEC5CA.70001@gmail.com> Hi, I wrote a simple GUI with tkinter which executes a function when pressing a button. When I press the button, the function indeed executes starts running itself (it's a loop which draws a graph using gnuplot). As long as the loop is running, I can't access the GUI - it's grayed out. Only when I break the loop can I properly see the GUI back again. Is this something you're familiar with or did I define the GUI improperly? Thanks, Amit. From gigs at hi.t-com.hr Wed Mar 5 17:55:37 2008 From: gigs at hi.t-com.hr (Gigs_) Date: Wed, 05 Mar 2008 17:55:37 +0100 Subject: [Tkinter-discuss] Windows inaccessible while a module is running In-Reply-To: <47CEC5CA.70001@gmail.com> References: <47CEC5CA.70001@gmail.com> Message-ID: <47CED089.5090105@hi.t-com.hr> Amit Finkler wrote: > Hi, > > > I wrote a simple GUI with tkinter which executes a function when > pressing a button. When I press the button, the function indeed executes > starts running itself (it's a loop which draws a graph using gnuplot). > As long as the loop is running, I can't access the GUI - it's grayed > out. Only when I break the loop can I properly see the GUI back again. > > > Is this something you're familiar with or did I define the GUI improperly? > > > Thanks, > > > Amit. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > you will need to make thread for that function to separate execution from gui From Cameron at phaseit.net Wed Mar 5 18:50:29 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Wed, 5 Mar 2008 17:50:29 +0000 Subject: [Tkinter-discuss] Windows inaccessible while a module is running In-Reply-To: <47CED089.5090105@hi.t-com.hr> References: <47CEC5CA.70001@gmail.com> <47CED089.5090105@hi.t-com.hr> Message-ID: <20080305175029.GA14239@lairds.us> On Wed, Mar 05, 2008 at 05:55:37PM +0100, Gigs_ wrote: . . . > > I wrote a simple GUI with tkinter which executes a function when > > pressing a button. When I press the button, the function indeed executes > > starts running itself (it's a loop which draws a graph using gnuplot). > > As long as the loop is running, I can't access the GUI - it's grayed > > out. Only when I break the loop can I properly see the GUI back again. > > > > > > Is this something you're familiar with or did I define the GUI improperly? . . . > you will need to make thread for that function to separate execution > from gui . . . Coding with threads certainly is one common approach. As the e-mail I just sent hints, it's not the only one--and sometimes not the best. From Cameron at phaseit.net Wed Mar 5 18:34:55 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Wed, 5 Mar 2008 17:34:55 +0000 Subject: [Tkinter-discuss] Windows inaccessible while a module is running In-Reply-To: <47CEC5CA.70001@gmail.com> References: <47CEC5CA.70001@gmail.com> Message-ID: <20080305173455.GA12124@lairds.us> On Wed, Mar 05, 2008 at 06:09:46PM +0200, Amit Finkler wrote: . . . > I wrote a simple GUI with tkinter which executes a function when > pressing a button. When I press the button, the function indeed executes > starts running itself (it's a loop which draws a graph using gnuplot). > As long as the loop is running, I can't access the GUI - it's grayed > out. Only when I break the loop can I properly see the GUI back again. > > > Is this something you're familiar with or did I define the GUI improperly? . . . Both. The symptom you describe is very common with naive codings. In general, an experienced Tkinter programmer can quickly transform an application which behaves that way into a responsive one. Without seeing your specific code, it's difficult to speculate exactly what the best approach is for you; the main keywords in any answer, though, appear in . From amit.finkler at gmail.com Thu Mar 6 12:13:01 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Thu, 06 Mar 2008 13:13:01 +0200 Subject: [Tkinter-discuss] Windows inaccessible while a module is running In-Reply-To: <20080305175029.GA14239@lairds.us> References: <47CEC5CA.70001@gmail.com> <47CED089.5090105@hi.t-com.hr> <20080305175029.GA14239@lairds.us> Message-ID: <47CFD1BD.6040303@gmail.com> Cameron Laird wrote: > On Wed, Mar 05, 2008 at 05:55:37PM +0100, Gigs_ wrote: > . > . > . > >>> I wrote a simple GUI with tkinter which executes a function when >>> pressing a button. When I press the button, the function indeed executes >>> starts running itself (it's a loop which draws a graph using gnuplot). >>> As long as the loop is running, I can't access the GUI - it's grayed >>> out. Only when I break the loop can I properly see the GUI back again. >>> >>> >>> Is this something you're familiar with or did I define the GUI improperly? >>> > . > . > . > >> you will need to make thread for that function to separate execution >> from gui >> > . > . > . > Coding with threads certainly is one common approach. As > the e-mail I just sent hints, it's not the only one--and > sometimes not the best. > Cameron, is it possible to give a more tkinter-specific hint, i.e. in the tkinter syntax? I started reading through the link you mentioned but the syntax looks more like core Tk/Tcl. In other words, how do I make a thread (or an equivalent solution) for a function in tkinter-python? Let's say that the code looks like the following sample: import Numeric, time, Gnuplot def cooldown() A = Numeric.arange(-1, 1, .1) delay = 5 ######################################## ######################################## X = [] Y = [] XY = [] g = Gnuplot.Gnuplot() g('set data style linespoints') try: while A[0]<10: val1 = 1 val2 = 2 XY.append([val1, val2]) if len(XY) > 1: g.plot(XY) except KeyboardInterrupt: # Pressing Ctrl-C will result in ending the program but saving all the data taken so far pass return g win1 = Tk() win1.title('Control Panel') RunFrame = Frame(win1, bd = 2, relief = 'groove') RunCooldown = Button(RunFrame) RunCooldown.configure(text = 'Cooldown', fg = 'blue', command = cooldown, cursor = 'target') RunCooldown.pack(side = LEFT) Thanks, Amit. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080306/4d1bf941/attachment.htm From ron.longo at cox.net Fri Mar 14 02:09:47 2008 From: ron.longo at cox.net (Ron Provost) Date: Thu, 13 Mar 2008 21:09:47 -0400 Subject: [Tkinter-discuss] Text, Tree & Tkinter. Ugh! Message-ID: <01f801c88570$194569f0$6501a8c0@aristotle> Hello, Don't know if I'll get much response to this but I figured this is about the best place to try. I have an application I've been developing for some time which is for organizing large amounts of information and publishing it to the web. This application is written 100% in Python. (Below are images of the application and the generated web page). It's not fancy, but it works. My issue is with the Text widget and styling my text/web pages. At first glance, the text widget appears amazing. It seems to be able to do everything I want it to to be able to develop a reasonaly decent looking document and web page with text styling and image insertion. However, I've just not been able to get my mind around how to use it as such. Consequently, I've resorted to a "mini language" (shown in the image) which I must translate into HTML to format my document. It's really a disappointing aspect of an otherwise nice application. Comparing the document to the web page jpgs you can see that I"m using something of the form [[ x ]]:unordered to transform 'x' into a level 2 header followed by an unordered list with one element (preceded by '@@'). I have quite a few of these kinds of things for generating all sorts of HTML code. But I hate them. I want to be able to remove this 'directives' and be able to view images and styles directly in my document. I have played around with the Text widget separately and developed a few 'sample' editing applications but I've never been able to capture the functionality of what I need. Pictured also is a control I wrote for an application which allows me to define text styles and assign them to sections of text that's selected in my text widget. The problem with this sample app is that in order to avoid the complexity of layered styles whenever a section of text is assigned a new style all previous styles (tags) on that section are first deleted. Layering of tags in itself doesn't bother me but then you have to get into special cases for fonts (family, size, weight and slant) which can't layer, but have to be specified at once. So, if you want a button to select just bold on your GUI, you have to start to play games to work around this. Also, I have not been able to figure out how to change the style of text being typed. Seems like I have to type text first, then go back, select it and assign a style. Then there's the who issue of lists and tables which I need but am not really sure how to implement in the control. For anyone curious, my tree is generated using the Tix Tree widget. The elements in the tree are actually entry widgets so that I can edit them inplace. I've implemented full editing capabilities of the tree with drag-and-drop to allow reorganizing. The tree control is very simple to use and those I've shown it to love it and describe it as intuitive. There's only one minor problem with the Tree control involving clicking on the +/- indicator. You need to click quickly to open or close the branch, if your click and release of the mouse button is too slow, the the branch state toggles twice putting you back in your original state. Annoying, not sure I can fix it since it's behavior of the control. If anyone is interested in examining the application I would be more than willing to zip the source code and email it to them. It's not pretty as it's been through about a thousand revisions. Note of interest: The outline displayed in the GUI and web page are for my research area, Logic. I have several other outlines in the works including a Tkinter one that's quite mature. Thanks for any help. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0001.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: untitled.JPG Type: image/jpeg Size: 104713 bytes Desc: not available Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0003.jpeg -------------- next part -------------- A non-text attachment was scrubbed... Name: web_resize.JPG Type: image/jpeg Size: 108394 bytes Desc: not available Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0004.jpeg -------------- next part -------------- A non-text attachment was scrubbed... Name: control.JPG Type: image/jpeg Size: 69411 bytes Desc: not available Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0005.jpeg From jimswalsh at gmail.com Fri Mar 14 15:03:23 2008 From: jimswalsh at gmail.com (Jim Walsh) Date: Fri, 14 Mar 2008 07:03:23 -0700 (PDT) Subject: [Tkinter-discuss] how to remove window borders In-Reply-To: References: Message-ID: <16048139.post@talk.nabble.com> You could try widget.overrideredirect(True) which takes all of the window decorations away. Jim brindly sujith wrote: > > hi > > i am developing a GUI application using TKINTER > > in my applicaton i dont want the window title bar(including MAX,MIN and > CLOSE) > > how to do this > > plz send me the code for this > > _______________________________________________ > 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-remove-window-borders-tp14751862p16048139.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jimswalsh at gmail.com Fri Mar 14 15:18:15 2008 From: jimswalsh at gmail.com (Jim Walsh) Date: Fri, 14 Mar 2008 07:18:15 -0700 (PDT) Subject: [Tkinter-discuss] how to maximize a window (beginner question!) In-Reply-To: <20070706141745.GA13441@lairds.us> References: <468E1FF4.6070709@gmx.de> <20070706141745.GA13441@lairds.us> Message-ID: <16048146.post@talk.nabble.com> Here is one idea: w=Tk() w.wm_state('zoomed') Cameron Laird-2 wrote: > > On Fri, Jul 06, 2007 at 12:56:52PM +0200, Marcus Gna? wrote: > . > . > . >> I like to know how I can maximize a window at program start. >> I haven't found any hint so far. Hope you can help me ... > . > . > . > Apparently no one has yet updated and transcribed > for Tkinter. That > would make a nice tiny task for someone ... > > Is the maximization on that page the sort you had > in mind? > _______________________________________________ > 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-maximize-a-window-%28beginner-question%21%29-tp11462410p16048146.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From timmortimer at d2.net.au Sat Mar 15 07:07:47 2008 From: timmortimer at d2.net.au (Tim Mortimer) Date: Fri, 14 Mar 2008 23:07:47 -0700 (PDT) Subject: [Tkinter-discuss] drawing multiple functions on the canvas Message-ID: <16064458.post@talk.nabble.com> Hi folks, So i've moved forward a little with Tkinter, & had a play & hack around with some example canvas drawing code from the example directory today. I posted a few weeks back about a creating a "function" drawing tool, but I'm looking now to represent a number of "freehand functions" on the canvas at the same time. Drawing on the canvas is relatively easy. The problem is I want to restrict my line to a "function" representation (in the mathematical sense) IE, as I draw relative to the canvas X axis, there should only ever be 1 & only one y value displayed against that particular X (for each function line anyway) to say this another way, i want to write lists / arrays of Y values to X indices as defined via the mouse, & then display the contents of these lists on the canvas, all together, but each array / list represented by a different colour line /squiggle once I am happy with my superimposed graph of trajectories, i would hit some sort of publish button, & the output of the function arrays / lists would be published to .txt file so i can go off & use the data in Csound. That's the easy bit ; ) Im not sure this is possible with tkinter, although in theory it should be pretty simple. The best i can think of involves maybe using 1 pixel diameter circles on the canvas or something.. the canvas.line() method after all does some smoothing & interpolation on the mouse input data... in a way it would be nice if my "trajectories" in the array reflected the discrete mapping from this "post smoothing" state... I'm aware that a greater "hybridisation" of input & plotting functionality might be available through some sort of wxPython / matplotlib combo ... essentially i am, after all, "plotting" data - it's just the data I am inputting is arbitrary / via the mouse - & the display needs to refresh after input I want to be sure however that I can't achieve this in Tkinter first before i go off trying more complex tools or environments. cheers T. ----- ******************* www.phasetransitions.net hermetic music * python * csound * possibly mindless ranting various werk in perpetual delusions of progress.... -- View this message in context: http://www.nabble.com/drawing-multiple-functions-on-the-canvas-tp16064458p16064458.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From overbyte at earthlink.net Sun Mar 16 04:54:19 2008 From: overbyte at earthlink.net (Stanley Sokolow) Date: Sat, 15 Mar 2008 20:54:19 -0700 (PDT) Subject: [Tkinter-discuss] WM_DELETE_WINDOW -- the correct syntax to use it. Message-ID: <16074408.post@talk.nabble.com> Here's a tip to help new Tkinter programmers avoid the trouble I had because of an error in Grayson's book Python and Tkinter Programming published by Manning. On page 309, the protocol methods are briefly explained, with an example: self.root.protocol(WM_DELETE_WINDOW, self.cleanup) This does not work. There is no error correction in the errata page on the Manning site for the book. I finally figured out that WM_DELETE_WINDOW is not a pre-defined constant like TOP, but rather should be a string in quotes. The correct way to invoke the protocol to intercept toplevel window closing is: self.root.protocol("WM_DELETE_WINDOW", self.cleanup) I wrote to Manning to have them add this to their errata, but just in case they don't do it, I wanted to post this correction note here for others to find. -- View this message in context: http://www.nabble.com/WM_DELETE_WINDOW----the-correct-syntax-to-use-it.-tp16074408p16074408.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jonathan at wikiterra.net Tue Mar 18 16:17:34 2008 From: jonathan at wikiterra.net (Jonathan Frankel) Date: Tue, 18 Mar 2008 11:17:34 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window Message-ID: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> Hi all, I've written a little app that looks quite handsome on OS X, much more than on Windows, but when I double click on it to open it (and the default is to launch using Python Launcher), a console appears in the background, and then even stays open after I close the Tkinter window. On Windows I changed the extension to .pyw and it works fine--no command prompt in the background. How do I run a Tkinter application on OS X without having a console window appear in the background? Thanks much, Jonathan From kw at codebykevin.com Tue Mar 18 16:23:31 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 18 Mar 2008 11:23:31 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> Message-ID: <47DFDE73.7010907@codebykevin.com> Jonathan Frankel wrote: > Hi all, > > I've written a little app that looks quite handsome on OS X, much more > than on Windows, but when I double click on it to open it (and the > default is to launch using Python Launcher), a console appears in the > background, and then even stays open after I close the Tkinter window. > On Windows I changed the extension to .pyw and it works fine--no > command prompt in the background. > > How do I run a Tkinter application on OS X without having a console > window appear in the background? > > Thanks much, > Jonathan Something like this works for me: try: self.tk.call('console', 'hide') except TclError: pass HTH, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From jonathan at wikiterra.net Tue Mar 18 16:48:59 2008 From: jonathan at wikiterra.net (Jonathan Frankel) Date: Tue, 18 Mar 2008 11:48:59 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <47DFDE73.7010907@codebykevin.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> Message-ID: <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> Hmm...this isn't working for me... This is a sketch of what I've got: from Tkinter import * class App: def __init__(self, master): self.frame = Frame(master) self.frame.pack() ...etc... def main(): root = Tk() try: root.tk.call('console','hide') except TclError: pass app = App(root) root.mainloop() Should I put "self.tk.call('console','hide')" somewhere else in the code? Humbly, Jonathan On Tue, Mar 18, 2008 at 11:23 AM, Kevin Walzer wrote: > > Jonathan Frankel wrote: > > Hi all, > > > > I've written a little app that looks quite handsome on OS X, much more > > than on Windows, but when I double click on it to open it (and the > > default is to launch using Python Launcher), a console appears in the > > background, and then even stays open after I close the Tkinter window. > > On Windows I changed the extension to .pyw and it works fine--no > > command prompt in the background. > > > > How do I run a Tkinter application on OS X without having a console > > window appear in the background? > > > > Thanks much, > > Jonathan > > Something like this works for me: > > try: > self.tk.call('console', 'hide') > except TclError: > pass > > HTH, > Kevin > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > From kw at codebykevin.com Tue Mar 18 16:51:21 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 18 Mar 2008 11:51:21 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> Message-ID: <47DFE4F9.3030401@codebykevin.com> Jonathan Frankel wrote: > Hmm...this isn't working for me... > > This is a sketch of what I've got: > > from Tkinter import * > > class App: > def __init__(self, master): > self.frame = Frame(master) > self.frame.pack() > ...etc... > > def main(): > root = Tk() > try: > root.tk.call('console','hide') > except TclError: > pass > app = App(root) > root.mainloop() > > Should I put "self.tk.call('console','hide')" somewhere else in the code? > > Humbly, > Jonathan I put the code in the __init__ method. What exactly is going on? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From jonathan at wikiterra.net Tue Mar 18 16:58:52 2008 From: jonathan at wikiterra.net (Jonathan Frankel) Date: Tue, 18 Mar 2008 11:58:52 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <47DFE4F9.3030401@codebykevin.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> <47DFE4F9.3030401@codebykevin.com> Message-ID: <111c9e510803180858p1ebf3b5fi6454e730416db494@mail.gmail.com> When I put this code (using self.tk... instead of root.tk...) in the __init__ method I get an error: AttributeError: App instance has no attribute 'tk' On Tue, Mar 18, 2008 at 11:51 AM, Kevin Walzer wrote: > Jonathan Frankel wrote: > > Hmm...this isn't working for me... > > > > This is a sketch of what I've got: > > > > from Tkinter import * > > > > class App: > > def __init__(self, master): > > self.frame = Frame(master) > > self.frame.pack() > > ...etc... > > > > def main(): > > root = Tk() > > try: > > root.tk.call('console','hide') > > except TclError: > > pass > > app = App(root) > > root.mainloop() > > > > Should I put "self.tk.call('console','hide')" somewhere else in the code? > > > > Humbly, > > Jonathan > > I put the code in the __init__ method. > > What exactly is going on? > > -- > > > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > From kw at codebykevin.com Tue Mar 18 17:22:38 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 18 Mar 2008 12:22:38 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <111c9e510803180858p1ebf3b5fi6454e730416db494@mail.gmail.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> <47DFE4F9.3030401@codebykevin.com> <111c9e510803180858p1ebf3b5fi6454e730416db494@mail.gmail.com> Message-ID: <47DFEC4E.7060702@codebykevin.com> Jonathan Frankel wrote: > When I put this code (using self.tk... instead of root.tk...) in the > __init__ method I get an error: > > AttributeError: App instance has no attribute 'tk' > Here's my __init__ code: class phynchronicityApp(Tk): def __init__(self, parent): Tk.__init__(self, parent) try: self.tk.call('console', 'hide') except TclError: pass self.masterlist = [] self.makePrefsDir() self.registerHelpBook() self.makeImages() self.readPrefs() What version of OS X/Python/Tk are you using? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From overbyte at earthlink.net Sun Mar 16 01:51:03 2008 From: overbyte at earthlink.net (Stanley Sokolow) Date: Sat, 15 Mar 2008 17:51:03 -0700 (PDT) Subject: [Tkinter-discuss] WM_DELETE_WINDOW Message-ID: <16074408.post@talk.nabble.com> Here's a tip to help new Tkinter programmers avoid the trouble I had because of an error in Grayson's book "Python and Tkinter Programming" published by Manning. On page 309 the protocol methods are briefly explained, with an example: self.root.protocol(WM_DELETE_WINDOW, self.cleanup) This does not work. There is no error correction in the errata page on the Manning site for the book. I finally figured out that WM_DELETE_WINDOW is not a pre-defined constant like TOP, but rather should be a string in quotes. The correct way to invoke the protocol to intercept toplevel window closing is: self.root.protocol("WM_DELETE_WINDOW", self.cleanup) I wrote to Manning to have them add this to their errata, but just in case they don't do it, I wanted to post this correction note here for others to find. -- View this message in context: http://www.nabble.com/WM_DELETE_WINDOW-tp16074408p16074408.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jonathan at wikiterra.net Tue Mar 18 18:20:53 2008 From: jonathan at wikiterra.net (Jonathan Frankel) Date: Tue, 18 Mar 2008 13:20:53 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <47DFEC4E.7060702@codebykevin.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> <47DFE4F9.3030401@codebykevin.com> <111c9e510803180858p1ebf3b5fi6454e730416db494@mail.gmail.com> <47DFEC4E.7060702@codebykevin.com> Message-ID: <111c9e510803181020p67034878ibab14e3d3fc46fbe@mail.gmail.com> I'm on 10.4.11, and I just updated python to the most recent version, with the Tkinter that came with it. When I do this: class App(Tk): def __init__(self, parent): Tk.__init__(self, parent) try: self.tk.call('console','hide') except TclError: pass I get another error when I run it: ...., line 19, in __init__ Tk.__init__(self, parent) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", line 1636, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) TypeError: create() argument 1 must be string or None, not instance Is this related to how I'm instantiating my App object (app=App(root)) in the first place? On Tue, Mar 18, 2008 at 12:22 PM, Kevin Walzer wrote: > Jonathan Frankel wrote: > > When I put this code (using self.tk... instead of root.tk...) in the > > __init__ method I get an error: > > > > AttributeError: App instance has no attribute 'tk' > > > > Here's my __init__ code: > > class phynchronicityApp(Tk): > > def __init__(self, parent): > Tk.__init__(self, parent) > try: > > self.tk.call('console', 'hide') > except TclError: > pass > self.masterlist = [] > self.makePrefsDir() > self.registerHelpBook() > self.makeImages() > self.readPrefs() > > What version of OS X/Python/Tk are you using? > > -- > > > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > From kw at codebykevin.com Tue Mar 18 19:38:59 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 18 Mar 2008 14:38:59 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <111c9e510803181020p67034878ibab14e3d3fc46fbe@mail.gmail.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> <47DFE4F9.3030401@codebykevin.com> <111c9e510803180858p1ebf3b5fi6454e730416db494@mail.gmail.com> <47DFEC4E.7060702@codebykevin.com> <111c9e510803181020p67034878ibab14e3d3fc46fbe@mail.gmail.com> Message-ID: <47E00C43.1050307@codebykevin.com> Jonathan Frankel wrote: > I'm on 10.4.11, and I just updated python to the most recent version, > with the Tkinter that came with it. > > When I do this: > > > class App(Tk): > > def __init__(self, parent): > > Tk.__init__(self, parent) > > try: > self.tk.call('console','hide') > except TclError: > pass > > I get another error when I run it: > > > ...., line 19, in __init__ > Tk.__init__(self, parent) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", > line 1636, in __init__ > self.tk = _tkinter.create(screenName, baseName, className, > interactive, wantobjects, useTk, sync, use) > TypeError: create() argument 1 must be string or None, not instance > > > Is this related to how I'm instantiating my App object (app=App(root)) > in the first place? > Not sure. This works for me: from Tkinter import * class App(Tk): def __init__(self, parent): Tk.__init__(self, parent) try: self.tk.call('console','hide') except TclError, msg: print msg if __name__ == '__main__': app = App(None) app.mainloop() -- Kevin Walzer Code by Kevin http://www.codebykevin.com From jonathan at wikiterra.net Tue Mar 18 23:00:37 2008 From: jonathan at wikiterra.net (Jonathan Frankel) Date: Tue, 18 Mar 2008 18:00:37 -0400 Subject: [Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window In-Reply-To: <47E00C43.1050307@codebykevin.com> References: <111c9e510803180817k54add0afr3e492bd9a60e463e@mail.gmail.com> <47DFDE73.7010907@codebykevin.com> <111c9e510803180848i5f640782v5e3bf30686aa8406@mail.gmail.com> <47DFE4F9.3030401@codebykevin.com> <111c9e510803180858p1ebf3b5fi6454e730416db494@mail.gmail.com> <47DFEC4E.7060702@codebykevin.com> <111c9e510803181020p67034878ibab14e3d3fc46fbe@mail.gmail.com> <47E00C43.1050307@codebykevin.com> Message-ID: <111c9e510803181500o4b584d3ci45d08a304d453fa8@mail.gmail.com> Okay, so I was instantiating differently. But now...when I run that code (I'm running exactly what you posted), I get: invalid command name "console" inside the console, and the console stays open. If I do it without catching the error, I get the additional info: ... self.tk.call('console','hide') _tkinter.TclError: invalid command name "console" and the whole thing crashes. This happens both on OS X and WinXP... I can't even find which module this 'call' method originate from, so I can't find out how it works. Does anyone know about tk.call? On Tue, Mar 18, 2008 at 2:38 PM, Kevin Walzer wrote: > Jonathan Frankel wrote: > > I'm on 10.4.11, and I just updated python to the most recent version, > > with the Tkinter that came with it. > > > > When I do this: > > > > > > class App(Tk): > > > > def __init__(self, parent): > > > > Tk.__init__(self, parent) > > > > try: > > self.tk.call('console','hide') > > except TclError: > > pass > > > > I get another error when I run it: > > > > > > ...., line 19, in __init__ > > Tk.__init__(self, parent) > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", > > line 1636, in __init__ > > self.tk = _tkinter.create(screenName, baseName, className, > > interactive, wantobjects, useTk, sync, use) > > TypeError: create() argument 1 must be string or None, not instance > > > > > > Is this related to how I'm instantiating my App object (app=App(root)) > > in the first place? > > > > Not sure. > > This works for me: > > from Tkinter import * > > > class App(Tk): > > def __init__(self, parent): > > Tk.__init__(self, parent) > > try: > self.tk.call('console','hide') > except TclError, msg: > print msg > > if __name__ == '__main__': > app = App(None) > app.mainloop() > > > > > -- > > > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > From inhahe at gmail.com Wed Mar 19 02:19:51 2008 From: inhahe at gmail.com (inhahe) Date: Tue, 18 Mar 2008 21:19:51 -0400 Subject: [Tkinter-discuss] having trouble, newbie Message-ID: I'm trying to make a simple app in tkinter and am having two problems 1, i can't figure out how to put widgets in the top left of the main window. no matter what i try with row, column and sticky parameters it puts my buttons in the middle of the window. 2, i pass width=800 and height=600 to Frame.__init__ and my window still comes up tiny, just barely big enough for two buttons. oh, while i'm at it--how do I make it so when the the window is created it gets focus, like a ... real app? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080318/e952f1b9/attachment.htm From msa01 at bitflipper.ca Wed Mar 19 03:33:25 2008 From: msa01 at bitflipper.ca (Cam Farnell) Date: Tue, 18 Mar 2008 23:33:25 -0300 Subject: [Tkinter-discuss] having trouble, newbie In-Reply-To: References: Message-ID: <47E07B75.7010503@bitflipper.ca> 1) Use grid_columnconfigure and grid_rowconfigure to create a "dummy" extra row and column beyond the columns and rows you actually use and set weight to 1. The dummy row and column then soak up any extra space and the actual widgets float up the the top left. It took me a while to figure this out. Any column/row index greater than what you actually use will do. 2) Use geometry to set the window size. 3) use focus_set. There is good tkinter documentation at this URL: http://infohost.nmt.edu/tcc/help/pubs/tkinter/ although it doesn't tell you about the columnconfigure trick. Here's a simple example: from Tkinter import * Root = Tk() Root.geometry('640x480') Root.grid_rowconfigure(index=10,weight=1) Root.grid_columnconfigure(index=10,weight=1) BB = Button(text='HelloWorld') BB.focus_set() BB.grid() Root.mainloop() Cam Farnell inhahe wrote: > I'm trying to make a simple app in tkinter and am having two problems > > 1, i can't figure out how to put widgets in the top left of the main > window. no matter what i try with row, column and sticky parameters it > puts my buttons in the middle of the window. > 2, i pass width=800 and height=600 to Frame.__init__ and my window still > comes up tiny, just barely big enough for two buttons. > oh, while i'm at it--how do I make it so when the the window is created > it gets focus, like a ... real app? > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From inhahe at gmail.com Wed Mar 19 07:34:38 2008 From: inhahe at gmail.com (inhahe) Date: Wed, 19 Mar 2008 02:34:38 -0400 Subject: [Tkinter-discuss] help on event types Message-ID: I can't find a comprehensive list of tkinter event types.. http://infohost.nmt.edu/tcc/help/pubs/tkinter/event-types.html just says 'The full set of event types is rather large, but a lot of them are not commonly used. Here are most of the ones you'll need:' particularly what i want to do is have something happen when the text in a text box changes.. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080319/876ab48b/attachment.htm From brindly at gmail.com Wed Mar 19 08:34:17 2008 From: brindly at gmail.com (brindly sujith) Date: Wed, 19 Mar 2008 13:04:17 +0530 Subject: [Tkinter-discuss] how to search a directory from a Tkinter program Message-ID: hi i am developing an application in tkinter i want to know whether we have any option to search a directory from tkinter program please answer me thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080319/7bd5e0e1/attachment.htm From msa01 at bitflipper.ca Wed Mar 19 14:17:37 2008 From: msa01 at bitflipper.ca (Cam Farnell) Date: Wed, 19 Mar 2008 10:17:37 -0300 Subject: [Tkinter-discuss] how to search a directory from a Tkinter program In-Reply-To: References: Message-ID: <47E11271.8050707@bitflipper.ca> A good start would be to read the documentation for the Python "OS" module. Cam Farnell brindly sujith wrote: > hi > > i am developing an application in tkinter > > i want to know whether we have any option to search a directory from > tkinter program > > please answer me > > thank you > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From timj at tolisgroup.com Wed Mar 19 16:07:38 2008 From: timj at tolisgroup.com (Tim Jones) Date: Wed, 19 Mar 2008 08:07:38 -0700 Subject: [Tkinter-discuss] how to search a directory from a Tkinter program In-Reply-To: <47E11271.8050707@bitflipper.ca> References: <47E11271.8050707@bitflipper.ca> Message-ID: <5D1E9A24-E609-4405-BF11-965069F57E67@tolisgroup.com> On Mar 19, 2008, at 6:17 AM, Cam Farnell wrote: > A good start would be to read the documentation for the Python "OS" > module. And that seems to be the answer to ALL of Brindly's queries. That and the fact that he's somehow confused tkinter as a self-contained programming API, not realizing that the core answer to all of his questions is to learn to code in Python *first*. Tim > > Cam Farnell > > brindly sujith wrote: >> hi >> >> i am developing an application in tkinter >> >> i want to know whether we have any option to search a directory from >> tkinter program >> >> please answer me >> >> thank you >> >> >> --------------------------------------------------------------------- >> --- >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From timj at tolisgroup.com Wed Mar 19 16:22:11 2008 From: timj at tolisgroup.com (Tim Jones) Date: Wed, 19 Mar 2008 08:22:11 -0700 Subject: [Tkinter-discuss] how to search a directory from a Tkinter program In-Reply-To: References: Message-ID: On Mar 19, 2008, at 12:34 AM, brindly sujith wrote: > hi > > i am developing an application in tkinter > > i want to know whether we have any option to search a directory > from tkinter program > > please answer me Brindly, While many of us on the list would be glad to answer specific implementation questions, you really need to gain a basic understanding of Python and tkinter before you attack a full blown application. The questions that you continue to ask are nebulous and basically translate to "I need a Python/tkinter application. Will you write it for me?" In the time you've spent asking your questions, you could have delved into the various Python and tkinter resources and gotten answers to your questions and more - an understanding of how Python and tkinter actually work. I suggest that you start here: http://python.org/doc/ Then look at: http://www.pythonware.com/library/tkinter/introduction/ Work through the examples provided by both sites and learn the Python and tkinter APIs ad SDKs before you undertake an actual application. Once you have worked through those, you'll better understand what questions to ask when you run into real confusion - questions that we can actually answer. Tim -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080319/34610a36/attachment.htm From jonathan at wikiterra.net Wed Mar 19 19:56:49 2008 From: jonathan at wikiterra.net (Jonathan Frankel) Date: Wed, 19 Mar 2008 14:56:49 -0400 Subject: [Tkinter-discuss] Trying to hide console on Mac OS X Message-ID: <111c9e510803191156u1421d2d8pd3545a94a17bf008@mail.gmail.com> As per someone's suggestion, I'm using this code: ----- from Tkinter import * class App(Tk): def __init__(self, parent): Tk.__init__(self, parent) try: self.tk.call('console','hide') except TclError, msg: print msg if __name__ == '__main__': app = App(None) app.mainloop() ----- in order to hide the console. But it's not working for me. When I catch the error, the console stays open and says: ----- invalid command name "console" ----- When I don't catch the the error, it gives me: ----- self.tk.call('console','hide') _tkinter.TclError: invalid command name "console" ----- This happens on both OS X and Windows XP. On Windows I've simply changed the extension to .pyw and that works fine for hiding the console. But I'd like this to run on OS X as well. Does anyone have any suggestions? Thanks much Jonathan From Cameron at phaseit.net Thu Mar 20 14:20:12 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 20 Mar 2008 13:20:12 +0000 Subject: [Tkinter-discuss] help on event types In-Reply-To: References: Message-ID: <20080320132012.GA12197@lairds.us> On Wed, Mar 19, 2008 at 02:34:38AM -0400, inhahe wrote: . . . > I can't find a comprehensive list of tkinter event types.. > http://infohost.nmt.edu/tcc/help/pubs/tkinter/event-types.html just says > 'The full set of event types is rather large, but a lot of them are not > commonly used. Here are most of the ones you'll need:' > > particularly what i want to do is have something happen when the text in a > text box changes.. . . . Oh, *that*; much the most canonical way to deal with changes-in-the-text-of-a-text is to set a textvariable, and a trace on that textvariable. give pertinent examples. From inhahe at gmail.com Fri Mar 21 06:31:22 2008 From: inhahe at gmail.com (inhahe) Date: Fri, 21 Mar 2008 01:31:22 -0400 Subject: [Tkinter-discuss] relative grid locations Message-ID: let's say you wanted to specify the column and row of a control, but relative to where it would have been placed by default, instead of an absolute location. so like i could tell the grid to place a control where the previous control had been placed... or perhaps by retrieving the grid location of the previous control and using those coordinates. if there's a way to do this the tutorial i have doesn't say it, i think -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080321/59c3cbf4/attachment.htm From inhahe at gmail.com Sat Mar 22 05:12:17 2008 From: inhahe at gmail.com (inhahe) Date: Sat, 22 Mar 2008 00:12:17 -0400 Subject: [Tkinter-discuss] why isn't grid_propagate working? Message-ID: I want to create a bunch of widgets, icnluding a label widget, and i want them to be sized automatically upon creation. but when i change the text in the label widget, I don't want any of the widgets to be resized. i tried doing this by calling grid_propagate(0) on the label widget after it's created, and it still resizes. and actually it's a little more complicated than that, i call grid_remove() on it and then grid() on it again before it shows the changed text, but i tried doing that by calling grid(), then grid_propagate(0), then config() to change the text, so that shouldn't really make a difference.. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080322/79c5fcc1/attachment.htm From ron.longo at cox.net Sun Mar 23 18:20:11 2008 From: ron.longo at cox.net (Ron Provost) Date: Sun, 23 Mar 2008 13:20:11 -0400 Subject: [Tkinter-discuss] fgstipple on Text widget Message-ID: <000701c88d0a$27053060$6501a8c0@aristotle> I've been trying to figure out how to use the stipple options for the Text widget. I've gotten bgstipple to work simply enough. Figure that fgstipple should work just the same but instead it just seems to blank out the complete range of characters to which it's applied. Here's the code I've been experimenting with: from Tkinter import * root = Tk() t = Text(root) t.insert( END, '01234567890123456789' ) t.tag_add( 'x', '1.4', '1.12') t.tag_config( 'x', fgstipple='gray12' ) t.pack( ) root.mainloop() Does anyone know what I'm doing wrong or is this a bug in the widget? Ron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080323/eb0a75b6/attachment.htm From inhahe at gmail.com Mon Mar 24 08:17:03 2008 From: inhahe at gmail.com (inhahe) Date: Mon, 24 Mar 2008 03:17:03 -0400 Subject: [Tkinter-discuss] modal windows? Message-ID: How do I create modal windows in Tkinter? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080324/c12ebdf9/attachment.htm From ron.longo at cox.net Tue Mar 25 02:52:49 2008 From: ron.longo at cox.net (Ron Provost) Date: Mon, 24 Mar 2008 21:52:49 -0400 Subject: [Tkinter-discuss] New Full Tkinter document editor widget -- suggestions, comments, etc. Message-ID: <003301c88e1a$eea60250$6501a8c0@aristotle> I've posted a demo (http://tkinter.unpy.net/wiki/StyledEditor). This demo creates a widget with full "styled editing" capabilities; sort of a mini-word processor. It runs "as is" on my WinXP machine with Python 2.5. The demo allows styling of any selected text via toolbars; just select the text, then select the styling. Also included are buttons to save and retrieve all content and styling information (works for the small tests I've tried myself, not guaranteed bug-free). The actual widget wraps the Text widget to give greater freedom in the assignment of any single styling attribute to any region. This differs from the Text widget itself in that the Text widget does not allow you to individually assign a family, size, weight or slant with tag_config(). That is, for example, you can't simply apply 'bold' to some region of text. This demo was written quite quickly (I pounded it out over the weekend) so I'm sure it's full of bugs. Also in my desire to get something working quickly its API doesn't really work like a normal widget, so I guess this serves as more of a proof of concept than full-blown widget but the basic functionality is there. I'm presenting it here because I thought maybe others might have thoughts on how to improve it. API Notes: applyStyleAttribute( index1, index2, attributeName, attributeValue ) This method is is frontend to the business. attributeName and attributeValue may be any option accpeted by tag_config() of the Text widget along with appropriate value. There are also some ''new'' options: - 'family', attributeValue is a font family name - 'size', attributeValue is a font point size - 'weight', attributeValue is one of: 'normal', 'bold' - 'bold', attributeValue is a boolean (alternative to using 'weight') - 'slant', attributeValue is one of: 'roman', 'italic' - 'italic', attributeValue is boolean (alternative to using 'slant') Several previously existing options have some new values: 'spacing1', 'spacing2' and 'spacing3' may take 'None', 'Half Line', 'One Line' or 'Two Lines' in addition to any of the values acceptable by tag_config(). 'offset' may take 'normal', 'superscript' or 'subscript' in addition to any value acceptable by tag_config. Please download and try-out my demo (http://tkinter.unpy.net/wiki/StyledEditor). I'm anxious for suggestions and comments. Ron Longo From mkieverpy at tlink.de Tue Mar 25 12:57:50 2008 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Tue, 25 Mar 2008 11:57:50 -0000 Subject: [Tkinter-discuss] fgstipple on Text widget Message-ID: <20080325104635.302C0BAA7@mail.terralink.de> Hi Ron, >from Tkinter import * >root = Tk() >t = Text(root) >t.insert( END, '01234567890123456789' ) >t.tag_add( 'x', '1.4', '1.12') >t.tag_config( 'x', fgstipple='gray12' ) >t.pack( ) >root.mainloop() your code works fine for me. With 'grey12' the text is just hard to see. Retry with 'grey75'. For completeness: I'm on Linux, Python 2.4.1, tcl/tk 8.4.6 Cheers, Matthias Kievernagel (mkiever/at/web/dot/de) From longorh at npt.nuwc.navy.mil Tue Mar 25 12:24:00 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Tue, 25 Mar 2008 04:24:00 -0700 (PDT) Subject: [Tkinter-discuss] help on event types In-Reply-To: References: Message-ID: <16273903.post@talk.nabble.com> The text widget does not have a textvariable option. However, it does have a virtual event named '<>'. You can bind to this event, and you'll get a callback when the widget it modified. You'll only get the callback the first time that the widget is modified. If you want to get a callback every time the widget changes, then you'll have to reset the modified flag in your callback. inhahe wrote: > > I can't find a comprehensive list of tkinter event types.. > http://infohost.nmt.edu/tcc/help/pubs/tkinter/event-types.html just says > 'The full set of event types is rather large, but a lot of them are not > commonly used. Here are most of the ones you'll need:' > > particularly what i want to do is have something happen when the text in a > text box changes.. > > _______________________________________________ > 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/help-on-event-types-tp16137853p16273903.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From longorh at npt.nuwc.navy.mil Tue Mar 25 12:26:34 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Tue, 25 Mar 2008 04:26:34 -0700 (PDT) Subject: [Tkinter-discuss] help on event types In-Reply-To: References: Message-ID: <16273951.post@talk.nabble.com> BTW, I've in the process of constructing a document which is a comprehensive Tkinter reference. I have a section on events. It's mostly just notes right now, but it is complete. If you would like me to send you copy of the list send me your email address at ron.longo at cox.net. inhahe wrote: > > I can't find a comprehensive list of tkinter event types.. > http://infohost.nmt.edu/tcc/help/pubs/tkinter/event-types.html just says > 'The full set of event types is rather large, but a lot of them are not > commonly used. Here are most of the ones you'll need:' > > particularly what i want to do is have something happen when the text in a > text box changes.. > > _______________________________________________ > 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/help-on-event-types-tp16137853p16273951.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From longorh at npt.nuwc.navy.mil Tue Mar 25 14:32:31 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Tue, 25 Mar 2008 06:32:31 -0700 (PDT) Subject: [Tkinter-discuss] Code to dump widget info In-Reply-To: References: Message-ID: <16274775.post@talk.nabble.com> Jim, This is a great piece of code. Why don't you add it to the Python Cookbook? Ron Jim Kleckner-5 wrote: > > I'm posting this code snippet for others who might want a cheap > way to see into the widget methods/attributes/configure options. > > Cheers - Jim > > import Tkinter > > allWidgets = { > "Wm": Tkinter.Wm, > "Tk": Tkinter.Tk, > "Event": Tkinter.Event, > "Variable": Tkinter.Variable, > "StringVar": Tkinter.StringVar, > "IntVar": Tkinter.IntVar, > "DoubleVar": Tkinter.DoubleVar, > "BooleanVar": Tkinter.BooleanVar, > "Misc": Tkinter.Misc, > "CallWrapper": Tkinter.CallWrapper, > "Pack": Tkinter.Pack, > "Place": Tkinter.Place, > "Grid": Tkinter.Grid, > "BaseWidget": Tkinter.BaseWidget, > "Widget": Tkinter.Widget, > "Toplevel": Tkinter.Toplevel, > "Button": Tkinter.Button, > "Canvas": Tkinter.Canvas, > "Checkbutton": Tkinter.Checkbutton, > "Entry": Tkinter.Entry, > "Frame": Tkinter.Frame, > "Label": Tkinter.Label, > "Listbox": Tkinter.Listbox, > "Menu": Tkinter.Menu, > "Menubutton": Tkinter.Menubutton, > "Message": Tkinter.Message, > "Radiobutton": Tkinter.Radiobutton, > "Scale": Tkinter.Scale, > "Scrollbar": Tkinter.Scrollbar, > "Text": Tkinter.Text, > "_setit": Tkinter._setit, > "OptionMenu": Tkinter.OptionMenu, > "Image": Tkinter.Image, > "PhotoImage": Tkinter.PhotoImage, > "BitmapImage": Tkinter.BitmapImage, > "Spinbox": Tkinter.Spinbox, > "LabelFrame": Tkinter.LabelFrame, > "PanedWindow": Tkinter.PanedWindow, > "Studbutton": Tkinter.Studbutton, > "Tributton": Tkinter.Tributton, > } > > someWidgets = { > "Button": Tkinter.Button, > "Canvas": Tkinter.Canvas, > "Checkbutton": Tkinter.Checkbutton, > "Entry": Tkinter.Entry, > "Label": Tkinter.Label, > "Listbox": Tkinter.Listbox, > "Menu": Tkinter.Menu, > "Menubutton": Tkinter.Menubutton, > "Message": Tkinter.Message, > "Radiobutton": Tkinter.Radiobutton, > "Scrollbar": Tkinter.Scrollbar, > "Text": Tkinter.Text, > "Spinbox": Tkinter.Spinbox, > "LabelFrame": Tkinter.LabelFrame, > "PanedWindow": Tkinter.PanedWindow, > } > > if __name__ == '__main__': > kl = allWidgets.keys() > kl.sort() > for k in kl: > print "%s:" % k > instance = allWidgets[k] > # options = instance.configure() > options = instance.__dict__ > ol = options.keys() > ol.sort() > for o in ol: > print " %s\t%s" % (o, options[o]) > #for k in []: > print '\n##################\n' > kl = someWidgets.keys() > kl.sort() > root = Tkinter.Tk() > for k in kl: > print "%s:" % k > instance = someWidgets[k](root) > options = instance.configure() > # options = instance._configure() > ol = options.keys() > ol.sort() > for o in ol: > print " %s\t%s" % (o, options[o]) > > _______________________________________________ > 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/Code-to-dump-widget-info-tp15615447p16274775.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From longorh at npt.nuwc.navy.mil Tue Mar 25 15:47:02 2008 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Tue, 25 Mar 2008 07:47:02 -0700 (PDT) Subject: [Tkinter-discuss] New Full Tkinter document editor widget -- suggestions, comments, etc. In-Reply-To: <003301c88e1a$eea60250$6501a8c0@aristotle> References: <003301c88e1a$eea60250$6501a8c0@aristotle> Message-ID: <16275292.post@talk.nabble.com> I just wanted to clarify that the purpose of this widget is to simplify the presentation and generation of styled text to/from multiple formats. In particular I'm interested in targeting HTML, but I believe the widget will facilitate most formats. With the new applyStyleAttribute method, it is now possible to easily handle most of the basic styling tags, such as , and . Similarly, from a call to dump() it's very simple to generate HTML code. tagon and tagoff entries in the dump should correspond directly to opening and closing HTML tags. My second alpha release will contain user-defined styles, which set multiple style attributes. This will facilitate presentation and generation of tags like (those that modify several style attributes at once.). Once this is completed and fairly well debugged, I plan to work on various ways to present and generate some of the structured HTML objects. In particular, I'm interested in lists and tables. Ron Provost-2 wrote: > > I've posted a demo (http://tkinter.unpy.net/wiki/StyledEditor). This demo > creates a widget with full "styled editing" capabilities; sort of a > mini-word processor. It runs "as is" on my WinXP machine with Python 2.5. > The demo allows styling of any selected text via toolbars; just select the > text, then select the styling. Also included are buttons to save and > retrieve all content and styling information (works for the small tests > I've > tried myself, not guaranteed bug-free). > > The actual widget wraps the Text widget to give greater freedom in the > assignment of any single styling attribute to any region. This differs > from > the Text widget itself in that the Text widget does not allow you to > individually assign a family, size, weight or slant with tag_config(). > That > is, for example, you can't simply apply 'bold' to some region of text. > > This demo was written quite quickly (I pounded it out over the weekend) so > I'm sure it's full of bugs. Also in my desire to get something working > quickly its API doesn't really work like a normal widget, so I guess this > serves as more of a proof of concept than full-blown widget but the basic > functionality is there. I'm presenting it here because I thought maybe > others might have thoughts on how to improve it. > > API Notes: > > applyStyleAttribute( index1, index2, attributeName, attributeValue ) > > This method is is frontend to the business. attributeName and > attributeValue may be any option accpeted by tag_config() of the Text > widget > along with appropriate value. There are also some ''new'' options: > > - 'family', attributeValue is a font family name > - 'size', attributeValue is a font point size > - 'weight', attributeValue is one of: 'normal', 'bold' > - 'bold', attributeValue is a boolean (alternative to using 'weight') > - 'slant', attributeValue is one of: 'roman', 'italic' > - 'italic', attributeValue is boolean (alternative to using 'slant') > > Several previously existing options have some new values: > > 'spacing1', 'spacing2' and 'spacing3' may take 'None', 'Half Line', 'One > Line' or 'Two Lines' in addition to any of the values acceptable by > tag_config(). > > 'offset' may take 'normal', 'superscript' or 'subscript' in addition to > any > value acceptable by tag_config. > > Please download and try-out my demo > (http://tkinter.unpy.net/wiki/StyledEditor). I'm anxious for suggestions > and comments. > > Ron Longo > > _______________________________________________ > 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.-tp16266693p16275292.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From inhahe at gmail.com Tue Mar 25 22:49:12 2008 From: inhahe at gmail.com (inhahe) Date: Tue, 25 Mar 2008 17:49:12 -0400 Subject: [Tkinter-discuss] New Full Tkinter document editor widget -- suggestions, comments, etc. In-Reply-To: <003301c88e1a$eea60250$6501a8c0@aristotle> References: <003301c88e1a$eea60250$6501a8c0@aristotle> Message-ID: I downloaded StyledEditor just in case I ever need it. I was wondering, since you mentioned the possibility of implementing tables, how you would draw the lines.. because I'm making an app right now where I'd like to draw some lines between labels in a grid. I might need lines only vertically between labels, or vertically and horizontally between labels, or vertically and horizontally between labels and around the grid -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080325/b2200237/attachment.htm From michael.odonnell at uam.es Tue Mar 25 23:33:23 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 25 Mar 2008 23:33:23 +0100 Subject: [Tkinter-discuss] New Full Tkinter document editor widget --suggestions, comments, etc. In-Reply-To: References: <003301c88e1a$eea60250$6501a8c0@aristotle> Message-ID: <47e491110803251533g5b6d4a8eide043e034437df38@mail.gmail.com> > I was wondering, since you mentioned the possibility of implementing tables, > how you would draw the lines.. because I'm making an app right now where I'd > like to draw some lines between labels in a grid. I might need lines only > vertically between labels, or vertically and horizontally between labels, or > vertically and horizontally between labels and around the grid You can insert widgets into a Text widget. The table itself could be a Frame widget, with cells being Label widgets, aligned using grid manager. 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. Mick From inhahe at gmail.com Tue Mar 25 23:42:56 2008 From: inhahe at gmail.com (inhahe) Date: Tue, 25 Mar 2008 18:42:56 -0400 Subject: [Tkinter-discuss] How to catch when the root window closes? Message-ID: 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080325/77d59a3e/attachment.htm From inhahe at gmail.com Wed Mar 26 00:22:49 2008 From: inhahe at gmail.com (inhahe) Date: Tue, 25 Mar 2008 19:22:49 -0400 Subject: [Tkinter-discuss] How to catch when the root window closes? In-Reply-To: References: Message-ID: oh, duh, i just had to put something after root.mainloop() On Tue, Mar 25, 2008 at 6:42 PM, 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 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080325/7220afd6/attachment-0001.htm From michael.odonnell at uam.es Thu Mar 27 10:16:15 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 27 Mar 2008 10:16:15 +0100 Subject: [Tkinter-discuss] Catching clicks on the Maxinise button on MacOSX Message-ID: <47e491110803270216m18beb602qefc57dcbb5e54a12@mail.gmail.com> Dear all, Under MacOSX/TKinter, clicking on the "Maximise Button" in the titlebar does not maximise the window. Does anyone know how to catch this event, under windows, so that I can run my own window resizing routine? Mick From ron.longo at cox.net Sat Mar 29 21:26:41 2008 From: ron.longo at cox.net (Ron Provost) Date: Sat, 29 Mar 2008 16:26:41 -0400 Subject: [Tkinter-discuss] tkinter coordinates, conversion Message-ID: <000701c891db$3306ad00$6501a8c0@aristotle> Is there any way in tkinter to convert between coordinate systems? Specifically, I'm refering to the canvas. I'm getting x and y's back in mouse events and I would like to convert them back to inches 'i', centemeters 'c', millimeters 'm' or points 'p'. Which I wish to use to provided information back to the user. Thanks, Ron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080329/f700bdf8/attachment.htm From fredrik at pythonware.com Sun Mar 30 14:44:03 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 30 Mar 2008 14:44:03 +0200 Subject: [Tkinter-discuss] modal windows? In-Reply-To: References: Message-ID: inhahe wrote: > How do I create modal windows in Tkinter? use the "grab_set" method to route all user events to the modal window. see e.g. http://effbot.org/tkinterbook/tkinter-dialog-windows.htm From fredrik at pythonware.com Sun Mar 30 15:37:35 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 30 Mar 2008 15:37:35 +0200 Subject: [Tkinter-discuss] tkinter coordinates, conversion In-Reply-To: <000701c891db$3306ad00$6501a8c0@aristotle> References: <000701c891db$3306ad00$6501a8c0@aristotle> Message-ID: Ron Provost wrote: > Is there any way in tkinter to convert between coordinate systems? > Specifically, I'm refering to the canvas. I'm getting x and y's back in > mouse events and I would like to convert them back to inches 'i', > centemeters 'c', millimeters 'm' or points 'p'. use winfo_screenheight() and winfo_screenmmheight() to determine the pixel size, and use that to calculate "real-life" values. e.g. pixel_size = w.winfo_screenmmheight() / w.winfo_screenheight() ... x = x * pixel_size print x, "mm" print x/10.0, "cm" print x/25.4, "inches" print 72*x/25.4, "points" (untested) From alix.zhang at gmail.com Sun Mar 30 15:48:54 2008 From: alix.zhang at gmail.com (chenguang Zhang) Date: Sun, 30 Mar 2008 21:48:54 +0800 Subject: [Tkinter-discuss] How to use color in the canvas? Message-ID: <63becf890803300648k687cb117u783def19a9e70480@mail.gmail.com> Today I came across a problem when using tkinter for GUI programming. Question 1.How to use the canvas.item_configure() method, for example, if I want to change a line's color from red to blue, how to arrange the parameters? Question 2.Tkinter has a tkColorChooser and its return value is something like ((0, 255, 255), '#00ffff'), and I'm wondering how to use it. Normally the color used in function (like mycanvas.create_line(ax,ay,bx,by,fill=color)) is in words such as 'red' or 'gray', how could I make the program recognize the numbers? Question 3. Suppose there are several separate lines in my canvas, all are created in one single function like 'createThings()'. What should I do so that when I choose a color from the tkColorChoose, all of them change their colors, like all change from red to ((0, 255, 255), '#00ffff')? It seems I can place a color parameter in the function createThings() and any functions inside it(create_line, create_oval and so on) take this parameter as the color to fill, but how to change the color parameter then? How can it be accessed and modified by other function(something like ChangeColor)?You don't need to answer this step be step, just some tips for the essentials would be enough. Any help would be appreciated! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080330/b1370277/attachment.htm From fredrik at pythonware.com Sun Mar 30 17:34:15 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 30 Mar 2008 17:34:15 +0200 Subject: [Tkinter-discuss] How to use color in the canvas? In-Reply-To: <63becf890803300648k687cb117u783def19a9e70480@mail.gmail.com> References: <63becf890803300648k687cb117u783def19a9e70480@mail.gmail.com> Message-ID: chenguang Zhang wrote: > Question 1.How to use the canvas.item_configure() method, for example, > if I want to change a line's color from red to blue, how to arrange the > parameters? Use the fill or outline option, just as you do when creating new items. > Question 2.Tkinter has a tkColorChooser and its return value is > something like ((0, 255, 255), '#00ffff'), and I'm wondering how to use > it. Normally the color used in function (like > mycanvas.create_line(ax,ay,bx,by,fill=color)) is in words such as 'red' > or 'gray', how could I make the program recognize the numbers? the "#rrggbb" form can be used everywhere Tkinter expects a colour name: http://effbot.org/tkinterbook/tkinter-widget-styling.htm#rgb-syntax so you can just pass in the second part of the chooser's return value. > Question 3. Suppose there are several separate lines in my canvas, all > are created in one single function like 'createThings()'. What should I > do so that when I choose a color from the tkColorChoose, all of them > change their colors, like all change from red to ((0, 255, 255), > '#00ffff')? use tags: http://effbot.org/tkinterbook/canvas.htm#item-specifiers From fredrik at pythonware.com Sun Mar 30 17:40:15 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 30 Mar 2008 17:40:15 +0200 Subject: [Tkinter-discuss] New Full Tkinter document editor widget --suggestions, comments, etc. In-Reply-To: <47e491110803251533g5b6d4a8eide043e034437df38@mail.gmail.com> References: <003301c88e1a$eea60250$6501a8c0@aristotle> <47e491110803251533g5b6d4a8eide043e034437df38@mail.gmail.com> Message-ID: 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 ;-) From klappnase at web.de Sun Mar 30 19:22:07 2008 From: klappnase at web.de (Michael Lange) Date: Sun, 30 Mar 2008 19:22:07 +0200 Subject: [Tkinter-discuss] tkinter coordinates, conversion In-Reply-To: References: <000701c891db$3306ad00$6501a8c0@aristotle> Message-ID: <20080330192207.7cb3cd49.klappnase@web.de> On Sun, 30 Mar 2008 15:37:35 +0200 Fredrik Lundh wrote: > Ron Provost wrote: > > > Is there any way in tkinter to convert between coordinate systems? > > Specifically, I'm refering to the canvas. I'm getting x and y's back in > > mouse events and I would like to convert them back to inches 'i', > > centemeters 'c', millimeters 'm' or points 'p'. > > use winfo_screenheight() and winfo_screenmmheight() to determine the > pixel size, and use that to calculate "real-life" values. e.g. > > pixel_size = w.winfo_screenmmheight() / w.winfo_screenheight() > > ... > > x = x * pixel_size > print x, "mm" > print x/10.0, "cm" > print x/25.4, "inches" > print 72*x/25.4, "points" > You should be aware however that the values reported by winfo_screenmmheight() and winfo_screenmmwidth() may be incorrect; I think this is because tk assumes a screen dpi value of 72 which may be different from what the system actually uses. For example my debian etch system uses a dpi value of 96 by default, so when I call w.winfo_screenmmheight() tk returns 203 where the actual value should be 203 * (96 / 72) = 270 . You can query the dpi value in use with w.winfo_fpixels('1i') which returns on my box: 95.976383763837632 You can even force tk to use a dpi value different from the system default: w.tk.call('tk', 'scaling', '-displayof', '.', your_dpi_value / 72.0) which may be useful if you want to make sure that for example some Canvas items are drawn in an exact mm-size onto the user's screen (however be careful, doing so might mess up the application's visual appearance on some systems, especially using point-sized fonts should be avoided). Hope this helps Michael