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
| from tkinter import *
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
class Exemple:
def __init__(self):
self.window = tk.Tk()
self.window.bind("<Button-1>", self.click)
self.console()
self.window.mainloop()
def click(self,event):
x = self.f1.winfo_rootx()
y = self.f1.winfo_rooty()
z = self.f1.grid_location(x, y)
messagebox.showinfo(z)
def console(self):
#Fichier_etalonnage_serveau = open("configuration.txt", "r")
Frame_Calibration = Frame(self.window, borderwidth=2)
Frame_Calibration .grid(row=0,column=0)
style = ttk.Style(Frame_Calibration)
style.configure("lefttab.TNotebook", tabposition="nw", background='blue', foreground='green')
notebook = ttk.Notebook(Frame_Calibration, style="lefttab.TNotebook")
f1 = Frame(notebook, width=200, height=200) #, bg='light grey')
f2 = Frame(notebook, width=200, height=200) #, bg='light grey')
notebook.add(f1, text="Frame 1")
notebook.add(f2, text="Frame 2")
notebook.grid(row=0, column=0, sticky="nw")
canvas_serveau_titre = Canvas(f1,height=13 ,background='light grey')
txt = canvas_serveau_titre.create_text(5, 2, text="Case 1", font="Arial 8", fill="black", anchor='nw')
canvas_serveau_titre.grid(sticky="W", row=0, column=0)
canvas_serveau_titre = Canvas(f1,height=13 ,width="42",background='light grey')
txt = canvas_serveau_titre.create_text(7, 2, text= "Case 2", font="Arial 8", fill="black", anchor='nw')
canvas_serveau_titre.grid( row=0, column=2)
Exemple() |
Partager