Skip to content

Commit a45a01c

Browse files
committed
Anyshape window demo added
A demo to draw an inherent non-square shape window is added. Also added a demo for a style 1 toggle switch.
1 parent eb8e9b1 commit a45a01c

13 files changed

+209
-0
lines changed
191 KB
Binary file not shown.
4.63 KB
Loading
2.91 KB
Loading
92.1 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Button:Minimise:[(214, 104)]:[(211, 83), (210, 84), (207, 84), (206, 85), (205, 85), (204, 86), (203, 86), (198, 91), (198, 92), (197, 93), (197, 94), (196, 95), (196, 96), (195, 97), (195, 99), (194, 100), (194, 109), (195, 110), (195, 112), (196, 113), (196, 114), (197, 115), (197, 116), (198, 117), (198, 118), (203, 123), (204, 123), (205, 124), (207, 124), (208, 125), (221, 125), (222, 124), (224, 124), (225, 123), (226, 123), (231, 118), (231, 117), (232, 116), (232, 115), (233, 114), (233, 113), (234, 112), (234, 97), (233, 96), (233, 95), (232, 94), (232, 93), (231, 92), (231, 91), (226, 86), (225, 86), (224, 85), (223, 85), (222, 84), (219, 84), (218, 83)]
2+
Button:Quit:[(280, 104)]:[(277, 83), (276, 84), (273, 84), (272, 85), (271, 85), (270, 86), (269, 86), (264, 91), (264, 92), (263, 93), (263, 94), (262, 95), (262, 96), (261, 97), (261, 99), (260, 100), (260, 109), (261, 110), (261, 112), (262, 113), (262, 114), (263, 115), (263, 116), (264, 117), (264, 118), (269, 123), (270, 123), (271, 124), (273, 124), (274, 125), (287, 125), (288, 124), (290, 124), (291, 123), (292, 123), (297, 118), (297, 117), (298, 116), (298, 115), (299, 114), (299, 113), (300, 112), (300, 97), (299, 96), (299, 95), (298, 94), (298, 93), (297, 92), (297, 91), (292, 86), (291, 86), (290, 85), (289, 85), (288, 84), (285, 84), (284, 83)]
3+
Window:root_window_shape:[(243, 230)]:[(211, 83), (210, 84), (207, 84), (206, 85), (205, 85), (204, 86), (203, 86), (198, 91), (198, 92), (197, 93), (197, 94), (196, 95), (196, 96), (195, 97), (195, 99), (194, 100), (194, 109), (195, 110), (195, 112), (196, 113), (196, 114), (197, 115), (197, 116), (199, 118), (198, 119), (183, 119), (178, 114), (177, 114), (176, 113), (175, 113), (174, 112), (172, 112), (171, 111), (158, 111), (157, 112), (155, 112), (154, 113), (149, 113), (148, 114), (145, 114), (144, 115), (141, 115), (140, 116), (139, 116), (138, 117), (137, 117), (136, 118), (134, 118), (133, 119), (131, 119), (130, 120), (129, 120), (128, 121), (127, 121), (125, 123), (124, 123), (122, 125), (121, 125), (111, 135), (111, 136), (110, 137), (110, 139), (109, 140), (109, 141), (108, 142), (108, 143), (107, 144), (107, 145), (104, 148), (104, 149), (103, 150), (103, 151), (101, 153), (101, 154), (100, 155), (100, 157), (99, 158), (99, 159), (98, 160), (98, 161), (97, 162), (97, 163), (96, 164), (96, 166), (94, 168), (94, 170), (93, 171), (93, 173), (92, 174), (92, 175), (91, 176), (91, 178), (90, 179), (90, 180), (89, 181), (89, 183), (88, 184), (88, 185), (87, 186), (87, 187), (86, 188), (86, 190), (85, 191), (85, 193), (84, 194), (84, 196), (83, 197), (83, 198), (82, 199), (82, 201), (81, 202), (81, 204), (80, 205), (80, 206), (79, 207), (79, 209), (78, 210), (78, 212), (77, 213), (77, 214), (76, 215), (76, 217), (75, 218), (75, 220), (74, 221), (74, 223), (73, 224), (73, 227), (72, 228), (72, 229), (71, 230), (71, 232), (70, 233), (70, 236), (69, 237), (69, 239), (68, 240), (68, 242), (67, 243), (67, 246), (66, 247), (66, 249), (65, 250), (65, 253), (64, 254), (64, 256), (63, 257), (63, 259), (62, 260), (62, 262), (61, 263), (61, 266), (60, 267), (60, 269), (59, 270), (59, 273), (58, 274), (58, 279), (57, 280), (57, 282), (56, 283), (56, 288), (55, 289), (55, 292), (54, 293), (54, 298), (53, 299), (53, 303), (52, 304), (52, 309), (51, 310), (51, 319), (50, 320), (50, 331), (51, 332), (51, 338), (52, 339), (52, 342), (53, 343), (53, 346), (54, 347), (54, 349), (55, 350), (55, 352), (56, 353), (56, 355), (57, 356), (57, 357), (59, 359), (59, 360), (61, 362), (61, 363), (64, 366), (64, 367), (67, 370), (68, 370), (72, 374), (73, 374), (75, 376), (77, 376), (78, 377), (80, 377), (81, 378), (82, 378), (83, 379), (94, 379), (96, 377), (97, 377), (98, 376), (99, 376), (109, 366), (110, 366), (116, 360), (116, 359), (120, 355), (120, 354), (125, 349), (125, 348), (127, 346), (127, 345), (132, 340), (132, 339), (135, 336), (135, 335), (138, 332), (138, 331), (142, 327), (142, 326), (143, 325), (143, 324), (151, 316), (152, 316), (155, 313), (156, 313), (158, 311), (159, 311), (160, 310), (161, 310), (162, 309), (163, 309), (164, 308), (165, 308), (166, 307), (170, 307), (171, 306), (173, 306), (174, 305), (315, 305), (316, 306), (317, 306), (318, 307), (322, 307), (323, 308), (324, 308), (325, 309), (326, 309), (327, 310), (328, 310), (329, 311), (330, 311), (332, 313), (333, 313), (346, 326), (346, 327), (348, 329), (348, 330), (352, 334), (352, 335), (355, 338), (355, 339), (360, 344), (360, 345), (364, 349), (364, 350), (366, 352), (366, 353), (374, 361), (374, 362), (383, 371), (384, 371), (386, 373), (387, 373), (390, 376), (391, 376), (393, 378), (394, 378), (395, 379), (404, 379), (405, 378), (406, 378), (407, 377), (409, 377), (410, 376), (411, 376), (412, 375), (413, 375), (415, 373), (416, 373), (420, 369), (421, 369), (423, 367), (423, 366), (426, 363), (426, 362), (428, 360), (428, 359), (429, 358), (429, 357), (430, 356), (430, 355), (431, 354), (431, 353), (432, 352), (432, 350), (433, 349), (433, 348), (434, 347), (434, 341), (435, 340), (435, 310), (434, 309), (434, 297), (433, 296), (433, 293), (432, 292), (432, 287), (431, 286), (431, 283), (430, 282), (430, 279), (429, 278), (429, 275), (428, 274), (428, 271), (427, 270), (427, 268), (426, 267), (426, 264), (425, 263), (425, 260), (424, 259), (424, 258), (423, 257), (423, 253), (422, 252), (422, 249), (421, 248), (421, 246), (420, 245), (420, 244), (419, 243), (419, 240), (418, 239), (418, 236), (417, 235), (417, 233), (416, 232), (416, 231), (415, 230), (415, 228), (414, 227), (414, 224), (413, 223), (413, 222), (412, 221), (412, 219), (411, 218), (411, 216), (410, 215), (410, 213), (409, 212), (409, 210), (408, 209), (408, 207), (407, 206), (407, 205), (406, 204), (406, 202), (405, 201), (405, 199), (404, 198), (404, 197), (403, 196), (403, 194), (402, 193), (402, 191), (401, 190), (401, 189), (400, 188), (400, 186), (399, 185), (399, 184), (398, 183), (398, 180), (397, 179), (397, 177), (395, 175), (395, 173), (394, 172), (394, 171), (393, 170), (393, 169), (392, 168), (392, 166), (390, 164), (390, 162), (389, 161), (389, 159), (388, 158), (388, 156), (387, 155), (387, 154), (386, 153), (386, 152), (384, 150), (384, 149), (382, 147), (382, 146), (379, 143), (379, 141), (378, 140), (378, 139), (376, 137), (376, 136), (375, 135), (375, 134), (366, 125), (365, 125), (363, 123), (362, 123), (360, 121), (359, 121), (358, 120), (357, 120), (356, 119), (354, 119), (353, 118), (352, 118), (351, 117), (349, 117), (348, 116), (347, 116), (346, 115), (344, 115), (343, 114), (340, 114), (339, 113), (332, 113), (331, 112), (329, 112), (328, 111), (316, 111), (315, 112), (314, 112), (313, 113), (312, 113), (311, 114), (310, 114), (306, 118), (305, 118), (304, 119), (297, 119), (296, 118), (298, 116), (298, 115), (299, 114), (299, 113), (300, 112), (300, 97), (299, 96), (299, 95), (298, 94), (298, 93), (297, 92), (297, 91), (292, 86), (291, 86), (290, 85), (289, 85), (288, 84), (285, 84), (284, 83), (277, 83), (276, 84), (273, 84), (272, 85), (271, 85), (270, 86), (269, 86), (264, 91), (264, 92), (263, 93), (263, 94), (262, 95), (262, 96), (261, 97), (261, 99), (260, 100), (260, 109), (261, 110), (261, 112), (262, 113), (262, 114), (263, 115), (263, 116), (265, 118), (264, 119), (231, 119), (230, 118), (232, 116), (232, 115), (233, 114), (233, 113), (234, 112), (234, 97), (233, 96), (233, 95), (232, 94), (232, 93), (231, 92), (231, 91), (226, 86), (225, 86), (224, 85), (223, 85), (222, 84), (219, 84), (218, 83)]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import sys
2+
import tkinter as tk
3+
from PIL import Image, ImageTk
4+
import ttkbootstrap as ttk
5+
from GIMPy_Widget_UI import ShapedWindow as shaped_window
6+
from GIMPy_Widget_UI import Btn_S1 as button
7+
8+
def start_move(event, root, start_pos):
9+
start_pos[0] = event.x
10+
start_pos[1] = event.y
11+
closesttag = canvas.find_closest(event.x, event.y)
12+
tag_name = canvas.gettags(closesttag)
13+
14+
if tag_name[0] == "baseImage":
15+
root.bind("<B1-Motion>", lambda e: move_window(e, root, start_pos))
16+
else:
17+
root.unbind("<B1-Motion>")
18+
19+
def move_window(event, root, from_pos):
20+
dx = event.x - from_pos[0]
21+
dy = event.y - from_pos[1]
22+
root.geometry(f"+{root.winfo_x() + dx}+{root.winfo_y() + dy}")
23+
24+
def quit_command(val):
25+
shaped_window.quit()
26+
27+
def minimise_window(val):
28+
shaped_window.minimise_window(root)
29+
30+
if __name__ == "__main__":
31+
root = ttk.Window()
32+
root.attributes("-topmost", True)
33+
root.wm_title("Game Controller")
34+
start_pos = [0, 0]
35+
36+
root.wm_attributes('-transparentcolor', 'white')
37+
38+
root.bind("<Button-1>", lambda event: start_move(event, root, start_pos))
39+
40+
canvas = tk.Canvas(root, width=600, height=600, bg='gray', highlightthickness=0)
41+
canvas.pack()
42+
43+
controls_file_loc = 'Positions.txt'
44+
canvas.create_polygon(shaped_window.str_to_coordinates(controls_file_loc,'root_window_shape',4),
45+
outline='gray', fill='', width=15)
46+
47+
passive_ui = Image.open("Controller_Passive.png").convert("RGBA")
48+
imagesize = passive_ui.size
49+
base_photo = ImageTk.PhotoImage(passive_ui)
50+
image_width, image_height = imagesize
51+
# Create a canvas and add the image
52+
canvas.create_image(0, 0, anchor=tk.NW, image=base_photo, tags='baseImage')
53+
root.place_window_center()
54+
root.update_idletasks()
55+
root.overrideredirect(True)
56+
57+
close_button = button('Quit', canvas,
58+
button.str_to_coordinates(controls_file_loc,'Quit',4),
59+
command=lambda q: shaped_window.quit())
60+
61+
minimise_button = button('Minimise', canvas,
62+
button.str_to_coordinates(controls_file_loc,'Minimise',4),
63+
command=lambda q:shaped_window.minimise_window(root))
64+
65+
root.mainloop()

0 commit comments

Comments
 (0)