Holger Frey
8 years ago
1 changed files with 53 additions and 0 deletions
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
import tkinter as tk |
||||
|
||||
|
||||
class StatusBar(tk.Frame): |
||||
|
||||
def __init__(self, master): |
||||
tk.Frame.__init__(self, master) |
||||
self.label = tk.Label(self, bd=1, relief=tk.SUNKEN, anchor=tk.SW) |
||||
self.label.pack(fill=tk.X) |
||||
self.pack(side=tk.BOTTOM, fill=tk.X) |
||||
|
||||
def set(self, text): |
||||
self.label.config(text=text) |
||||
self.label.update_idletasks() |
||||
|
||||
def clear(self): |
||||
self.label.config(text="") |
||||
self.label.update_idletasks() |
||||
|
||||
|
||||
class Application(tk.Frame): |
||||
|
||||
def __init__(self, master=None): |
||||
#master.geometry("500x500") |
||||
master.minsize(height=100, width=100) |
||||
tk.Frame.__init__(self, master) |
||||
self.pack(fill=tk.BOTH) |
||||
self.status = StatusBar(self.master) |
||||
self.create_widgets() |
||||
|
||||
def create_widgets(self): |
||||
self.btn_files = tk.Button(self, text="Select Files", command=self.selected_files) |
||||
self.btn_files.pack(side=tk.LEFT, pady=5, padx=5) |
||||
self.btn_quit = tk.Button(self, text="Quit", command=self.quit) |
||||
self.btn_quit.pack(side=tk.RIGHT, pady=5, padx=5) |
||||
|
||||
def selected_files(self): |
||||
opts = { |
||||
'initialdir': '~', |
||||
'filetypes': [('text files', '.txt'), ('python files', '.py')], |
||||
'multiple':True} |
||||
result = tk.filedialog.askopenfilename(**opts) |
||||
print(type(result), ':', result) |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
root = tk.Tk() |
||||
app = Application(master=root) |
||||
app.mainloop() |
||||
try: |
||||
root.destroy() |
||||
except tk.TclError: |
||||
pass |
Loading…
Reference in new issue