Compare commits
2 Commits
408c6e53a5
...
4da03f099c
Author | SHA1 | Date | |
---|---|---|---|
4da03f099c | |||
056dab1fa5 |
@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "📼 Смотри аниме во время кодинга | mpv по верх всех окон"
|
||||
date: 2023-06-05T21:25:54+03:00
|
||||
draft: true
|
||||
draft: false
|
||||
tags: [video, tools, tips]
|
||||
---
|
||||
|
||||
|
42
content/posts/2023/python/tk-file-folder-select-dialog.md
Normal file
42
content/posts/2023/python/tk-file-folder-select-dialog.md
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
title: "🗂️ Диалог выбора директории/файлов в Tk на Python"
|
||||
date: 2023-06-05T21:47:33+03:00
|
||||
draft: false
|
||||
tags: [tk, python, tips]
|
||||
---
|
||||
|
||||
## 📄 Выбор файла
|
||||
|
||||
```python
|
||||
from tkinter import filedialog
|
||||
from tkinter import *
|
||||
|
||||
root = Tk()
|
||||
root.withdraw()
|
||||
|
||||
file_selected = filedialog.askopenfilename(
|
||||
title='Open a file',
|
||||
initialdir='/',
|
||||
filetypes=(
|
||||
('Text files', '*.txt'),
|
||||
('All files', '*.*')
|
||||
)
|
||||
)
|
||||
|
||||
print(file_selected)
|
||||
```
|
||||
|
||||
## 📁 Выбор директории
|
||||
|
||||
```python
|
||||
from tkinter import filedialog
|
||||
from tkinter import *
|
||||
|
||||
root = Tk()
|
||||
root.withdraw()
|
||||
|
||||
folder_selected = filedialog.askdirectory()
|
||||
|
||||
print(folder_selected)
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user