Skip to content

Commit fc37698

Browse files
committed
Update dev version
Update dev version * Using QTextCharFormat and textCursor to insert text
1 parent f3ac86b commit fc37698

5 files changed

Lines changed: 51 additions & 26 deletions

File tree

automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from je_auto_control.gui.main_widget import AutoControlGUIWidget
66
from je_editor import EditorWidget, language_wrapper
7+
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
78

89
from automation_ide.automation_editor_ui.menu.menu_utils import open_web_browser
910

@@ -12,7 +13,7 @@
1213
import sys
1314

1415
import je_auto_control
15-
from PySide6.QtGui import QAction
16+
from PySide6.QtGui import QAction, QTextCharFormat
1617

1718
from automation_ide.extend.process_executor.auto_control.auto_control_process import \
1819
call_auto_control, call_auto_control_with_send, call_auto_control_multi_file, \
@@ -155,7 +156,11 @@ def create_project() -> None:
155156
def stop_record(editor_instance: AutomationEditor):
156157
widget = editor_instance.tab_widget.currentWidget()
157158
if isinstance(widget, EditorWidget):
158-
widget.code_edit.appendPlainText(str(je_auto_control.stop_record()))
159+
text_cursor = widget.code_edit.textCursor()
160+
text_format = QTextCharFormat()
161+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
162+
text_cursor.insertText(str(je_auto_control.stop_record()), text_format)
163+
text_cursor.insertBlock()
159164

160165

161166
def add_autocontrol_gui(ui_we_want_to_set: AutomationEditor) -> None:

automation_ide/extend/process_executor/python_task_process_manager.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Union
1111

1212
from PySide6.QtCore import QTimer
13+
from PySide6.QtGui import QTextCharFormat
1314
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
1415
from je_editor.utils.venv_check.check_venv import check_and_choose_venv
1516

@@ -99,19 +100,24 @@ def start_test_process(self, package: str, exec_str: str):
99100
# Pyside UI update method
100101
def pull_text(self):
101102
try:
102-
self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
103103
if not self.run_output_queue.empty():
104104
output_message = self.run_output_queue.get_nowait()
105105
output_message = str(output_message).strip()
106106
if output_message:
107-
self.main_window.code_result.append(output_message)
108-
self.main_window.code_result.setTextColor(actually_color_dict.get("error_output_color"))
107+
text_cursor = self.main_window.code_result.textCursor()
108+
text_format = QTextCharFormat()
109+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
110+
text_cursor.insertText(output_message, text_format)
111+
text_cursor.insertBlock()
109112
if not self.run_error_queue.empty():
110113
error_message = self.run_error_queue.get_nowait()
111114
error_message = str(error_message).strip()
112115
if error_message:
113-
self.main_window.code_result.append(error_message)
114-
self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
116+
text_cursor = self.main_window.code_result.textCursor()
117+
text_format = QTextCharFormat()
118+
text_format.setForeground(actually_color_dict.get("error_output_color"))
119+
text_cursor.insertText(error_message, text_format)
120+
text_cursor.insertBlock()
115121
except queue.Empty:
116122
pass
117123
if self.process is not None:
@@ -140,7 +146,11 @@ def exit_program(self):
140146
self.print_and_clear_queue()
141147
if self.process is not None:
142148
self.process.terminate()
143-
self.main_window.code_result.append(f"Task exit with code {self.process.returncode}")
149+
text_cursor = self.main_window.code_result.textCursor()
150+
text_format = QTextCharFormat()
151+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
152+
text_cursor.insertText(f"Task exit with code {self.process.returncode}", text_format)
153+
text_cursor.insertBlock()
144154
self.process = None
145155

146156
def print_and_clear_queue(self):

automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import threading
77
from pathlib import Path
88
from queue import Queue
9-
from typing import TYPE_CHECKING
9+
from typing import TYPE_CHECKING, Union
1010

1111
from PySide6.QtCore import QTimer
12+
from PySide6.QtGui import QTextCharFormat
1213
from PySide6.QtWidgets import QWidget
1314
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
1415
from je_editor.utils.venv_check.check_venv import check_and_choose_venv
@@ -38,8 +39,8 @@ def __init__(
3839
self._program_buffer_size = program_buffer
3940
self._run_output_queue: Queue = Queue()
4041
self._run_error_queue: Queue = Queue()
41-
self._read_program_error_output_from_thread: [threading.Thread, None] = None
42-
self._read_program_output_from_thread: [threading.Thread, None] = None
42+
self._read_program_error_output_from_thread: Union[threading.Thread, None] = None
43+
self._read_program_output_from_thread: Union[threading.Thread, None] = None
4344
self._timer: QTimer = QTimer(self._code_window)
4445
if self._main_window.python_compiler is None:
4546
# Renew compiler path
@@ -74,19 +75,24 @@ def __init__(
7475
# Pyside UI update method
7576
def pull_text(self):
7677
try:
77-
self._code_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
7878
if not self._run_output_queue.empty():
7979
output_message = self._run_output_queue.get_nowait()
8080
output_message = str(output_message).strip()
8181
if output_message:
82-
self._code_window.code_result.append(output_message)
83-
self._code_window.code_result.setTextColor(actually_color_dict.get("error_output_color"))
82+
text_cursor = self._code_window.code_result.textCursor()
83+
text_format = QTextCharFormat()
84+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
85+
text_cursor.insertText(output_message, text_format)
86+
text_cursor.insertBlock()
8487
if not self._run_error_queue.empty():
8588
error_message = self._run_error_queue.get_nowait()
8689
error_message = str(error_message).strip()
8790
if error_message:
88-
self._code_window.code_result.append(error_message)
89-
self._code_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
91+
text_cursor = self._code_window.code_result.textCursor()
92+
text_format = QTextCharFormat()
93+
text_format.setForeground(actually_color_dict.get("error_output_color"))
94+
text_cursor.insertText(error_message, text_format)
95+
text_cursor.insertBlock()
9096
except queue.Empty:
9197
pass
9298
if self._process is not None:
@@ -115,7 +121,11 @@ def exit_program(self):
115121
self.print_and_clear_queue()
116122
if self._process is not None:
117123
self._process.terminate()
118-
self._code_window.code_result.append(f"Task exit with code {self._process.returncode}")
124+
text_cursor = self._code_window.code_result.textCursor()
125+
text_format = QTextCharFormat()
126+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
127+
text_cursor.insertText(f"Task exit with code {self._process.returncode}", text_format)
128+
text_cursor.insertBlock()
119129
self._process = None
120130

121131
def print_and_clear_queue(self):

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to build stable version
2-
# This is stable version
1+
# Rename to dev version
2+
# This is dev version
33
[build-system]
44
requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "automation_ide"
9-
version = "0.0.45"
8+
name = "automation_ide_dev"
9+
version = "0.0.52"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]
@@ -35,5 +35,6 @@ Code = "https://github.com/Intergration-Automation-Testing/AutomationEditor"
3535
file = "README.md"
3636
content-type = "text/markdown"
3737

38+
3839
[tool.setuptools.packages]
3940
find = { namespaces = false }

dev.toml renamed to stable.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to dev version
2-
# This is dev version
1+
# Rename to build stable version
2+
# This is stable version
33
[build-system]
44
requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "automation_ide_dev"
9-
version = "0.0.51"
8+
name = "automation_ide"
9+
version = "0.0.45"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]
@@ -35,6 +35,5 @@ Code = "https://github.com/Intergration-Automation-Testing/AutomationEditor"
3535
file = "README.md"
3636
content-type = "text/markdown"
3737

38-
3938
[tool.setuptools.packages]
4039
find = { namespaces = false }

0 commit comments

Comments
 (0)