I would like to know if there is any team that will put the picture in the foreground, set its transparency and block it, that is, the picture will look like a background for a text editor.

  • one
  • Thanks for the tip, but how to do it with PIL - A.Kross
  • I understand you correctly, do you want to set the background for the window? - Gleb
  • I want to create a background for the text widget - A.Kross
  • Then I hurry to upset you that you cannot create a background for a text widget, if I'm not mistaken, you can't. - Gleb

1 answer 1

I really did not understand what exactly needs to be done, but I can show how to make a picture on the background

from tkinter import * root=Tk()#ΠΌΠΎΠΆΠ½ΠΎ вмСсто root Π½Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ любоС Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ с ΠΎΠΊΠ½ΠΎΠΌ root.state('zoomed')#это Π΄Π΅Π»Π°Π΅Ρ‚ ΠΏΠΎΠ»Π½ΠΎ экранный Ρ€Π΅ΠΆΠΈΠΌ ΠΎΠΊΠ½Π° cnv=Canvas(root, width=500, height=500)# вмСсто root, вписываСм Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ Ρ€ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΡΠΊΠΎΠ³ΠΎ ΠΎΠΊΠ½Π° ΠΈ Π² ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ width вписываСм Π»ΡŽΠ±ΡƒΡŽ ΡˆΠΈΡ€ΠΈΠ½Ρƒ для Π²ΠΈΠ΄ΠΆΠ΅Ρ‚Π° Canvas ΠΈ Π² ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ height- Π΅Π³ΠΎ высоту cnv.pack()# ΡƒΠ°ΠΏΠΊΠΎΠ²ΡƒΠ΅ΠΌ Canvas Π² Ρ€ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΡΠΊΠΎΠ΅ ΠΎΠΊΠ½ΠΎ Π² скобках ΡƒΠΊΠ°Π·Ρ‹Π²Π°Π΅ΠΌ Π½ΡƒΠΆΠ½Ρ‹Π΅ настройки img=PhotoImage(file='ΠΏΡƒΡ‚ΡŒ ΠΊ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ΅')# ΠΌΠΎΠΆΠ½ΠΎ любоС Π΄Ρ€ΡƒΠ³ΠΎΠ΅ Π½Π°Π·Π²Π°Π½ΠΈΠ΅, ΠΊΡ€ΠΎΠΌΠ΅ img cnv.create_image(image=img, x=5, y=5) #создаСт ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ x-пиксСли Π² ΡˆΠΈΡ€ΠΈΠ½Ρƒ y- пиксСли Π² Π΄Π»ΠΈΠ½Ρƒ 

In my opinion, everything is clear and correct. If not, then okay, I’m just too lazy to check, you can make a Frame and push a picture in there, and on top of it is a Text

  • In the future, if you write the code, you need to retreat four spaces or press K + Ctrl. Please read the help first before answering - A.Kross