Commits

Anonymous committed d50bfce

Adding tooltips to restructuring dialog

  • Participants
  • Parent commits fdd7681

Comments (0)

Files changed (7)

docs/dev/issues.txt

 Hot Topics
 ==========
 
-* `Releasing library package`_
-
 
 To Be Discussed
 ===============
 
 * `Memory management`_
-* `Getting ready for Python 3.0`_
 * Should `rope.base` be thread safe? which parts?
 * Better `WordRangeFinder`
 
 
+Sorting Scope Elements
+======================
+
+Issues:
+
+* Where should we put scope statements that are outside other
+  sub-scopes?
+* How to specify the new order
+
+
 Enhancing Refactorings
 ======================
 
 * PyPackage: ``__init__.py`` attributes
 
 
-Releasing Library Package
-=========================
-
-Issues:
-
-* Two separate ``README.txt`` files?
-* Separating common, library and IDE documents
-
-New document tree:
-
-  docs/
-    dev/
-      workingon.txt
-      issues.txt
-      done.txt
-      stories.txt
-    library.txt
-    overview.txt
-    tutorial.txt
-    contributing.txt
-    done.txt
-  README.txt
-  COPYING
-
-Library Docs:
-
-* README.txt
-* tutorial.txt
-* overview.txt
-* done.txt
-* library.txt
-* contributing.txt
-
-IDE Docs:
-
-* README.txt
-* done.txt
-* library.txt
-* contributing.txt
-
-
 Memory Management
 =================
 

docs/dev/stories.txt

 * Generate method and class hierarchies
 
 
-* Sorting methods
-
-
 * Handling tuple parameters
 
 
 * Split tuple assignment refactoring
 
 
-* Better restructuring dialog
+* Sorting methods
 
 
 > Public Release 0.6 : August 5, 2007
+
+
+* Better restructuring dialog

docs/dev/workingon.txt

 Small Stories
 =============
 
+- Using tooltips in restructuring dialog
+
+* Adding restructuring scope; local scope, module, all files?
+* Better search triggering in find type dialog
 * Some of the things in `codeanalyze.WordFinder` can be achieved using
   asts; make a clone and do them there
 * Assignment to parameters in inline method
 example we'll extract a variable in a file.  First we need the
 `Resource` object that points to a file in a project::
 
-  resource = libutils.path_to_resource(myproject, '/path/to/my/module')
+  resource = libutils.path_to_resource(myproject, '/path/to/my/module.py')
 
 So we can make our Refactoring class::
 

rope/base/taskhandle.py

+import warnings
 from rope.base import exceptions
 
 
     def get_jobsets(self):
         return self.job_sets
 
+    def get_job_sets(self):
+        warnings.warn('Use `TaskHandle.get_jobsets` instead',
+                      DeprecationWarning, stacklevel=2)
+        return self.get_jobsets()
+
     def create_jobset(self, name='JobSet', count=None):
         result = JobSet(self, name=name, count=count)
         self.job_sets.append(result)

rope/ui/refactor.py

 from rope.refactor import ImportOrganizer
 from rope.ui.actionhelpers import (ConfirmEditorsAreSaved,
                                    StoppableTaskRunner, check_project)
-from rope.ui import uihelpers
+from rope.ui import uihelpers, tkhelpers
 from rope.ui.extension import SimpleAction
 from rope.ui.menubar import MenuAddress
 from rope.ui.uihelpers import (TreeViewHandle, TreeView,
             'Rope searches for `pattern` in the project and replaces its\n' \
             'occurrences with `goal`.  They can contain ``${?name}`` and \n' \
             '``${name}`` wildcards.  See ``docs/overview.txt`` for examples.'
-        help_label = Tkinter.Label(frame, text=patterns_help,
-                                   justify=Tkinter.LEFT, width=70)
-        help_label.grid(row=0, columnspan=2, sticky=Tkinter.W)
-        pattern_label.grid(row=1, column=0, sticky=Tkinter.W)
-        self.pattern.grid(row=1, column=1, sticky=Tkinter.W)
-        goal_label.grid(row=2, column=0, sticky=Tkinter.W)
-        self.goal.grid(row=2, column=1, sticky=Tkinter.W)
+        tkhelpers.ToolTip(self.pattern, patterns_help)
+        tkhelpers.ToolTip(self.goal, patterns_help)
+        pattern_label.grid(row=0, column=0, sticky=Tkinter.W)
+        self.pattern.grid(row=0, column=1, sticky=Tkinter.W)
+        goal_label.grid(row=1, column=0, sticky=Tkinter.W)
+        self.goal.grid(row=1, column=1, sticky=Tkinter.W)
 
         # Handling checks
         checks_frame = Tkinter.Frame(frame, borderwidth=1,
                                      relief=Tkinter.RIDGE)
         checks_help = 'Add checks here; One each line.  For instance:\n' \
                       '?var.type == mymod.AClass'
-        checks_label = Tkinter.Label(checks_frame, text=checks_help,
+        checks_label = Tkinter.Label(checks_frame, text='Checks',
                                      justify=Tkinter.LEFT, width=70)
         checks_label.grid(row=0)
         self.checks = Tkinter.Text(checks_frame, height=4, width=70)
         self.checks.grid(row=1)
-        checks_frame.grid(row=3, columnspan=2)
+        checks_frame.grid(row=2, columnspan=2)
+        tkhelpers.ToolTip(self.checks, checks_help)
 
         # Handling Imports
         imports_frame = Tkinter.Frame(frame, borderwidth=1,
                                       relief=Tkinter.RIDGE)
         imports_help = 'Add imports here; These imports are added to ' \
                        'changed files:'
-        imports_label = Tkinter.Label(imports_frame, text=imports_help,
+        imports_label = Tkinter.Label(imports_frame, text='Imports',
                                       justify=Tkinter.LEFT, width=70)
         imports_label.grid(row=0)
         self.imports = Tkinter.Text(imports_frame, height=4, width=70)
         self.imports.grid(row=1)
-        imports_frame.grid(row=4, columnspan=2)
+        tkhelpers.ToolTip(self.imports, imports_help)
+        imports_frame.grid(row=3, columnspan=2)
 
         self.pattern.focus_set()
         return frame

rope/ui/tkhelpers.py

         if name in self.dict:
             previous = dict[name]
         else:
-            previous = OriginalCommand(self, name)
+            previous = _OriginalCommand(self, name)
         self.dict[name] = function
         setattr(self.widget, name, function)
         return previous
             else:
                 return self.tk.call((self.orig, cmd) + args)
         except TclError, e:
-#            print e
             return ""
 
 
-class OriginalCommand(object):
+class ToolTip(object):
+    """Got from idlelib for adding tooltips"""
+
+    def __init__(self, button, text):
+        self.button = button
+        self.text = text
+        self.tipwindow = None
+        self.id = None
+        self.x = self.y = 0
+        self._id1 = self.button.bind("<Enter>", self.enter)
+        self._id2 = self.button.bind("<Leave>", self.leave)
+        self._id3 = self.button.bind("<ButtonPress>", self.leave)
+
+    def enter(self, event=None):
+        self.schedule()
+
+    def leave(self, event=None):
+        self.unschedule()
+        self.hidetip()
+
+    def schedule(self):
+        self.unschedule()
+        self.id = self.button.after(700, self.showtip)
+
+    def unschedule(self):
+        id = self.id
+        self.id = None
+        if id:
+            self.button.after_cancel(id)
+
+    def showtip(self):
+        if self.tipwindow:
+            return
+        # The tip window must be completely outside the button;
+        # otherwise when the mouse enters the tip window we get
+        # a leave event and it disappears, and then we get an enter
+        # event and it reappears, and so on forever :-(
+        x = self.button.winfo_rootx() + 20
+        y = self.button.winfo_rooty() + self.button.winfo_height() + 1
+        self.tipwindow = tw = Toplevel(self.button)
+        tw.wm_overrideredirect(1)
+        tw.wm_geometry("+%d+%d" % (x, y))
+        self.showcontents()
+
+    def showcontents(self):
+        # Override this in derived class
+        label = Label(self.tipwindow, text=self.text, justify=LEFT,
+                      background="#ffffe0", relief=SOLID, borderwidth=1)
+        label.pack()
+
+    def hidetip(self):
+        tw = self.tipwindow
+        self.tipwindow = None
+        if tw:
+            tw.destroy()
+
+
+class _OriginalCommand(object):
 
     def __init__(self, redir, name):
         self.redir = redir
 
     def __call__(self, *args):
         return self.tk_call(self.orig_and_name + args)
-