Commit Graph

241 Commits

Author SHA1 Message Date
Fredrik Lundh 06d2815350 -- untabification (use "diff -b" to verify) 2000-08-09 18:03:12 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Guido van Rossum 0a3f7978c4 Change whitespace in two places to silence tabnanny.
Also fix spelling tupel -> tuple.
2000-07-06 05:34:14 +00:00
Guido van Rossum 5917ecb0a4 Nils Fischbeck: added doc strings to everything. Martin von Loewis
has reviewed this, too.
2000-06-29 16:30:50 +00:00
Andrew M. Kuchling e475e70128 Patch from /F:
this patch adds a fast _flatten function to the _tkinter
module, and imports it from Tkinter.py (if available).

this speeds up canvas operations like create_line and
create_polygon.  for example, a create_line with 5000
vertices runs about 50 times faster with this patch in
place.
2000-06-18 18:45:50 +00:00
Guido van Rossum aaa8bb4211 Work the Tcl version number in the path we search for. 2000-04-04 23:32:21 +00:00
Guido van Rossum 42405a5d7d A version of FixTk.py that works with the way the installer now
installs Tcl/Tk.
2000-03-31 03:11:40 +00:00
Guido van Rossum 2ab9082a07 Show Tcl/Tk version number in _test() and show Unicode test if possible. 2000-03-30 23:19:44 +00:00
Guido van Rossum 0ba33002e1 Fix a typo in Barry's checkin.
Reported both by Gerrit Holl and Mark Favas.
2000-02-27 15:35:47 +00:00
Barry Warsaw 7d3f27c090 Changes inspired by Randall Hooper to allow callbacks when an
OptionMenu is modified.  Somewhat rewritten and elaborated by myself.

class _setit: The constructor now takes an optional argument
`callback' and stashes this in a private variable.  If set, the
__call__() method will invoke this callback after the variable's value
has changed.  It will pass the callback the value, followed by any
args passed to __call__().

class OptionMenu: The constructor now takes keyword arguments, the
only one that's legally recognized is `command', which can be set to a
callback.  This callback is invoked when the OptionMenu value is set.
Any other keyword argument throws a TclError.
2000-02-25 21:54:19 +00:00
Guido van Rossum d5062babed Moshe Zadka:
Added docstrings to tkSimpleDialog.py
2000-02-24 15:01:43 +00:00
Guido van Rossum 8fa42af978 Fix PR#107: wm_colormapwindows() did the wrong thing when presented
more than one window argument.
1999-10-20 12:29:56 +00:00
Guido van Rossum f8d8e07601 Fixed PR#106: winfo_visualsavailable() with the includeids=1 option
didn't properly handle the hex numbers returned.
1999-10-18 22:06:38 +00:00
Guido van Rossum ea7364c7cd Peter Haight discovered that this code uses a mutable default for cnf
and then (under certain circumstances) can clobber the default!
He also submitted this patch as PR#82.
1999-09-20 00:39:47 +00:00
Guido van Rossum e61e98d2ae Add calls to self.protocol("WM_DELETE_WINDOW", self.destroy) to the Tk
and Toplevel class constructors.  This means that if the window
manager closes the window, the Python-side Tkinter data structures
will be destroyed correctly.  (Most apps do this anyway, and it's
recommended practice; I see no reason why making it the default
behavior could be bad.)
1999-08-20 18:26:06 +00:00
Guido van Rossum 42b334d93d Remove some redundant code from Canvas.tag_bind(), which added all
bindings to a dictionary _tagcommands which was otherwise unused.
(This was checked in accidentally with rev. 1.125 and not deleted with
rev. 1.127 when the other half of this code was removed -- although
even as originally checked in the _tagcommands variable was never
used.)

(PR#40, reported by Peter Stoehr)
1999-07-30 12:22:12 +00:00
Guido van Rossum 7ea8f8404c Break some cycles when the widget is destroyed. 1999-06-25 15:53:54 +00:00
Guido van Rossum 1a03cf56e0 Greg McFarlane submitted two missing Text methods: mark_next() and
mark_previous().
1999-06-21 14:13:30 +00:00
Guido van Rossum fa8c3eab79 Greg McFarlane writes: Tkinter.Text.tag_add should take multiple
arguments.  [Slightly changed from submitted patch.]
1999-06-01 13:57:15 +00:00
Guido van Rossum 8e40759d5a Nathan Paul Simons noticed that the grid_remove() method was missing.
(The difference between grid_remove() and grid_forget() is that the
former remembers the options for the slave.)
1999-05-05 23:03:48 +00:00
Guido van Rossum 6e9dadc1da Delete an accidentally checked-in feature that actually broke more
than was worth it: when deleting a canvas item, it would try to
automatically delete the bindings for that item.  Since there's
nothing that says you can't reuse the tag and still have the bindings,
this is not correct.  Also, it broke at least one demo
(Demo/tkinter/matt/rubber-band-box-demo-1.py).
1999-04-08 14:46:06 +00:00
Guido van Rossum 0d8d3dd5b0 lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,
so the preferred name for them is tag_lower, tag_raise
(similar to tag_bind, and similar to the Text widget);
unfortunately can't delete the old ones yet (maybe in 1.6)
1999-04-07 16:25:54 +00:00
Guido van Rossum eb354b31e5 Bug reported by Jim Robinson:
An attempt to execute grid_slaves with arguments (0,0) results in
*all* of the slaves being returned, not just the slave associated with
row 0, column 0.  This is because the test for arguments in the method
does not test to see if row (and column) does not equal None, but
rather just whether is evaluates to non-false.  A value of 0 fails
this test.
1999-03-16 21:54:50 +00:00
Guido van Rossum c55b0ca601 Put a try-except around the "image delete" call in Image.__del__ to
avoid tracebacks when the root is destroyed before the image object.
1999-02-08 15:26:49 +00:00
Guido van Rossum f8d579c5e3 This hopefully fixes the problem of having to set PATH
in autoexec.bat in order to find the Tcl DLLs -- Tkinter calls FixTk
which will hunt around in a few common places and then set PATH
and try again, or else issue a big clarifying error message.
1999-01-04 18:06:45 +00:00
Guido van Rossum dfaac4df9e Add XXX comment about the need to add a dump() method to the Text
widget -- no time to do this right now.
1998-12-21 18:25:03 +00:00
Barry Warsaw 107e623ef0 grid_bbox(): support new Tk API: grid bbox ?column row? ?column2 row2? 1998-12-15 00:44:15 +00:00
Guido van Rossum b241b67b89 Turtle graphics 1998-12-04 16:42:46 +00:00
Guido van Rossum 9f1292d840 Perhaps a controversial change: when reporting a callback exception,
assign the exception info to sys.last_{type,value,traceback}.  That
way, an introspective Tkinter app can inspect its own stack trace.

(The controversy is that it would keep some objects alive, but that's
probably no big deal.)
1998-10-13 20:02:39 +00:00
Barry Warsaw 4eaadf002e Added {xview,yview}_{moveto,scroll} to the Canvas class. 1998-10-13 19:01:10 +00:00
Guido van Rossum 243ac4f497 Updated listbox methods to Tk 8.0. (Moved some around, added
x/yview_scroll/moveto.)
1998-10-13 13:37:30 +00:00
Guido van Rossum 3179b36014 When no master widget is specified, use options['parent'] if it exists. 1998-10-12 20:40:47 +00:00
Guido van Rossum 7f20263349 Only reference Tkinter._default_root when needed. 1998-10-12 20:40:09 +00:00
Guido van Rossum da65450530 The message "Exception in Tkinter callback" should go to stderr.
Fix bug in NoDefaultRoot() -- _default_root wasn't declared global;
and made it reentrant.

Don't set _default_root to whatever master gets passed in to
BaseWidget._setup() (only set it when we need to create a new Tk()
widget).
1998-10-06 19:06:27 +00:00
Barry Warsaw 4cbe3876ec NSEW is also valid for -sticky 1998-10-01 15:54:48 +00:00
Barry Warsaw 9190046289 Added NS and EW constants, which are meaningful values for grid's
-sticky option.
1998-10-01 13:49:37 +00:00
Guido van Rossum 0c92000b7a Ignore the TclError exception raised when deleting the registration
for callit, used by the after() command.  This can happen when the
callback deletes the window.
1998-09-14 19:06:39 +00:00
Guido van Rossum c86b7c63e0 Make bind variants without a sequence return a tuple of sequences
(formerly it returned a string, which wasn't very convenient).

Add image commands to the Text widget (these are new in Tk 8.0).
1998-08-31 16:54:33 +00:00
Guido van Rossum 3d16d3e643 Fredrik Lundh's font wrapper. 1998-08-11 19:07:58 +00:00
Guido van Rossum b4750db3b3 Added coords() and identify() methods to Scale class. 1998-08-11 19:07:14 +00:00
Guido van Rossum 2b427c74e1 Nannified. 1998-08-10 20:13:17 +00:00
Guido van Rossum 5ff1761d3f From: "Fredrik Lundh" <fredrik@pythonware.com>
Date: Fri, 7 Aug 1998 13:37:12 +0100

the "initialcolor" code is broken in several places in the
current version of tkColorChooser.  I've attached an up-
dated version for 1.5.2.
1998-08-07 14:55:21 +00:00
Guido van Rossum 93d1fe1c56 From: Nicolas CHAUVAT <nico@caesium.fr>
In the bbox method of Group (Canvas.py file), you should read

	return self.canvas._getints(self._do('bbox'))

instead of

	return self._getints(self._do('bbox'))
1998-07-16 13:43:05 +00:00
Fred Drake 182c590869 Tk.__init__(): In computing baseName, add ".pyo" to list of dropped
extensions, and include the "." in ".pyc".  Still need to get
	_tkinter.c:Tkapp_New() to use baseName....
1998-07-15 04:36:56 +00:00
Guido van Rossum 88b63b8d30 Allow binding a Tcl command (given as a string) as well as a Python
function.
1998-06-25 18:54:49 +00:00
Guido van Rossum cef4c844df Turns out that 'winfo id' returns the id as a hex string, with 0x prefix.
The int() function (aliased to getint()) doesn't handle that, so we must
use self.tk.getint() again...
1998-06-19 04:35:45 +00:00
Guido van Rossum 268824e089 Different trick to get the _test() window to pop up. 1998-06-19 04:34:19 +00:00
Guido van Rossum fe02efdbf4 getint() now raises ValueError, not TclError, on errors. 1998-06-09 02:37:45 +00:00
Guido van Rossum 0bd5433cf8 Get rid of nearly all clals to self._do -- turns out self.tk.call can
be used just as well, so this saves one Python call in many cases!
1998-05-19 21:18:13 +00:00
Fred Drake 073b829021 When a file name is selected ("OK" button, <Return> in the filename entry),
and the "key" keyword parameter was used to invoke .go(), use the directory
of the selected file as the stored directory to return to when the same key
is used again.  This is useful since the user may well entry at least part
of the path in the filename box instead of doing a lot of clicking around in
the listboxes.
1998-05-06 17:28:23 +00:00
Guido van Rossum e365a590d4 Change the names of all methods in the Wm class: they are now
wm_title(), etc.  The old names (title() etc.) are still defined as
aliases.

This brings all methods up to use the same naming convention: whether
the Tcl syntax is

   .window.path.name command subcommand [options]

or

   command subcommand .window.path.name [optins]

the Python equivalent is always

   windowobject.command_subcommand(options)
1998-05-01 19:48:20 +00:00
Guido van Rossum 0132f69c2e Another optimization, probably of negligeable effect: instead of
calling self.tk.getint() and self.tk.getdouble(), call the globals
getint() and getdouble(), which in turn are just names for the Python
builtins int() and double().  (Making them globals actually save a
dict lookup compared to using the built-in.)  The corresponding
methods of class Misc have been changed similarly.  (Note that
getboolean() hasn't been changed because there's no Python
equivalent.)

The use of int() and float() has another advantage: if/when Tcl calls
can actually return Tcl objects with other types than string, use of
int() and float() is essential.
1998-04-30 17:50:36 +00:00
Guido van Rossum dc59340646 In _bind(), found a way to test for break without a temp variable. 1998-04-29 22:16:57 +00:00
Guido van Rossum f975699c07 Save a tiny bit of time: self.tk.call takes a tuple argument so it's
not needed to say apply(self.tk.call, t); self.tk.call(t) has the same
effect.  This cuts down tremendously on the number of apply() calls
made.  No measurable effect, but at the very least it saves the lookup
of apply() in the globals!
1998-04-29 21:57:08 +00:00
Guido van Rossum f0c891a2b2 Import MacOS at the top instead of insize Tk.__init__() -- the latter
repeats the I/O for the failed import on each interpreter creation.
1998-04-29 21:43:36 +00:00
Guido van Rossum e86271af72 When setting the event structure fields, don't die when the widget
name is not registered; simply use the string.  This happens for
tear-off widgets (e.g. if you've registered enter/leave events for the
menu).
1998-04-27 19:32:59 +00:00
Guido van Rossum c296651e10 Add image_types() and image_names() as methods to Misc class. 1998-04-10 19:16:10 +00:00
Guido van Rossum 4cee3c49c2 Another easter present. 1998-04-10 16:14:34 +00:00
Guido van Rossum 56c04b8376 Restructured the event_* calls slightly -- there's really no need to
use the default root, and instead of string.split, use splitlist.
1998-04-06 03:10:03 +00:00
Guido van Rossum 117a5a8138 Return the name of the Tcl command defined by _bind(). This can
optionally be passed to unbind() (or you can apss it to
deletecommand()).
1998-03-27 21:26:51 +00:00
Guido van Rossum cd0f59ea08 Get rid of the Emacs cruft now that Python-mode guess the desired settings! 1998-03-26 19:30:30 +00:00
Guido van Rossum c457048744 Give in to the tab police. 1998-03-20 20:45:49 +00:00
Guido van Rossum 21df8f5dc4 Typo: baseWidht -> baseWidth. 1998-02-24 23:26:18 +00:00
Guido van Rossum 0001a11986 Fix bug in trace_vdelete(); should use master's delete command. 1998-02-19 21:20:30 +00:00
Guido van Rossum e2c6e203c6 Add trace methods to class Variable 1998-01-14 16:44:34 +00:00
Guido van Rossum 1cd6a457d9 Two critical fixes to the changes that I made for Greg McFarlane --
patches provided by Greg (am I glad I sent him my latest version!).
1997-12-30 04:07:19 +00:00
Guido van Rossum 9fd41e363b Fixed several bugs reported by Greg McFarmane:
*  The invoke methods of the three Tkinter widgets Button,
    Checkbutton and Radiobutton should return the value returned by
    the callback, (like the Menu widget does):

	def invoke(self):
	    return self.tk.call(self._w, 'invoke')

 *  The select_from method of the Canvas widget should use 'from', not
    'set':

	def select_from(self, tagOrId, index):
	    self.tk.call(self._w, 'select', 'from', tagOrId, index)

    Currently, if you use select_from, you get the error message:
 'TclError: bad select option "set": must be adjust, clear, from, item, or to'

 *  The 'entrycget' and 'type' methods of the Tk menu widget are
    missing from Tkinter.

 *  There is a bug in grid_columnconfigure and grid_rowconfigure.  For
    example, this should return the current value of the 'minsize'
    option for column 0:

	f.grid_columnconfigure(0, 'minsize')

    Instead it returns the same as:

	f.grid_columnconfigure(0)

    I suggest that the hint given in the comment in the
    Tkinter.Misc.configure method should be followed - "ought to
    generalize this so tag_config etc.  can use it".  Repeating the
    same configure code several times in Tkinter is inviting errors.
    [I did not follow this advice --G]

 *  The grid_slaves method should handle options.  Currently, to pass
    options to the grid_slaves method, you have to do something like:

	grid_slaves('-row', 1)
1997-12-29 19:59:33 +00:00
Guido van Rossum adfacf4e2e Do a better job of keeping the dialog visible when the master window
is near or beyond the edge of the screen.  Patch by Skip Montanaro.
1997-12-28 03:42:50 +00:00
Guido van Rossum 4d9d3f18c2 Typo: Widht instead of Width... 1997-12-27 15:14:43 +00:00
Guido van Rossum fedc6d0d5a Added SOLID definition. 1997-12-16 17:54:18 +00:00
Fred Drake b5323999d2 PhotoImage.put(): Fixed -to handling, including backward compatibility hack.
Guido, please take a look at this.
1997-12-16 15:03:43 +00:00
Guido van Rossum f0413d4841 Added tag_prevrange analogous to rag_nextrange. 1997-12-15 17:31:52 +00:00
Guido van Rossum 98b9d77666 Change _nametowidget to nametowidget -- it is a public interface. 1997-12-12 00:09:34 +00:00
Guido van Rossum 7814ea64ff Last minute fix to Text.window_cget(), which should properly Tcl-ify
the option name (prepend '-', strip trailing '_').
1997-12-11 17:08:52 +00:00
Guido van Rossum 5ac00ac140 Fix problem detected by Greg McFarlane -- callbacks passed to
bind_class() and bind_all() are destroyed when the widget to which
they were passed is destroyed.
1997-12-11 02:03:55 +00:00
Guido van Rossum 7f9732880e Fix the exclusion of "config" in the methods copied from Pack to also
exclude "configure".
1997-12-05 17:05:04 +00:00
Guido van Rossum 80f8be8901 Support for the "event" command, new in Tk 4.2.
By Case Roole.
1997-12-02 19:51:39 +00:00
Guido van Rossum c0b93191e6 bind_class should return a value 1997-11-22 21:49:56 +00:00
Guido van Rossum 368e06b6f0 Some restructuring.
All geometry manager methods that apply to a master widget instead of
to a slave widget have been moved to the Misc class, which is
inherited by all of Tk(), Toplevel() and Widget().  They have been
renamed to have their geometry manager name as a prefix,
e.g. pack_propagate(); the short names can still be used where
ambiguities are resolved so that pack has priority over place has
priority over grid (since this was the old rule).

Also, the method definitions in the Pack, Place and Grid classes now
all have their respective geometry manager name as a prefix
(e.g. pack_configure); the shorter names are aliases defined through
assignment.

A similar renaming has been done for all config() methods found
elsewhere; these have been renamed to configure() with config being
the alias (instead of the other way around).  (This may not make much
of a difference but the official Tk command name is now 'configure'
and it may help in debugging tracebacks.)

Finally, a new base class BaseWidget has been introduced, which
implements the methods common between Widget and Toplevel (the
difference between those two classes is that Toplevel has a different
__init__() but also that Toplevel doesn't inherit from Pack, Place or
Grid.
1997-11-07 20:38:49 +00:00
Guido van Rossum 83bd9a9c8c Move Widget.config() c.s. to Misc class, so the Tk class also inherits them. 1997-09-29 23:24:52 +00:00
Guido van Rossum 9918e0c750 Add missing comma to make a tuple of (tagOrId). 1997-08-18 14:44:04 +00:00
Guido van Rossum 1530c87985 Fred Lundh's latest versions. 1997-08-14 14:17:28 +00:00
Guido van Rossum f53c86c2b6 Add dummies for create/delete filehandles, just so that vanilla Grail
0.3 won't break on Windows.
1997-08-14 14:15:54 +00:00
Guido van Rossum f55afae3c6 New dialog from Fred Lundh 1997-08-12 18:21:21 +00:00
Guido van Rossum 9d9af2c7a8 Fixes for the Mac. (Jack) 1997-08-12 18:21:08 +00:00
Guido van Rossum d6615ab30c Get READABLE c.s. from _tkinter instead of conditional definition.
in Tk.destroy(), reset _default_root to None when it is us.
1997-08-05 02:35:01 +00:00
Guido van Rossum 1e8c8a20f2 New dialog routines (Fred Lundh) 1997-07-19 20:02:36 +00:00
Guido van Rossum 65c78e18b5 Use dictionary's update() method in _cnfmerge(). 1997-07-19 20:02:04 +00:00
Fred Drake c8296db67d Widget._setup(): Support name=None in a similar way to the handling of other
Tkinter keyword parameters.
1997-05-27 22:45:10 +00:00
Guido van Rossum 16cd332aab Add root.tkraise() to the _test() program so the window doesn't hide
behind the shell window on NT.
1997-05-09 00:59:43 +00:00
Fred Drake 526749b678 Misc.__init__(): Removed method, replaced with class attribute (which
was all that the method set anyway).  Removed calls to the
	constructor.  This reduces the number of Python function calls
	per widget construction by one, for every widget construction.
1997-05-03 04:16:23 +00:00
Guido van Rossum 103cc6dd11 Patch by Craig McPheeters to clean up the back-references to widgets
contained in commands created by those same widgets.
1997-04-14 13:30:24 +00:00
Guido van Rossum 9580609ba3 Require _tkinter -- don't attempt to import tkinter when _tkinter does
not exist.  All 8 uses of tkinter are replaced with _tkinter.  Still
create a variable tkinter though, because that is used by other
modules importing Tkinter (e.g. tkinter.createfilehandler()).

Also added a comment to the 'import _tkinter' line saying that if this
fails, Python is not configured correctly.
1997-02-15 18:33:24 +00:00
Guido van Rossum 764d6c7acd Gave the Listbox selection methods their correct (longer) names.
Removed select_adjust -- Tk no longer supports this.
1997-02-14 16:21:16 +00:00
Guido van Rossum 17ca992818 Put support for a cnf dictionary back in, since it is still supported
by all true Tkinter widgets.  (Not that I *like* this module -- it
stinks, but until I have something better, I can't nuke it.)
1997-02-12 16:49:57 +00:00
Guido van Rossum 76f587b7f8 Avoid traceback in selection_own_get() when no Tk widget owns the
selection; return None instead.
1997-01-21 23:22:03 +00:00
Fred Drake 41dc09d10e (Tkinter.py): Add support for Frame(w, class_="classname") as an alternative
to Frame(w, cnf={"class": "classname"}).  I think this is the only
	widget other than Toplevel that needs to be concerned about setting
	the widget's class (-class must be the first option on the Tcl
	widget creation command).
1997-01-10 15:13:12 +00:00
Guido van Rossum 7fc0bf8247 Fix the following bug:
- When dragging the mouse in either listbox, the *first* entry
clicked on is selected rather than the last (but the last one is
highlighted).

This is done by changing the bindtags so that our binding is executed
after the default binding (which sets the 'active' index to the last
item selected), and using 'active' instead of 'anchor' as the index to
ask for.
1997-01-03 23:39:26 +00:00
Guido van Rossum 178ff353e8 Fix bogus implementation of Group.bind().
Added unbind() to CanvasItem and Group classes.
1996-12-27 15:40:31 +00:00
Guido van Rossum 8371013f9a Added config(ure) method to Image class.
(Fred Drake)
1996-12-27 15:33:17 +00:00