Exemplo n.º 1
0
 def create_edit_menu(self):
     modifier = TkUtil.menu_modifier()
     self.editMenu = tk.Menu(self.menubar)
     self.editMenu.add_command(label=UNDO, underline=0,
             command=self.editor.edit_undo,
             image=self.menuImages[UNDO], compound=tk.LEFT,
             accelerator=modifier + "+Z")
     redo = "+Shift+Z"
     if TkUtil.windows():
         redo = "+Y"
     self.editMenu.add_command(label=REDO, underline=0,
             command=self.editor.edit_redo,
             image=self.menuImages[REDO], compound=tk.LEFT,
             accelerator=modifier + redo)
     self.editMenu.add_separator()
     self.editMenu.add_command(label=COPY, underline=0,
             command=lambda: self.editor.text.event_generate(
                 "<<Copy>>"), image=self.menuImages[COPY],
             compound=tk.LEFT, accelerator=modifier + "+C")
     self.editMenu.add_command(label=CUT, underline=2,
             command=lambda: self.editor.text.event_generate("<<Cut>>"),
             image=self.menuImages[CUT], compound=tk.LEFT,
             accelerator=modifier + "+X")
     self.editMenu.add_command(label=PASTE, underline=0,
             command=lambda: self.editor.text.event_generate(
                 "<<Paste>>"), image=self.menuImages[PASTE],
             compound=tk.LEFT, accelerator=modifier + "+V")
     self.editMenu.add_separator()
     self.editMenu.add_command(label=FIND + ELLIPSIS, underline=0,
             command=self.find, image=self.menuImages[FIND],
             compound=tk.LEFT, accelerator=modifier + "+F")
     self.menubar.add_cascade(label="Edit", underline=0,
             menu=self.editMenu)
Exemplo n.º 2
0
 def create_edit_menu(self):
     modifier = TkUtil.menu_modifier()
     self.editMenu = tk.Menu(self.menubar)
     self.editMenu.add_command(label=UNDO, underline=0,
             command=self.editor.edit_undo,
             image=self.menuImages[UNDO], compound=tk.LEFT,
             accelerator=modifier + "+Z")
     redo = "+Shift+Z"
     if TkUtil.windows():
         redo = "+Y"
     self.editMenu.add_command(label=REDO, underline=0,
             command=self.editor.edit_redo,
             image=self.menuImages[REDO], compound=tk.LEFT,
             accelerator=modifier + redo)
     self.editMenu.add_separator()
     self.editMenu.add_command(label=COPY, underline=0,
             command=lambda: self.editor.text.event_generate(
                 "<<Copy>>"), image=self.menuImages[COPY],
             compound=tk.LEFT, accelerator=modifier + "+C")
     self.editMenu.add_command(label=CUT, underline=2,
             command=lambda: self.editor.text.event_generate("<<Cut>>"),
             image=self.menuImages[CUT], compound=tk.LEFT,
             accelerator=modifier + "+X")
     self.editMenu.add_command(label=PASTE, underline=0,
             command=lambda: self.editor.text.event_generate(
                 "<<Paste>>"), image=self.menuImages[PASTE],
             compound=tk.LEFT, accelerator=modifier + "+V")
     self.editMenu.add_separator()
     self.editMenu.add_command(label=FIND + ELLIPSIS, underline=0,
             command=self.find, image=self.menuImages[FIND],
             compound=tk.LEFT, accelerator=modifier + "+F")
     self.menubar.add_cascade(label="Edit", underline=0,
             menu=self.editMenu)
Exemplo n.º 3
0
 def set_drag_cursor(self, on=True):
     if on:
         cursor = "sizing"  # Mac OS X can only use built-in Tk cursors
         path = os.path.realpath(os.path.join(os.path.dirname(__file__), "images"))
         if TkUtil.windows():
             cwd = None
             try:
                 cwd = os.getcwd()
                 os.chdir(path)  # Paths don't work on Windows 7
                 self.master.config(cursor="@drag.cur")
             finally:
                 if cwd is not None:
                     os.chdir(cwd)
         elif not TkUtil.mac():
             # Mask made by http://www.kirsle.net/wizards/xbmask.cgi
             cursor = ("@" + os.path.join(path, "drag.xbm"), os.path.join(path, "drag_mask.xbm"), "#DF00FF", "white")
             self.master.config(cursor=cursor)
     else:
         self.master.config(cursor="")
     self.master.update()
Exemplo n.º 4
0
 def undock(self, dock, x=None, y=None):
     """Warning: On Mac OS X 10.5 undocking works imperfectly.
     Left and right docking work fine though.
     """
     dock.pack_forget()
     dock.config(relief=tk.FLAT, borderwidth=0)
     dock.tk.call("wm", "manage", dock)
     on_close = dock.register(dock.on_close)
     dock.tk.call("wm", "protocol", dock, "WM_DELETE_WINDOW", on_close)
     title = dock.title if hasattr(dock, "title") else "Dock"
     dock.tk.call("wm", "title", dock, title)
     minsize = dock.minsize if hasattr(dock, "minsize") else (60, 30)
     dock.tk.call("wm", "minsize", dock, *minsize)
     dock.tk.call("wm", "resizable", dock, False, False)
     if TkUtil.windows():
         dock.tk.call("wm", "attributes", dock, "-toolwindow", True)
     if x is not None and y is not None:
         self.xy_for_dock[dock] = (x, y)
     x, y = self.xy_for_dock.get(dock, (None, None))
     if x is not None and y is not None:
         dock.tk.call("wm", "geometry", dock, "{:+}{:+}".format(x, y))
     self.__remove_area(dock)
 def undock(self, dock, x=None, y=None):
     """Warning: On Mac OS X 10.5 undocking works imperfectly.
     Left and right docking work fine though.
     """
     dock.pack_forget()
     dock.config(relief=tk.FLAT, borderwidth=0)
     dock.tk.call("wm", "manage", dock)
     on_close = dock.register(dock.on_close)
     dock.tk.call("wm", "protocol", dock, "WM_DELETE_WINDOW", on_close)
     title = dock.title if hasattr(dock, "title") else "Dock"
     dock.tk.call("wm", "title", dock, title)
     minsize = dock.minsize if hasattr(dock, "minsize") else (60, 30)
     dock.tk.call("wm", "minsize", dock, *minsize)
     dock.tk.call("wm", "resizable", dock, False, False)
     if TkUtil.windows():
         dock.tk.call("wm", "attributes", dock, "-toolwindow", True)
     if x is not None and y is not None:
         self.xy_for_dock[dock] = (x, y)
     x, y = self.xy_for_dock.get(dock, (None, None))
     if x is not None and y is not None:
         dock.tk.call("wm", "geometry", dock, "{:+}{:+}".format(x, y))
     self.__remove_area(dock)
Exemplo n.º 6
0
 def set_drag_cursor(self, on=True):
     if on:
         cursor = "sizing"  # Mac OS X can only use built-in Tk cursors
         path = os.path.realpath(
             os.path.join(os.path.dirname(__file__), "images"))
         if TkUtil.windows():
             cwd = None
             try:
                 cwd = os.getcwd()
                 os.chdir(path)  # Paths don't work on Windows 7
                 self.master.config(cursor="@drag.cur")
             finally:
                 if cwd is not None:
                     os.chdir(cwd)
         elif not TkUtil.mac():
             # Mask made by http://www.kirsle.net/wizards/xbmask.cgi
             cursor = ("@" + os.path.join(path, "drag.xbm"),
                       os.path.join(path,
                                    "drag_mask.xbm"), "#DF00FF", "white")
             self.master.config(cursor=cursor)
     else:
         self.master.config(cursor="")
     self.master.update()