-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropOS.py
More file actions
903 lines (786 loc) · 31.2 KB
/
DropOS.py
File metadata and controls
903 lines (786 loc) · 31.2 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
import tkinter as tk
import threading
from tkinter import simpledialog, filedialog, colorchooser, messagebox
import random
import sys
import datetime
import os
import webbrowser
import ctypes
from ctypes import wintypes
import shutil
def enable_window_shadow(win):
try:
hwnd = wintypes.HWND(win.winfo_id())
DWMWA_NCRENDERING_POLICY = 2
DWMNCRP_ENABLED = 1
ctypes.windll.dwmapi.DwmSetWindowAttribute(
hwnd,
DWMWA_NCRENDERING_POLICY,
ctypes.byref(ctypes.c_int(DWMNCRP_ENABLED)),
ctypes.sizeof(ctypes.c_int)
)
except:
pass
boot_messages = []
current_user = None
font_size = 12
BRUSH_COLOR = "black"
BRUSH_SIZE = 3
clock_paper_enabled = False
default_installed_apps = {
"Calculator": True,
"Notepad": True,
"Dice Roller": True,
"Color Picker": True,
"Mini Quiz": True,
"Flappy Bird": True,
"Geometry Dash": False,
"Paint": True,
"Dropper": True,
"CMD": False,
"File Manager": True,
"Media Viewer": True,
"Settings": True,
}
installed_apps = default_installed_apps.copy()
app_emojis = {
"Calculator": "🧮",
"Notepad": "📝",
"Dice Roller": "🎲",
"Color Picker": "🎨",
"Mini Quiz": "❓",
"Flappy Bird": "🐦",
"Geometry Dash": "⬛",
"Paint": "🖌️",
"Dropper": "🔎",
"CMD": "💻",
"File Manager": "🗂️",
"Media Viewer": "🖼️",
"Settings": "⚙️",
}
FILES_DIR = "files"
os.makedirs(FILES_DIR, exist_ok=True)
app_positions = {}
app_functions = {}
dark_mode = False
clock_enabled = False
clock_label = None
app_button_bg = None
app_button_width = 20
# ======================================================
# finally its working
# ======================================================
def add_message(msg):
boot_messages.append(msg)
if len(boot_messages) > 8:
boot_messages.pop(0)
output_label.config(text="\n".join(boot_messages))
# ======================================================
# BOOTLOADER COMMANDS
# ======================================================
def execute_command(event=None):
cmd = entry.get().strip().lower()
entry.delete(0, "end")
if cmd == "!start":
add_message("Launching DropOS...")
boot.after(100, boot.destroy)
show_boot_screen()
elif cmd == "time":
add_message(datetime.datetime.now().strftime("%H:%M:%S"))
elif cmd == "clear":
boot_messages.clear()
output_label.config(text="")
elif cmd == "exit":
boot.destroy()
elif cmd == "!cmds":
commands_list = "Commands- !Cmds !Search !Info !Reboot !ReinstallOS !Unistall \"app name\" !Color \"Y-Yellow B-Blue R-Red P-Purple\" !Print !dir !systeminfo !rename \"Application Name\" to \"Desired Name\" !exit !getownerdata !clearownerdata !hideownerdata !unhideownerdata !notify \"TEXT\" !execute \"Installed Apllication name\""
add_message(commands_list)
else:
add_message("Unknown command")
# ======================================================
# core
# ======================================================
def open_calculator(parent):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Calculator")
win.geometry("300x420")
expr = tk.StringVar()
def press(v): expr.set(expr.get() + v)
def clear(): expr.set("")
def equals():
try: expr.set(str(eval(expr.get())))
except: expr.set("Error")
tk.Entry(win, textvariable=expr, font=("Arial", 18),
justify="right").pack(fill="x", padx=10, pady=10)
grid = tk.Frame(win)
grid.pack()
for i,b in enumerate(["7","8","9","/","4","5","6","*",
"1","2","3","-","0",".","=","+"]):
cmd = equals if b=="=" else lambda x=b: press(x)
tk.Button(grid, text=b, width=5, height=2,
command=cmd).grid(row=i//4, column=i%4)
tk.Button(win, text="RESET", command=clear).pack(pady=5)
def open_notepad(parent):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Notepad")
win.geometry("500x400")
text = tk.Text(win)
text.pack(expand=True, fill="both")
menubar = tk.Menu(win)
edit_menu = tk.Menu(menubar, tearoff=0)
def save():
name = simpledialog.askstring("Save", "What do you want it to be named?")
if name:
path = os.path.join(FILES_DIR, name + ".txt")
if os.path.exists(path):
messagebox.showerror("Error", f"There already is a {name} .txt file!")
else:
with open(path, "w") as f:
f.write(text.get("1.0", tk.END))
def open_f():
owin = tk.Toplevel(win)
enable_window_shadow(owin)
owin.title("Open File")
olist = tk.Listbox(owin, width=50)
for f in [fi for fi in os.listdir(FILES_DIR) if fi.endswith(".txt")]:
olist.insert("end", f)
olist.pack(pady=10, padx=10)
def load():
try:
sel = olist.get(olist.curselection()[0])
path = os.path.join(FILES_DIR, sel)
with open(path, "r") as f:
text.delete("1.0", tk.END)
text.insert("1.0", f.read())
owin.destroy()
except:
pass
tk.Button(owin, text="Open", command=load).pack()
edit_menu.add_command(label="Open", command=open_f)
edit_menu.add_command(label="Save", command=save)
menubar.add_cascade(label="Edit", menu=edit_menu)
win.config(menu=menubar)
def open_dice_roller(parent):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Dice Roller")
tk.Label(win, text=str(random.randint(1,6)),
font=("Arial", 30)).pack(pady=20)
def open_color_picker(parent):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Color Picker")
for c in ["red","green","blue","yellow","purple"]:
tk.Button(win, bg=c, width=20,
command=lambda x=c: parent.configure(bg=x)).pack()
def open_mini_quiz(parent):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Mini Quiz")
tk.Label(win, text="2 + 2 = ?").pack()
ans = tk.Entry(win)
ans.pack()
tk.Button(win, text="Check",
command=lambda:
tk.Label(win, text="Correct!" if ans.get()=="4"
else "Wrong").pack()).pack()
# ======================================================
# ADVANCED PAINT
# ======================================================
def open_paint(parent):
global BRUSH_COLOR, BRUSH_SIZE
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Paint")
win.geometry("700x500")
canvas = tk.Canvas(win, bg="white")
canvas.pack(fill="both", expand=True)
bar = tk.Frame(win, bg="#222")
bar.pack(fill="x", side="bottom")
strokes = []
current_stroke = []
def start_draw(e):
nonlocal current_stroke
current_stroke = []
def draw(e):
r = BRUSH_SIZE
id_ = canvas.create_oval(e.x-r, e.y-r, e.x+r, e.y+r,
fill=BRUSH_COLOR, outline="")
current_stroke.append(id_)
def end_draw(e):
nonlocal current_stroke
if current_stroke:
strokes.append(current_stroke)
current_stroke = []
canvas.bind("<ButtonPress-1>", start_draw)
canvas.bind("<B1-Motion>", draw)
canvas.bind("<ButtonRelease-1>", end_draw)
def undo():
if strokes:
last = strokes.pop()
for id_ in last:
canvas.delete(id_)
tk.Button(bar, text="Undo", command=undo).pack(side="left", padx=5)
for c in ["black","red","green","blue","yellow","purple"]:
tk.Button(bar, bg=c, width=2,
command=lambda x=c:
globals().update(BRUSH_COLOR=x)).pack(side="left")
size = tk.Scale(bar, from_=1, to=15,
orient="horizontal",
command=lambda v:
globals().update(BRUSH_SIZE=int(v)))
size.set(BRUSH_SIZE)
size.pack(side="left", padx=10)
# ======================================================
# Fix later igues
# ======================================================
def open_flappy(parent):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Flappy Bird")
win.geometry("400x500")
c = tk.Canvas(win, bg="skyblue")
c.pack(fill="both", expand=True)
bird = c.create_oval(180,240,210,270, fill="yellow")
vel = 0
score = 0
pipes = []
label = tk.Label(win, text="Score: 0")
label.pack()
def flap(e=None):
nonlocal vel
vel = -8
win.bind("<space>", flap)
def loop():
nonlocal vel, score
vel += 0.6
c.move(bird, 0, vel)
if random.randint(1,40)==1:
y=random.randint(100,350)
pipes.append((
c.create_rectangle(400,0,440,y-80,fill="green"),
c.create_rectangle(400,y+80,440,500,fill="green")
))
for p in pipes[:]:
c.move(p[0],-4,0); c.move(p[1],-4,0)
if c.coords(p[0])[2]<0:
pipes.remove(p); score+=1
label.config(text=f"Score: {score}")
win.after(20, loop)
loop()
# ======================================================
# FILE MANAGER
# ======================================================
def open_file_manager(parent, refresh):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("File Manager")
win.geometry("400x400")
listbox = tk.Listbox(win, width=50, height=20)
listbox.pack(pady=10)
def refresh_list():
listbox.delete(0, "end")
for f in sorted(os.listdir(FILES_DIR)):
listbox.insert("end", f)
refresh_list()
def rename():
try:
idx = listbox.curselection()[0]
old = listbox.get(idx)
new = simpledialog.askstring("Rename", "New name", initialvalue=old)
if new and new != old:
os.rename(os.path.join(FILES_DIR, old), os.path.join(FILES_DIR, new))
refresh_list()
except:
pass
def delete():
try:
idx = listbox.curselection()[0]
f = listbox.get(idx)
if messagebox.askyesno("Delete", f"Delete {f}?"):
os.remove(os.path.join(FILES_DIR, f))
refresh_list()
except:
pass
tk.Button(win, text="Rename", command=rename).pack(side="left", padx=10)
tk.Button(win, text="Delete", command=delete).pack(side="left", padx=10)
# ======================================================
# MEDIA VIEWER
# ======================================================
def open_media_viewer(parent):
query = simpledialog.askstring("Media Viewer", "Enter YouTube search query")
if query:
webbrowser.open(f"https://www.youtube.com/results?search_query={query.replace(' ', '+')}")
# ======================================================
# CMD APP
# ======================================================
def open_cmd_app(parent, refresh_fn):
cmd_win = tk.Toplevel(parent)
enable_window_shadow(cmd_win)
cmd_win.title("CMD")
cmd_win.geometry("700x400")
cmd_win.configure(bg="black")
output_label = tk.Label(cmd_win, fg="red", bg="black", anchor="se", justify="left")
output_label.pack(fill="both", expand=True)
entry = tk.Entry(cmd_win, bg="black", fg="white", insertbackground="white")
entry.pack(fill="x", side="bottom")
messages = []
def add_msg(msg):
messages.append(msg)
if len(messages) > 20:
messages.pop(0)
output_label.config(text="\n".join(messages))
def exec_cmd(event):
cmd = entry.get().strip()
entry.delete(0, "end")
add_msg(f"> {cmd}")
cmd_lower = cmd.lower()
if cmd_lower.startswith("!"):
cmd_name = cmd_lower[1:].split()[0]
args = cmd.split()[1:]
if cmd_name == "cmds":
commands_list = "Commands- !Cmds !Search !Info !Reboot !ReinstallOS !Unistall \"app name\" !Color \"Y-Yellow B-Blue R-Red P-Purple\" !Print !dir !systeminfo !rename \"Application Name\" to \"Desired Name\" !exit !getownerdata !clearownerdata !hideownerdata !unhideownerdata !notify \"TEXT\" !execute \"Installed Apllication name\""
add_msg(commands_list)
elif cmd_name == "search":
if args:
query = " ".join(args)
webbrowser.open(f"https://www.google.com/search?q={query}")
add_msg("Searching...")
else:
add_msg("Usage: !Search query")
elif cmd_name == "info":
add_msg("DropOS®")
elif cmd_name == "reboot":
add_msg("Rebooting...")
cmd_win.destroy()
parent.destroy()
open_dropos()
elif cmd_name == "reinstallos":
add_msg("Reinstalling OS...")
user_file = "user_data.txt"
if os.path.exists(user_file):
os.remove(user_file)
global installed_apps
installed_apps = default_installed_apps.copy()
cmd_win.destroy()
parent.destroy()
open_dropos()
elif cmd_name == "unistall":
if args:
app = " ".join(args).strip('"')
if app in installed_apps:
installed_apps[app] = False
add_msg(f"Uninstalled {app}")
refresh_fn()
else:
add_msg("App not found")
else:
add_msg("Usage: !Unistall \"app name\"")
elif cmd_name == "color":
if args:
col = args[0].lower()
col_map = {"y":"yellow", "b":"blue", "r":"red", "p":"purple"}
if col in col_map:
output_label.config(fg=col_map[col])
add_msg("Color changed")
else:
add_msg("Invalid color")
else:
add_msg("Usage: !Color Y/B/R/P")
elif cmd_name == "print":
if args:
add_msg(" ".join(args))
else:
add_msg("Usage: !Print text")
elif cmd_name == "dir":
add_msg("Installed Apps:")
for app, inst in installed_apps.items():
if inst:
add_msg(app)
elif cmd_name == "systeminfo":
add_msg("System Info:")
add_msg(f"User: {current_user}")
add_msg(f"Time: {datetime.datetime.now()}")
add_msg("OS: DropOS")
elif cmd_name == "rename":
if len(args) >= 3 and args[1].lower() == "to":
old = " ".join(args[:1]).strip('"')
new = " ".join(args[2:]).strip('"')
if old in installed_apps:
installed_apps[new] = installed_apps.pop(old)
app_emojis[new] = app_emojis.pop(old)
add_msg(f"Renamed {old} to {new}")
refresh_fn()
else:
add_msg("App not found")
else:
add_msg("Usage: !rename \"old\" to \"new\"")
elif cmd_name == "exit":
cmd_win.destroy()
elif cmd_name == "getownerdata":
user_file = "user_data.txt"
if os.path.exists(user_file):
with open(user_file, "r") as f:
lines = f.readlines()
u = lines[0].strip()
p = lines[1].strip()
h = bool(int(lines[2].strip())) if len(lines) > 2 else False
if not h:
add_msg(f"User: {u}")
add_msg(f"Password: {p}")
else:
add_msg("Owner data hidden")
else:
add_msg("No owner data")
elif cmd_name == "clearownerdata":
user_file = "user_data.txt"
if os.path.exists(user_file):
os.remove(user_file)
add_msg("Owner data cleared")
elif cmd_name == "hideownerdata":
user_file = "user_data.txt"
if os.path.exists(user_file):
with open(user_file, "r") as f:
lines = f.readlines()
with open(user_file, "w") as f:
f.write(lines[0])
f.write(lines[1])
f.write("1\n")
add_msg("Owner data hidden")
elif cmd_name == "unhideownerdata":
user_file = "user_data.txt"
if os.path.exists(user_file):
with open(user_file, "r") as f:
lines = f.readlines()
with open(user_file, "w") as f:
f.write(lines[0])
f.write(lines[1])
f.write("0\n")
add_msg("Owner data unhidden")
elif cmd_name == "notify":
if args:
text = " ".join(args)
notif = tk.Toplevel(cmd_win)
notif.geometry(f"300x50+{cmd_win.winfo_screenwidth()-300}+0")
notif.overrideredirect(True)
tk.Label(notif, text=text, bg="gray", fg="white").pack(fill="both")
notif.after(3000, notif.destroy)
else:
add_msg("Usage: !notify \"text\"")
elif cmd_name == "execute":
if args:
app = " ".join(args).strip('"')
app_lower = app.lower()
fn = app_functions.get(app)
if fn:
if installed_apps.get(app, False):
if app in ["CMD", "File Manager", "Settings"]:
fn(parent, refresh_fn)
else:
fn(parent)
add_msg(f"Executing {app}")
else:
add_msg("App not installed")
else:
add_msg("App not found")
else:
add_msg("Usage: !execute \"app name\"")
else:
add_msg("Unknown command")
else:
add_msg("Commands start with !")
entry.bind("<Return>", exec_cmd)
# ======================================================
# SETTINGS APP
# ======================================================
def open_settings(parent, refresh):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Settings")
win.geometry("400x500")
def toggle_dark():
global dark_mode
dark_mode = not dark_mode
if dark_mode:
parent.config(bg="black")
desktop.config(bg="black")
logo_label.config(fg="white", bg="black")
if clock_label:
clock_label.config(bg="black", fg="white")
else:
parent.config(bg="#cfe9ff")
desktop.config(bg="#cfe9ff")
logo_label.config(fg="black", bg="#cfe9ff")
if clock_label:
clock_label.config(bg="#cfe9ff", fg="black")
refresh()
tk.Button(win, text="Toggle Dark Theme", command=toggle_dark).pack(pady=5)
def toggle_clock():
global clock_enabled, clock_label
clock_enabled = not clock_enabled
if clock_enabled:
if not clock_label:
bg_col = "black" if dark_mode else "#cfe9ff"
fg_col = "white" if dark_mode else "black"
clock_label = tk.Label(desktop, text="", font=("Arial", 72), bg=bg_col, fg=fg_col)
clock_label.place(x=300, y=200)
bind_drag(clock_label)
update_clock()
else:
if clock_label:
clock_label.place_forget()
clock_label = None
tk.Button(win, text="Toggle Clock Background", command=toggle_clock).pack(pady=5)
def update_clock():
if clock_label:
clock_label.config(text=datetime.datetime.now().strftime("%H:%M:%S"))
desktop.after(1000, update_clock)
def choose_bg():
color = colorchooser.askcolor()[1]
if color:
parent.config(bg=color)
desktop.config(bg=color)
logo_label.config(bg=color)
if clock_label:
clock_label.config(bg=color)
refresh()
tk.Button(win, text="Choose Background Color", command=choose_bg).pack(pady=5) # for some reason it's not working
def choose_app_color():
global app_button_bg
color = colorchooser.askcolor()[1]
if color:
app_button_bg = color
refresh()
tk.Button(win, text="Choose Apps Color", command=choose_app_color).pack(pady=5)
def set_button_width(v):
global app_button_width
app_button_width = int(v)
refresh()
tk.Scale(win, from_=10, to=30, orient="horizontal", label="App Button Width",
command=set_button_width).pack(pady=5)
tk.Scale(win, from_=10, to=30, orient="horizontal", label="App Button Width",
command=set_button_width).set(app_button_width)
def change_emoji():
app = simpledialog.askstring("Change Emoji", "App name")
if app in app_emojis:
new = simpledialog.askstring("New Emoji", "New emoji")
if new:
app_emojis[app] = new
refresh()
tk.Button(win, text="Change App Emoji", command=change_emoji).pack(pady=5)
def create_shortcut():
f = filedialog.askopenfilename()
if f:
sname = os.path.basename(f) + " shortcut"
if sname in installed_apps:
messagebox.showerror("Error", "Shortcut exists")
return
installed_apps[sname] = True
app_emojis[sname] = "🔗"
app_functions[sname] = lambda p, path=f: os.startfile(path)
refresh()
tk.Button(win, text="Create Shortcut", command=create_shortcut).pack(pady=5)
# ======================================================
# REMOVED Can be restored
# ======================================================
def open_drop_store(parent, refresh):
win = tk.Toplevel(parent)
enable_window_shadow(win)
win.title("Drop Store")
for app in default_installed_apps:
if app == "Settings": continue # dont touch this guys i got like 50 errors when i did, be careful
def toggle(a=app):
installed_apps[a] = not installed_apps[a]
refresh()
win.destroy()
tk.Button(win,
text=f"{app} ({'Uninstall' if installed_apps[app] else 'Install'})",
command=toggle).pack(fill="x")
# ======================================================
# MAIN OS
# ======================================================
app_functions = {
"Calculator": open_calculator,
"Notepad": open_notepad,
"Dice Roller": open_dice_roller,
"Color Picker": open_color_picker,
"Mini Quiz": open_mini_quiz,
"Flappy Bird": open_flappy,
"Paint": open_paint,
"Dropper": lambda p: webbrowser.open("https://google.com"), # i had no idea it was this simple all along
"CMD": open_cmd_app,
"File Manager": open_file_manager,
"Media Viewer": open_media_viewer,
"Settings": open_settings,
}
def bind_drag(widget):
def start_drag(e):
widget._drag_start_x = e.x
widget._drag_start_y = e.y
def motion_drag(e):
x = widget.winfo_x() + e.x - widget._drag_start_x
y = widget.winfo_y() + e.y - widget._drag_start_y
widget.place(x=x, y=y)
app_positions[widget._app_name] = (x, y) if hasattr(widget, '_app_name') else None
widget.bind("<Button-1>", start_drag)
widget.bind("<B1-Motion>", motion_drag)
def open_dropos():
global logo_label, desktop
root = tk.Tk()
root.after(10, lambda: enable_window_shadow(root))
root.geometry("900x600")
root.configure(bg="#cfe9ff")
desktop = tk.Frame(root, bg="#cfe9ff")
desktop.pack(fill="both", expand=True)
logo_label = tk.Label(desktop, text="DropOS®",
font=("Arial",48),
fg="#000", bg="#cfe9ff")
logo_label.place(x=300, y=10)
bind_drag(logo_label)
def refresh():
for w in desktop.winfo_children():
if isinstance(w, tk.Button) and w != logo_label and w != clock_label:
w.destroy()
row = 0
col = 0
start_y = 100
col_width = 200
for name in sorted([k for k,v in installed_apps.items() if v]):
fn = app_functions.get(name)
if fn:
emoji = app_emojis.get(name, "❓")
btn = tk.Button(desktop,
text=f"{emoji} {name}",
width=app_button_width,
command=lambda f=fn, n=name: f(root, refresh) if n in ["CMD", "File Manager", "Settings"] else f(root))
if app_button_bg:
btn.config(bg=app_button_bg)
def_x = 40 + col * col_width
def_y = start_y + row * 45
pos = app_positions.get(name, (def_x, def_y))
btn.place(x=pos[0], y=pos[1])
btn._app_name = name
bind_drag(btn)
col = (col + 1) % 2
if col == 0:
row += 1
if dark_mode:
root.config(bg="black")
desktop.config(bg="black")
logo_label.config(fg="white", bg="black")
if clock_label:
clock_label.config(bg="black", fg="white")
else:
root.config(bg="#cfe9ff")
desktop.config(bg="#cfe9ff")
logo_label.config(fg="black", bg="#cfe9ff")
if clock_label:
clock_label.config(bg="#cfe9ff", fg="black")
refresh()
taskbar = tk.Frame(root, bg="#222", height=40)
taskbar.pack(side="bottom", fill="x")
tk.Button(taskbar, text="☰",
command=lambda:
open_drop_store(root, refresh)).pack(side="left", padx=10)
tk.Button(taskbar, text="CLOSE",
command=root.destroy).pack(side="right", padx=10)
root.mainloop()
def show_boot_screen():
loading = tk.Tk()
loading.geometry("900x600")
loading.configure(bg="black")
enable_window_shadow(loading)
label = tk.Label(loading, text="DropOS®", font=("Arial",48), fg="white", bg="black")
label.place(relx=0.5, rely=0.5, anchor="center")
canvas = tk.Canvas(loading, width=50, height=50, bg="black", highlightthickness=0)
canvas.place(relx=0.5, rely=0.6, anchor="center")
circle = canvas.create_oval(5,5,45,45, outline="#fff", width=4)
colors = ["#222", "#444", "#666", "#888", "#aaa", "#ccc", "#eee", "#fff", "#eee", "#ccc", "#aaa", "#888", "#666", "#444", "#222"]
i = 0
def pulse():
nonlocal i
canvas.itemconfig(circle, outline=colors[i])
i = (i + 1) % len(colors)
loading.after(200, pulse)
pulse()
loading.after(random.randint(3000, 5000), lambda: (loading.destroy(), show_login()))
loading.mainloop()
def show_login():
global current_user
user_file = "user_data.txt"
username = password = None
hidden = False
if os.path.exists(user_file):
with open(user_file, "r") as f:
lines = f.readlines()
if len(lines) >= 2:
username = lines[0].strip()
password = lines[1].strip()
if len(lines) > 2:
hidden = bool(int(lines[2].strip())) # fucking hell
login_win = tk.Tk()
login_win.geometry("400x300")
login_win.title("DropOS Login")
enable_window_shadow(login_win)
if username is None:
tk.Label(login_win, text="Create User").pack()
user_entry = tk.Entry(login_win)
tk.Label(login_win, text="Username:").pack()
user_entry.pack()
pass_entry = tk.Entry(login_win, show="*")
tk.Label(login_win, text="Password:").pack()
pass_entry.pack()
def create():
global current_user
u = user_entry.get()
p = pass_entry.get()
if u and p:
with open(user_file, "w") as f:
f.write(u + "\n")
f.write(p + "\n")
f.write("0\n")
current_user = u
login_win.destroy()
open_dropos()
tk.Button(login_win, text="Create", command=create).pack()
else:
tk.Label(login_win, text="Login").pack()
user_entry = tk.Entry(login_win)
tk.Label(login_win, text="Username:").pack()
user_entry.pack()
pass_entry = tk.Entry(login_win, show="*")
tk.Label(login_win, text="Password:").pack()
pass_entry.pack()
def login():
global current_user
u = user_entry.get()
p = pass_entry.get()
if u == username and p == password:
current_user = u
login_win.destroy()
open_dropos()
else:
tk.Label(login_win, text="Invalid", fg="red").pack()
tk.Button(login_win, text="Login", command=login).pack()
login_win.mainloop()
# ======================================================
# BOOTLOADER UI
# ======================================================
boot = tk.Tk()
boot.after(10, lambda: enable_window_shadow(boot))
boot.title("DropOS Bootloader")
boot.geometry("700x400")
boot.configure(bg="black")
tk.Label(boot, text="DropOS Bootloader\nType '!start'",
fg="white", bg="black",
font=("Arial",14)).pack(pady=40)
entry = tk.Entry(boot, bg="black", fg="white",
insertbackground="white")
entry.pack()
entry.bind("<Return>", execute_command)
output_label = tk.Label(boot, fg="red", bg="black")
output_label.pack(anchor="se")
boot.mainloop()