Coverage for main/page.py: 56%

18 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-03 15:51 +0000

1from PyQt6.QtWidgets import QWidget 

2 

3 

4class Page(QWidget): 

5 """ 

6 Base class for all application pages. 

7 

8 This abstract widget defines the lifecycle and navigation interface 

9 shared by all pages in the UI (e.g., `on_enter`, `next`, `back`). 

10 Subclasses should override relevant methods to implement page-specific 

11 logic, layout, and transitions. 

12 """ 

13 

14 def _setup_ui(self): 

15 """ 

16 Initialize and configure the page's user interface. 

17 

18 To be implemented by subclasses for defining layouts, widgets, 

19 and signal connections. 

20 """ 

21 pass 

22 

23 def is_ready_to_advance(self): 

24 """ 

25 Check whether the page is ready to advance to the next step. 

26 

27 Returns 

28 ------- 

29 bool 

30 True if navigation to the next page is allowed. 

31 """ 

32 return True 

33 

34 def is_ready_to_go_back(self): 

35 """ 

36 Check whether the page can return to the previous step. 

37 

38 Returns 

39 ------- 

40 bool 

41 True if navigation backward is allowed. 

42 """ 

43 return True 

44 

45 def reset_page(self): 

46 """ 

47 Reset the page state and clear any user input or temporary data. 

48 

49 Should be overridden by subclasses that maintain internal state. 

50 """ 

51 pass 

52 

53 def on_enter(self): 

54 """ 

55 Hook called when this page becomes active. 

56 

57 Used for refreshing content or resetting temporary UI state. 

58 Subclasses can override this to perform actions when the user 

59 navigates to this page. 

60 """ 

61 pass 

62 

63 def next(self, context): 

64 """ 

65 Handle transition to the next page. 

66 

67 Parameters 

68 ---------- 

69 context : dict 

70 Shared application context passed across pages. 

71 

72 Returns 

73 ------- 

74 Page | None 

75 The next page instance, or None if navigation should stop. 

76 """ 

77 pass 

78 

79 def back(self): 

80 """ 

81 Handle transition to the previous page. 

82 

83 Returns 

84 ------- 

85 Page | None 

86 The previous page instance, or None if there is no previous page. 

87 """ 

88 pass 

89 

90 def _translate_ui(self): 

91 """ 

92 Update translatable text in the UI when the language changes. 

93 

94 Subclasses should override this method to refresh localized labels, 

95 buttons, and other text elements. 

96 """ 

97 pass