Добавить изображение к письменному тексту - PullRequest
0 голосов
/ 10 марта 2020

Я хотел бы написать текст и добавить картинку. Изображение должно быть вставлено в верхнем правом углу. В настоящее время мой результат выглядит следующим образом

enter image description here

Есть несколько вещей, которые мне не нравятся в моем решении:

  • Изображение сдвигается, когда окно развернуто
  • Я хочу удалить рамку изображения
  • Можно подписать (= подчеркивание ('')) заголовок 'Раздел'

Мой минимальный пример кода:

import tkinter as tk
from tkinter import ttk

root = Tk()

# Create Tabs
tab_control = ttk.Notebook(root)
tab1 = ttk.Frame(tab_control)
#Create Names for tabs
tab_control.add(tab1, text='NAME 1')
tab_control.pack(expand=1, fill='both')

# Add text widget
text_main = tk.Text(tab1, height=20, width=76) 
text_main.tag_configure('section', font=('Verdana', 18, 'bold'))
text_main.tag_configure('main_text', font=('Arial', 12, 'bold', 'italic'))

text_main.insert(tk.END,'\nSection \n', 'section') # uses fonts that the keyword 'big'
quote = """
To be, or not to be that is the question:
Whether 'tis Nobler in the mind to suffer
The Slings and Arrows of outrageous Fortune,
Or to take Arms against a Sea of troubles
To be, or not to be that is the question:
Whether 'tis Nobler in the mind to suffer
The Slings and Arrows of outrageous Fortune,
Or to take Arms against a Sea of troubles
"""
text_main.insert(tk.END, quote, 'main_text')
text_main.pack()

# Add picture 
text1 = tk.Text(root, height=13, width=30)
photo = tk.PhotoImage(file='Download.png')
text1.insert(tk.END, '\n')
text1.image_create(tk.END, image=photo)
text1.place(x=400, y = 10)

mainloop()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...