Python packaged as Mac App__python

Source: Internet
Author: User

Python packaged into Mac App


First, create a simple Tkinter applied, and named sandwich.py:

Import Sys

If Sys.version_info < (3, 0):

# Python 2

Import Tkinter as TK

Else

# Python 3

Import Tkinter as TK

root = Tk. Tk ()

Root.title ("Sandwich")

tk. button (root, text= "Make Me a Sandwich"). Pack ()

Tk.mainloop ()


This small application is like this:




Second, Py2app packaging


1. Create a virtualenv environment

# Create a custom directory

$ mkdir Sandwichapp

$ CD Sandwichapp


# Use Virtualenv to create a isolated environment

$ virtualenv venv

$ . Venv/bin/activate




2. Install Py2app

Pip Install Py2app


3. Generate the Setup file

Py2applet--make-setup sandwich.py



4. Packing

#自己开发, pack quickly. (Because the computer has a dependent library installed, it can be run directly)

Python setup.py py2app-a



#给其他没有sdk的电脑使用, including the Lib library. (without the SDK installed on the computer, you need to remove-A, will be all the dependencies packaged.) )

Python setup.py Py2app



reference materials

1.python packaged as an executable file app

http://blog.csdn.net/freewebsys/article/details/46683645

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.