Bonsoir,
J'essaie en vain de redimensionner le widget en fonction de la fenêtre (notament en collant les bords à la frame) mais aucune des solution ne fonctionne. J'aimerais donc votre aide voici mon code actuel :
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
 
from tkinter import *
from tkinter.filedialog import *
from tkinter.scrolledtext import *
import os
 
class Editor:
	def __init__(self):
		# Fenêtre Principal du programme
		global MainWindow
		MainWindow = Tk()
		MainWindow.title('PyEditor')
 
		OpenButton = Button(MainWindow, text='Ouvrir un fichier', command=self.New).pack()
 
		MainWindow.mainloop()
 
	def New(self):
		"""Création d'un nouveau document"""
		Filename = askopenfilename(title="Ouvrir un fichier", filetypes=[('Fichiers text', '.txt'), ('Tous les fichiers', '.*')])
		File = open(Filename, 'r')
		Content = File.read()
		File.close()
 
		Container = Frame(MainWindow, bg='black')
 
		Container.grid_columnconfigure(0, weight=1)  # <<
		Container.grid_rowconfigure(0, weight=1)  # <<
 
		TextZone = Text(Container)
		TextZone.insert(END, Content)
		TextZone.grid(row=0, column=0, padx=5, pady=5, sticky='NSEW')
 
		# Boutons Enregistrer, Quitter
		ButtonQuit = Button(Container, text='Quitter', command=MainWindow.destroy).grid(row=1, column=0, padx=5, pady=5)
 
		Container.pack(expand=1)
 
Editor()