Aug-22-2019, 01:11 PM
why
you destroy the main window.
You never get a main window with your code.
try this and add your other functions
Quote:command = master.destroy
you destroy the main window.
You never get a main window with your code.
try this and add your other functions
from tkinter.filedialog import askopenfilename import tkinter import pandas as pd import matplotlib.pyplot as plt from gi.repository import GLib ### linux only class myApp: def __init__(self,master): self.master = master # Add a grid self.mainframe = tkinter.Frame(self.master) self.mainframe.grid(column=0,row=0, sticky=(tkinter.N,tkinter.W,tkinter.E,tkinter.S) ) self.mainframe.columnconfigure(0, weight = 2) self.mainframe.rowconfigure(0, weight = 2) self.mainframe.pack(pady = 100, padx = 100) self.button = tkinter.Button(self.mainframe, text="Auswahl", fg="red", command = self.openFile) self.popupMenu = tkinter.OptionMenu(self.mainframe, None, None) tkinter.Label(self.mainframe, text="Choose a sheet").grid(row = 1, column = 1) self.popupMenu.grid(row = 2, column =1) self.button.grid(row = 3, column = 1) def openFile(self): docs = GLib.get_user_special_dir(GLib.USER_DIRECTORY_DOCUMENTS) ### linux only Filename = askopenfilename(initialdir=docs, filetypes = (("ExcelFiles","*.xlsm *.xlsx *.xls"),("all files","*.*")),title='Jetzt wähl endlich die Kagg-Datei') print(Filename) return Filename if __name__ == '__main__': master = tkinter.Tk() master.title("Sheetauswahl") sheet = myApp(master).mainframe master.mainloop()