Python Forum
Functions with Tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Functions with Tkinter
#1
Hi there, I'm new to tkinter. I want to create a window, in which a button appears. I managed to make this first step. The issue is that I want when you click the button , a function which contains inputs appears. I tried the last 3 days but no idea how do to do it. The code shows me the window, but the function is made in the console and in the window. I hope you understood. Thanks a lot for reading my message and helping me .

import tkinter
from tkinter import *

def retraite_fonctionnaire():
    i=input("Your name: ")
    k=input("Date of birth ?: ")
    revenu_moyen=int(input("Your salary: "))
    trimestre_cotis├ęs = int(input("Number of years working ?: " ))
    enfants = int(input("Number of child ?: " ))
    

#adding text
label_title= Label(frame, text="Hi there", font=("scrubble", 45), bg="#205BA9",fg="white", bd=1, relief=SUNKEN)
label_title.pack()

#first function
retraite_simple= Button(frame, text="Continue", font=("scrubble", 25), bg="white",fg="#205BA9", command=retraite_fonctionnaire )
retraite_simple.pack(pady=25, fill=X)

frame.pack(expand=YES)
window.mainloop()
Reply
#2
you'll find a good example here: https://runestone.academy/runestone/book...vents.html
Reply
#3
Thx bro Thumbs Up
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Redirecting all print statements from all functions inside a class to Tkinter Anan 1 249 Apr-24-2021, 08:57 AM
Last Post: ndc85430
  Help with tkinter gui and functions Omer_ 0 303 Sep-22-2020, 11:43 AM
Last Post: Omer_
  [Tkinter] tkinter issue with variables carrying over between functions PengEng 1 612 Apr-06-2020, 06:13 PM
Last Post: deanhystad
  def functions in tkinter Fureneshi 5 1,453 Dec-26-2019, 11:34 PM
Last Post: woooee
  Functions running before they should be - Python Tkinter logic error jhf2 2 706 Nov-23-2019, 03:45 PM
Last Post: jhf2
  Binding functions to Menus in tkinter?? Mocap 1 957 Jul-23-2019, 01:37 AM
Last Post: Larz60+
  Variable not sharing same value between two different functions Python 2.7 Tkinter albert 0 1,144 Aug-31-2018, 10:45 AM
Last Post: albert

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020