孤荷凌寒自學python第四十五天Python初學基礎基本結束的下階段預安裝準備

 孤荷凌寒自學python第四十五天Python初學基礎基本結束的下階段預安裝準備

 

(完整學習過程屏幕記錄視頻地址在文末,手寫筆記在文末)java

今天原本應當繼續學習Python的數據庫操做,但根據過去我自學其它編程語言的經驗,我以爲對Python的膚淺的基礎的知識學習完成以後,必定也要開始的構建本身的Python編程大廈的腳手架——開始將一些本身用起來順手的經常使用功能封裝塊化,創建模塊和類,造成一種基礎沉澱,這樣整個本身的Python學習大廈纔將越修越好,這是從我過往的編程語言自學中總結出來的,固然還不知道是否也適用於Python.python

不過我仍然決定對Python後續可能必須用到的一些模塊和知識進行了解,並預安裝相關的,以便在搭建本身的通用的模塊和類時,可以有針對性的向實用的方向進行建構。linux

因而今天發現了Python必須面對的可視化界面的相關組件,因而進行了安裝相應模塊和簡單的測試,且分別在windows下和linux下兩種系統進行了屢敗屢戰的嘗試,最終勉強成功。android

1、  在windows10下對可視化界面相關組件的安裝ios

python 自帶的基礎的可視化界面的標準庫模塊tkinter,足夠通常性的應用,所以目前不打算專門安裝其它擴展性更好的可視化界面庫。但tkinter有一個先天不足,要描述一個窗體界面上的控件(如按鈕和輸入框等)時,必須只能經過代碼來指定每一個控件的屬性(如大小,位置等等)。這其實很是花費時間,並非可見便可得,因而爲了效率,人們想出了不少方法來讓tkinter的可視化界面設計也可能直接【畫出】控件來,方法各類各樣,但我選擇了了安裝page-python來實現,由於此程序在windows和linux下均可以使用。c++

1. tcl/tkgit

在安裝page-python以前首先應當安裝tcl組件和tk組件,不然page-python安裝後也沒法運行。github

(1)     首先找到windows版本的tcl/tk組件的下載網站:sql

https://www.activestate.com/activetcl/downloads數據庫

選擇適合當前操做系統的文件版本,注意是32位仍是64位且是windows版本的安裝包才行。

(2)     下載後是一個EXE文件,直接安裝便可。

2. page-python

(1)到下邊的網站去下載page-python

https://sourceforge.net/projects/page/

此網站打開後,自動判斷你的操做系統,而後在界面上只出現惟一的一個下載地址,直接點擊下載便可。

(2)下載完成後,也是一個exe文件,直接安裝便可。

(3)     安裝完成後,桌面上會有Page的圖標,打開就能夠直接在上面設置窗體並在窗體上畫上各類控件並設置每一個控件的屬性。

(4)     也能夠代碼編輯每一個控件觸發時要執行的操做,整個操做就很是方便了。

(5)     具體使用沒有深刻研究,但進行了簡單的測試,經過Page-python軟件獲得的python文件源代碼以下:

 

#!/usr/bin/env python

#  -*- coding: utf-8 -*-

#

# GUImodule generated by PAGE version 4.16

# Inconjunction with Tcl version 8.6

#    Aug 31, 2018 05:56:26 PM CST  platform: Windows NT

 

import sys

 

try:

    from Tkinter import *

except ImportError:

    from tkinter import *

 

try:

    import ttk

    py3 = False

except ImportError:

    import tkinter.ttk as ttk

    py3 = True

 

def vp_start_gui():

    '''Starting point when module is themain routine.'''

    global val, w, root

    root = Tk()

    top = __________ (root)

    init(root, top)

    root.mainloop()

 

w = None

def create___________(root, *args, **kwargs):

    '''Starting point when module isimported by another program.'''

    global w, w_win, rt

    rt = root

    w = Toplevel (root)

    top = __________ (w)

    init(w, top, *args, **kwargs)

    return (w, top)

 

def destroy___________():

    global w

    w.destroy()

    w = None

 

class __________:

    def __init__(self, top=None):

        '''This classconfigures and populates the toplevel window.

           top is the toplevel containingwindow.'''

        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'

        _fgcolor = '#000000'  # X11 color: 'black'

        _compcolor = '#d9d9d9' # X11color: 'gray85'

        _ana1color = '#d9d9d9' # X11color: 'gray85'

        _ana2color = '#d9d9d9' # X11color: 'gray85'

        font9 = "-family{Microsoft YaHei UI} -size 16 -weight normal "  \

            "-slant roman -underline0 -overstrike 0"

 

        top.geometry("1234x818+1499+413")

        top.title("孤荷凌寒的第一個界面")

        top.configure(background="#d9d9d9")



        self.txtMain= Text(top)

        self.txtMain.place(relx=0.1, rely=0.01, relheight=0.24, relwidth=0.81)

        self.txtMain.configure(background="white")

        self.txtMain.configure(font="TkTextFont")

        self.txtMain.configure(foreground="black")

        self.txtMain.configure(highlightbackground="#d9d9d9")

        self.txtMain.configure(highlightcolor="black")

        self.txtMain.configure(insertbackground="black")

        self.txtMain.configure(selectbackground="#c4c4c4")

        self.txtMain.configure(selectforeground="black")

        self.txtMain.configure(width=1004)

        self.txtMain.configure(wrap=WORD)

 

        self.bntMain= Button(top,command=onBtnMainClick)

        self.bntMain.place(relx=0.38, rely=0.4, height=106, width=343)

        self.bntMain.configure(activebackground="#d9d9d9")

        self.bntMain.configure(activeforeground="#000000")

        self.bntMain.configure(background="#18cbd8")

        self.bntMain.configure(disabledforeground="#a3a3a3")

        self.bntMain.configure(font=font9)

        self.bntMain.configure(foreground="#840da8")

        self.bntMain.configure(highlightbackground="#d9d9d9")

        self.bntMain.configure(highlightcolor="black")

        self.bntMain.configure(pady="0")

        self.bntMain.configure(text='''肯定''')

        self.bntMain.configure(width=343)

        #self.bntMain.configure(command=onBtnMainClick)

       

 

def init(top, gui, *args, **kwargs):

    global w, top_level, root

    w = gui

    top_level = top

    root = top

 

def destroy_window():

    # Function which closes the window.

    global top_level

    top_level.destroy()

    top_level = None

   

def onBtnMainClick():

   

    w.txtMain.insert('1.0','hello\n')

 

if __name__ == '__main__':

   

    vp_start_gui()

運行結果會彈出一個windows窗口,點擊按鈕能夠執行代碼指定的操做。具體過程請參看我學習過程當中的屏幕錄像。

 

2、  在Fedora系統下對可視化界面相關組件的安裝

在個人fedora系統中,python中自帶的的tkinter竟然沒有安裝!

因而又費了些周折才安裝起:

[pw@localhost~]$ yum -y install tkinter

錯誤:該命令必須以 root 用戶運行

[pw@localhost~]$ sudo su

[sudo]pw 的密碼:

[root@localhostpw]# yum -y install tkinter

上次元數據過時檢查:0:07:30 前,執行於 2018年09月08日 星期六 10時24分32秒。

依賴關係解決。

=======================

 軟件包                架構         版本                    倉庫          大小

==========================

安裝:

 python2-tkinter       x86_64       2.7.15-2.fc28           updates       400 k

正在安裝安裝依賴關係:

 tix                   x86_64       1:8.4.3-21.fc28         fedora        261 k

 

事務概要

======================

安裝  2 軟件包

 

總下載:662 k

安裝大小:2.6 M

下載軟件包:

(1/2):python2-tkinter-2.7.15-2.fc28.x86_64.rpm 1.1 MB/s | 400 kB     00:00   

(2/2):tix-8.4.3-21.fc28.x86_64.rpm            676 kB/s | 261 kB     00:00   

-----------------------

總計                                             25kB/s | 662 kB     00:26    

運行事務檢查

事務檢查成功。

運行事務測試

事務測試成功。

運行事務

  準備中  :                                                                1/1

  安裝    : tix-1:8.4.3-21.fc28.x86_64                                      1/2

  運行腳本:tix-1:8.4.3-21.fc28.x86_64                                     1/2

  安裝    : python2-tkinter-2.7.15-2.fc28.x86_64                            2/2

  運行腳本:python2-tkinter-2.7.15-2.fc28.x86_64                            2/2

  驗證    : python2-tkinter-2.7.15-2.fc28.x86_64                            1/2

  驗證    : tix-1:8.4.3-21.fc28.x86_64                                      2/2

 

已安裝:

  python2-tkinter.x86_64 2.7.15-2.fc28        tix.x86_64 1:8.4.3-21.fc28      

 

完畢!

[root@localhostpw]# yum install python3-tkinter

上次元數據過時檢查:0:08:29 前,執行於 2018年09月08日 星期六 10時24分32秒。

依賴關係解決。

===============

 軟件包                 架構          版本                 倉庫            大小

================

安裝:

 python3-tkinter        x86_64        3.6.6-1.fc28         updates        370 k

 

事務概要

=====================

安裝  1 軟件包

 

總下載:370 k

安裝大小:1.5 M

肯定嗎?[y/N]:y

下載軟件包:

python3-tkinter-3.6.6-1.fc28.x86_64.rpm         1.1 MB/s | 370 kB     00:00   

-------------

總計                                            297kB/s | 370 kB     00:01    

運行事務檢查

事務檢查成功。

運行事務測試

事務測試成功。

運行事務

  準備中  :                                                                1/1

  安裝    : python3-tkinter-3.6.6-1.fc28.x86_64                             1/1

  運行腳本:python3-tkinter-3.6.6-1.fc28.x86_64                             1/1

  驗證    : python3-tkinter-3.6.6-1.fc28.x86_64                             1/1

 

已安裝:

  python3-tkinter.x86_64 3.6.6-1.fc28          

1. tcl/tk

在安裝page-python以前首先應當安裝tcl組件和tk組件,不然page-python安裝後也沒法運行。

(1)  首先找到linux版本的tcl/tk組件的下載網站:

https://www.activestate.com/activetcl/downloads

選擇適合當前操做系統的文件版本,注意是32位仍是64位且是linux版本的壓縮包才行。

(2)  下載後的文件以下命名的文件:

ActiveTcl.tar.gz

可使用命令行解壓這個文件,我是直接鼠標右鍵提取的這個文件到下載目錄。

命令行解壓是這樣的:

cd 下載的文件所在目錄

tar zxvf ActiveTcl.tar.gz

解壓後獲得的文件夾的名稱是:

ActiveTcl

(3)如今經過命令行的cp命令將這個文件夾複製到主目錄的/usr/share/目錄下

命令行以下:

cp -a/home/pw/ActiveTcl /usr/share

注意複製命令的參數-a必需要有,我一開始就遺忘了,上網搜索才弄對,所以在Linux系統下對Linux的命令行必定要很是熟悉。

(4)此時經過cd命令進入複製到的目標文件夾:

cd /usr/share/ActiveTcl

(5)這個時候就能夠直接執行ActiveTcl文件中的install.sh文件安裝便可

命令行以下:

./install.sh

然而,個人fedora系統在這兒卻失敗了,提示缺乏依賴項:

libXss.so.1

因而我執行安裝命令安裝libXss.so.1

命令行以下:

yum install libXss.so.1

這個順利安裝成功,但當再次執行ActiveTcl文件中的install.sh文件安裝時,仍是提示沒有libXss.so.1組件,頓時懵了,明明安裝成功了啊!

又花了一個小時才終於明白,原來個人fedora系統是64位的,而yum install libXss.so.1 命令默認只會安裝32位的,不得不讓我發出悲嘆這是多麼坑爹的設計啊!這Linux系統果真是明不虛傳的難弄!

因而下載了64位的libXss.so.1進行安裝:

下載地址:

https://pkgs.org/download/libXss.so.1

注意選擇正確的Linux系統版本與32位或64位的文件下載

我下載的文件名:

libXScrnSaver-1.2.2-14.fc28.x86_64.rpm

注意文件名中的FC28指的是對應的fedora系統版本fedora28版。

rpm文件能夠在fedora系統中右鍵直接點擊安裝。

固然也能夠經過命令行,直接下載和安裝:

直接自動下載並安裝64位的命令行以下:

sudo dnf install/usr/lib64/libXss.so.1

而後再次執行下面的命令就成功了:

./install.sh

可是此時命令行會有不少英文提示輸入安裝的目錄和工做文件夾等,我英文不是很好,費不盡的力才終於設置好,最終獲得的結論是保持它默認設置的的目錄就好了。這個個人操做看下我操做過程當中的屏幕錄像。

2. page-python

(1)到下邊的網站去下載page-python

https://sourceforge.net/projects/page/

此網站打開後,自動判斷你的操做系統,而後在界面上只出現惟一的一個下載地址,直接點擊下載便可。

(2)此時下載下來的是一個壓縮包,以下文件命名的壓縮包:

page-4.16.tgz

在Fedora系統中能夠直接鼠標右鍵解壓它。

(3)而後經過cp命令複製到須要的目錄下

cp -a/home/pw/page-4.16 /usr/share/Visual/

(4)接下來經過cd命令進入page-4.16目錄中

cd /usr/share/Visual/page-4.16

(5)這時候要手動打開/usr/share/Visual/page-4.16目錄下的文件:

page.tcl

把文件中的第一行修改成如下的內容:

#!/usr/bin/env tclsh

其實修改的就是最後的tclsh這五個字母

爲了解決這個問題,當時反覆上網搜索,結果網上講的都並不適用於個人操做系統,花了數個小時,最後才本身獨立思考得出它原文件中的第一行根本沒有提到tcl這個組件,因而我就嘗試將其修改成了tclsh,沒想到就成功了。

(6)修改完成後,再輸入如下命令:

tclsh page.tcl

這樣,與windows系統中如出一轍的page界面就出現了,可是不知道是否是個人fedora系統顯示的緣由,整個page編輯的界面上的文字很是的小,基本看不到文字,固然我是將屏幕顯示分辨率提升到300%,加上是4K顯示器,不知道是否是這個緣由,具體狀況看我操做過程的屏幕錄像。所以實際上這個Page軟件界面對個人系統而言沒法操做,除非我還得配上放大鏡。

可是最終是安裝成功的。

3.一樣在fedora系統下測試了上面在windows系統下測試過的可視化界面的Py文件,發現運行效果是徹底同樣的。

 

3、  在windows系統下安裝相關組件以便將Py文件打包成exe文件

1.安裝pyinstaller組件

經過如下命令安裝pyinstaller組件

pip install pyinstaller

若是安裝過程當中報錯,主要是32位windows系統報錯的話,可能要先安裝下面的組件,命令行以下:

pipinstall pywin32

2.安裝完成後,此操做在windows下就大功形成了,關於pyintaller的使用目前並無研究,只知道它既能夠將單個Py文件打包成一個exe文件,也能夠將一個文件夾的Py程序彙總打包成exe文件,並且要獲得exe文件此操做必須在windows環境下運行才行。

 

4、  在Linux系統下安裝相關組件以便將Py文件打包成Linux系統下的可執行文件

1. .安裝pyinstaller組件

經過如下命令安裝pyinstaller組件

pip install pyinstaller

但若是fedora系統中有兩個Python版本,此命令默認安裝的是:Python2.7對應的pyinstaller,若是要安裝python3.6對應的版本,則應當使用如下命令:

pip3install pyinstaller

2.此組件安裝完成後,就可使用此組件將一個或多個Py文件直接打包爲在Linux下能夠執行的執行文件了,此類執行文件是沒有後綴名的。且只能在Linux系統下運行。

 

5、  嘗試將Py文件打包爲可執行文件

1.就使用剛纔測試過的用tkinter庫設計編寫的有可視化編程界面的的Py文件(此文件的可視化界面是在windows下用page-python手動畫控件設置的)在windows10環境下打包成windows的可執行程序exe文件。

此py文件名爲:

unknown.py

在windows的命令行窗口中輸入如下命令:

pyinstaller-Fw I:\MAKEAPP\python\Python365\邊學習邊測試文件夾\自學PYTHON部分\unknown.py --distpath=E:/dist

注意參數 –Fw 是必須 的,這樣才能保證打開exe文件時,程序直接出現程序窗口界面,就再不會先出現命令行窗口了。

打包完成後,就會在參數中指明的「E:/dist」文件夾下出現一個exe文件,名爲:

unknown.exe

而後我在打包所用的windows10系統環境下進行了測試,此係統中安裝有python3.6.5,能夠輕鬆打開並正確執行。

接下來在沒有安裝Python的其它windows10系統中進行測試,也能夠完美運行。、但在windows10以外的其它操做系統上就不能運行了(如windows7和windows8都不行)。

並且由於我打包用的windows10系統是64位的,打包出來的exe文件也就是64位的exe程序,所以不能在32位windows10系統上運行。

2.就使用與windows10下打包相同的同一個Py文件在fedora28系統環境下打包成linux系統的可執行程序文件(這種執行文件沒有可區別的後綴名)。

此py文件名爲:

unknown.py

打開fedora操做系統的命令行終端,輸入如下命令:

pyinstaller-Fw /home/pw/unknown.py--distpath=/home/pw/dist

注意參數 –Fw 是必須 的,這樣才能保證打開打包獲得的linux下可執行的程序文件時,程序直接出現程序窗口界面,就再不會先出現命令行窗口了。

打包完成後,就會在命令行中指明的目錄「/home/pw/dist」中獲得一個在Linux下可執行的程序文件:

unknown

個人fedora28系統是64位的,但也沒有安裝32位的Linux系統能夠測試。

在當前打包時用到的fedora28系統中能夠輕鬆完美的運行這個程序文件。

而後就開始到其它linux系統中去測試:

在安裝有python3.5.6的fedora28,64位系統中,測試結果爲:能夠正常打開程序並執行全部功能。

在centos7, 64位系統中,也沒有安裝任何 python3.6.6,測試結果爲:不能正常打開任何程序。

 

今天只對pyinstaller的基本功能進行了一下測試,且只打包了有可視界面的單一一個Py文件而已,從此在實際學習到的時候,還將使用它來打包整個python程序工程目錄,其它功能將在實際須要的時候再學習。

 

6、  安裝能夠將Py文件打包爲Android系統可執行的apk程序文件的相關組件

python的神奇之處在於它的Py文件也能夠被打包成apk文件,而後就能夠在android系統中運行了。

固然今天只是對須要的打包環境組件進行了安裝,且打包的實際操做只能在linux系統下進行,因而重點就在個人fedora28系統中進行。

核心的教程來自於:

https://kivy.org/#download

其中包含了全部操做系統的教程,不過是英文的。

整個過程很是艱辛,現記錄安裝過程的具體流程以下:

1.升級yum安裝包

yum-y upgrade

 

2.安裝依賴項組件

sudo yum install \

    make \

    mercurial \

    automake \

    gcc \

    gcc-c++ \

    SDL_ttf-devel \

    SDL_mixer-devel \

    khrplatform-devel \

    mesa-libGLES \

    mesa-libGLES-devel \

    gstreamer-plugins-good \

    gstreamer \

    gstreamer-python \

    mtdev-devel \

    python-devel \

    python-pip

這些全部依賴項組件安裝都比較順利,只有其中的:

khrplatform-devel

無論怎樣升級擴充yum源包都沒法安裝它,但最後沒有安裝它也仍是沒有發生任何錯誤。

 

3.升級更新兩個安裝組件

sudopip install --upgrade pip virtualenv setuptools

 

4 .安裝kivy解釋器

virtualenv--no-site-packages kivyinstall

 

5.激活解釋器

.kivyinstall/bin/activate

 

6.安裝python的numpy組件

pip3install numpy

 

7.安裝cython

pip3install Cython

 

8.安裝pygame

pip3install hg+http://bitbucket.org/pygame/pygame

 

9.安裝kivy(若是要安裝下一步的開發版本就不要安裝這一個)

pip3install kivy

 

10.實際上我安裝的是開發版本(若是已安裝上一個就不要安裝這一個)

pip3install git+https://github.com/kivy/kivy.git@master

 

11.安裝kivy周邊組件包

pip3install git+https://github.com/kivy/buildozer.git@master

pip3install git+https://github.com/kivy/plyer.git@master

pip3install -U pygments docutils

 

12.安裝buildozer 生成器(我fedora28系統中已自帶,因此沒有安裝,下面是網絡上的從源安裝最新版的方法)

(1)下載包:

gitclone https://github.com/kivy/buildozer.git

(2)cd 到下載的包(解壓 後的包所在目錄)

(3)執行包根目錄下的安裝文件

sudopython3.6 setup.py install

固然也能夠直接嘗試用Pip安裝(可能失敗,並且可能沒有安裝到最新版本)

pip3 install buildozer

 

13.安裝javac

sudodnf install java*jdk*devel*

 

到此在Fedora28下的全部安裝都已完成

 

7、實際測試下,將一個用Kivy寫的有可視界面的Py程序打包成apk文件

關於打包apk的詳細教程在如下網站:

https://pypi.org/project/buildozer/

1.複製了網絡上的一個測試py文件,我命名爲main.py

程序代碼以下:

importkivy

kivy.require('1.11.0')

 

 

frommath import floor

fromkivy.app import App

fromkivy.properties import NumericProperty

fromkivy.clock import Clock

fromkivy.vector import Vector

fromkivy.animation import Animation

fromkivy.lang import Builder

importpygame

importkivy.lib.vidcore_lite

 

 

 

kv =Builder.load_string('''

Button:

    text: "I am a button."

''')

 

class TestApp(App):

    def build(self):

        return kv

 

TestApp().run()

 

此main.py文件存放在/home/pw/a目錄下。

 

2.而後在fedora的命令行終端中輸入:

 

[pw@localhost~]$ cd /home/pw/a

[pw@localhost~]$ buildozer init

執行此命令後,將在a目錄下獲得一個配置文件:

buildozer.spec

此文件中設置了生成的各類參數:

[app]

 

# (str)Title of your application

title =My Application

 

# (str)Package name

package.name= myapp

 

# (str)Package domain (needed for android/ios packaging)

package.domain= org.test

 

# (str)Source code where the main.py live

source.dir= .

 

# (list)Source files to include (let empty to include all the files)

source.include_exts= py,png,jpg,kv,atlas

 

# (list)List of inclusions using pattern matching

#source.include_patterns= assets/*,images/*.png

 

# (list)Source files to exclude (let empty to not exclude anything)

#source.exclude_exts= spec

 

# (list)List of directory to exclude (let empty to not exclude anything)

#source.exclude_dirs= tests, bin

 

# (list)List of exclusions using pattern matching

#source.exclude_patterns= license,images/*/*.jpg

 

# (str)Application versioning (method 1)

version= 0.1

 

# (str)Application versioning (method 2)

#version.regex = __version__ = ['"](.*)['"]

#version.filename = %(source.dir)s/main.py

 

# (list)Application requirements

# commaseperated e.g. requirements = sqlite3,kivy

requirements= kivy

 

# (str)Custom source folders for requirements

# Setscustom source for any requirements with recipes

#requirements.source.kivy = ../../kivy

 

# (list)Garden requirements

#garden_requirements=

 

# (str)Presplash of the application

#presplash.filename= %(source.dir)s/data/presplash.png

 

# (str)Icon of the application

#icon.filename= %(source.dir)s/data/icon.png

 

# (str)Supported orientation (one of landscape, portrait or all)

orientation= portrait

 

# (list)List of service to declare

#services= NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

 

#

# OSXSpecific

#

 

#

# author= © Copyright Info

 

# changethe major version of python used by the app

osx.python_version= 3

 

# Kivyversion to use

osx.kivy_version= 1.11.0

 

#

#Android specific

#

 

# (bool)Indicate if the application should be fullscreen or not

fullscreen= 0

 

#(string) Presplash background color (for new android toolchain)

#Supported formats are: #RRGGBB #AARRGGBB or one of the following names:

# red,blue, green, black, white, gray, cyan, magenta, yellow, lightgray,

#darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,

# olive,purple, silver, teal.

#android.presplash_color= #FFFFFF

 

# (list)Permissions

#android.permissions= INTERNET

 

# (int)Android API to use

#android.api= 19

 

# (int)Minimum API required

#android.minapi= 9

 

# (int)Android SDK version to use

#android.sdk= 20

 

# (str)Android NDK version to use

#android.ndk= 9c

 

# (bool)Use --private data storage (True) or --dir public storage (False)

#android.private_storage= True

 

# (str)Android NDK directory (if empty, it will be automatically downloaded.)

#android.ndk_path=

 

# (str)Android SDK directory (if empty, it will be automatically downloaded.)

#android.sdk_path=

 

# (str)ANT directory (if empty, it will be automatically downloaded.)

#android.ant_path=

 

# (bool)If True, then skip trying to update the Android sdk

# Thiscan be useful to avoid excess Internet downloads or save time

# whenan update is due and you just want to test/build your package

#android.skip_update = False

 

# (str)Android entry point, default is ok for Kivy-based app

#android.entrypoint= org.renpy.android.PythonActivity

 

# (list)Pattern to whitelist for the whole project

#android.whitelist=

 

# (str)Path to a custom whitelist file

#android.whitelist_src=

 

# (str)Path to a custom blacklist file

#android.blacklist_src=

 

# (list)List of Java .jar files to add to the libs so that pyjnius can access

# theirclasses. Don't add jars that you do not need, since extra jars can slow

# downthe build process. Allows wildcards matching, for example:

#OUYA-ODK/libs/*.jar

#android.add_jars= foo.jar,bar.jar,path/to/more/*.jar

 

# (list)List of Java files to add to the android project (can be java or a

#directory containing the files)

#android.add_src=

 

# (list)Android AAR archives to add (currently works only with sdl2_gradle

#bootstrap)

#android.add_aars=

 

# (list)Gradle dependencies to add (currently works only with sdl2_gradle

#bootstrap)

#android.gradle_dependencies=

 

# (list)Java classes to add as activities to the manifest.

#android.add_activites= com.example.ExampleActivity

 

# (str)python-for-android branch to use, defaults to stable

#p4a.branch= stable

 

# (str)OUYA Console category. Should be one of GAME or APP

# If youleave this blank, OUYA support will not be enabled

#android.ouya.category= GAME

 

# (str)Filename of OUYA Console icon. It must be a 732x412 png image.

#android.ouya.icon.filename= %(source.dir)s/data/ouya_icon.png

 

# (str)XML file to include as an intent filters in <activity> tag

#android.manifest.intent_filters=

 

# (str)launchMode to set for the main activity

#android.manifest.launch_mode= standard

 

# (list)Android additionnal libraries to copy into libs/armeabi

#android.add_libs_armeabi= libs/android/*.so

#android.add_libs_armeabi_v7a= libs/android-v7/*.so

#android.add_libs_x86= libs/android-x86/*.so

#android.add_libs_mips= libs/android-mips/*.so

 

# (bool)Indicate whether the screen should stay on

# Don'tforget to add the WAKE_LOCK permission if you set this to True

#android.wakelock= False

 

# (list)Android application meta-data to set (key=value format)

#android.meta_data=

 

# (list)Android library project to add (will be added in the

#project.properties automatically.)

#android.library_references=

 

# (str)Android logcat filters to use

#android.logcat_filters= *:S python:D

 

# (bool)Copy library instead of making a libpymodules.so

#android.copy_libs= 1

 

# (str)The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86

android.arch= armeabi-v7a

 

#

# Pythonfor android (p4a) specific

#

 

# (str)python-for-android git clone directory (if empty, it will be automaticallycloned from github)

#p4a.source_dir=

 

# (str)The directory in which python-for-android should look for your own buildrecipes (if any)

#p4a.local_recipes=

 

# (str)Filename to the hook for p4a

#p4a.hook=

 

# (str)Bootstrap to use for android builds

#p4a.bootstrap = sdl2

 

# (int)port number to specify an explicit --port= p4a argument (eg for bootstrap flask)

#p4a.port=

 

 

#

# iOSspecific

#

 

# (str)Path to a custom kivy-ios folder

#ios.kivy_ios_dir= ../kivy-ios

 

# (str)Name of the certificate to use for signing the debug version

# Get alist of available identities: buildozer ios list_identities

#ios.codesign.debug= "iPhone Developer: <lastname> <firstname>(<hexstring>)"

 

# (str)Name of the certificate to use for signing the release version

#ios.codesign.release= %(ios.codesign.debug)s

 

 

[buildozer]

 

# (int)Log level (0 = error only, 1 = info, 2 = debug (with command output))

log_level= 1

 

# (int)Display warning if buildozer is run as root (0 = False, 1 = True)

warn_on_root= 1

 

# (str)Path to build artifact storage, absolute or relative to spec file

#build_dir = ./.buildozer

 

# (str) Pathto build output (i.e. .apk, .ipa) storage

#bin_dir = ./bin

 

#   -----------------------------------------------------------------------------

#    List as sections

#

#    You can define all the "list" as[section:key].

#    Each line will be considered as a option tothe list.

#    Let's take [app] / source.exclude_patterns.

#    Instead of doing:

#

#[app]

#source.exclude_patterns= license,data/audio/*.wav,data/images/original/*

#

#    This can be translated into:

#

#[app:source.exclude_patterns]

#license

#data/audio/*.wav

#data/images/original/*

#

 

 

#   -----------------------------------------------------------------------------

#    Profiles

#

#    You can extend section / key with a profile

#    For example, you want to deploy a demoversion of your application without

#    HD content. You could first change thetitle to add "(demo)" in the name

#    and extend the excluded directories toremove the HD content.

#

#[app@demo]

#title =My Application (demo)

#

#[app:source.exclude_patterns@demo]

#images/hd/*

#

#    Then, invoke the command line with the"demo" profile:

#

#buildozer--profile demo android debug

 

這個文件中各個參數的含義沒有具體瞭解,所以我只能保持默認狀態。

 

3.而後執行生成操做

[pw@localhosta]$ buildozer android debug

# Checkconfiguration tokens

# Ensurebuild layout

# Checkconfiguration tokens

#Preparing build

# Checkrequirements for android

#Install platform

# ApacheANT found at /home/pw/.buildozer/android/platform/apache-ant-1.9.4

#Android SDK found at /home/pw/.buildozer/android/platform/android-sdk-20

#Android NDK found at /home/pw/.buildozer/android/platform/android-ndk-r9c

 

通常說來執行到這兒,由於這個時候要鏈接google的服務器下載android的不少文件來安裝,所以,我試過連續讓它運行十個小時,也沒法再在此處有所進展。這網絡速度是硬傷。最終沒有等來apk文件的生成。

 

最後我在windows10下也成功安裝了kivy 且功能使用正常,但沒法安裝執行 buildozer,所以要生成apk文件仍是隻能在linux下運行buildozer才行。

——————————

今天整理的學習筆記完成,最後例行說明下個人自學思路:

根據過去多年我自學各類編程語言的經歷,認爲只有真正體驗式,解決實際問題式的學習纔會有真正的效果,即讓學習實際發生。在2004年的時候我開始在一個鄉村小學自學電腦 並學習vb6編程語言,沒有學習同伴,也沒有高師在上,甚至電腦都是孤島(鄉村那時尚未網絡),有的只是一本舊書,在痛苦的自學摸索中,我找到適應本身零基礎的學習方法:首先是每讀書的一小節就做相應的手寫筆記,第二步就是上機測試每個筆記內容是否實現,其中會發現書中講的其實有出入或錯誤,第三步就是在上機測試以後,將筆記改成電子版,造成最終的修訂好的正確無誤的學習筆記。

經過反覆嘗試錯誤,在那個沒有分享與交流的黑暗時期我摸黑學會了VB6,爾後接觸了其它語言,也曾聽過付費視頻課程,結果發現也許本身學歷果真過低,就算是零基礎的入門課程,其實也難以跟上進度,講師的教學多數出現對初學者的實際狀況並不瞭解的狀況,何況學習者的個體也存在差別呢?固然更可怕的是收費課程的價格每每是本身難以承受的。

因而個人全部編程學習都改成了自學,繼續本身的三步學習筆記法的學習之路。

固然自學的最大問題是會走那麼多的彎路,沒有導師直接輸入式的教學來得直接,好在網絡給咱們帶來無限搜索的機會,你們在網絡上的學習日誌帶給咱們共享交流的機會,而QQ羣等交流平臺、網絡社區的成立,咱們能夠一塊兒自學,互相批評交流,也能夠得到更有效,更自主的自學成果。

因而我以人生已過半的年齡,決定繼續個人編程自學之路,開始學習python,只但願與你們共同交流,一我的的獨行是可怕的,只有一羣人的共同前進纔是有但願的。

誠摯期待您的交流分享批評指點!歡迎聯繫我加入從零開始的自學聯盟。

這個時代互聯網成爲了一種基礎設施的存在,因而原本在孤獨學習之路上的咱們變得再也不孤獨,由於網絡就是一個新的客廳,咱們時刻均可以進行沙龍活動。

很是樂意能與你們一塊兒交流本身自學心得和發現,更但願你們可以對我學習過程當中的錯誤給予指點——是的,這樣我就能有許多免費的高師了——這也是分享時代,社區時代帶來的好福利,我相信你們會的,是吧!

 

根據徹底共享的精神,開源互助的理念,個人我的自學錄製過程是所有按4K高清視頻錄製的,從手寫筆記到驗證手寫筆記的上機操做過程全程錄製,但由於4K高清文件太大均超過5G以上,因此沒法上傳至網絡,若有須要可聯繫我QQ578652607對傳,樂意分享。上傳分享到百度網盤的只是壓縮後的720P的視頻。

 

個人學習過程錄像百度盤地址分享以下:(清晰度:1280x720)

連接:https://pan.baidu.com/s/1VVs-bCKxBUJZzUaeMTq7HQ 

提取碼:f84e

 

Bilibili:

https://member.bilibili.com/v2#/upload-manager/article

 

喜馬拉雅語音筆記:
https://www.ximalaya.com/keji/19103006/146755924

圖片

相關文章
相關標籤/搜索