/
copy_tool_postit.py
145 lines (115 loc) · 4.62 KB
/
copy_tool_postit.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import tkinter as tk
from tkinter import ttk
from thonny.codeview import CodeViewText
from thonny.shell import ShellText
from thonny import get_workbench, get_shell
from .tool_postit import ToolWidget, ToolCodeMixin
from ..base_postit import BaseCode, BasePost, BasePopup
class CopyToolPostMixin:
def post_init(self):
self.drag_window = None
self.drag_button = None
self.drag_hover_selection = False
self.hover_text_backup = ''
#self.mouse_dragging = False
# drag and press event
#self.postit_button.bind("<B1-Motion>", self.on_mouse_drag)
self.postit_button.bind("<Button-1>", self.on_mouse_release)
#self.postit_button.config(cursor='arrow')
def insert_into_editor(self, editor_text,
pressing=False, dragging=False,
selecting=False, hovering=False):
widget = get_workbench().focus_get()
if widget:
return widget.event_generate("<<Copy>>")
return None
def insert_into_shell(self, shell_text,
pressing=False, dragging=False,
selecting=False, hovering=False):
widget = get_workbench().focus_get()
if widget:
return widget.event_generate("<<Copy>>")
return None
class CopyToolPostit(ToolWidget,
ToolCodeMixin, BaseCode,
CopyToolPostMixin, BasePost,
#CommentToolPopup
):
""" composite and mixin approach postit"""
def __init__(self, master):
self.widget_init(master, 'copy')
self.code_init()
self.post_init()
#self.popup_init()
class CutToolPostMixin:
def post_init(self):
self.drag_window = None
self.drag_button = None
self.drag_hover_selection = False
self.hover_text_backup = ''
#self.mouse_dragging = False
# drag and press event
#self.postit_button.bind("<B1-Motion>", self.on_mouse_drag)
self.postit_button.bind("<Button-1>", self.on_mouse_release)
#self.postit_button.config(cursor='arrow')
def insert_into_editor(self, editor_text,
pressing=False, dragging=False,
selecting=False, hovering=False):
widget = get_workbench().focus_get()
if widget:
return widget.event_generate("<<Cut>>")
return None
def insert_into_shell(self, shell_text,
pressing=False, dragging=False,
selecting=False, hovering=False):
widget = get_workbench().focus_get()
if widget:
return widget.event_generate("<<Cut>>")
return None
class CutToolPostit(ToolWidget,
ToolCodeMixin, BaseCode,
CutToolPostMixin, BasePost,
#CommentToolPopup
):
""" composite and mixin approach postit"""
def __init__(self, master):
self.widget_init(master, 'cut')
self.code_init()
self.post_init()
#self.popup_init()
class PasteToolPostMixin:
def post_init(self):
self.drag_window = None
self.drag_button = None
self.drag_hover_selection = False
self.hover_text_backup = ''
#self.mouse_dragging = False
# drag and press event
#self.postit_button.bind("<B1-Motion>", self.on_mouse_drag)
self.postit_button.bind("<Button-1>", self.on_mouse_release)
#self.postit_button.config(cursor='arrow')
def insert_into_editor(self, editor_text,
pressing=False, dragging=False,
selecting=False, hovering=False):
widget = get_workbench().focus_get()
if widget:
return widget.event_generate("<<Paste>>")
return None
def insert_into_shell(self, shell_text,
pressing=False, dragging=False,
selecting=False, hovering=False):
widget = get_workbench().focus_get()
if widget:
return widget.event_generate("<<Paste>>")
return None
class PasteToolPostit(ToolWidget,
ToolCodeMixin, BaseCode,
PasteToolPostMixin, BasePost,
#CommentToolPopup
):
""" composite and mixin approach postit"""
def __init__(self, master):
self.widget_init(master, 'paste')
self.code_init()
self.post_init()
#self.popup_init()