Skip to content

TBevelDemo 项目分析

项目信息

  • 项目名称: TBevelDemo
  • 下载链接: TBevelDemo.rar
  • 分析时间: 2026-03-05

文件结构

TBevelDemo/
├── Extractor_Icon.ico
├── Project1.py
├── Project1.xml
├── Unit1.py
├── Unit1.pydfm
├── Unit1.sct
├── Unit1.sfm

主程序文件: Project1.py

from glcl import *
from Unit1 import *

def main():
    Application.Initialize()
    Application.Title = 'Project1'
    Application.MainFormOnTaskbar = True
    Application.Icon.LoadFromFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Extractor_Icon.ico"))
    MainForm = Form1(Application)
    MainForm.Show()
    FreeConsole()
    Application.Run()
    MainForm.Free()

if __name__ == '__main__':
    main()

单元文件: Unit1.py

import os
from glcl import *

class Form1(Form):

    def __init__(self, owner):
        self.Label2 = Label(self)
        self.Bevel1 = Bevel(self)
        self.LoadProps(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Unit1.pydfm"))

        # 创建 TBevel 对象
        self.bevel = Bevel(self)
        self.bevel.Parent = self  # 设置 TBevel 的父控件
        # 设置 TBevel 的位置和大小
        self.bevel.Left = 50      # 距离窗体左边50个单位
        self.bevel.Top = 50       # 距离窗体顶部50个单位
        self.bevel.Width = 300    # 宽度为300个单位
        self.bevel.Height = 100    # 高度为100个单位

        # 添加文本说明
        self.label = Label(self)
        self.label.Parent = self  # 设置 TLabel 的父控件
        self.label.Left = 60
        self.label.Top = 80
        self.label.Caption = "这是一个 TBevel 示例"  # 设置标签内容

设计文件: Unit1.sct


设计文件: Unit1.sfm

object Form1: TForm
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 361
  ClientWidth = 504
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -15
  Font.Name = 'Segoe UI'
  Font.Style = []
  TextHeight = 20
  object Bevel1: TBevel
    Left = 24
    Top = 264
    Width = 218
    Height = 50
    Shape = bsFrame
  end
  object Label2: TLabel
    Left = 104
    Top = 280
    Width = 44
    Height = 20
    Caption = 'Label2'
  end
end

其他文件

  • Extractor_Icon.ico
  • Project1.xml

详细分析

功能概述

GUI组件演示

使用的组件

  • Form1 (TForm)
  • Bevel1 (TBevel)
  • Label2 (TLabel)

技术特点

  • 包含3个GUI组件
  • 定义0个事件处理

窗体属性

  • caption: Label2
  • height: 361
  • width: 504

代码分析

导入的模块: - import os - from glcl import *

定义的类: - Form1

定义的方法: - init