Answers for "tkinter filedialog"

4

askopenfilename

filename2 =  filedialog.askopenfilename(title = "Select file",filetypes = (("Excel files", ".xlsx .xls"),))
Posted by: Guest on September-13-2020
3

python tkinter filedialog

from tkinter import filedialog

						# Where it open to.					# What the window is called.	# What file types the user can choose between. first one is the defualt. (("what ever", "*.format"), ("what ever 2", "*.format2"))
filedialog.askopenfilename(initialdir=os.path.normpath("C://"), title="Example", filetypes =(("PNG", "*.png"),("JPG", "*.jpg"),("All Files","*.*")))
Posted by: Guest on January-02-2021
3

python tkinter filedialog folder

from tkinter import filedialog

								# Where it open to.					# What the window is called.
folder = filedialog.askdirectory(initialdir=os.path.normpath("C://"), title="Example")
Posted by: Guest on January-02-2021
5

tkinter radiobutton

from tkinter import *

root = Tk()

i = IntVar() #Basically Links Any Radiobutton With The Variable=i.
r1 = Radiobutton(root, text="option 1", value=1, variable=i)
r2 = Radiobutton(root, text="option 2", value=2, variable=i)
#
"""
If both values where equal, when one of the buttons
are pressed all buttons would be pressed.
If a button is pressed its value is true, or 1.
If you want to acess the data from the
radiobuttons, use a if statment like
"""
if (i.get() ==1):
       print("you picked option1")
else:
        print("you picked option2")
        
# :)

r1.pack()
r2.pack()

root.mainloop()
Posted by: Guest on March-28-2020
0

tkinter filedialog filename

def open_file():
    file = askopenfile(mode='r', filetypes=[
                       ('Text files', '*.txt'), ('CSV Files', '*.csv')])
    if file is not None:
        print(file.name.split("/")[-1]) # this will print the file name

btn = Button(root, text='Open', command=lambda: open_file())
btn.pack(side=TOP, pady=10)
Posted by: Guest on May-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language