Bonjour, depuis que je veux faire des sous programme, je constate que je dois déjà refaire tout les imports Tkinter dans mon sous programme Construit_tableau.py, ensuite malgré ça blogue sur Fenetre(Windows) qui est dans le corps de mon programme.
Le corps actuel de mon programme :
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#-------------------------------------------------------------------------------
# Name:        clavier et liste permanence
# Purpose:
#
# Author:      LENOVO
#
# Created:     09/09/2023
# Copyright:   (c) LENOVO 2023
# Licence:     <your licence>
#-------------------------------------------------------------------------------
 
##########################################
########    Importation   ################
##########################################
 
#import tkinter as tk
#import tkinter
from tkinter import *
from tkinter.messagebox import showinfo   #permet Fenetre dialogue
from random import *
#from tkinter import filedialog
from pandastable import Table
#from pandastable import * # Ne fonctionne que plus bas.
import pandas as pd
import numpy as np
from Construit_tableau import construction_PT1
 
#import tkinter.ttk as TTK #Notebook pour onglet
 
import random
########################################################
########## Liste et Variable Globales  #################
########################################################
 
 
 
L = ['<-','->',0,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,'<=','=>','<x']
 
 
 
 
 
 
 
 
 
 
global CPT_choisir
global Identation_choisir
global Identation_effacement
CPT_choisir = []
Identation_choisir = 0
Identation_effacement = 0
 
 
 
 
 
#############################################################
##################### FONCTIONS  ############################
#############################################################
 
 
 
ListeEntrePerma=[]
Inverser_ListeEntrePerma=[]
Legende_Tableau=[]
Inverser_Legende_Tableau=[]
N_Tableau_1=[]
P_Tableau_1=[]
 
#################################################################################
def choisir(x,ListeEntrePerma,Inverser_ListeEntrePerma,Legende_Tableau,Inverser_Legende_Tableau,N_Tableau_1,P_Tableau_1):
 
 
    global Identation_effacement
 
    global Affichage_Legende
    global Affichage_Liste
 
    if (str(L[x]).isdigit()):
 
        ListeEntrePerma.append(L[x])
        Identation_choisir=len(ListeEntrePerma)
        Inverser_ListeEntrePerma.insert(0,L[x])
 
        Legende_Tableau.append(Identation_choisir)
        Inverser_Legende_Tableau.insert(0,Identation_choisir)
 
 
        N_Tableau_1 = np.array(Inverser_ListeEntrePerma)
        P_Tableau_1 = pd.DataFrame([N_Tableau_1], columns = Inverser_Legende_Tableau)
        construction_PT1(P_Tableau_1,Fenetre)
 
    elif L[x]=="<x":
        del Legende_Tableau[-1]
        del ListeEntrePerma[-1]
        del Inverser_Legende_Tableau[0]
        del Inverser_ListeEntrePerma[0]
 
        N_Tableau_1 = np.array(Inverser_ListeEntrePerma)
        P_Tableau_1 = pd.DataFrame([N_Tableau_1], columns = Inverser_Legende_Tableau)
        construction_PT1(P_Tableau_1)
############################################
############ fenêtre graphique   ###########
############################################
Fenetre=Tk()
Fenetre.geometry('1400x1350')
Fenetre.title('PandasTable Liaison')
 
 
 
 
###############################################################
###### espace d'affichage du clavier numerique  ##############
#############################################################
 
Clavier=Frame(Fenetre, bg="#ffffff")
Clavier.place(x = 7, y = 7) #Positionne ou je veux.
Numero=[k for k in range(1,43)]
 
Dbt = 3
for Ligne in range(3):
    Dbt = Dbt - 1
    k = Dbt
    for Colone in range(14):
        Couleur = "gray99"
        Taille = ("Courier", 10)
 
        #red 1,3,5,7,9,12,14,16,18,21,23,25,27,30,32,34,36
        if L[k] == "<=" or L[k] == "=>" or L[k] == "<x":
            Couleur = "gainsboro"
        if L[k] == 0:
            Couleur = "green2"
        if L[k] == 1 or L[k] == 3 or L[k] == 5 or L[k] == 7 or L[k] == 9 or L[k] == 12 or L[k] == 14 or L[k] == 16 or L[k] == 18 or L[k] == 21 or L[k] == 23 or L[k] == 25 or L[k] == 27 or L[k] == 30 or L[k] == 32 or L[k] == 34 or L[k] == 36:
            Couleur = "red"
        if k>1 and k < 12:
            Taille = ("Courier", 13)
 
        Numero[k]=Button(Clavier,text=str(L[k]),font=Taille,bg=Couleur,command=lambda x=k: choisir(x,ListeEntrePerma,Inverser_ListeEntrePerma,Legende_Tableau,Inverser_Legende_Tableau,N_Tableau_1,P_Tableau_1))
        #Numero[k]=Button(Clavier,text=str(L[k]),command=lambda x=k: choisir(x))
        Numero[k].grid(row=Ligne,column=Colone,sticky='ew''ns') # Sticky ew pour ealrgir moins de 10
 
        k = k + 3
 
 
 
 
Fenetre.mainloop()
La fonction mise en sous programme :
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
#-------------------------------------------------------------------------------
# Name:        Construit_Tableau
# Purpose:
#
# Author:      LENOVO
#
# Created:     13/09/2023
# Copyright:   (c) LENOVO 2023
# Licence:     <your licence>
#-------------------------------------------------------------------------------
from tkinter import *
from tkinter.messagebox import showinfo   #permet Fenetre dialogue
from random import *
#from tkinter import filedialog
from pandastable import Table
#from pandastable import * # Ne fonctionne que plus bas.
import pandas as pd
import numpy as np
 
#import tkinter.ttk as TTK #Notebook pour onglet
 
import random
 
 
 
 
 
 
 
 
 
 
 
 
def construction_PT1(P_Tableau_1):
 
 
 
    Cadre = Frame(Fenetre, bg="gainsboro")
    Cadre.place(x = 7, y = 120, width=1350, height=55) # Donne emplacement mesure (alors que impossible avec Cadre.config)
    # Construit Tableau dans Tkinter
    PT_Tableau_1 = Table(Cadre, dataframe=P_Tableau_1) #, showstatusbar=True, showtoolbar=True) #Statusbar endessous showtoolbar a droite
 
    PT_Tableau_1.cellwidth =  25 #Largeur de la cellule.
    PT_Tableau_1.maxcellwidth = 300
    PT_Tableau_1.mincellwidth = 20
    PT_Tableau_1.rowheight = 24 #hAUTEUR DE LA CELLULE
    PT_Tableau_1.thefont = ('Arial',12) # FONCTIONNE !
 
    #PT_Tableau_1.cellbackgr = 'white'  #Couleur des cellules du fond
    PT_Tableau_1.colheadercolor = 'gray50' #couleur Nom Colonne
    #########  Active pandastable ############################
    PT_Tableau_1.show()
    return PT_Tableau_1
Si je voudrais remettre une deuxième fois Fenetre=Tk(), j'aurais alors 2 fenêtre, je ne vois donc pas bien ou l'écrire une seule fois pour que ça fonctionne.