Problèmes interfichier

Strong214356 Messages postés 2 Statut Membre -  
bobonou Messages postés 83 Statut Membre -
bonjour j'ai un problème avec mes inclusions.
pouvez vous maider? (je suis sous linux)
main.py:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from Tkinter import *
from functions import *


f = Tk()

f.title("Lancé de dé")

mbar = Menu(f)
f.config(menu=mbar)

mlance = Menu(mbar, tearoff=0)
mbar.add_cascade(label="menu", menu=mlance)

mlance.add_command(label="lancer", command=afficher())
mlance.add_separator()
mlance.add_command(label="quitter", command=f.destroy)

nbmdd = Spinbox(f, from_=2, to=100)
nbmdd.pack(side=TOP)

l1 = Label(f, text="nombre maximal du dé ^")
l1.pack(side=TOP)

nbdd = Spinbox(f, from_=1, to=20)
nbdd.pack(side=TOP)

l2 = Label(f, text="nombre de dé ^")
l2.pack(side=TOP)

f.mainloop()


functions.py :
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *
from Tkinter import *
result = 0

def afficher():
    print ("test")


merci

1 réponse

  1. bobonou Messages postés 83 Statut Membre 43
     
    salut,

    dans ton main.py

    à la place de
    from functions import *

    utilise
    import functions as func
    par exemple

    et tu utilise la fonction comme ça:
    func.afficher()
    1
    1. Strong214356 Messages postés 2 Statut Membre
       
      merci mais en fait le problème est que si j'utilise le bouton lancer alors il ne ce passe rien ni auniveau du terminal ni au niveau du module Tk
      0
    2. bobonou Messages postés 83 Statut Membre 43
       
      Je ne connais pas Tkinter,
      il faut peut-être mettre func.afficher sans les parenthèses à la fin.
      0