Skip to content

Commit a19549e

Browse files
committed
Added the Tip Calculator sample project to Samples
1 parent 8bc2874 commit a19549e

File tree

13 files changed

+72601
-0
lines changed

13 files changed

+72601
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- BEGIN_INCLUDE(manifest) -->
3+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="%package%"
5+
android:versionCode="%versionCode%"
6+
android:versionName="%versionName%"
7+
android:installLocation="%installLocation%">
8+
<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
9+
<%uses-permission%>
10+
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
11+
<queries>
12+
<%queries-child-elements%>
13+
</queries>
14+
<application
15+
android:persistent="%persistent%"
16+
android:restoreAnyVersion="%restoreAnyVersion%"
17+
android:label="%label%"
18+
android:debuggable="%debuggable%"
19+
android:largeHeap="%largeHeap%"
20+
android:icon="%icon%"
21+
android:theme="%theme%"
22+
android:hardwareAccelerated="%hardwareAccelerated%"
23+
android:resizeableActivity="false"
24+
android:requestLegacyExternalStorage="true">
25+
<%provider%>
26+
<%application-meta-data%>
27+
<%uses-libraries%>
28+
<%services%>
29+
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
30+
This will take care of integrating with our NDK code. -->
31+
<activity
32+
android:name="com.embarcadero.firemonkey.FMXNativeActivity"
33+
android:label="%activityLabel%"
34+
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
35+
android:launchMode="singleTask">
36+
<!-- Tell NativeActivity the name of our .so -->
37+
<meta-data android:name="android.app.lib_name" android:value="%libNameValue%" />
38+
39+
<intent-filter>
40+
<action android:name="android.intent.action.MAIN" />
41+
42+
<category android:name="android.intent.category.LAUNCHER" />
43+
</intent-filter>
44+
</activity>
45+
<%activity%>
46+
<%receivers%>
47+
</application>
48+
</manifest>
49+
<!-- END_INCLUDE(manifest) -->
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from delphifmx import *
2+
from TipMain import Main_Window
3+
4+
def main():
5+
Application.Initialize()
6+
Application.Title = 'Tip Calculator'
7+
Application.MainForm = Main_Window(Application)
8+
Application.MainForm.Show()
9+
Application.Run()
10+
Application.MainForm.Destroy()
11+
12+
if __name__ == '__main__':
13+
main()
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import os
2+
from delphifmx import *
3+
4+
class Main_Window(Form):
5+
6+
def __init__(self, owner):
7+
self.styleRuby = None
8+
self.styleLight = None
9+
self.ListBox1 = None
10+
self.ListBoxItem1 = None
11+
self.editTotal = None
12+
self.Label6 = None
13+
self.ListBoxItem2 = None
14+
self.Label7 = None
15+
self.editTip = None
16+
self.ListBoxItem3 = None
17+
self.trackTip = None
18+
self.ListBoxItem4 = None
19+
self.editPeople = None
20+
self.Label3 = None
21+
self.ListBoxItem5 = None
22+
self.trackPeople = None
23+
self.ListBoxItem6 = None
24+
self.Layout2 = None
25+
self.ListBoxItem7 = None
26+
self.per_person_share = None
27+
self.Label1 = None
28+
self.ListBoxItem8 = None
29+
self.bill_plus_tip = None
30+
self.Label5 = None
31+
self.ListBoxItem9 = None
32+
self.gold_style_btn = None
33+
self.ruby_style_btn = None
34+
self.light_style_btn = None
35+
self.default_style = None
36+
self.styleGold = None
37+
self.LoadProps(os.path.join(os.path.dirname(os.path.abspath(__file__)), "TipMain.pyfmx"))
38+
self.editTotal.OnChange = self.editTotalChange
39+
self.editTotal.Value = 100
40+
self.editTip.Value = 20
41+
self.editPeople.Value = 4
42+
43+
def calc_bill_plus_tip(self):
44+
total = self.editTotal.Value
45+
tip_percent = self.editTip.Value
46+
47+
if total != 0:
48+
self.bill_plus_tip.Text = str(round(total + (tip_percent*total)/100, 2))
49+
print(round(total + (tip_percent/total)*100, 2))
50+
else:
51+
self.bill_plus_tip.Text = str(0)
52+
53+
def calc_per_person_share(self):
54+
persons = self.editPeople.Value
55+
56+
self.per_person_share.Text = str(round(float(self.bill_plus_tip.Text) / persons, 2))
57+
58+
def editTotalChange(self, Sender):
59+
self.calc_bill_plus_tip()
60+
self.calc_per_person_share()
61+
62+
def editTipChange(self, Sender):
63+
self.trackTip.Value = self.editTip.Value
64+
self.calc_bill_plus_tip()
65+
self.calc_per_person_share()
66+
67+
def trackTipChange(self, Sender):
68+
self.editTip.Value = self.trackTip.Value
69+
self.calc_bill_plus_tip()
70+
self.calc_per_person_share()
71+
72+
def editPeopleChange(self, Sender):
73+
self.trackPeople.Value = self.editPeople.Value
74+
self.calc_bill_plus_tip()
75+
self.calc_per_person_share()
76+
77+
def trackPeopleChange(self, Sender):
78+
self.editPeople.Value = self.trackPeople.Value
79+
self.calc_bill_plus_tip()
80+
self.calc_per_person_share()
81+
82+
def gold_style_btnClick(self, Sender):
83+
self.styleBook = self.styleGold
84+
85+
def ruby_style_btnClick(self, Sender):
86+
self.styleBook = self.styleRuby
87+
88+
def light_style_btnClick(self, Sender):
89+
self.styleBook = self.styleLight
90+
91+
def default_styleClick(self, Sender):
92+
self.styleBook = None

0 commit comments

Comments
 (0)