-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-Listbox.pyw
74 lines (61 loc) · 1.97 KB
/
test-Listbox.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
from __future__ import print_function
import sys
if sys.version_info.major >= 3:
print("\nUsing Python %s" % sys.version, file=sys.stderr)
# sys.path.insert(0, "/usr/lib/python3.10") # even this doesn't prevent
# VSCode linux "ModuleNotFoundError: No module named 'tkinter'"
# even though with or without that, the path above is in sys.path
# and has tkinter in it :(
print("PYTHON=%s" % (sys.executable))
print("PYTHONPATH=%s" % (sys.path))
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
else:
# Python 2
print("\nUsing Python 2", file=sys.stderr)
import Tkinter as tk
import ttk
import tkMessageBox as messagebox
from outputinspector import OutputInspector
class MainWindow(ttk.Frame): # (OutputInspector, tk.Tk)
def __init__(self, root):
# tk.Tk.__init__(self)
OutputInspector.__init__(self)
self.root = root
if root is not None:
self._window_init(root)
else:
# Use console mode.
pinfo("")
pinfo("Output Inspector")
pinfo("----------------")
def _window_init(self, parent):
# self.bV = tk.StringVar()
ttk.Frame.__init__(self, parent)
self.mainListWidget = tk.Listbox(
self,
)
self.mainListWidget.pack() # ensure statusbar last
self.pack(fill=tk.BOTH, expand=True)
# textvariable=self.bV,
# Avoid
# "AttributeError: 'tkinter.ttk' has no attribute 'Listbox'"
def showinfo(self, title, msg):
messagebox.showinfo(title, msg)
def showerror(self, title, msg):
messagebox.showerror(title, msg)
root = None
window = None
def main():
global root
global window
root = tk.Tk()
root.title("Listbox Test Application")
# app.setOrganizationDomain("poikilos.org")
window = MainWindow(root)
root.mainloop()
return 0
if __name__ == "__main__":
main()