[EMAIL PROTECTED] wrote:
if I try to run blobedit.py in the IDLE ide ...
> the path is equal to "8833" for some
reason.
I believe that IDLE sets up some kind of debugging
connection to its child process. That number might
be a processs ID or port number or something related
to that.
I tried to hunt down where the problem occurs, but I was led
to the method "application_openFile_(self, ns_app, path)" in the
class _PyGui_NSApplication. I couldn't find out how this method
ever got called though.
It's called by the Cocoa framework to handle files
passed to the application from the Finder. It also
seems to get called when there are command-line
arguments. But it works on the C-level argv, which
means it can pick up stuff that doesn't normally
end up in sys.argv. The check for sys.argv[0]
is there to work around one of the side effects of
that. It appears that you've encountered another
one.
I'm using a different method of dealing with
this now, which will probably fix your problem as
well. I've attached a replacement for
GUI/Cocoa/Applications.py. Let me know if it
works for you.
--
Greg
#
# Python GUI - Application class - PyObjC
#
import os, sys, traceback
import objc
#from ExceptionHandling import \
# NSExceptionHandler, NSLogUncaughtExceptionMask,
NSLogAndHandleEveryExceptionMask
from Foundation import NSObject, NSBundle, NSDefaultRunLoopMode
import AppKit
from AppKit import NSApplication, NSResponder, NSScreen, NSMenu, NSMenuItem, \
NSKeyDown, NSKeyUp, NSMouseMoved, NSLeftMouseDown, NSSystemDefined, \
NSCommandKeyMask, NSPasteboard, NSStringPboardType,
NSModalPanelRunLoopMode, \
NSAnyEventMask
import GApplications
from GApplications import application, Application as GApplication
from Events import Event
from Exceptions import Cancel, Quit
from Menus import _ns_standard_actions
#--
ns_application = None
ns_screen_height = None
ns_last_mouse_moved_event = None
#--
class Application(GApplication):
# _ns_app _PyGui_NSApplication
# _ns_pasteboard NSPasteboard
# _ns_key_window Window
_ns_menubar_update_pending = False
def __init__(self, **kwds):
#print "Application.__init__: argv =", sys.argv ###
create_ns_application()
self._ns_app = ns_application
self._ns_app.pygui_app = self
self._ns_init_standard_menu_items()
self._ns_pasteboard = NSPasteboard.generalPasteboard()
self._ns_key_window = None
GApplication.__init__(self, **kwds)
ns_application.init_application_name()
def destroy(self):
del self.menus[:]
import Windows
Windows._ns_zombie_window = None
self._ns_app.pygui_app = None
self._ns_app = None
self._ns_pasteboard = None
GApplication.destroy(self)
def set_menus(self, menu_list):
GApplication.set_menus(self, menu_list)
self._update_menubar()
def _update_menubar(self):
ns_app = self._ns_app
ns_menubar = NSMenu.alloc().initWithTitle_("")
menu_list = self._effective_menus()
for menu in menu_list:
ns_item = NSMenuItem.alloc()
ns_item.initWithTitle_action_keyEquivalent_(menu.title,
'', "")
ns_menubar.addItem_(ns_item)
ns_menu = menu._ns_menu
# An NSMenu can only be a submenu of one menu at a
time, so
# remove it from the old menubar if necessary.
old_supermenu = ns_menu.supermenu()
if old_supermenu:
i =
old_supermenu.indexOfItemWithSubmenu_(ns_menu)
old_supermenu.removeItemAtIndex_(i)
ns_menubar.setSubmenu_forItem_(ns_menu, ns_item)
ns_app.setMainMenu_(ns_menubar)
# Apple's docs fail to explain that the menu you pass to
setAppleMenu_
# must *also* be a member of the menu bar.
ns_app_menu = menu_list[0]._ns_menu
self._ns_app.setAppleMenu_(ns_app_menu)
def handle_events(self):
#print "Application.handle_events: entering NS run loop" ###
#try:
self._ns_app.run()
#finally:
#print "Application.handle_events: exiting NS run loop"
###
def handle_next_event(self, modal_window = None):
#print "Application.handle_next_event" ###
ns_app = self._ns