|
2 | 2 | from PySide6.QtWidgets import ( |
3 | 3 | QDialog, |
4 | 4 | QFileDialog, |
| 5 | + QLabel, |
5 | 6 | QMessageBox, |
6 | 7 | QTextBrowser, |
7 | 8 | QVBoxLayout, |
8 | 9 | QWidget, |
9 | 10 | ) |
10 | 11 |
|
11 | | -""" |
12 | | -由于各种对话框的设置代码较繁琐且独立,故单独在本模块中配置 |
13 | | -""" |
| 12 | +from py2exe_gui.Core.subprocess_tool import SubProcessTool |
14 | 13 |
|
15 | 14 |
|
16 | 15 | class ScriptFileDlg(QFileDialog): |
17 | 16 | """用于获取入口脚本文件的对话框""" |
18 | 17 |
|
19 | 18 | def __init__(self, parent: QWidget = None) -> None: |
20 | | - super().__init__(parent) |
| 19 | + super(ScriptFileDlg, self).__init__(parent) |
21 | 20 | self._setup() |
22 | 21 |
|
23 | 22 | def _setup(self) -> None: |
@@ -63,7 +62,7 @@ class AboutMessage(QMessageBox): |
63 | 62 | """用于显示关于信息的对话框""" |
64 | 63 |
|
65 | 64 | def __init__(self, parent: QWidget = None) -> None: |
66 | | - super(AboutMessage, self).__init__(parent=parent) |
| 65 | + super(AboutMessage, self).__init__(parent) |
67 | 66 | self._about_text: str = "" |
68 | 67 | self._setup() |
69 | 68 |
|
@@ -97,30 +96,40 @@ class SubProcessDlg(QDialog): |
97 | 96 | """用于显示子进程信息的对话框""" |
98 | 97 |
|
99 | 98 | def __init__(self, parent: QWidget = None) -> None: |
100 | | - super(SubProcessDlg, self).__init__(parent=parent) |
101 | | - self.browser = QTextBrowser() |
| 99 | + super(SubProcessDlg, self).__init__(parent) |
| 100 | + self.info_label = QLabel(self) |
| 101 | + self.browser = QTextBrowser(self) |
102 | 102 | self._setup() |
103 | 103 |
|
104 | | - def _setup(self): |
| 104 | + def _setup(self) -> None: |
105 | 105 | """ |
106 | 106 | 配置子进程信息对话框 \n |
107 | 107 | """ |
108 | 108 |
|
| 109 | + self.setWindowTitle("PyInstaller") |
| 110 | + self.setModal(True) |
| 111 | + |
109 | 112 | layout = QVBoxLayout() |
| 113 | + layout.addWidget(self.info_label) |
110 | 114 | layout.addWidget(self.browser) |
111 | 115 | self.setLayout(layout) |
112 | 116 |
|
113 | | - def handle_output(self, subprocess_output: tuple[int, str]): |
| 117 | + def handle_output(self, subprocess_output: tuple[int, str]) -> None: |
114 | 118 | """ |
115 | 119 | 处理子进程的输出 \n |
116 | 120 | :param subprocess_output: 子进程输出 |
117 | 121 | :return: None |
118 | 122 | """ |
| 123 | + |
119 | 124 | output_type, output_text = subprocess_output |
120 | | - if output_type == 2: |
| 125 | + if output_type == SubProcessTool.STDOUT: |
121 | 126 | self.browser.append(output_text) |
122 | | - elif output_type == 3: |
| 127 | + elif output_type == SubProcessTool.STDERR: |
123 | 128 | self.browser.append(output_text) |
| 129 | + elif output_type == SubProcessTool.FINISHED: |
| 130 | + self.info_label.setText("打包完成!") |
| 131 | + elif output_type == SubProcessTool.STATE: |
| 132 | + self.info_label.setText(output_text) |
124 | 133 |
|
125 | 134 |
|
126 | 135 | if __name__ == "__main__": |
|
0 commit comments