本篇開始:
- 我的開發環境是win11
- python是3.10.7版本
- kivy我設定在2.1.0版本
- 編碼的工具是Visual Studio Code(VS Code)
以我實際開發的APP為例,
我想做的是可以訓練基本加(減)法的心算工具。命名app叫 「CountInMind」。
前言:
繼續製作app首頁,編寫countinmind.kv,在底下使用FloatLayout版面。
1.加入 Button物件(字首要大寫)
2.設定文字內容:加法
text:'加法'
3.設定語法:引用中文字體
font_name: './font/TW-Kai-98_1.ttf'
4.設定文字大小:23
font_size: 23
5.設定文字顏色:深灰
color: (30/255, 30/255, 30/255)
6.設定按鈕大小:寬為視窗0.3、長為視窗0.1
size_hint:0.3, 0.1
7.設定按鈕位置:寬的中心位置在視窗0.5處、長的中心位置在視窗0.36處
pos_hint: {'center_x':0.5, 'center_y':0.36}
以下為本篇程式碼(.kv)
Button:
text:'加法'
font_name: './font/TW-Kai-98_1.ttf'
font_size: 23
color: (30/255, 30/255, 30/255)
size_hint:0.3, 0.1
pos_hint: {'center_x':0.5, 'center_y':0.36}

▲按鈕顏色為預設的
8.本篇小結
加入 Button物件基本功能,如 text文字、大小、顏色以及按鈕的大小(size_hint)、位置(pos_hint)。
本篇所使用程式碼(.py):請參考01內容。
其他程式碼(.kv):請參考06內容。
本篇結束:
在自學路上遇到困難是很正常的事,只要堅持到底,相信就會有所成果,期勉大家一同努力。