Skip to content

Commit bb0dd39

Browse files
committed
FMX form demo
1 parent 3027ed1 commit bb0dd39

File tree

6 files changed

+1267
-0
lines changed

6 files changed

+1267
-0
lines changed

Demos/FMX/FormDemo/FormDemo.dpr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
program FormDemo;
2+
3+
uses
4+
System.StartUpCopy,
5+
FMX.Forms,
6+
MainForm in 'MainForm.pas' {Form1},
7+
SecondForm in 'SecondForm.pas' {DelphiSecondForm};
8+
9+
{$R *.res}
10+
11+
begin
12+
Application.Initialize;
13+
Application.CreateForm(TForm1, Form1);
14+
Application.Run;
15+
end.

Demos/FMX/FormDemo/FormDemo.dproj

+976
Large diffs are not rendered by default.

Demos/FMX/FormDemo/MainForm.fmx

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
object Form1: TForm1
2+
Left = 0
3+
Top = 0
4+
Caption = 'MainForm'
5+
ClientHeight = 480
6+
ClientWidth = 640
7+
FormFactor.Width = 320
8+
FormFactor.Height = 480
9+
FormFactor.Devices = [Desktop]
10+
DesignerMasterStyle = 0
11+
object OpenDialog1: TOpenDialog
12+
DefaultExt = '*.py'
13+
Filter = 'Python files|*.py|Text files|*.txt|All files|*.*'
14+
Left = 200
15+
end
16+
object SaveDialog1: TSaveDialog
17+
DefaultExt = '*.py'
18+
Filter = 'Python files|*.py|Text files|*.txt|All files|*.*'
19+
Left = 232
20+
end
21+
object Memo1: TMemo
22+
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
23+
DataDetectorTypes = []
24+
Align = Top
25+
Size.Width = 640.000000000000000000
26+
Size.Height = 200.000000000000000000
27+
Size.PlatformDefault = False
28+
TabOrder = 8
29+
Viewport.Width = 636.000000000000000000
30+
Viewport.Height = 196.000000000000000000
31+
end
32+
object Splitter1: TSplitter
33+
Align = Top
34+
Cursor = crVSplit
35+
MinSize = 20.000000000000000000
36+
Position.Y = 200.000000000000000000
37+
Size.Width = 640.000000000000000000
38+
Size.Height = 3.000000000000000000
39+
Size.PlatformDefault = False
40+
end
41+
object Memo2: TMemo
42+
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
43+
DataDetectorTypes = []
44+
Lines.Strings = (
45+
'from spam import Form'
46+
''
47+
'class SubForm(Form): '
48+
' def __init__(self, Owner):'
49+
' self.Caption = '#39'Subclassed form defined in Python'#39
50+
''
51+
'class DelphiSecondForm(Form):'
52+
' pass'
53+
''
54+
'def createbaseform():'
55+
' print('#39'Creates a Delphi FMX.TForm'#39')'
56+
' form = Form(None)'
57+
' try:'
58+
' form.Caption = "Delphi FMX base form"'
59+
' form.ShowModal()'
60+
' finally:'
61+
' form.Free();'
62+
''
63+
'def createpysubform():'
64+
' print('#39'Creates a Delphi FMX.TForm subtype defined in Python'#39')'
65+
' form = SubForm(None)'
66+
' try:'
67+
' form.ShowModal()'
68+
' finally:'
69+
' form.Free()'
70+
''
71+
'def createdelphisubform():'
72+
73+
' print('#39'Creates an instance of TDelphiSecondForm registerd form' +
74+
#39')'
75+
' form = DelphiSecondForm(None)'
76+
' try:'
77+
' print('#39'Label: '#39', form.Label1.Text)'
78+
' form.ShowModal()'
79+
' finally:'
80+
' form.Free()'
81+
''
82+
'def main():'
83+
' createbaseform()'
84+
' createpysubform()'
85+
' createdelphisubform()'
86+
''
87+
'if __name__ == '#39'__main__'#39':'
88+
' try:'
89+
' main()'
90+
' except SystemExit:'
91+
' pass')
92+
Align = Client
93+
Size.Width = 640.000000000000000000
94+
Size.Height = 232.000000000000000000
95+
Size.PlatformDefault = False
96+
TabOrder = 10
97+
Viewport.Width = 620.000000000000000000
98+
Viewport.Height = 228.000000000000000000
99+
end
100+
object Panel1: TPanel
101+
Align = Bottom
102+
Position.Y = 435.000000000000000000
103+
Size.Width = 640.000000000000000000
104+
Size.Height = 45.000000000000000000
105+
Size.PlatformDefault = False
106+
TabOrder = 11
107+
object Button1: TButton
108+
Position.X = 8.000000000000000000
109+
Position.Y = 10.000000000000000000
110+
Size.Width = 97.000000000000000000
111+
Size.Height = 22.000000000000000000
112+
Size.PlatformDefault = False
113+
TabOrder = 2
114+
Text = 'Execute script'
115+
OnClick = Button1Click
116+
end
117+
object Button2: TButton
118+
Position.X = 192.000000000000000000
119+
Position.Y = 10.000000000000000000
120+
TabOrder = 1
121+
Text = 'Load script...'
122+
OnClick = Button2Click
123+
end
124+
object Button3: TButton
125+
Position.X = 280.000000000000000000
126+
Position.Y = 10.000000000000000000
127+
TabOrder = 0
128+
Text = 'Save script...'
129+
OnClick = Button3Click
130+
end
131+
end
132+
object PythonEngine1: TPythonEngine
133+
IO = PythonGUIInputOutput1
134+
Left = 8
135+
end
136+
object PythonModule1: TPythonModule
137+
Engine = PythonEngine1
138+
ModuleName = 'spam'
139+
Errors = <>
140+
Left = 40
141+
end
142+
object PythonGUIInputOutput1: TPythonGUIInputOutput
143+
UnicodeIO = True
144+
RawOutput = False
145+
Output = Memo1
146+
Left = 104
147+
end
148+
object PyDelphiWrapper1: TPyDelphiWrapper
149+
Engine = PythonEngine1
150+
Module = PythonModule1
151+
Left = 72
152+
end
153+
end

Demos/FMX/FormDemo/MainForm.pas

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
unit MainForm;
2+
3+
interface
4+
5+
uses
6+
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7+
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
8+
FMX.StdCtrls, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo,
9+
PythonEngine, WrapDelphi, FMX.PythonGUIInputOutput, WrapDelphiFmx;
10+
11+
type
12+
TForm1 = class(TForm)
13+
OpenDialog1: TOpenDialog;
14+
SaveDialog1: TSaveDialog;
15+
Memo1: TMemo;
16+
Splitter1: TSplitter;
17+
Memo2: TMemo;
18+
Panel1: TPanel;
19+
Button1: TButton;
20+
Button2: TButton;
21+
Button3: TButton;
22+
PythonEngine1: TPythonEngine;
23+
PythonModule1: TPythonModule;
24+
PythonGUIInputOutput1: TPythonGUIInputOutput;
25+
PyDelphiWrapper1: TPyDelphiWrapper;
26+
procedure Button2Click(Sender: TObject);
27+
procedure Button3Click(Sender: TObject);
28+
procedure Button1Click(Sender: TObject);
29+
private
30+
{ Private declarations }
31+
public
32+
{ Public declarations }
33+
end;
34+
35+
var
36+
Form1: TForm1;
37+
38+
implementation
39+
40+
{$R *.fmx}
41+
42+
procedure TForm1.Button1Click(Sender: TObject);
43+
begin
44+
PythonEngine1.ExecStrings(Memo2.Lines);
45+
end;
46+
47+
procedure TForm1.Button2Click(Sender: TObject);
48+
begin
49+
with OpenDialog1 do begin
50+
if Execute then
51+
Memo2.Lines.LoadFromFile( FileName );
52+
end;
53+
end;
54+
55+
procedure TForm1.Button3Click(Sender: TObject);
56+
begin
57+
with SaveDialog1 do begin
58+
if Execute then
59+
Memo2.Lines.SaveToFile(FileName);
60+
end;
61+
end;
62+
63+
end.

Demos/FMX/FormDemo/SecondForm.fmx

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
object DelphiSecondForm: TDelphiSecondForm
2+
Left = 0
3+
Top = 0
4+
Caption = 'Delphi second form'
5+
ClientHeight = 480
6+
ClientWidth = 640
7+
FormFactor.Width = 320
8+
FormFactor.Height = 480
9+
FormFactor.Devices = [Desktop]
10+
DesignerMasterStyle = 0
11+
object Label1: TLabel
12+
Align = Top
13+
AutoSize = True
14+
StyledSettings = [Family, FontColor]
15+
Margins.Left = 10.000000000000000000
16+
Margins.Top = 10.000000000000000000
17+
Margins.Right = 10.000000000000000000
18+
Margins.Bottom = 10.000000000000000000
19+
Position.X = 10.000000000000000000
20+
Position.Y = 10.000000000000000000
21+
Size.Width = 620.000000000000000000
22+
Size.Height = 30.000000000000000000
23+
Size.PlatformDefault = False
24+
StyleLookup = 'labelstyle'
25+
TextSettings.Font.Size = 22.000000000000000000
26+
TextSettings.Font.StyleExt = {00070000000000000004000000}
27+
TextSettings.HorzAlign = Center
28+
Text = 'This is a Delphi registerd form'
29+
TabOrder = 1
30+
end
31+
end

Demos/FMX/FormDemo/SecondForm.pas

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
unit SecondForm;
2+
3+
interface
4+
5+
uses
6+
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7+
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
8+
FMX.Controls.Presentation, FMX.StdCtrls;
9+
10+
type
11+
TDelphiSecondForm = class(TForm)
12+
Label1: TLabel;
13+
private
14+
{ Private declarations }
15+
public
16+
{ Public declarations }
17+
end;
18+
19+
var
20+
DelphiSecondForm: TDelphiSecondForm;
21+
22+
implementation
23+
24+
{$R *.fmx}
25+
26+
initialization
27+
RegisterClass(TDelphiSecondForm);
28+
29+
end.

0 commit comments

Comments
 (0)