From kmmcdonald at wisc.edu Thu Apr 1 19:02:10 2004 From: kmmcdonald at wisc.edu (Kenneth McDonald) Date: Thu Apr 1 19:02:19 2004 Subject: [Tkinter-discuss] How to do things before Tk window creation --or--, how to perform initial window initialization correctly ? Message-ID: This came about as a result of the following specific problem, but is something I've been wondering about for a while. There seem to be some Tk things which don't (or shouldn't) require an actual Tk widget instance of some sort in order to actually call them. The 'bind' command is what's giving me problems right now. According to the Tk docs (if I am reading them correctly), bind creates sets of event/script pairs associated with a string (and associated with a widget if the widget happens to have the same name as that string) I'd like to predefine some sets of bindings, which I can then apply to widgets as desired. However, I just can't figure out how to call this without using a widget! I've looked through Tkinter and tried various things (for example, calling Misc.bind(...)), but of course, Misc.bind wants an instance of Misc as its first argument.) I've tried to figure out some of the things Tkinter does internally to get around these problems, in particular it seems to create a _default_root. However, it apparently does this _after_ I try to create my binding sets (I know not when), and in any case, using _default_root strikes me as a dodgy way of doing things. More generally, what is the "best" Tkinter way to call Tk functions which aren't actually associated with specific widgets. Does Tk need to create some sort of root widget before _any_ of its functions can be called? And if so, is there a reasonably standard way of doing this without creating extraneous windows on the screen, or causing problems to Tkinter programmers who might not realize there is a "special" widget floating around. Thanks, Ken McDonald From cybermanxu at hotmail.com Thu Apr 1 22:29:48 2004 From: cybermanxu at hotmail.com (Jinming Xu) Date: Thu Apr 1 22:29:52 2004 Subject: [Tkinter-discuss] Embedding compilation problems after installing Tkinter modules on RedHat Linux Message-ID: Dear Sirs, I am having a problem resulted from Tkinter. I installed Python 2.3 on my PC, running RedHat Linux 9. Before installing the Tkinter module, that is, Python was installed with the Module/Setup file untouched, I was able to compile the embedding example at Demo/embed. But after installing the Tkinter module, that is, uncommenting the options relevant to Tkinter in Module/Setup and installing Python again, I was unable to compile the embedding example at Demo/embed. There were a bunch of errors while attempting to compile the c code: ../../libpython2.3.a(_tkinter.o)(.text+0x10c):Modules/_tkinter.c:463: undefined reference to `Tcl_Free' ../../libpython2.3.a(_tkinter.o)(.text+0x122):Modules/_tkinter.c:465: undefined reference to `Tcl_Free' ../../libpython2.3.a(_tkinter.o)(.text+0x165):Modules/_tkinter.c:460: undefined reference to `Tcl_Free' ../../libpython2.3.a(_tkinter.o)(.text+0x22e):Modules/_tkinter.c:425: undefined reference to `Tcl_Alloc' ../../libpython2.3.a(_tkinter.o)(.text+0x23c):Modules/_tkinter.c:426: undefined reference to `Tcl_Alloc' ../../libpython2.3.a(_tkinter.o)(.text+0x2bb): In function `Split': Modules/_tkinter.c:485: undefined reference to `Tcl_SplitList' ../../libpython2.3.a(_tkinter.o)(.text+0x2fa):Modules/_tkinter.c:510: undefined reference to `Tcl_Free' Since these errors didn't appear before the installation of Tkinter, I think this may indirectly caused by Tkinter. Is Tkinter incompatible with embedding or any thing else? Any answer or suggestion regarding this is well appreciated! Thanks a lot! Jinming Xu _________________________________________________________________ MSN Toolbar provides one-click access to Hotmail from any Web page – FREE download! http://toolbar.msn.com/go/onm00200413ave/direct/01/ From jepler at unpythonic.net Fri Apr 2 09:29:28 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Fri Apr 2 09:29:34 2004 Subject: [Tkinter-discuss] How to do things before Tk window creation --or--, how to perform initial window initialization correctly ? In-Reply-To: References: Message-ID: <20040402142927.GG20484@unpythonic.net> You can create your Tk application and immediately withdraw the main window. Something like this: t = Tkinter.Tk() t.wm_withdraw() # other setup here t.wm_deiconify() t.raise() t.mainloop() On the other hand, you should be able to run code between creation of Tk() and t.mainloop during which time no window is shown (I tested this on Unix only): import Tkinter, time t = Tkinter.Tk() print "created" time.sleep(1) print "done with setup" t.mainloop() ... the window doesn't appear until after "done with setup" is printed. You can make calls like 't.bind_class()' instead of calling sleep. If you make calls like 't.update_idletasks()', though, the window will appear. Jeff From jepler at unpythonic.net Fri Apr 2 09:50:22 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Fri Apr 2 09:50:31 2004 Subject: [Tkinter-discuss] Embedding compilation problems after installing Tkinter modules on RedHat Linux In-Reply-To: References: Message-ID: <20040402145021.GH20484@unpythonic.net> If you have built the _tkinter module into libpython, you must link with additional libraries. This probably means something like '-L/usr/X11R6/lib -ltcl8.3 -ltk8.3 -lX11'. Jeff From cybermanxu at hotmail.com Fri Apr 2 10:13:59 2004 From: cybermanxu at hotmail.com (Jinming Xu) Date: Fri Apr 2 10:14:03 2004 Subject: [Tkinter-discuss] Embedding compilation problems after installing Tkinter mo Message-ID: Dear Jeff, Thanks for your reply. Yes, I linked those additional libraries by uncommenting relevant linking options in Module/Setup. My Tkinter is running smoothly. The trouble is that embedding programs are in trouble after installing Tkinter modules. Can you compile the embeding example at Demo/embed directory successfully? Thanks again for your help! Jinming >From: Jeff Epler >To: Jinming Xu >CC: tkinter-discuss@python.org >Subject: Re: [Tkinter-discuss] Embedding compilation problems after >installing Tkinter modules on RedHat Linux >Date: Fri, 2 Apr 2004 08:50:22 -0600 > >If you have built the _tkinter module into libpython, you must link >with additional libraries. This probably means something like >'-L/usr/X11R6/lib -ltcl8.3 -ltk8.3 -lX11'. > >Jeff _________________________________________________________________ Free up your inbox with MSN Hotmail Extra Storage! Multiple plans available. http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1/go/onm00200362ave/direct/01/ From jepler at unpythonic.net Fri Apr 2 14:29:30 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Fri Apr 2 14:29:36 2004 Subject: [Tkinter-discuss] Embedding compilation problems after installing Tkinter mo In-Reply-To: References: Message-ID: <20040402192930.GA11343@unpythonic.net> Yes, it works just fine when I link in the libs required by _tkinter, which is exactly what I intended to suggest in my earlier message. I made this change to Demo/embed/Makefile: --- Demo/embed/Makefile 25 Jul 2002 16:23:21 -0000 1.12 +++ Demo/embed/Makefile 2 Apr 2004 19:20:32 -0000 @@ -22,7 +22,8 @@ LIBPYTHON= $(blddir)/libpython$(VERSION).a # XXX edit LIBS (in particular) to match $(blddir)/Modules/Makefile -LIBS= -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil +LIBS= -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil \ + -L/usr/X11R6/lib -ltcl8.3 -ltk8.3 -lX11 LDFLAGS= -Xlinker -export-dynamic SYSLIBS= -lm MODLIBS= $ make demo gcc -g -I../../Include -I../.. -c -o demo.o demo.c gcc -Xlinker -export-dynamic demo.o ../../libpython2.4.a -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil -L/usr/X11R6/lib -ltcl8.3 -ltk8.3 -lX11 -lm -o demo ../../libpython2.4.a(posixmodule.o)(.text+0x3628): In function `posix_tmpnam': Modules/posixmodule.c:5873: the use of `tmpnam' is dangerous, better use `mkstemp' ../../libpython2.4.a(posixmodule.o)(.text+0x359a): In function `posix_tempnam': Modules/posixmodule.c:5826: the use of `tempnam' is dangerous, better use `mkstemp' $ ./demo Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import site' failed; use -v for traceback Hello, brave new world ('__builtin__', '__main__', '_codecs', '_sre', '_symtable', '_tkinter', 'errno', 'exceptions', 'gc', 'imp', 'marshal', 'posix', 'signal', 'sys', 'xxsubtype', 'zipimport') ['zipimport', 'signal', '__builtin__', 'sys', '__main__', 'exceptions', 'xyzzy'] /usr/src/python/dist/src/Demo/embed/demo ['./demo'] Goodbye, cruel world Jeff From cybermanxu at hotmail.com Fri Apr 2 15:57:56 2004 From: cybermanxu at hotmail.com (Jinming Xu) Date: Fri Apr 2 15:58:00 2004 Subject: [Tkinter-discuss] Embedding compilation problems after installing Tkinter mo Message-ID: Dear Jeff, It works now after following what you said. I thought I didn't need to change to default makefile for Demo. //blush. By the way, why should we do this. It seems the demo actully doesn't used those additional libraries. Isn't it? Thanks a lot and I really appreciate it! Have a good weekend! Jinming _________________________________________________________________ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 From kmmcdonald at wisc.edu Sat Apr 3 18:45:27 2004 From: kmmcdonald at wisc.edu (Kenneth McDonald) Date: Sat Apr 3 19:51:18 2004 Subject: [Tkinter-discuss] A function to allow easier use of gridding in Tk widgets. Message-ID: I poked around in Tkinter, but couldn't find a way to make use of Tk's ability to specify grid layouts in a formatted way which gives a sort of a textual visual representation of the actual layout. Here's a little function which does this. Sorry, at the moment everything is inserted with sticky='news', and you still have to do column/row weighting the old way. I haven't used this much, so be on the lookout for bugs. Ken ------------------------------- def grid(specs, sticky='news', widget=None): ''' Function to allow easy use of Tk's formatted gridding specification. Example: ... title=Label(self, text='Title', background='lightgray', justify='left', relief='groove') itext = Text(self, width=width) itext.configure(yscrollcommand=hscroll.set, xscrollcommand=vscroll.set) vscroll.configure(command=itext.xview) hscroll.configure(command=itext.yview) grid([ [title, '-' ], [itext, vscroll ], [hscroll, '^' ] ]) ... results in a title occupying row 0, columns 0-1; a text object in row=1, column=0; a horizontal scrollbar in row=2, col=0; and a vertical scrollbar in rows=1-2, col=1. '-' indicates carry cell in previous column into this column, '^' indicates carry call in previous row into this row. 'x' can be used to indicate a grid cell that should be left empty. See the Tk 'grid' man page for more details. ''' # If we aren't passed a widget via which to call # from tk, we need to find one. The only reason # to pass in a widget is efficiency, and I doubt # that it would make any perceptible difference # anyway. tk = None if widget==None: for row in specs: for cell in row: if type(cell) != type(""): tk = cell.tk break if tk: break else: tk=widget.tk for row in specs: tkrow = [] for cell in row: if cell=='-' or cell=='^' or cell=='x': tkrow.append(cell) else: tkrow.append(cell._w) if sticky: tkrow.append('-sticky') tkrow.append(sticky) tk.call('grid', *tkrow) From stewart at midtoad.homelinux.org Sat Apr 3 20:19:53 2004 From: stewart at midtoad.homelinux.org (Stewart Midwinter) Date: Sat Apr 3 20:22:51 2004 Subject: [Tkinter-discuss] A function to allow easier use of gridding in Tk widgets. In-Reply-To: References: Message-ID: <20040403181953.65da3d81@pc-00065.midtoad.homelinux.org> On Sat, 03 Apr 2004 17:45:27 -0600 Kenneth McDonald spake thusly: > def grid(specs, sticky='news', widget=None): > ''' > Function to allow easy use of Tk's formatted gridding specification. would you happen to have a little app that makes use of your grid function so we can see how it works? thanks, -- Stewart Midwinter Tkintern newbie running on Mandrake Linux 10.0 e-mail: Stewart 'at' Midwinter.ca, stewart 'at' midtoad.homelinux.org web: http://www.midwinter.ca, http://midtoad.homelinux.org voice: +1.403.714.4329 PGP key:http://www.keyserver.net Umwelt schuetzen, Rad benuetzen! From fredrik at pythonware.com Sun Apr 4 17:25:21 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun Apr 4 18:00:30 2004 Subject: [Tkinter-discuss] Re: Embedding compilation problems after installingTkinter mo References: Message-ID: Jinming Xu wrote: > It works now after following what you said. I thought I didn't need to > change to default makefile for Demo. //blush. By the way, why should we do > this. It seems the demo actully doesn't used those additional libraries. > Isn't it? Jeff already explained this: if _tkinter is statically linked to libpython, you need to link with the tcl and tk libraries everywhere you're using libpython. (if this is the case, sys.builtin_module_names contains the string "_tkinter", and there's no "_tkinter.so" in your Python build directory) From kmmcdonald at wisc.edu Wed Apr 7 02:56:08 2004 From: kmmcdonald at wisc.edu (Kenneth McDonald) Date: Wed Apr 7 02:56:14 2004 Subject: [Tkinter-discuss] Graphing packages for Tkinter Message-ID: Given that there is no evidence that BLT's graph widget will be available on Mac OS X anytime soon (I might have a shot, but doubt I could do it), could anyone recommend a nice graphing widget that wraps a Canvas in a Python library? Thanks, Ken From clnethery at juno.com Wed Apr 14 19:29:22 2004 From: clnethery at juno.com (Lisa Nethery) Date: Wed Apr 14 19:22:18 2004 Subject: [Tkinter-discuss] Graying out and disabling widgets that are not selected Message-ID: <000801c42278$52d57fc0$d893e404@DCSMRF01> Hi everyone, I have a problem which, while probably simple for most of you, I am having a hard time figuring out. For the sake of argument, let's say that I create an entry field and two comboboxes. I want the application to gray-out and disable the two comboboxes if typing occurs in the entry field. Likewise, if an item is selected from one of the comboboxes, I want to gray-out and disable the entry field and the other combobox. Any ideas? Thanking you in advance, Christopher Nethery -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20040414/e0655711/attachment.html From PeterM at resmed.com.au Wed Apr 14 19:57:52 2004 From: PeterM at resmed.com.au (Peter Milliken) Date: Wed Apr 14 19:57:58 2004 Subject: [Tkinter-discuss] Graying out and disabling widgets that are not selected Message-ID: <274A369893F5FB4099345F006439D987013878B8@bella.corp.resmed.org> I have done something similar in an application (broadly speaking of course :-)). I used Pmw for my application but the same should be true of using tkinter elements (I find that Pmw provides a very nice model when it comes to controlling and using groupings of GUI elements - 'configuration' of them (assuming you create classes that inherit from Pmw.MegaWidget) becomes very flexible and powerful as it fits right in which the OO model). Create a class which "manages" the display elements. Have the action events of each GUI element point to a different method of the class and make the appropriate actions in that method to control which elements are "grayed out" and which aren't. Peter -----Original Message----- From: Lisa Nethery [mailto:clnethery@juno.com] Sent: Thursday, April 15, 2004 9:29 AM To: tkinter-discuss@python.org Subject: [Tkinter-discuss] Graying out and disabling widgets that are not selected Hi everyone, I have a problem which, while probably simple for most of you, I am having a hard time figuring out. For the sake of argument, let's say that I create an entry field and two comboboxes. I want the application to gray-out and disable the two comboboxes if typing occurs in the entry field. Likewise, if an item is selected from one of the comboboxes, I want to gray-out and disable the entry field and the other combobox. Any ideas? Thanking you in advance, Christopher Nethery Warning: Copyright ResMed. Where the contents of this email and/or attachment includes materials prepared by ResMed, the use of those materials is subject exclusively to the conditions of engagement between ResMed and the intended recipient. This communication is confidential and may contain legally privileged information. By the use of email over the Internet or other communication systems, ResMed is not waiving either confidentiality of, or legal privilege in,the content of the email and of any attachments. If the recipient of this message is not the intended addressee, please call ResMed immediately on +61 2 9886 5000 Sydney, Australia. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20040415/ea03baef/attachment.html From jepler at unpythonic.net Wed Apr 14 20:57:45 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Wed Apr 14 20:58:32 2004 Subject: [Tkinter-discuss] Graying out and disabling widgets that are not selected In-Reply-To: <000801c42278$52d57fc0$d893e404@DCSMRF01> References: <000801c42278$52d57fc0$d893e404@DCSMRF01> Message-ID: <20040415005745.GB13706@unpythonic.net> Let me for a moment take the role of a naysayer. If something in your program's user interface isn't seen in standard applications, and it takes a paragraph to explain, it's probably not a good idea. The behavior you describe doesn't say how to get back to the state where another of the 3 items can be chosen, after the user first interacts with one of the widgets. In today's user interfaces, the standard way to choose among alternatives is the radiobutton. In fact, this reminds me of the proxy settings dialog in various incarnations of Netscape and Mozilla. In this setup, three radiobuttons control the state of a number of other widgets which are grouped below the radiobutton that enables them. You can see a screenshot of this screen at http://texturizer.net/firefox/options.html#connection The radiobuttons offer a clear solution to both problems I posed: There is a clear way to "undo" the selection of a particular widget, and there is a clear visual relationship between the radiobuttons and the widgets they control. I'm not convinced this is a *great* solution, but the strange thing about sins of user interface design is that they're less sinful the more frequent they are. If you use this approach, you can either use the command= of the radiobuttons to enable and disable the other widgets, or you can use an IntVar and trace_variable so you get a callback when the value is changed. Jeff From fredrik at pythonware.com Thu Apr 15 12:05:31 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Apr 15 12:06:52 2004 Subject: [Tkinter-discuss] Re: Graphing packages for Tkinter References: Message-ID: Kenneth McDonald wrote: > Given that there is no evidence that BLT's graph widget will be > available on Mac OS X anytime soon (I might have a shot, but > doubt I could do it), could anyone recommend a nice graphing > widget that wraps a Canvas in a Python library? what specific requirements do you have? - graph types - is print support required? - mac only, or other platforms required? - can you build C extensions for your target platform(s), or do you need a pure Python extension? (or ready-made packages for all platforms) From fredrik at pythonware.com Thu Apr 15 12:16:34 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Apr 15 12:17:31 2004 Subject: [Tkinter-discuss] Re: Tools for summarizing a module? References: Message-ID: Kenneth McDonald wrote: > Before I start any documentation effort on Tkinter, I'd like to get > a good idea of what's in there right now. Is there a good tool > that will go through a module, and print out, in summary form, > its functions, classes, methods, etc., with docstrings if present? "pythondoc -f -x" generates an XML description of any Python module: http://effbot.org/zone/pythondoc.htm if you know how to manipulate XML files, turning that XML into a stub module should be pretty easy. for bonus points, make your stub generator into a pythondoc output formatter: http://effbot.org/zone/pythondoc-plugins.htm From FBatista at uniFON.com.ar Thu Apr 15 13:14:20 2004 From: FBatista at uniFON.com.ar (Batista, Facundo) Date: Thu Apr 15 13:16:55 2004 Subject: [Tkinter-discuss] Listbox selection issue Message-ID: Hi, I set up a ListBox. When it appears, it gets the first item selected. With selected I mean that its line is colored. I want the user to have to double click to change the selection. So I binded double-click to a function. That's ok. But I want that if the user just click in other item, that item don't get selected/colored. I implemented something this: self.listbox.bind("", self.noIr) self.listbox.select_set(0) ... def noIr(self, evento): print self.listbox.curselection() sel = self.listbox.curselection() sel = int(sel[0]) self.listbox.select_set(sel) print self.listbox.curselection() return The prints are for debug only. With the second one, I see that the selection didn't change. but another item is colored!! I think I'm have a terminology problem, please explain it to me if I'm wrong. Thank you! . Facundo From klappnase at web.de Thu Apr 15 19:05:51 2004 From: klappnase at web.de (Michael Lange) Date: Thu Apr 15 19:06:42 2004 Subject: [Tkinter-discuss] Listbox selection issue In-Reply-To: References: Message-ID: <20040416010551.77967fe7.klappnase@web.de> On Thu, 15 Apr 2004 14:14:20 -0300 "Batista, Facundo" wrote: > Hi, > > I set up a ListBox. When it appears, it gets the first item selected. With > selected I mean that its line is colored. > > I want the user to have to double click to change the selection. So I binded > double-click to a function. That's ok. > > But I want that if the user just click in other item, that item don't get > selected/colored. > > I implemented something this: > > self.listbox.bind("", self.noIr) > self.listbox.select_set(0) > ... > > def noIr(self, evento): > print self.listbox.curselection() > sel = self.listbox.curselection() > sel = int(sel[0]) > self.listbox.select_set(sel) > print self.listbox.curselection() > return > > > The prints are for debug only. With the second one, I see that the selection > didn't change. but another item is colored!! > > I think I'm have a terminology problem, please explain it to me if I'm > wrong. > > Thank you! > > . Facundo > I havent't tried this, but it sounds like the "print self.listbox.curselection()" at the end of your noIr() method doesn'treturn the item that is colored on the screen, maybe calling self.listbox.update_idletasks() at the end of noIr() would fix this; anyway, I think a method that would do what you actually want might look like this: ... self.listbox.bind("", self.noIr) ... def noIr(self, evento): '''Dummy function to stop a mouse-click from selecting a listbox item.''' return "break" I hope this helps Michael From fredrik at pythonware.com Fri Apr 16 05:16:24 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri Apr 16 05:16:14 2004 Subject: [Tkinter-discuss] ANN: updated reference pages Message-ID: Just fyi, I've updated the reference pages in the effbot.org draft edition of my "an introduction to tkinter". This includes documentation for the new Spinbox, LabelFrame and PanedWindow widgets. http://effbot.org/zone/tkinter-toc.htm (under "class references") From FBatista at uniFON.com.ar Fri Apr 16 08:29:15 2004 From: FBatista at uniFON.com.ar (Batista, Facundo) Date: Fri Apr 16 08:31:25 2004 Subject: [Tkinter-discuss] Listbox selection issue Message-ID: #- #- ... #- self.listbox.bind("", self.noIr) #- ... #- #- def noIr(self, evento): #- '''Dummy function to stop a mouse-click from selecting #- a listbox item.''' #- return "break" #- #- I hope this helps No. Was told about this out-of-list. The issue is this ways neither works double-click. . Facundo From kmmcdonald at wisc.edu Fri Apr 16 16:56:12 2004 From: kmmcdonald at wisc.edu (Kenneth McDonald) Date: Fri Apr 16 17:53:45 2004 Subject: [Tkinter-discuss] Re: Graphing package for Tkinter? In-Reply-To: References: Message-ID: <7EBB8AB8-8FE8-11D8-B923-000A956870AC@wisc.edu> On Apr 16, 2004, at 11:04 AM, tkinter-discuss-request@python.org wrote: >> Given that there is no evidence that BLT's graph widget will be >> available on Mac OS X anytime soon (I might have a shot, but >> doubt I could do it), could anyone recommend a nice graphing >> widget that wraps a Canvas in a Python library? > > what specific requirements do you have? > > - graph types > - is print support required? > - mac only, or other platforms required? > - can you build C extensions for your target platform(s), or > do you need a pure Python extension? (or ready-made > packages for all platforms) As it turns out, some kind soul sent me a BLT package hacked so that the graph works under OS X. However, this is an interesting enough topic to me that I'm still curious as to what other options might exist. Fred put up a good list of questions, so here are the answers: 1) My main need is to support i) both log and linear scales, ii) overlaying multiple graphs (i.e. with potentially different y-axes). Of course, I need standard things such as being able to label axes, etc., but not much else in the way of special needs. 2) Print support is always nice, but is not required. 3) Crossplatform support (or at least potential) is highly desirable. 4) C extensions are fine. If an extension has a decent set of makefiles, I can generally get it to compile, but not always--I still have no idea if Qt and PyKDE are actually correctly installed on my system or not :-) Thanks, Ken From fredrik at pythonware.com Sat Apr 17 11:22:14 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat Apr 17 11:22:00 2004 Subject: [Tkinter-discuss] Re: Graphing package for Tkinter? References: <7EBB8AB8-8FE8-11D8-B923-000A956870AC@wisc.edu> Message-ID: Kenneth McDonald wrote: > As it turns out, some kind soul sent me a BLT package hacked > so that the graph works under OS X. However, this is an interesting > enough topic to me that I'm still curious as to what other options > might exist. Fred put up a good list of questions, so here are the > answers: I spent an hour (and a little more) whipping up the following little package: http://www.effbot.org/zone/wckgraph.htm it's far from complete, and mostly untested, but it addresses most of your requirements: > 1) My main need is to support i) both log and linear scales, > ii) overlaying multiple graphs (i.e. with potentially different > y-axes). Of course, I need standard things such as being able > to label axes, etc., but not much else in the way of special > needs. the first release supports multiple line graphs (with optional markers). you can use different extents (and axes) for different layers, but the current version always draws the Y axis to the left, so that may look a bit strange... and no, log scales are not yet supported. shouldn't be very hard to add, though. > 2) Print support is always nice, but is not required. not yet supported. > 3) Crossplatform support (or at least potential) is highly > desirable. works everywhere you can run Tkinter. > 4) C extensions are fine. If an extension has a decent > set of makefiles, I can generally get it to compile, but not > always--I still have no idea if Qt and PyKDE are actually > correctly installed on my system or not :-) you need to build the Tkinter WCK to use it, but that should work almost everywhere (may need some slight tweaking to find your Tcl/Tk libraries; see setup.py for details). if anyone's interested, feel free to play with the code (see the above link for pointers), and let me know what I should add next... From klappnase at web.de Sat Apr 17 19:03:04 2004 From: klappnase at web.de (Michael Lange) Date: Sat Apr 17 19:03:55 2004 Subject: [Tkinter-discuss] Listbox selection issue In-Reply-To: References: Message-ID: <20040418010304.66103545.klappnase@web.de> On Fri, 16 Apr 2004 09:29:15 -0300 "Batista, Facundo" wrote: > #- > #- ... > #- self.listbox.bind("", self.noIr) > #- ... > #- > #- def noIr(self, evento): > #- '''Dummy function to stop a mouse-click from selecting > #- a listbox item.''' > #- return "break" > #- > #- I hope this helps > > No. Was told about this out-of-list. The issue is this ways neither works > double-click. > > . Facundo > I can hardly believe that, I wrote a little test app and double clicking works fine here: ###########file test.py############################################ #!/usr/bin/env python from Tkinter import * class Test(Tk): def __init__(self): Tk.__init__(self) l = Listbox(self) l.pack() l.insert('end', 'line 1') l.insert('end', 'line 2') l.insert('end', 'line 3') l.bind('<1>', self.dummy) l.bind('', self.test) def dummy(self, event): return 'break' def test(self, event): print 'hello' if __name__ == '__main__': t = Test() t.mainloop() ###################################################################### At least on my box (Python2.2/Tk8.3) the listbox behaves just like I expected. What does the function you bound to ''-events look like, maybe this one is the problem here? Regards Michael From FBatista at uniFON.com.ar Mon Apr 19 09:02:38 2004 From: FBatista at uniFON.com.ar (Batista, Facundo) Date: Mon Apr 19 09:05:01 2004 Subject: [Tkinter-discuss] Listbox selection issue Message-ID: #- I can hardly believe that, I wrote a little test app and #- double clicking works fine here: #- #- ###########file test.py############################################ #- #!/usr/bin/env python #- from Tkinter import * #- #- class Test(Tk): #- def __init__(self): #- Tk.__init__(self) #- l = Listbox(self) #- l.pack() #- l.insert('end', 'line 1') #- l.insert('end', 'line 2') #- l.insert('end', 'line 3') #- l.bind('<1>', self.dummy) #- l.bind('', self.test) #- #- def dummy(self, event): #- return 'break' #- #- def test(self, event): #- print 'hello' #- #- if __name__ == '__main__': #- t = Test() #- t.mainloop() #- #- ############################################################# #- ######### #- #- At least on my box (Python2.2/Tk8.3) the listbox behaves #- just like I expected. #- What does the function you bound to #- ''-events look like, maybe this #- one is the problem here? The issue here is that when you click in an item, it does not get colored (or remarked, or selected, or however it says). Why that happens? . Facundo From klappnase at web.de Mon Apr 19 17:10:01 2004 From: klappnase at web.de (Michael Lange) Date: Mon Apr 19 17:09:00 2004 Subject: [Tkinter-discuss] Listbox selection issue In-Reply-To: References: Message-ID: <20040419231001.689bf01d.klappnase@web.de> On Mon, 19 Apr 2004 10:02:38 -0300 "Batista, Facundo" wrote: > #- ###########file test.py############################################ > #- #!/usr/bin/env python > #- from Tkinter import * > #- > #- class Test(Tk): > #- def __init__(self): > #- Tk.__init__(self) > #- l = Listbox(self) > #- l.pack() > #- l.insert('end', 'line 1') > #- l.insert('end', 'line 2') > #- l.insert('end', 'line 3') > #- l.bind('<1>', self.dummy) > #- l.bind('', self.test) > #- > #- def dummy(self, event): > #- return 'break' > #- > #- def test(self, event): > #- print 'hello' > #- > #- if __name__ == '__main__': > #- t = Test() > #- t.mainloop() > #- > #- ############################################################# > The issue here is that when you click in an item, it does not get colored > (or remarked, or selected, or however it says). > > Why that happens? > That's because selecting an item is done by Button-1 events normally and this is prevented here by the "return 'break'" statement (I thought that's what you wanted, or did I misunderstand something?). If you want the item selected on Double-Button-1 events you need of course do this in the "test()" method here. I wrote a method a while ago that returns the index of the listbox item that was clicked on, which might be helpful, see example below: ########file test.py########################################## #!/usr/bin/env python from Tkinter import * class Test(Tk): def __init__(self): Tk.__init__(self) self.listbox = l = Listbox(self) l.pack() l.insert('end', 'line 1') l.insert('end', 'line 2') l.insert('end', 'line 3') l.bind('<1>', self.dummy) l.bind('', self.test) def dummy(self, event): return 'break' def test(self, event): i = self.where(event) if i > -1: self.listbox.select_clear(0, 'end') self.listbox.select_set(i) print 'item double-clicked: ' + self.listbox.get(i) def where(self, event): '''Returns the index of the listbox where the event occured.''' # where the corner of the listbox is relative to the screen: x_org = self.listbox.winfo_rootx() y_org = self.listbox.winfo_rooty() # where the pointer is relative to the listbox widget: x = event.x_root - x_org y = event.y_root - y_org i = self.listbox.index('@' + str(x) + ',' + str(y)) b = self.listbox.bbox(i) if not b or y > b[1] + b[3]: # listbox is empty or event occured below the last item return -1 else: return i if __name__ == '__main__': t = Test() t.mainloop() ################################################################### Is it something like this, what you had in mind or did I get something wrong (unfortunately I already deleted the first posts from this thread)? Best regards Michael From fredrik at pythonware.com Mon Apr 19 17:26:26 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Apr 19 17:26:09 2004 Subject: [Tkinter-discuss] Re: Listbox selection issue References: <20040419231001.689bf01d.klappnase@web.de> Message-ID: Michael Lange wrote: > # where the corner of the listbox is relative to the screen: > x_org = self.listbox.winfo_rootx() > y_org = self.listbox.winfo_rooty() > # where the pointer is relative to the listbox widget: > x = event.x_root - x_org > y = event.y_root - y_org any reason you cannot just do x = event.x y = event.y ? From klappnase at web.de Tue Apr 20 06:52:26 2004 From: klappnase at web.de (Michael Lange) Date: Tue Apr 20 06:51:23 2004 Subject: [Tkinter-discuss] Re: Listbox selection issue In-Reply-To: References: <20040419231001.689bf01d.klappnase@web.de> Message-ID: <20040420125226.054296f5.klappnase@web.de> On Mon, 19 Apr 2004 23:26:26 +0200 "Fredrik Lundh" wrote: > Michael Lange wrote: > > > # where the corner of the listbox is relative to the screen: > > x_org = self.listbox.winfo_rootx() > > y_org = self.listbox.winfo_rooty() > > # where the pointer is relative to the listbox widget: > > x = event.x_root - x_org > > y = event.y_root - y_org > > any reason you cannot just do > > x = event.x > y = event.y > > ? > > Oops! Thanks, not really, it seems. The reason I did so was that I "stole" the whole part of the function you quoted (including the comments) from someone who used it in a canvas widget without thinking very much about it and adapted it for my listbox method; well, at least the complicated way works, too;-) Best regards Michael From usenet at datahansa.com Tue Apr 20 23:13:31 2004 From: usenet at datahansa.com (Oleg A. Paraschenko) Date: Wed Apr 21 10:32:48 2004 Subject: [Tkinter-discuss] Python GUI wrapper for a long operation Message-ID: <20040421071331.660def7b.usenet@datahansa.com> Hello, maybe of some interest: A complete Python Tkinter sample application for a long operation http://uucode.com/texts/pylongopgui/pyguiapp.html A complete Python Tkinter application demonstrates one of the ways to implement a GUI wrapper for a long operation. The long operation works in a separated thread without frozing a GUI. A progress bar visializes a progress in calculations. A notification widget displays log messages. User can cancel the operation. Log messages are stored in a viewable history buffer. Please beware that documentation describes how things are done, but does not explain why. It is so because some advanceed knowledge is assumed: * threads, * master-view-controller pattern (it is partially used in the code), * logging in a log4j style. Regards, Oleg From FBatista at uniFON.com.ar Wed Apr 21 12:38:28 2004 From: FBatista at uniFON.com.ar (Batista, Facundo) Date: Wed Apr 21 12:40:51 2004 Subject: [Tkinter-discuss] Automagically calling functions Message-ID: I'm using Radiobutton: rb_var = IntVar() Radiobutton(master, text="foo", variable=rb_var, value=1, command=function1) Radiobutton(master, text="bar", variable=rb_var, value=2, command=function2) So, the user chooses whatever he/she wants and Radiobutton automatically calls the corresponding function. But then, when creating the dialog again, I read the config and want to put the Radiobutton in the same state the user left it. So, I do: rb_var.set(previous_state) The issue is that this last step don't automatically call the corresponding function. I want Radiobutton to trigger function1 if I do rb_var.set(1), for exmaple. There's a way? Thank you! . Facundo From fredrik at pythonware.com Wed Apr 21 13:13:04 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Apr 21 13:12:55 2004 Subject: [Tkinter-discuss] Re: Graphing package for Tkinter? References: <7EBB8AB8-8FE8-11D8-B923-000A956870AC@wisc.edu> Message-ID: > if anyone's interested, feel free to play with the code (see the > above link for pointers), and let me know what I should add > next... fyi, I just posted wckgraph 0.5: http://www.effbot.org/zone/wckgraph.htm From kmmcdonald at wisc.edu Thu Apr 22 15:40:02 2004 From: kmmcdonald at wisc.edu (Kenneth McDonald) Date: Thu Apr 22 15:40:10 2004 Subject: [Tkinter-discuss] Re: Re: Graphing package for Tkinter? (Fredrik Lundh) In-Reply-To: References: Message-ID: Fred, I did download and install wck and wckgraph. I'd love to play with wck, it looks really nice! Too many toys, too little time, hopefully in the next month or so... If you have need/use for a "semi-batch-driven" Python graphing facility (with Tk as an optional backend for viewing and simple manipulation), check out matplotlib.sourceforge.net. Very nice output, quite a bit of capability, though the Python OO API is a little clunky at the moment (but the project is aware of that, and working on it.) Posted to the mailing list in case others might be interested in matplotlib. Thanks, Ken From klappnase at web.de Wed Apr 28 16:03:19 2004 From: klappnase at web.de (Michael Lange) Date: Wed Apr 28 16:04:29 2004 Subject: [Tkinter-discuss] Widget collection project Message-ID: <20040428220319.26da0d22.klappnase@web.de> Hello everyone, a recent thread on comp.lang.python suggested to create a central place to collect Tkinter "mega" widgets people wrote; I thought that the Tkinter wiki might be a good place for that. My idea was that many people might have written widgets that are nice, but not "full-featured", so that it would be cool if you could simply add features by editing the source code on the wiki page (or maybe fix a bug); on the other hand you could just copy & paste the code into your application without having to download and install some package. Before I start with that I thought I'd ask what you folks think, is this really a good idea? Best regards Michael From clnethery at juno.com Thu Apr 29 23:55:11 2004 From: clnethery at juno.com (Chris Nethery) Date: Thu Apr 29 23:57:02 2004 Subject: [Tkinter-discuss] Graying out and disabling widgets Message-ID: <20040429.205528.20413.39397@webmail21.nyc.untd.com> Hello everyone. I have once again come up with an issue I cannot seem to resolve, although I would have thought it simple. I am trying to "gray out" and disable widgets when they lose focus. To that end, the code works. The problem is...it takes two mouse clicks on the widget to facilitate the method. To illustrate this, type anything in the entry field and hit enter...so far, so good...now select an item from the combobox...that enables the combobox but does not populate the combobox's entry with the item--the item must be selected a second time in order for this to happen. I have included the code for your perusal... Any ideas? Thanking you in advance, Chris Nethery ############################################ from Tkinter import * import Pmw root = Tk() root.title('Graying out and disabling') #root.wm_geometry("1015x705") Pmw.initialise(root) class GrayOutAndDisableMethod: def __init__(self, root): Frame1 = Frame(root, borderwidth=2, width=1015, height=705) Frame1.pack(fill='both', expand=1, padx=5, pady=5) Frame1.place(relx=0.01, rely=0.01, anchor=NW) Frame2 = Frame(Frame1, borderwidth=2, width=300, height=18) self.ConstantEntryField = Pmw.EntryField(Frame2, labelpos=W, labelmargin=30, label_text='1) Input stuff:', command = self.constantValue) self.ConstantEntryField.pack(fill=X, expand=1, padx=5, pady=5) Frame2.pack(fill='both', expand=1, padx=5, pady=5) Frame2.place(relx=0.01, rely=0.08, anchor=NW) Frame3 = Frame(Frame1, borderwidth=2, width=300, height=18) MapComboItems = ('', 'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10') self.MapComboBox = Pmw.ComboBox(Frame3, history=0, listheight=150, label_text='2) Select stuff:', labelmargin=24, labelpos='w', selectioncommand=self.mapSelection, scrolledlist_items=MapComboItems) self.MapComboBox.pack(side='right', anchor='w', fill='x', expand=1, padx=5, pady=5) Frame3.pack(fill='both', expand=1, padx=5, pady=5) Frame3.place(relx=0.01, rely=0.14, anchor=NW) def constantValue(self): if self.ConstantEntryField.get() == '' or None: self.ConstantEntryField.component('entry').config(state='normal') self.MapComboBox.component('entry').config(state='normal') self.MapComboBox.component('listbox').config(state='normal') else: self.ConstantEntryField.component('entry').config(state='normal') self.MapComboBox.component('entry').config(state='disabled') self.MapComboBox.component('listbox').config(state='disabled') def mapSelection(self, event): if self.MapComboBox.get() != '' or None: self.MapComboBox.component('entry').config(state='normal') self.MapComboBox.component('listbox').config(state='normal') self.ConstantEntryField.clear() self.ConstantEntryField.component('entry').config(state='disabled') else: self.MapComboBox.component('entry').config(state='normal') self.MapComboBox.component('listbox').config(state='normal') self.ConstantEntryField.component('entry').config(state='normal') nbn = GrayOutAndDisableMethod(root) root.mainloop() ###############################################