Skip to content

Commit 655339a

Browse files
committed
init
0 parents  commit 655339a

File tree

10 files changed

+198
-0
lines changed

10 files changed

+198
-0
lines changed

.github/contributing.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Contributing Guide
2+
3+
## Requirement
4+
When we get a project, we must first install the dependencies contained in requirement.txt in the project runtime environment:
5+
6+
```bash
7+
pip install -r requirement.txt
8+
```
9+
When we want to write the dependencies in the environment into requirement.txt, we can use the freeze command:
10+
```bash
11+
pip freeze >requirements.txt
12+
```
13+
14+
## Build exe
15+
16+
```bash
17+
pyinstaller -w -i ./win/assets/img/logo.ico ./win/main.py --add-data "./win/bat/classic.bat;." --add-data "./win/bat/default.bat;." -n "win-menu-editor"
18+
```
19+
## Reference
20+
https://tkdocs.com/tutorial/

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ide
2+
*.DS_Store
3+
.idea
4+
# .vscode
5+
6+
7+
dist
8+
build
9+
lib
10+
docs
11+
__pycache__
12+
13+
# Logs
14+
logs
15+
*.log
16+
17+
# Runtime config
18+
pids
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# dotenv environment variables file
24+
.env
25+
26+
.history
27+
# examples
28+
29+
*.spec

README-zh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Windows 11 Classic Right-Click Menu Editor
2+
3+
简体中文 | [English](./README.md)
4+
5+
[Contributing Guide](./.github/contributing.md)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Windows 11 Classic Right-Click Menu Editor
2+
3+
English| [简体中文](./README-zh.md)
4+
5+
[Contributing Guide](./.github/contributing.md)

requirements.txt

Whitespace-only changes.

setup.py

Whitespace-only changes.

win/assets/img/logo.ico

90.9 KB
Binary file not shown.

win/bat/classic.bat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@REM Modify the registration form and add a piece of registration information
2+
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f
3+
4+
@REM Kill file explorer
5+
taskkill /IM explorer.exe /F
6+
7+
@REM Start windows explorer
8+
explorer
9+

win/bat/default.bat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@REM Modify the registry, delete the record
2+
reg.exe delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f
3+
4+
@REM Kill file explorer
5+
taskkill /IM explorer.exe /F
6+
7+
@REM Start windows explorer
8+
explorer
9+

win/main.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import os
2+
from tkinter import *
3+
from tkinter import ttk
4+
import subprocess
5+
from subprocess import Popen, PIPE, STDOUT
6+
7+
# reference https://stackoverflow.com/a/34466743
8+
class CustomButton(Label):
9+
10+
def __init__(self, *args, **kwargs):
11+
# TODO: Create a Frame for border https://www.geeksforgeeks.org/how-to-change-border-color-in-tkinter-widget/
12+
Label.__init__(self)
13+
self.bind("<Enter>", self.changeBGEnter)
14+
self.bind("<Leave>", self.changeBGLeave)
15+
self.bind("<Button-1>",kwargs.get('handleClick',self.handleClickDefault) )
16+
17+
self.background = kwargs.get('background',"#1890ff")
18+
self.hoverBackground = kwargs.get('hoverBackground',"#40a9ff")
19+
self.foreground = kwargs.get('foreground',"#fff")
20+
self.fontsize = kwargs.get('fontsize',14)
21+
self.fontfamily = kwargs.get('fontfamily',"微软雅黑")
22+
self.text = kwargs.get('text',"Button")
23+
self.width = kwargs.get('width',30)
24+
self.padx = kwargs.get('padx',10)
25+
self.pady = kwargs.get('pady',10)
26+
self.relief = kwargs.get('relief','solid')
27+
self.borderwidth = kwargs.get('borderwidth',1)
28+
self.anchor = kwargs.get('anchor','center')
29+
self.justify = kwargs.get('justify','center')
30+
31+
self.config(
32+
anchor=self.anchor, # Where to anchor the text in the widget
33+
justify=self.justify,
34+
background=self.background,
35+
foreground=self.foreground,
36+
font=(self.fontfamily, self.fontsize),
37+
text=self.text,
38+
relief=self.relief,
39+
width=self.width,
40+
padx=self.padx,
41+
pady=self.pady,
42+
borderwidth=self.borderwidth
43+
)
44+
45+
def changeBGEnter(self,event):
46+
self.config(background=self.hoverBackground,foreground=self.foreground)
47+
48+
def changeBGLeave(self, event):
49+
self.config(background=self.background,foreground=self.foreground)
50+
51+
def handleClickDefault(self, event):
52+
print('click')
53+
54+
class Win:
55+
def __init__(self,root):
56+
# path
57+
dirname = os.path.dirname(__file__)
58+
self.classic = os.path.join(dirname, 'bat/classic.bat')
59+
self.default = os.path.join(dirname, 'bat/default.bat')
60+
61+
62+
# set title
63+
root.title("Windows 11 Menu Editor")
64+
65+
# screen width
66+
sw = root.winfo_screenwidth()
67+
# screen height
68+
sh = root.winfo_screenheight()
69+
# frame width
70+
ww = 380
71+
# frame height
72+
wh = 180
73+
x = (sw-ww) / 2
74+
y = (sh-wh) / 2 - 20
75+
76+
root.geometry("%dx%d+%d+%d" %(ww,wh,x,y))
77+
root.resizable(False, False)
78+
root.config(background="white")
79+
80+
# create content frame
81+
mainFrame = ttk.Frame(root,padding='20 20 20 20')
82+
mainFrame.grid(column=0,row=0,sticky=(N,W,E,S))
83+
# The columnconfigure/rowconfigure bits tell Tk that the frame should expand to fill any extra space if the window is resized.
84+
root.columnconfigure(0,weight=1)
85+
root.rowconfigure(0,weight=1)
86+
87+
# classic button
88+
classicButton = CustomButton(root, text="Change to Win10 Classic Menu",handleClick=self.useClassic)
89+
classicButton.grid(column=0, row=0, columnspan=2, sticky=(N, W), padx=5,pady=20)
90+
91+
# default button
92+
defaultButton = CustomButton(root, text="Change to Win11 Default Menu",foreground='#1a1a1a',hoverBackground="#ede9e5",background='#fcfbfa',handleClick=self.useDefault)
93+
defaultButton.grid(column=0, row=1, columnspan=2, sticky=(N, W), padx=5,pady=20)
94+
# exec bat
95+
def useClassic(self,*args):
96+
97+
# os.system(self.classic)
98+
subprocess.Popen(self.classic)
99+
100+
# not working
101+
# process = Popen(["cmd"], shell=False, stdout=PIPE, stdin=PIPE, stderr=STDOUT)
102+
103+
# commands = ("reg.exe delete 'HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}' /f\n"
104+
# "taskkill /IM explorer.exe /F\n"
105+
# "explorer\n"
106+
# )
107+
# outs, errs = process.communicate(commands.encode("gbk"))
108+
# content = [z.strip() for z in outs.decode("gbk").split("\n") if z]
109+
# print(*content,sep="\n")
110+
111+
def useDefault(self,*args):
112+
113+
# os.system(self.default)
114+
subprocess.Popen(self.default)
115+
116+
# sets up the main application window
117+
root = Tk()
118+
# init function
119+
Win(root)
120+
# necessary for everything to appear onscreen and allow users to interact with it.
121+
root.mainloop()

0 commit comments

Comments
 (0)