spilornis / nibbler

python pyobjc utility for macOS for displaying dialogs using .nib files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nibbler

Nibbler is a Python PyOjbC utility for displaying dialogs using .nib files.

Examples

The best way to play with nibbler is to download this git repo and play with the two example files.

  1. Download this repo:

    git clone https://github.com/pudquick/nibbler.git
    cd nibbler/examples
  2. Now you can choose between running the sweet_example.py and sam_example.py scripts.

Getting Started

Now that you've seen what nibbler does from the examples you'll likely want to build your own dialog box. To get started you'll need:

  • A Mac with Python (fortunately all modern Macs come with this built-in)
  • The PyObjC bridge (again comes built-in)
  • Xcode (available from the MAS or Apple Developer Portal)

Once the requirements above are meet we're able to create our dialog.

  1. Launch Xcode.
  2. From your menu bar select File > New > File....
  3. For the correct template in Xcode 8, select macOS and in User Interface select Window.
  4. Click Next and you'll be prompted to save your file. Select a name and location.
  5. Now we need to get this file into a .nib file. From your menu bar select File > Export.... Make sure and change your File Format to Interface Builder Cocoa NIB.
  6. Now you need to write the python code to connect your elements.

Tips

  • Make sure and give all of your UI elements in Xcode a static identifier. Xcode by default sets identifiers to Automatic however that does not work with nibbler.
  • Printing your content handles is very helpful: print n.nib_contents
  • Printing your views can also help with troubleshooting: print n.views
  • Consult Apple's macOS Human Interface Guidelines for the authoritative source on the correct usage of UI elements.
  • Consult Apple's Start Developing iOS Apps (Swift):Build a Basic UI for a tutorial on building a UI in Xcode.

About

python pyobjc utility for macOS for displaying dialogs using .nib files

License:MIT License


Languages

Language:Python 100.0%