Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:09:18+00:00 2026-06-09T06:09:18+00:00

This is the Python code: #!/usr/bin/python import os import sys from Foundation import *

  • 0

This is the Python code:

#!/usr/bin/python

import os
import sys

from Foundation import *
from AppKit import *
import objc

def setupWindowMenu(app):
    windowMenu = NSMenu.alloc().initWithTitle_('Window')
    windowMenu.retain()
    menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Minimize', 'performMiniaturize:', 'm')
    windowMenu.addItem_(menuItem)
    windowMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Window', None, '')
    windowMenuItem.setSubmenu_(windowMenu)
    app.mainMenu().addItem_(windowMenuItem)
    app.setWindowsMenu_(windowMenu)

app = NSApplication.sharedApplication()

mainMenu = NSMenu.alloc().init()
app.setMainMenu_(mainMenu)
setupWindowMenu(app)

app.finishLaunching()
app.updateWindows()
app.activateIgnoringOtherApps_(True)

app.run()

I am getting this output:

$ python pyobjcdemo.py
2011-09-11 23:22:40.470 Python[21409:1507] _createMenuRef called with existing principal MenuRef already associated with menu
2011-09-11 23:22:40.471 Python[21409:1507] (
    0   CoreFoundation                      0x00007fff93acb986 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8f3b4d5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff93acb7ba +[NSException raise:format:arguments:] + 106
    3   CoreFoundation                      0x00007fff93acb744 +[NSException raise:format:] + 116
    4   AppKit                              0x00007fff8a8841fb -[NSCarbonMenuImpl _createMenuRef] + 64
    5   AppKit                              0x00007fff8a883ae6 -[NSCarbonMenuImpl _instantiateCarbonMenu] + 148
    6   AppKit                              0x00007fff8a8588e9 -[NSApplication finishLaunching] + 878
    7   AppKit                              0x00007fff8a85827d -[NSApplication run] + 118
    8   libffi.dylib                        0x00007fff8cf29e7c ffi_call_unix64 + 76
    9   ???                                 0x00007fbd1b480d10 0x0 + 140450183253264
)

Why?

What does it mean?

Why does this simple PyObjC code has any Carbon dependencies?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:09:19+00:00Added an answer on June 9, 2026 at 6:09 am

    The error is the call to finishLaunching. Just remove it, it should eliminate the error.

    Concerning why you see Carbon types in Cocoa, it is just a matter of code layers. Carbon and Cocoa are not two totally separate systems, they are APIs into the same system. (Although the lower “Carbon” layers are often referred to as “core” technologies, like Core Graphics.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: #! /usr/bin/python import sys, string def findAll(search, fh): count =
This is my piece of code: #!/usr/bin/python from xml.etree.ElementTree import ElementTree from array import
So I found this code: #!/usr/bin/python import sys #for cmd line argv import time
here is my code #!/usr/bin/python # -*- coding:utf-8 -*- import sys import pysvn def
I have the following code: #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore
Consider the code below: #!/usr/bin/env python from PyQt4 import QtCore, QtGui import os,sys class
I'm trying to work out what's not working in this code: #!/usr/bin/python import cmd
I have a Python code that uses Paramiko. #!/usr/bin/env python import paramiko username =
/Users/smcho/Desktop/bracket/[10,20] directory has abc.txt, but when I run this Python code import glob import
I ran into unbound method error in python with this code: import random class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.