[Update] Main Window: メッセージ送信ボタンの追加。

設定項目で非表示、表示、表示しつつメッセージ入力欄でのエンターキー送信を無効 を選択可能に。

デフォルトが表示の理由: メッセージ入力欄のプレースホルダーが使えなくなり、初見でどこに入力すればいいのか分かりにくくなったので、横に送信ボタンが付くことにより、よくあるUIとなり、メッセージ入力欄っぽくなる。

その他要らないコードの削除や、corner radius指定し忘れなどの修正あり。
This commit is contained in:
Sakamoto Shiina
2024-01-07 03:30:46 +09:00
parent a5eb0a874f
commit 5128fa590c
16 changed files with 258 additions and 14 deletions

View File

@@ -120,4 +120,4 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable):
createTextbox(settings, vrct_gui, view_variable)
createEntryMessageBox(settings, vrct_gui)
createEntryMessageBox(settings, vrct_gui, view_variable)

View File

@@ -1,7 +1,10 @@
from customtkinter import CTkFont, CTkFrame, CTkTextbox
from customtkinter import CTkFont, CTkFrame, CTkTextbox, CTkLabel, CTkImage
def createEntryMessageBox(settings, main_window):
main_window.main_entry_message_container = CTkFrame(main_window.main_bg_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
from ...ui_utils import bindButtonFunctionAndColor
from utils import callFunctionIfCallable
def createEntryMessageBox(settings, main_window, view_variable):
main_window.main_entry_message_container = CTkFrame(main_window.main_bg_container, corner_radius=settings.uism.TEXTBOX_ENTRY_CORNER_RADIUS, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
main_window.main_entry_message_container.grid(row=2, column=0, sticky="nsew")
@@ -9,6 +12,7 @@ def createEntryMessageBox(settings, main_window):
main_window.main_entry_message_container.grid_rowconfigure(0, weight=1)
main_window.entry_message_box = CTkTextbox(
main_window.main_entry_message_container,
corner_radius=settings.uism.TEXTBOX_ENTRY_CORNER_RADIUS,
border_color=settings.ctm.TEXTBOX_ENTRY_BORDER_COLOR,
fg_color=settings.ctm.TEXTBOX_ENTRY_BG_COLOR,
text_color=settings.ctm.TEXTBOX_ENTRY_TEXT_COLOR,
@@ -31,3 +35,58 @@ def createEntryMessageBox(settings, main_window):
main_window.entry_message_box.bind("<Any-KeyPress>", messageBoxAnyKeyPress)
main_window.main_send_message_button_container = CTkFrame(main_window.main_entry_message_container, corner_radius=settings.uism.SEND_MESSAGE_BUTTON_CORNER_RADIUS, fg_color=settings.ctm.SEND_MESSAGE_BUTTON_BG_COLOR, width=0, height=0)
main_window.main_send_message_button_container.grid(row=0, column=1, padx=(0, settings.uism.TEXTBOX_ENTRY_PADX), pady=settings.uism.TEXTBOX_ENTRY_PADY, sticky="nsew")
main_window.main_send_message_button_container.grid_columnconfigure(0, weight=0, minsize=settings.uism.SEND_MESSAGE_BUTTON_MIN_WIDTH)
main_window.main_send_message_button_container.grid_rowconfigure(0, weight=1)
main_window.main_send_message_button = CTkFrame(main_window.main_send_message_button_container, corner_radius=0, fg_color=settings.ctm.SEND_MESSAGE_BUTTON_BG_COLOR, height=0, width=0)
main_window.main_send_message_button.grid(row=0, column=0, sticky="nsew")
main_window.main_send_message_button.configure(cursor="hand2")
main_window.main_send_message_button.grid_columnconfigure((0,2), weight=1)
main_window.main_send_message_button.grid_rowconfigure((0,2), weight=1)
main_window.main_send_message_button_image = CTkLabel(
main_window.main_send_message_button,
text=None,
height=0,
image=CTkImage((settings.image_file.SEND_MESSAGE_ICON),size=(settings.uism.SEND_MESSAGE_BUTTON_IMAGE_SIZE,settings.uism.SEND_MESSAGE_BUTTON_IMAGE_SIZE)),
)
main_window.main_send_message_button_image.grid(row=1, column=1)
bindButtonFunctionAndColor(
target_widgets=[main_window.main_send_message_button, main_window.main_send_message_button_image],
enter_color=settings.ctm.SEND_MESSAGE_BUTTON_BG_HOVERED_COLOR,
leave_color=settings.ctm.SEND_MESSAGE_BUTTON_BG_COLOR,
clicked_color=settings.ctm.SEND_MESSAGE_BUTTON_BG_CLICKED_COLOR,
buttonReleasedFunction=lambda _e: callFunctionIfCallable(view_variable.CALLBACK_CLICKED_SEND_MESSAGE_BUTTON, _e),
)
main_window.main_send_message_button__disabled = CTkFrame(main_window.main_send_message_button_container, corner_radius=0, fg_color=settings.ctm.SEND_MESSAGE_BUTTON_BG_COLOR, height=0, width=0)
main_window.main_send_message_button__disabled.grid(row=0, column=0, sticky="nsew")
main_window.main_send_message_button__disabled.grid_columnconfigure((0,2), weight=1)
main_window.main_send_message_button__disabled.grid_rowconfigure((0,2), weight=1)
main_window.main_send_message_button_image__disabled = CTkLabel(
main_window.main_send_message_button__disabled,
text=None,
height=0,
image=CTkImage((settings.image_file.SEND_MESSAGE_ICON_DISABLED),size=(settings.uism.SEND_MESSAGE_BUTTON_IMAGE_SIZE,settings.uism.SEND_MESSAGE_BUTTON_IMAGE_SIZE)),
)
main_window.main_send_message_button_image__disabled.grid(row=1, column=1)
main_window.main_send_message_button__disabled.grid_remove()

View File

@@ -59,7 +59,7 @@ def createTextbox(settings, main_window, view_variable):
# Text box
main_window.main_bg_container.grid_rowconfigure(1, weight=1)
main_window.main_textbox_container = CTkFrame(main_window.main_bg_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
main_window.main_textbox_container.grid(row=1, column=0, sticky="nsew")
main_window.main_textbox_container.grid(row=1, column=0, columnspan=2, sticky="nsew")
main_window.main_textbox_container.grid_columnconfigure(0,weight=1)
main_window.main_textbox_container.grid_rowconfigure(0,weight=1)