0

I am trying to run a python script(loop to listen to incoming email) with tkinter GUI, but the problem is when I executed the GUI my script is also run with the GUI even the button not pushed yet pls any help also if possible a little help with a button to stop my script, already thanks

the script used https://stackoverflow.com/a/59538076/13780184 my gui code:

import tkinter as tk
from tkinter import ttk
from tkinter import * 
from itertools import chain
import os

# this is the function called when the button is clicked
def btnClickFunction():  
    print('clicked')
    #the script is pasted here




# this is the function called when the button is clicked
def btnClickFunction():
    print('clicked2')


# this is a function to get the user input from the text input box
def getInputBoxValue():
    userInput = tInput.get()
    return userInput



root = Tk()

# This is the section of code which creates the main window
root.geometry('618x400')
root.configure(background='#FFEFDB')
root.title('Hello, I\'m the main window')


# This is the section of code which creates a button
Button(root, text='Button text!', bg='#FFEFDB', font=('arial', 12, 'normal'), command=btnClickFunction).place(x=31, y=67)

# This is the section of code which creates the a label
Label(root, text='this is a label', bg='#FFEFDB', font=('arial', 12, 'normal')).place(x=43, y=151)


# This is the section of code which creates a button
Button(root, text='Button text!2', bg='#FFEFDB', font=('arial', 12, 'normal'), command=btnClickFunction).place(x=203, y=73)


# This is the section of code which creates a text input box
tInput=Entry(root)
tInput.place(x=251, y=200)


root.mainloop()
timomo
  • 67
  • 1
  • 8
  • Please consider editing your question. We accept correct grammar in all posts, and it could help with reading in order to answer these quickly. –  Jan 11 '21 at 18:21
  • 1
    In order to link a function to a button you must bind the action to the function. For a good tutorial on how best to do this see [Tkinter 8.5 reference: a GUI for Python](https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/index.html). The section on evets is most helpful – itprorh66 Jan 11 '21 at 19:28

0 Answers0