@@ -12,7 +12,7 @@ interface
12
12
13
13
type
14
14
TThreadSortForm = class (TForm)
15
- StartBtn : TButton;
15
+ Start3Btn : TButton;
16
16
BubbleSortBox: TPaintBox;
17
17
SelectionSortBox: TPaintBox;
18
18
QuickSortBox: TPaintBox;
@@ -25,23 +25,23 @@ TThreadSortForm = class(TForm)
25
25
PythonMemo: TMemo;
26
26
PythonEngine1: TPythonEngine;
27
27
SortModule: TPythonModule;
28
- Start2Btn : TButton;
28
+ Start1Btn : TButton;
29
29
LoadBtn: TButton;
30
30
PythonDialog: TOpenDialog;
31
31
SaveDialog: TSaveDialog;
32
32
SaveBtn: TButton;
33
- Button1 : TButton;
33
+ StopBtn : TButton;
34
34
procedure BubbleSortBoxPaint (Sender: TObject);
35
35
procedure SelectionSortBoxPaint (Sender: TObject);
36
36
procedure QuickSortBoxPaint (Sender: TObject);
37
37
procedure FormCreate (Sender: TObject);
38
- procedure StartBtnClick (Sender: TObject);
39
- procedure Start2BtnClick (Sender: TObject);
38
+ procedure Start3BtnClick (Sender: TObject);
39
+ procedure Start1BtnClick (Sender: TObject);
40
40
procedure LoadBtnClick (Sender: TObject);
41
41
procedure SaveBtnClick (Sender: TObject);
42
42
procedure SortModuleInitialization (Sender: TObject);
43
43
procedure FormCloseQuery (Sender: TObject; var CanClose: Boolean);
44
- procedure Button1Click (Sender: TObject);
44
+ procedure StopBtnClick (Sender: TObject);
45
45
private
46
46
OwnThreadState: PPyThreadState;
47
47
ThreadsRunning: Integer;
@@ -129,22 +129,22 @@ procedure TThreadSortForm.InitThreads(ThreadExecMode: TThreadExecMode; script: T
129
129
130
130
end ;
131
131
132
- StartBtn .Enabled := False;
133
- Start2Btn .Enabled := False;
132
+ Start1Btn .Enabled := False;
133
+ Start3Btn .Enabled := False;
134
134
end ;
135
135
136
- procedure TThreadSortForm.Start2BtnClick (Sender: TObject);
136
+ procedure TThreadSortForm.Start1BtnClick (Sender: TObject);
137
137
begin
138
138
with GetPythonEngine do
139
139
begin
140
140
ExecStrings(PythonMemo.Lines);
141
- self.InitThreads(emNewState,nil );
141
+ self.InitThreads(emNewState, nil );
142
142
end ;
143
143
end ;
144
144
145
- procedure TThreadSortForm.StartBtnClick (Sender: TObject);
145
+ procedure TThreadSortForm.Start3BtnClick (Sender: TObject);
146
146
begin
147
- InitThreads(emNewInterpreter,PythonMemo.Lines);
147
+ InitThreads(emNewInterpreter, PythonMemo.Lines);
148
148
// PythonEngine1.ExecStrings(PythonMemo.Lines);
149
149
end ;
150
150
@@ -182,8 +182,8 @@ procedure TThreadSortForm.ThreadDone(Sender: TObject);
182
182
if ThreadsRunning = 0 then
183
183
begin
184
184
GetPythonEngine.PyEval_RestoreThread(OwnThreadState);
185
- StartBtn .Enabled := True;
186
- Start2Btn .Enabled := True;
185
+ Start1Btn .Enabled := True;
186
+ Start3Btn .Enabled := True;
187
187
ArraysRandom := False;
188
188
Thread1 := nil ;
189
189
Thread2 := nil ;
@@ -196,7 +196,8 @@ procedure TThreadSortForm.ThreadDone(Sender: TObject);
196
196
}
197
197
198
198
function TThreadSortForm.SortModule_GetValue ( pself, args : PPyObject ) : PPyObject; cdecl;
199
- var psort,index: integer;
199
+ var
200
+ psort, index: Integer;
200
201
begin
201
202
with GetPythonEngine do
202
203
begin
@@ -208,12 +209,10 @@ function TThreadSortForm.SortModule_GetValue( pself, args : PPyObject ) : PPyObj
208
209
end ;
209
210
end ;
210
211
211
-
212
-
213
212
function TThreadSortForm.SortModule_Swap ( pself, args : PPyObject ) : PPyObject; cdecl;
214
- var psort,i,j: integer;
213
+ var
214
+ psort, i, j: Integer;
215
215
begin
216
-
217
216
with GetPythonEngine do
218
217
begin
219
218
if (PyErr_Occurred() = nil ) and (PyArg_ParseTuple( args, ' iii' ,@psort, @i, @j) <> 0 ) then
@@ -225,8 +224,6 @@ function TThreadSortForm.SortModule_Swap( pself, args : PPyObject ) : PPyObject;
225
224
end ;
226
225
end ;
227
226
228
-
229
-
230
227
procedure TThreadSortForm.SortModuleInitialization (Sender: TObject);
231
228
begin
232
229
with Sender as TPythonModule do
@@ -240,7 +237,7 @@ procedure TThreadSortForm.SortModuleInitialization(Sender: TObject);
240
237
end ;
241
238
end ;
242
239
243
- procedure TThreadSortForm.Button1Click (Sender: TObject);
240
+ procedure TThreadSortForm.StopBtnClick (Sender: TObject);
244
241
begin
245
242
if Assigned(Thread1) and not Thread1.Finished then Thread1.Stop();
246
243
if Assigned(Thread2) and not Thread2.Finished then Thread2.Stop();
0 commit comments