пытаюсь разместить вкладки, как в блокноте в Windows, с вкладками на той же линии, что и строка заголовка, с вкладкой рядом со значком и на той же строке, что и кнопки закрытия минимального и максимального значения с кривой табуляции. это касается редактирования вкладок и файлов, а также текстовой панели.
пробовал пользовательские строки заголовка, но безуспешно, пытаясь встроить вкладки в один ряд с кнопками закрытия с переносом вкладок в блокнот Windows имеет
tab +newtab [min][max][close]
file
textpad
Где файл вкладки и текстовая панель свернуты вместе, как блокнот Windows< /p>
редактировать: сделал черновой вариант в tkinter
import tkinter as tk
from tkinter import ttk
def new_file():
# Create a new tab with a new frame and custom menubar
tab_name = f"Tab {len(notebook.tabs()) + 1}"
new_tab_frame = create_tab_frame()
notebook.add(new_tab_frame, text=tab_name)
def open_file():
# Open file dialog and read the file content into a new tab (omitted for simplicity)
pass
def save_file():
# Save content of textpad to a file (omitted for simplicity)
pass
def close_window(event=None):
root.quit()
def create_tab_frame():
# Create a new tab frame
tab_frame = tk.Frame(notebook)
tab_frame.pack(fill="both", expand=True)
# Add a custom menubar inside the tab
tab_menubar = tk.Frame(tab_frame, bg="lightgray", height=30)
tab_menubar.pack(fill="x", side="top")
# Add buttons to the custom menubar
new_button = tk.Button(tab_menubar, text="New", command=new_file)
new_button.pack(side="left", padx=5)
save_button = tk.Button(tab_menubar, text="Save", command=save_file)
save_button.pack(side="left", padx=5)
# Add a textpad below the custom menubar
text_pad = tk.Text(tab_frame, wrap="word", font=("Arial", 12))
text_pad.pack(fill="both", expand=True)
return tab_frame
# Create the main window
root = tk.Tk()
root.geometry("600x400")
root.title("Custom Title Bar Example")
root.overrideredirect(True)
# Create a custom title bar
title_bar = tk.Frame(root, bg="gray", relief="raised", bd=2, height=30)
title_bar.pack(fill="x", side="top")
title_label = tk.Label(title_bar, text="Custom Title Bar Example", bg="gray", fg="white", font=("Arial", 14))
title_label.pack(side="left", padx=10)
close_button = tk.Button(title_bar, text="X", command=close_window, bg="gray", fg="white", bd=0)
close_button.pack(side="right", padx=5)
# Create a notebook (tabbed interface)
notebook = ttk.Notebook(root)
notebook.pack(fill="both", expand=True, padx=10, pady=5)
# Create the initial tab with a custom menubar
initial_tab = create_tab_frame()
notebook.add(initial_tab, text="Tab 1")
root.mainloop()
чтобы новая вкладка и сохранение находились между текстовой вкладкой и текстовой панелью вкладок. как мне сделать вкладку теперь в пользовательской строке заголовка, например в блокноте Windows по умолчанию
сделал клон окон в блокноте и не могу заставить вкладки располагаться в той же строке, что и заголовок [code]import sys from PySide6.QtWidgets import QApplication, QMainWindow, QTabWidget, QWidget, QVBoxLayout, QTextEdit, QFileDialog from PySide6.QtGui import QAction
class Notepad(QMainWindow): def __init__(self): super().__init__()
self.setWindowTitle("Notepad with Tabs") self.setGeometry(300, 100, 800, 600)
[/code] пытаюсь разместить вкладки, как в блокноте в Windows, с вкладками на той же линии, что и строка заголовка, с вкладкой рядом со значком и на той же строке, что и кнопки закрытия минимального и максимального значения с кривой табуляции. это касается редактирования вкладок и файлов, а также текстовой панели. пробовал пользовательские строки заголовка, но безуспешно, пытаясь встроить вкладки в один ряд с кнопками закрытия с переносом вкладок в блокнот Windows имеет tab +newtab [min][max][close] file textpad Где файл вкладки и текстовая панель свернуты вместе, как блокнот Windows< /p> редактировать: сделал черновой вариант в tkinter [code]import tkinter as tk from tkinter import ttk
def new_file(): # Create a new tab with a new frame and custom menubar tab_name = f"Tab {len(notebook.tabs()) + 1}" new_tab_frame = create_tab_frame() notebook.add(new_tab_frame, text=tab_name)
def open_file(): # Open file dialog and read the file content into a new tab (omitted for simplicity) pass
def save_file(): # Save content of textpad to a file (omitted for simplicity) pass
def close_window(event=None): root.quit()
def create_tab_frame(): # Create a new tab frame tab_frame = tk.Frame(notebook) tab_frame.pack(fill="both", expand=True)
# Add a custom menubar inside the tab tab_menubar = tk.Frame(tab_frame, bg="lightgray", height=30) tab_menubar.pack(fill="x", side="top")
# Add buttons to the custom menubar new_button = tk.Button(tab_menubar, text="New", command=new_file) new_button.pack(side="left", padx=5)
# Create the initial tab with a custom menubar initial_tab = create_tab_frame() notebook.add(initial_tab, text="Tab 1")
root.mainloop() [/code] чтобы новая вкладка и сохранение находились между текстовой вкладкой и текстовой панелью вкладок. как мне сделать вкладку теперь в пользовательской строке заголовка, например в блокноте Windows по умолчанию