|
Last change
on this file was 11160, checked in by stuerze, 5 days ago |
|
screenshots are updated
|
-
Property svn:executable
set to
*
|
|
File size:
621 bytes
|
| Line | |
|---|
| 1 | #!/usr/bin/env python3
|
|---|
| 2 | """Simple text viewer window (stands in for a text editor in screenshots)
|
|---|
| 3 |
|
|---|
| 4 | viewer.py <file> [columns] [rows]
|
|---|
| 5 | """
|
|---|
| 6 | import os
|
|---|
| 7 | import sys
|
|---|
| 8 | import tkinter as tk
|
|---|
| 9 |
|
|---|
| 10 | path = sys.argv[1]
|
|---|
| 11 | root = tk.Tk()
|
|---|
| 12 | root.title(os.path.basename(path))
|
|---|
| 13 | text = tk.Text(root, width=int(sys.argv[2]) if len(sys.argv) > 2 else 90,
|
|---|
| 14 | height=int(sys.argv[3]) if len(sys.argv) > 3 else 22,
|
|---|
| 15 | font=("DejaVu Sans Mono", 9), bg="white", relief="flat", padx=6, pady=4)
|
|---|
| 16 | text.insert("1.0", open(path, errors="replace").read())
|
|---|
| 17 | text.config(state="disabled")
|
|---|
| 18 | text.pack(fill="both", expand=True)
|
|---|
| 19 | root.mainloop()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.