[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-idle-dev
Subject:    [Idle-dev] IDLE, Tk, and WindowMaker
From:       glyph () twistedmatrix ! com (Glyph Lefkowitz)
Date:       2000-03-30 20:24:25
Message-ID: Pine.LNX.4.21.0003301126370.31169-200000 () helix ! twistedmatrix ! com
[Download RAW message or body]

(note: lots of this is Tk specific, so if I'm addressing this issue in the
wrong forum feel free to redirect me)

Hi everyone!

IDLE is a really nifty IDE.  I hadn't really considered trying it, because
Tk is ugly, buggy and functions incorrectly with many windowmanagers
(Enlightenment, fvwm, IceWM, and Sawmill come to mind).  The particularly
annoying bug that these WMs exhibit with Tk is that sometimes when an
event is processed (particularly frequently when closing a window or
tearing off a menu) the program will hang for 10-30 seconds before drawing
anything to the screen.

In order to fix the 'ugly' problem, I installed Tkstep.  IDLE, and all
Python/Tk programs, work wonderfully with this little hack.  Continuing in
the NeXTSTEP theme, to work around Tk's allergy to the ICCCM, (and for
various other reasons, which I'll get to in a moment) WindowMaker, which
seems to allow it to at least process events correctly.  After munging a
few Xdefaults, I had a very nice looking setup which integrated nicely
with the rest of my desktop, and didn't hang when I tried to use menus.

I heard that IDLE 0.5 was significantly niftier than the debian packaged
version, 0.4, and indeed it is!  I played with it and was very impressed
with the popup argument-listing ;-). Is something like VB's '.' completion
in the works?  (I always loved that feature, but couldn't stomach actually
writing VB)

However, there is a final problem.  Something which I gather is only a
problem for WindowMaker users, but seems odd in general.  The specific
problem is that IDLE does not produce a usable app-icon.  This is a pretty
big deal for me, because I use a lot of apps, frequently all at the same
time; I use WMaker's facility for hiding and showing these rather
frequently.  It is MUCH more convenient than "workspaces", since I don't
have to manually associate windows with a group; X does it for me.  I also
prefer to use them to launch applications.  The first part I have mostly
fixed (see the attached tiny patch against 0.5 -- I also fixed a minor
typo ^_^) but the second is that Tk seems to flaunt established
conventions for the WM_CLASS hint.

glyph@helix:~% xprop | grep CLASS
Clicking on their various windows;

IDLE says:		WM_CLASS(STRING) = "135690688", "Toplevel"
Gnome Terminal says:	WM_CLASS(STRING) = "GnomeTerminal", "GnomeTerminal.2"
XEmacs says:		WM_CLASS(STRING) = "emacs", "Emacs"
Netscape says:		WM_CLASS(STRING) = "Navigator", "Netscape"

To quote the venerable Sesame Street, "One of these things is not like the
others.  One of these things is not the same." :-)

Attempting to change this particular thing was no good, either.  I noticed
that WM_CLASS is sent according to the className of the widget and
attempted to change the WM_CLASS/name of EditorWindow by changing its
_name... then I noticed and there's this snippet of code in
Tkinter.BaseWidget._setup:

                if self.master.children.has_key(self._name):
                        self.master.children[self._name].destroy()
                self.master.children[self._name] = self

which means if 2 Tkinter.Toplevel windows in the same [group?  root
somethingorother?] have the same WM_CLASS (as other apps indicate they're
supposed to) one of the others will disappear. I watched a few
EditorWindows just vanish inexplicably before figuring this out.

The most important thing, though, is that the "group leader" window
('root', in this case) doesn't seem to have any WM_CLASS at *all*. (I
can't prove this, because if I don't withdraw() it, it seems to have the
class of tk#2.Tk...?) The result of this is that the appicon behaves
erratically (I can provide more specifics if you're interested) and that
when I right-click on it, it doesn't know what application that icon is
associated with.  WMaker uses the second half of the WM_CLASS
specification of the group leader window by default, I believe, giving
XEmacs an application name of 'Emacs', netscape of 'Netscape', etcetera.  
I can't figure out a way to change this.

Can anyone with a high degree of Tk Zen perhaps explain this to me?  I
wish I could have finished the patch before submitting it here, but I am
definitely way out of my depth.

                      ______      __   __  _____  _     _
                     |  ____ |      \_/   |_____] |_____|
                     |_____| |_____  |    |       |     |
                     @ t w i s t e d m a t r i x  . c o m
                     http://www.twistedmatrix.com/~glyph/





["idle-appicon.patch" (TEXT/PLAIN)]

diff -u idle-orig/EditorWindow.py idle-0.5/EditorWindow.py
--- idle-orig/EditorWindow.py	Tue Feb 15 13:05:15 2000
+++ idle-0.5/EditorWindow.py	Wed Mar 29 20:34:26 2000
@@ -101,6 +101,7 @@
             self.vars = flist.vars
         self.menubar = Menu(root)
         self.top = top = self.Toplevel(root, menu=self.menubar)
+        self.top.group(root)
         self.vbar = vbar = Scrollbar(top, name='vbar')
         self.text_frame = text_frame = Frame(top)
         self.text = text = Text(text_frame, name='text', padx=5,
@@ -664,7 +665,7 @@
         if self.get_tabwidth() != newtabwidth:
             pixels = text.tk.call("font", "measure", text["font"],
                                   "-displayof", text.master,
-                                  "n" * newtabwith)
+                                  "n" * newtabwidth)
             text.configure(tabs=pixels)
 
 def prepstr(s):
Common subdirectories: idle-orig/Icons and idle-0.5/Icons
diff -u idle-orig/PyShell.py idle-0.5/PyShell.py
--- idle-orig/PyShell.py	Fri Jun 25 12:26:34 1999
+++ idle-0.5/PyShell.py	Wed Mar 29 20:27:21 2000
@@ -711,6 +711,8 @@
     root = Tk()
     fixwordbreaks(root)
     root.withdraw()
+    root.group(root)
+    root.command('idle')
     flist = PyShellFileList(root)
 
     if edit:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic