Bonjour à tous,

Voici un code avec des formes créées avec create_rectangle, create_text et un frame rouge créé avec create_window.
Pourquoi le frame déborde sur les ascenseurs quand je réduit la fenêtre alors que les formes rectangles et le text disparaissent convenablement au bord des ascenseurs?

Je ne trouve rien sur les forums qui semblent discuter de ce pb.
Dans l'attente de vous lire.
Passy261

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import tkinter as tk
from tkinter import *
import random 
 
#######################################################################################################
 
class Appli(tk.Canvas):     # FENETRE PRINCIPALE
 
   def __init__(self,root):
      tk.Canvas.__init__(self,root)
 
      self.config(background="bisque") 
      self.xsb = tk.Scrollbar(self, orient="horizontal", command=self.xview) 
      self.ysb = tk.Scrollbar(self, orient="vertical", command=self.yview) 
      self.config(yscrollcommand=self.ysb.set, xscrollcommand=self.xsb.set) 
      self.config(scrollregion=(0,0,2000,2000)) 
 
      self.xsb.grid(row=1, column=0, sticky="ew") 
      self.ysb.grid(row=0, column=1, sticky="ns") 
      self.grid(row=0, column=0, sticky="nsew") 
      self.grid_rowconfigure(0, weight=1) 
      self.grid_columnconfigure(0, weight=1)
      for n in range(50): 
         x0 = random.randint(0, 900) 
         y0 = random.randint(50, 900) 
         x1 = x0 + random.randint(50, 100) 
         y1 = y0 + random.randint(50,100) 
         color = ("red", "orange", "yellow", "green", "blue")[random.randint(0,4)] 
         self.create_rectangle(x0,y0,x1,y1, outline="black", fill=color) 
      self.create_text(50,10, anchor="nw", 
           text="Click and drag to move the canvas")
 
      self.fr=Frame(self,width=270,height=300,bg="red")#pour obtenir toutes les données nécessaires
 
      self.create_window(30,50,anchor='nw',window=self.fr)#pour obtenir toutes les données nécessaires
 
 
     # This is what enables scrolling with the mouse: 
      self.bind("<ButtonPress-1>", self.scroll_start) 
      self.bind("<B1-Motion>", self.scroll_move) 
 
   def scroll_start(self, event): 
      self.scan_mark(event.x, event.y) 
 
   def scroll_move(self, event): 
      self.scan_dragto(event.x, event.y, gain=1) 
 
############# LANCEMENT PROGRAMME ##################
root = Tk()
root.title('tournoi')
root.state('zoomed')
Appli(root).pack(fill="both", expand=True)
root.mainloop()  
 
############# FIN ##################