ANN: PyGUI 1.7.2-1

2006-06-10 Thread greg
I have uploaded a new PyGUI 1.7.2 package to correct
a couple of errors in the setup.py file.

http://www.cosc.canterbury.ac.nz/~greg/python_gui/

-

What is PyGUI?
--

PyGUI is an experimental highly-Pythonic cross-platform
GUI API. Implementations are currently available for
MacOSX and Gtk. For a full description of the project
goals, see the PyGUI web page at the above address.

--
Greg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 1.7.2-1

2006-06-12 Thread hale

greg wrote:
> I have uploaded a new PyGUI 1.7.2 package to correct
> a couple of errors in the setup.py file.
>
> http://www.cosc.canterbury.ac.nz/~greg/python_gui/
>
> -
>
> What is PyGUI?
> --
>
> PyGUI is an experimental highly-Pythonic cross-platform
> GUI API. Implementations are currently available for
> MacOSX and Gtk. For a full description of the project
> goals, see the PyGUI web page at the above address.
>
> --
> Greg

I downloaded the new version of PyGUI, but I am having
some problems with running it in the IDLE ide.

I will use BlobEdit.py as an example.

If I run the the makefile, then blobedit runs ok as an application.

If I use the terminal, and execute pythonw with argument blobedit.py,
then it runs ok.

However, if I try to run blobedit.py in the IDLE ide, I get an error
since it tries to open a file when no file was given. Looking at your
code, I see that you noticed certain situation where this occurs
and tried to handle it by comparing path == sys.argv[0] and skipping
opening the file in this case.

But, when running it within IDLE, the path is equal to "8833" for some
reason. 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.

Is there some way to work around this problem?

Thanks.

-- Bill Hale

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 1.7.2-1

2006-06-12 Thread greg

[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