├── .gitignore ├── GUIcoder ├── __init__.py ├── app.py ├── board.py ├── manager.py ├── myTkinter.py ├── palette.py ├── selector.py ├── settings.py └── writer.py ├── LICENSE.txt ├── README.md ├── README.txt ├── requirements.txt ├── setup.cfg.txt ├── setup.py └── simple_demonstration.mov /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | __pycache__/ 3 | venv 4 | inutility 5 | .git 6 | .DS_Store 7 | .gitignore 8 | Prototype.py 9 | simple_demonstration.mov 10 | __pycache__ -------------------------------------------------------------------------------- /GUIcoder/__init__.py: -------------------------------------------------------------------------------- 1 | from GUIcoder.board import Board 2 | from GUIcoder.manager import Manager 3 | from GUIcoder.myTkinter import myButton 4 | from GUIcoder.palette import Palette 5 | from GUIcoder.selector import Selector 6 | from GUIcoder.settings import * 7 | from GUIcoder.writer import Writer 8 | from GUIcoder.app import * 9 | 10 | 11 | if __name__ == "__main__": 12 | root = Tk() 13 | 14 | App(root) 15 | 16 | root.mainloop() 17 | -------------------------------------------------------------------------------- /GUIcoder/app.py: -------------------------------------------------------------------------------- 1 | from tkinter import Toplevel, Label, Entry, Radiobutton, Checkbutton, Spinbox, Listbox, Text, Tk 2 | from tkinter import ttk 3 | from GUIcoder.board import Board 4 | from GUIcoder.manager import Manager 5 | from GUIcoder.writer import Writer 6 | from GUIcoder.palette import Palette 7 | from time import time 8 | 9 | 10 | class App: 11 | def __init__(self, root): 12 | self.root = root 13 | self.writer = Writer() 14 | w = root.winfo_screenwidth() // 2 15 | root.geometry(f"{w}x800+{w // 4 * 3}+100") 16 | root.title("") 17 | 18 | top = Toplevel(root) 19 | Palette(top).place(relx=0, rely=0, relheight=1, relwidth=1) 20 | 21 | self.board = Board(root, height=800, width=w) 22 | self.board.pack(fill="both", expand=True) 23 | 24 | self.manager = Manager(root, self.writer, self.root, bg="#435661", height=800, width=w // 5 * 2) 25 | self.manager.geometry("+250+100") 26 | 27 | self.set_bind() 28 | 29 | def create_frame(self): 30 | P0, widget_dims, board_dims = self.board.get_geometry() 31 | x, y = P0 32 | width, height = widget_dims 33 | board_width, board_height = board_dims 34 | 35 | tag = str(time()) 36 | 37 | self.board.create_rectangle(x, y, x + width, y + height, width=0, tag=tag) 38 | self.board.delete("line") 39 | 40 | x, y = x / board_width, y / board_height 41 | width, height = width / board_width, height / board_height 42 | self.manager.fake_frame_place_info = {"relx": x, "rely": y, 43 | "relwidth": width, "relheight": height, "anchor": "nw"} 44 | self.manager.switch_for_frame(self.board, tag, board_dims) 45 | 46 | def create_label(self): 47 | P0, widget_dims, board_dims = self.board.get_geometry() 48 | x, y = P0 49 | width, height = widget_dims 50 | board_width, board_height = board_dims 51 | 52 | x, y = x / board_width, y / board_height 53 | width, height = width / board_width, height / board_height 54 | 55 | label = Label(self.board) 56 | label.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 57 | self.board.delete("line") 58 | items = [item for item in label.keys() if len(item) > 2] 59 | 60 | label.bind("", lambda event: self.get_widget_info(label)) 61 | label.bind("", lambda event: self.focus_out()) 62 | label.bind("", lambda event: self.modify(label, items)) 63 | 64 | self.manager.switch(label, items) 65 | 66 | def create_entry(self): 67 | P0, widget_dims, board_dims = self.board.get_geometry() 68 | x, y = P0 69 | width, height = widget_dims 70 | board_width, board_height = board_dims 71 | 72 | x, y = x / board_width, y / board_height 73 | width, height = width / board_width, height / board_height 74 | 75 | entry = Entry(self.board) 76 | entry.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 77 | self.board.delete("line") 78 | items = [item for item in entry.keys() if len(item) > 2] 79 | 80 | entry.bind("", lambda event: self.get_widget_info(entry)) 81 | entry.bind("", lambda event: self.focus_out()) 82 | entry.bind("", lambda event: self.modify(entry, items)) 83 | 84 | self.manager.switch(entry, items) 85 | 86 | def create_button(self): 87 | P0, widget_dims, board_dims = self.board.get_geometry() 88 | x, y = P0 89 | width, height = widget_dims 90 | board_width, board_height = board_dims 91 | 92 | x, y = x / board_width, y / board_height 93 | width, height = width / board_width, height / board_height 94 | 95 | button = ttk.Button(self.board) 96 | button.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 97 | self.board.delete("line") 98 | items = [item for item in button.keys() if len(item) > 2] 99 | 100 | button.bind("", lambda event: self.get_widget_info(button)) 101 | button.bind("", lambda event: self.focus_out()) 102 | button.bind("", lambda event: self.modify(button, items)) 103 | 104 | self.manager.switch(button, items) 105 | 106 | def create_radiobutton(self): 107 | P0, widget_dims, board_dims = self.board.get_geometry() 108 | x, y = P0 109 | width, height = widget_dims 110 | board_width, board_height = board_dims 111 | 112 | x, y = x / board_width, y / board_height 113 | width, height = width / board_width, height / board_height 114 | 115 | button = Radiobutton(self.board) 116 | button.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 117 | self.board.delete("line") 118 | items = [item for item in button.keys() if len(item) > 2] 119 | 120 | button.bind("", lambda event: self.get_widget_info(button)) 121 | button.bind("", lambda event: self.focus_out()) 122 | button.bind("", lambda event: self.modify(button, items)) 123 | 124 | self.manager.switch(button, items) 125 | 126 | def create_checkbutton(self): 127 | P0, widget_dims, board_dims = self.board.get_geometry() 128 | x, y = P0 129 | width, height = widget_dims 130 | board_width, board_height = board_dims 131 | 132 | x, y = x / board_width, y / board_height 133 | width, height = width / board_width, height / board_height 134 | 135 | button = Checkbutton(self.board) 136 | button.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 137 | self.board.delete("line") 138 | items = [item for item in button.keys() if len(item) > 2] 139 | 140 | button.bind("", lambda event: self.get_widget_info(button)) 141 | button.bind("", lambda event: self.focus_out()) 142 | button.bind("", lambda event: self.modify(button, items)) 143 | 144 | self.manager.switch(button, items) 145 | 146 | def create_combobox(self): 147 | P0, widget_dims, board_dims = self.board.get_geometry() 148 | x, y = P0 149 | width, height = widget_dims 150 | board_width, board_height = board_dims 151 | 152 | x, y = x / board_width, y / board_height 153 | width, height = width / board_width, height / board_height 154 | 155 | box = ttk.Combobox(self.board) 156 | box.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 157 | self.board.delete("line") 158 | items = [item for item in box.keys() if len(item) > 2] 159 | 160 | box.bind("", lambda event: self.get_widget_info(box)) 161 | box.bind("", lambda event: self.focus_out()) 162 | box.bind("", lambda event: self.modify(box, items)) 163 | 164 | self.manager.switch(box, items) 165 | 166 | def create_spinbox(self): 167 | P0, widget_dims, board_dims = self.board.get_geometry() 168 | x, y = P0 169 | width, height = widget_dims 170 | board_width, board_height = board_dims 171 | 172 | x, y = x / board_width, y / board_height 173 | width, height = width / board_width, height / board_height 174 | 175 | box = Spinbox(self.board) 176 | box.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 177 | self.board.delete("line") 178 | 179 | items = [item for item in box.keys() if len(item) > 2] 180 | 181 | box.bind("", lambda event: self.get_widget_info(box)) 182 | box.bind("", lambda event: self.focus_out()) 183 | box.bind("", lambda event: self.modify(box, items)) 184 | 185 | self.manager.switch(box, items) 186 | 187 | def create_listbox(self): 188 | P0, widget_dims, board_dims = self.board.get_geometry() 189 | x, y = P0 190 | width, height = widget_dims 191 | board_width, board_height = board_dims 192 | 193 | x, y = x / board_width, y / board_height 194 | width, height = width / board_width, height / board_height 195 | 196 | box = Listbox(self.board) 197 | box.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 198 | self.board.delete("line") 199 | 200 | items = [item for item in box.keys() if len(item) > 2] 201 | 202 | box.bind("", lambda event: self.get_widget_info(box)) 203 | box.bind("", lambda event: self.focus_out()) 204 | box.bind("", lambda event: self.modify(box, items)) 205 | 206 | self.manager.switch(box, items) 207 | 208 | def create_text(self): 209 | P0, widget_dims, board_dims = self.board.get_geometry() 210 | x, y = P0 211 | width, height = widget_dims 212 | board_width, board_height = board_dims 213 | 214 | x, y = x / board_width, y / board_height 215 | width, height = width / board_width, height / board_height 216 | 217 | text = Text(self.board, bg="red") 218 | text.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw") 219 | self.board.delete("line") 220 | items = [item for item in text.keys() if len(item) > 2] 221 | 222 | text.bind("", lambda event: self.get_widget_info(text)) 223 | text.bind("", lambda event: self.focus_out()) 224 | text.bind("", lambda event: self.modify(text, items)) 225 | 226 | self.manager.switch(text, items) 227 | 228 | def get_widget_info(self, widget): 229 | text = widget.winfo_geometry() + ", ({}, {}, {}, {}) = (relx, rely, relwidth, relheight)" 230 | rels = [] 231 | for key, value in widget.place_info().items(): 232 | if key in ["relx", "rely", "relwidth", "relheight"]: 233 | rels.append(float(value)) 234 | self.root.title(text.format(*rels)) 235 | self.board.draw_constraints(*rels) 236 | 237 | def focus_out(self): 238 | self.root.title("") 239 | self.board.delete("constraint") 240 | 241 | def modify(self, widget, items): 242 | self.manager.switch(widget, items, modifying=True) 243 | 244 | def set_root(self): 245 | self.manager.set_root(self.board) 246 | 247 | def set_bind(self): 248 | self.manager.bind("<