Nếu bạn từng thắc mắc hộp thoại (dialog) hoạt động như thế nào trong ứng dụng Python, thì bạn có thể đã nghe đến module filedialog trong Tkinter. Module filedialog chứa một số hàm tích hợp sẵn có thể được sử dụng để hiển thị các loại dialog khác nhau để xử lý file trong hệ thống.
Trong hầu hết các trường hợp, chúng ta sử dụng hàm filedialog.askopenfilename() để yêu cầu người dùng duyệt và mở file từ hệ thống. Dựa trên lựa chọn loại file, kịch bản được lập trình để thực hiện thao tác ghi hoặc đọc.
Một khi file được mở, bạn có thể sử dụng hàm open(file, 'mode') để mở và thực hiện thao tác ở bất kỳ chế độ nào. Để minh họa, hãy lấy ví dụ nơi chúng ta sẽ tạo ứng dụng yêu cầu người dùng mở file văn bản. Khi file được chọn và mở, chúng ta có thể đọc file này sử dụng chế độ hoạt động "read".
Ví dụ
# Nhập thư viện
from tkinter import *
from tkinter import filedialog
# Tạo instance của cửa sổ
win = Tk()
# Thiết lập hình học cửa sổ
win.geometry("700x300")
# Tạo nhãn
Label(win, text="Click the button to open a dialog", font='Arial 16 bold').pack(pady=15)
# Hàm mở file trong hệ thống
def open_file():
filepath = filedialog.askopenfilename(title="Open a Text File", filetypes=(("text files","*.txt"), ("all files","*.*")))
file = open(filepath, 'r')
print(file.read())
file.close()
# Tạo nút để kích hoạt dialog
button = Button(win, text="Open", command=open_file)
button.pack()
win.mainloop()
Kết quả
Chạy mã trên sẽ hiển thị cửa sổ với nút để mở dialog.

Chọn và mở file văn bản thì console sẽ hiển thị toàn bộ nội dung file.
Centralized Database Vs Blockchain A blockchain can be both permissionless (like Bitcoin or Ethereum) or permissioned (like the different Hyperledger blockchain frameworks). A permissionless blockchain is also known as a public blockchain, because anyone can join the network. A permissioned blockchain, or private blockchain, requires pre-verification of the participating parties within the network, and these parties are usually known to each other. Types of Blockchains The choice between permissionless versus permissioned blockchains should be driven by the particular application at hand (or use case). Most enterprise use cases involve extensive vetting before parties agree to do business with each other. An example where a number of businesses exchange information is supply chain management. The supply chain management is an ideal use case for permissioned blockchains. You would only want trusted parties participating in the network. Each participant that is involved in the supply chain would require permissions to execute transactions on the blockchain. These transactions would allow other companies to understand where in the supply chain a particular item is.