Coverage for aipyapp/gui/about.py: 0%

1 import wx

2 import importlib.resources as resources

3

4 from .. import __version__, T, __respkg__

5 from ..aipy.config import CONFIG_DIR

6

7 class AboutDialog(wx.Dialog):

8 def __init__(self, parent):

9 super().__init__(parent, title=T("About AIPY"))

10

11 # 创建垂直布局

12 vbox = wx.BoxSizer(wx.VERTICAL)

13

14 logo_panel = wx.Panel(self)

15 logo_sizer = wx.BoxSizer(wx.HORIZONTAL)

16

17 with resources.path(__respkg__, "aipy.ico") as icon_path:

18 icon = wx.Icon(str(icon_path), wx.BITMAP_TYPE_ICO)

19 bmp = wx.Bitmap()

20 bmp.CopyFromIcon(icon)

21 # Scale the bitmap to a more appropriate size

22 scaled_bmp = wx.Bitmap(bmp.ConvertToImage().Scale(48, 48, wx.IMAGE_QUALITY_HIGH))

23 logo_sizer.Add(wx.StaticBitmap(logo_panel, -1, scaled_bmp), 0, wx.ALL | wx.ALIGN_CENTER, 5)

24

25 # 添加标题

26 title = wx.StaticText(logo_panel, -1, label=T("AIPy"))

27 title.SetFont(wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))

28 logo_sizer.Add(title, 0, wx.ALL|wx.ALIGN_CENTER, 10)

29 logo_panel.SetSizer(logo_sizer)

30 vbox.Add(logo_panel, 0, wx.ALL|wx.ALIGN_CENTER, 10)

31

32 # 添加描述

33 desc = wx.StaticText(self, label=T("AIPY is an intelligent assistant that can help you complete various tasks."))

34 desc.Wrap(350)

35 vbox.Add(desc, 0, wx.ALL|wx.ALIGN_CENTER, 10)

36

37 # 添加版本信息

38 version = wx.StaticText(self, label=f"{T('Version')}: {__version__}")

39 vbox.Add(version, 0, wx.ALL|wx.ALIGN_CENTER, 5)

40

41 # 添加配置目录信息

42 config_dir = wx.StaticText(self, label=f"{T('Current configuration directory')}: {CONFIG_DIR}")

43 config_dir.Wrap(350)

44 vbox.Add(config_dir, 0, wx.ALL|wx.ALIGN_CENTER, 5)

45

46 # 添加工作目录信息

47 work_dir = wx.StaticText(self, label=f"{T('Current working directory')}: {parent.tm.workdir}")

48 work_dir.Wrap(350)

49 vbox.Add(work_dir, 0, wx.ALL|wx.ALIGN_CENTER, 5)

50

51 # 添加团队信息

52 team = wx.StaticText(self, label=T("AIPY Team"))

53 vbox.Add(team, 0, wx.ALL|wx.ALIGN_CENTER, 10)

54

55 # 添加确定按钮

56 ok_button = wx.Button(self, wx.ID_OK, T("OK"))

57 vbox.Add(ok_button, 0, wx.ALL|wx.ALIGN_CENTER, 10)

58

59 self.SetSizer(vbox)

60 self.SetMinSize((400, 320))

61 self.Fit()

62 self.Centre()