我最近开始用 Python 编程,我决定用 Python 编写一些 Delphi 函数。我决定创建一个单独的 Python 模块来保存我的函数。
现在,我尝试导入它,但在 Visual Studio Code 中出现此错误:
unable to import 'functions' pylint(import error) [5, 1]
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
unable to import 'functions' pylint(import error) [5, 1]
Run Code Online (Sandbox Code Playgroud)
这是一张图片:
所以我使用 Delphi Rad Studio 版本 10.3。
我必须为学校(11 年级)的 PAT 创建统计表格。
我正在尝试创建一个包含 2 个面板的表单。一个用于显示统计数据并与之交互的按钮,另一个用于实际统计数据。
问题是:我希望能够调整表单的大小,并且两个面板应该按比例调整自身大小。我的代码中的错误(我似乎无法修复)是,在缩小表单后,面板的宽度不会减少,而是增加。我使用第三个面板来确定更改是表单的大小调整,因为我发现表单的宽度!=可放置组件的宽度。
function TFrmHelp_Dialog.My_Round(number: real): integer;
var
Decimal_value, Integer_value, snumber: string;
begin
try
snumber := floattostrF(number, fffixed, 12, 8);
Decimal_value := copy(snumber, pos('.', snumber) + 1, length(snumber));
Integer_value := copy(snumber, 1, pos('.', snumber) - 1);
if Decimal_value[1] >= '5' then
begin
result := strtoint(Integer_value) + 1;
end
else
begin
result := strtoint(Integer_value);
end;
except
beep;
messagedlg
('An error occured during function "Round" excecution in …Run Code Online (Sandbox Code Playgroud) 我希望能够创建一个类的实例,而不必将它们每个都声明为对象。一个简单的例子。我有一个程序可以为狗展注册狗。每次用户点击添加它应该创建一个新的 TDog 类实例。我该怎么做呢?
我的尝试静态:
//clsDog_u
type
TDog = class(TObject)
private
fName : string;
public
constructor Create(Name);
function Get_Name():string;
end;
implementation
//I think you guys knows what goes here ;)
//------------Main Form---------------
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, clsDog;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
objDog: tDog;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Name: string; …Run Code Online (Sandbox Code Playgroud)