MCPcopy
hub / github.com/makelove/OpenCV-Python-Tutorial / __init__

Method __init__

官方samples/demo.py:68–109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

66
67class App:
68 def __init__(self):
69 root = tk.Tk()
70 root.title('OpenCV Demo')
71
72 self.win = win = tk.PanedWindow(root, orient=tk.HORIZONTAL, sashrelief=tk.RAISED, sashwidth=4)
73 self.win.pack(fill=tk.BOTH, expand=1)
74
75 left = tk.Frame(win)
76 right = tk.Frame(win)
77 win.add(left)
78 win.add(right)
79
80 scrollbar = tk.Scrollbar(left, orient=tk.VERTICAL)
81 self.demos_lb = demos_lb = tk.Listbox(left, yscrollcommand=scrollbar.set)
82 scrollbar.config(command=demos_lb.yview)
83 scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
84 demos_lb.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
85
86 self.samples = {}
87 for fn in glob('*.py'):
88 name = splitfn(fn)[1]
89 if fn[0] != '_' and name not in exclude_list:
90 self.samples[name] = fn
91
92 for name in sorted(self.samples):
93 demos_lb.insert(tk.END, name)
94
95 demos_lb.bind('<<ListboxSelect>>', self.on_demo_select)
96
97 self.cmd_entry = cmd_entry = tk.Entry(right)
98 cmd_entry.bind('<Return>', self.on_run)
99 run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)
100
101 self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
102 self.linker = linker = LinkManager(text, self.on_link)
103 self.text.tag_config("header1", font=('arial', 14, 'bold'))
104 self.text.tag_config("header2", font=('arial', 12, 'bold'))
105 text.config(state='disabled')
106
107 text.pack(fill='both', expand=1, side=tk.BOTTOM)
108 cmd_entry.pack(fill='x', side='left' , expand=1)
109 run_btn.pack()
110
111 def on_link(self, url):
112 print(url)

Callers

nothing calls this directly

Calls 3

splitfnFunction · 0.90
LinkManagerClass · 0.85
addMethod · 0.45

Tested by

no test coverage detected