3 Replies - 297 Views - Last Post: 20 February 2020 - 12:39 AM Rate Topic: -----

#1 SacPy   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 18-June 19

Dialogue box getting opened twice

Posted 19 February 2020 - 06:20 AM

Hi,

I am using below code to get Excel file with dialogue box.
The code is running without any issues, however with this code dialogue box gets activate twice.
I am not able to understand what is causing this.
Can anyone please help me in this.

#Import Excel file using dialogue box
import tkinter as Mytkinter
from tkinter import filedialog
import pandas as MyPandas

root= Mytkinter.Tk()

canvas1 = Mytkinter.Canvas(root, width = 300, height = 300, bg = 'lightsteelblue')
canvas1.pack()

def getExcel ():
    global OpenFile
    
    import_file_path = filedialog.askopenfilename()
    OpenFile = MyPandas.read_excel (import_file_path)
    print (OpenFile)
    
browseButton_Excel = Mytkinter.Button(text='Select Excel File', command=getExcel, bg='green', fg='white', font=('calibri', 10, 'bold'))
canvas1.create_window(150, 150, window=browseButton_Excel)

root.mainloop()



Is This A Good Question/Topic? 0
  • +

Replies To: Dialogue box getting opened twice

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15564
  • View blog
  • Posts: 62,309
  • Joined: 12-June 08

Re: Dialogue box getting opened twice

Posted 19 February 2020 - 08:21 AM

I am not seeing that behavior with that code.
Was This Post Helpful? 1
  • +
  • -

#3 SacPy   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 18-June 19

Re: Dialogue box getting opened twice

Posted 19 February 2020 - 08:44 AM

Hi modi123_1 sir thanks for the help. I will re-check and confirm. Good night.
Was This Post Helpful? 0
  • +
  • -

#4 SacPy   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 18-June 19

Re: Dialogue box getting opened twice

Posted 20 February 2020 - 12:39 AM

Hi,
I was wrong. Code is not running twice. However the dialogue box is not getting closed after the first run of the code. Even after selecting the file it still remains open. How do I close dialogue box post first selection.
Can anyone please help me this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1