Skip to content

Commit f63e25d

Browse files
authored
Merge pull request #13 from Adentent/master
更换了字体的加载方式, 添加了英文 README.
2 parents c3f53e8 + 65c4a45 commit f63e25d

12 files changed

Lines changed: 197 additions & 57 deletions

Docs/README_EN.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<div align="center">
2+
3+
![Logo](../assets/icon.ico)
4+
5+
# *Minecraft Server Ports Scanner GUI*
6+
7+
</div>
8+
9+
Language:
10+
11+
1. [简体中文](../README.md)
12+
2. [English](README_EN.md)
13+
14+
---
15+
16+
> [!IMPORTANT]
17+
>
18+
> _Disclaimer of Warranties: This is only for the educational purpose, not responsible for any conflict._
19+
>
20+
> Selling, reselling, or engaging in any profit-making activity is strictly forbidden.
21+
>
22+
> The project uses `Python 3.10.9 64-bit`.
23+
>
24+
> Before any pull requests submitted, [join our QQ channel](https://qm.qq.com/q/RTR91LyV0o) first.
25+
26+
## Introduction
27+
28+
A tool to scan for a Minecraft server on all ports of an IP address and display the information.
29+
30+
Our QQ channel is `153037480` named `MCSPS交流群`. If you have any problems about our project, highly recommended to [join us](https://qm.qq.com/q/RTR91LyV0o).
31+
32+
## Features
33+
34+
* Beautiful GUI ( which is present by ttkbootstrap )
35+
* ~~Lagged window size changing~~
36+
* ~~Ancient tkinter library~~
37+
* Scan
38+
* Pause supported
39+
* Multi-thread scanning
40+
* Advanced port range adjustment control
41+
* Server versions filtering available
42+
* Information displaying
43+
* Beautiful colorful title parse
44+
* Minecraft fonts
45+
* Player UUID displayed
46+
* Mod name & version displayed
47+
48+
## Future
49+
* [x] Settings
50+
* [ ] Multi-window for scanning tasks
51+
* [x] The functionality for the info window to be reloaded
52+
* [ ] Live-time chart showing scanning speed
53+
* [ ] Minecraft server ports displaying with chart
54+
* [ ] Listing ports with treemap
55+
* [x] Scan records with date recorded
56+
57+
## Environment Setups & Using
58+
59+
The main branch only support Windows, Mac / Linux development is welcomed if interested.
60+
61+
There are two choice for you.
62+
63+
1. Download the code and run.
64+
65+
> You can use `git clone`, etc. to download the repository, then run `pip install -r requirements.txt`
66+
to install all the modules needed, finally run `main.py` to run the program.
67+
68+
2. Download the zip package and run the executable program.
69+
70+
> The code in this zip package runs on `Python 3.8.9 32-bit` embedded.
71+
>
72+
> You can directly go to Releases, download the zip package, unzip, and run `MC服务器扫描器3.0.exe`.
73+
>
74+
> `xx.exe` on Releases page is a 7-Zip self-extracting program.
75+
76+
## To developers
77+
78+
`Google Python Style Guide` & `PEP 8` is **recommended** to obey.
79+
80+
## Gallery
81+
82+
![beautiful_GUI](https://github.com/hite4044/Minecraft-Server-Ports-Scanner-GUI/assets/129571243/a571046d-78af-4250-b70c-e8a52938f6bd)
83+
![Colorful MOTD](https://github.com/hite4044/Minecraft-Server-Ports-Scanner-GUI/assets/129571243/f9f1b704-9f71-42a2-9e62-2a09c864fdbc)
84+
![ScanControlBar](https://github.com/hite4044/Minecraft-Server-Ports-Scanner-GUI/assets/129571243/0bf193ce-c7d0-4cec-a7a3-46d9d6708112)
85+
![ServerFilter](https://github.com/hite4044/Minecraft-Server-Ports-Scanner-GUI/assets/129571243/7f8bece8-46ad-401c-baa1-fc6ac668066c)

Gui/InfoGui.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def load_icon(self, favicon: PhotoImage):
7373
"""
7474
将一个 PIL.ImageTK.PhotoImage 加载为 GUI 图标
7575
76-
@param favicon: 一个 PIL.ImageTK.PhotoImage 实例化对象
76+
Args:
77+
favicon: 一个 PIL.ImageTK.PhotoImage 实例化对象
7778
"""
7879
self.iconphoto(True, favicon)
7980

Gui/ScanBarGui.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ def __init__(self, master: Misc, logger: Logger, server_list: ServerList, gui):
4545
self.input_frame = Frame(self)
4646
self.host_input = TextCombobox(self.input_frame, "域名: ", server_addresses)
4747
self.timeout_input = EntryScaleFloatFrame(self.input_frame, 0.1, 3.0, 0.2, "超时时间: ")
48-
self.thread_num_input = EntryScaleIntFrame(self.input_frame, 1, 256, 192, "线程数: ")
48+
self.thread_num_input = EntryScaleIntFrame(self.input_frame, 1,
49+
Vars.user_settings_loader.configs["max_thread_number"],
50+
1,
51+
"线程数: ")
4952
self.range_input = RangeSelector(self.input_frame, "端口选择: ", 1024, 65535)
5053

5154
self.input_frame.pack(side=LEFT, fill=X, expand=True, padx=5, pady=5)

Gui/ServerListGui.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ def load_scan_record(self, data: Dict):
167167
"""
168168
加载服务器记录
169169
170-
@param data: 服务器信息
170+
Args:
171+
data: 服务器信息
171172
"""
172173
# 检查数据中是否存在必需的键
173174
if "servers" not in data:
@@ -225,7 +226,7 @@ def __init__(self, master: Misc, logger: Logger):
225226
self.server_filter = ServerFilter(self) # 服务器筛选器
226227
self.sep = Separator(self, orient=HORIZONTAL) # 分割线
227228
self.servers_frame = ScrolledFrame(self, autohide=True) # 装服务器的容器
228-
self.empty_tip = Label(self, text="没有服务器", font=("微软雅黑", 25)) # 无服务器提示
229+
self.empty_tip = Label(self, text="没有服务器", font=(Vars.user_settings_loader.configs['font'], 25)) # 提示
229230
self.record_bar = RecordBar(self, self) # 保存加载功能
230231
self.servers_info = ServerInfoFrame(self.record_bar) # 服务器数量信息
231232

@@ -331,7 +332,7 @@ def __init__(self, master: Misc, data: ServerInfo):
331332

332333
self.favicon = Label(self)
333334
self.MOTD = MOTD(self)
334-
self.base_info = Label(self, font=("微软雅黑", 9))
335+
self.base_info = Label(self, font=(Vars.user_settings_loader.configs['font'], 9))
335336

336337
self.events_add()
337338
self.pack_weights()

Gui/SettingsFrame.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
from ttkbootstrap.scrolled import ScrolledFrame
24

35
from Gui.Widgets import *
@@ -32,7 +34,10 @@ def __init__(self, master: Misc):
3234
self.language_support = {
3335
"if_version_name_shown_as_label": "将 VersionName 显示为纯文本格式",
3436
"theme_name": "主题 ( 不建议在此处修改 )",
35-
"ping_before_scan": "扫描之前先检测连通性"
37+
"ping_before_scan": "扫描之前先检测连通性",
38+
"use_legacy_font": "使用原先的旧版字体 ( 任何渲染问题开发者没有义务修复 )",
39+
"font": "字体",
40+
"max_thread_number": "扫描时允许的最大线程数"
3641
}
3742

3843
self.config_frame = ScrolledFrame(self)
@@ -51,6 +56,10 @@ def pack_widgets(self):
5156
for sitting_frame in self.configs.values():
5257
sitting_frame.grid(row=row, column=0, sticky=W)
5358
row += 1
59+
for i in range(len(self.int_settings_spinbox)):
60+
self.int_settings_spinbox[i].grid(column=1, row=row, sticky=W)
61+
self.int_settings_label[i].grid(column=0, row=row, sticky=W)
62+
row += 1
5463
self.confirm_button.pack(anchor=SE, side=RIGHT)
5564
self.update_button.pack(anchor=SE, side=RIGHT, padx=5)
5665

Gui/UserInterface.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def set_default_font():
13-
font.nametofont("TkDefaultFont").config(family="微软雅黑", size=10)
13+
font.nametofont("TkDefaultFont").config(family=Vars.user_settings_loader.configs['font'], size=10)
1414

1515

1616
def load_unifont():
@@ -27,7 +27,7 @@ class Title(Label):
2727
def __init__(self, master: Misc):
2828
super(Title, self).__init__(master)
2929
self.configure(text="Minecraft服务器扫描器")
30-
self.configure(font=("微软雅黑", 24))
30+
self.configure(font=(Vars.user_settings_loader.configs['font'], 24))
3131

3232

3333
class TitleBar(Frame):
@@ -59,7 +59,6 @@ def __init__(self):
5959

6060
self.pack_widgets()
6161
print(f"GUI构建时间: {perf_counter() - timer:.3f}秒")
62-
Thread(target=load_unifont).start() # 加载字体
6362

6463
def config_root_window(self): # 设置窗体
6564
self.wm_title("MC服务器扫描器") # 设置标题

Gui/Widgets.py

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
# -*- coding: UTF-8 -*-
2+
from copy import copy
23
from math import ceil
34
from queue import Queue
4-
from ttkbootstrap import *
5-
from typing import Any, List
6-
from tkinter.font import Font
7-
from tkinter import Misc, Event
85
from threading import Lock, Thread
9-
from ttkbootstrap.constants import *
10-
from pyperclip import copy as copy_clipboard
116
from time import strftime, localtime, time, sleep
12-
from copy import copy
7+
from tkinter import Misc, Event
8+
from tkinter.font import Font
9+
from typing import Any, List
10+
11+
from pyperclip import copy as copy_clipboard
12+
from tkextrafont import Font
13+
from ttkbootstrap import *
14+
from ttkbootstrap.constants import *
1315

1416
from Libs import Vars
17+
from Libs.ColorLib import Color
1518
from Libs.Vars import scale_rater, color_map_hex
1619
from Network.Scanner import ServerInfo
17-
from Libs.ColorLib import Color
1820

1921
ERROR = "error"
2022
DEBUG = "debug"
@@ -30,12 +32,13 @@ def __init__(self, master: Misc):
3032

3133
self.bind("<Button-1>", lambda _: "break") # 让此 Text 的文字无法被选中
3234

35+
self.font = self.return_font()
36+
3337
def load_motd(self, data: ServerInfo):
3438
self.configure(state=NORMAL)
3539
self.delete("1.0", END)
3640
for extra in data.description_json:
3741
try:
38-
tag_font = Font(family="Unifont", size=12)
3942
if extra.get("color"):
4043
if "#" not in extra["color"]:
4144
color = color_map_hex[extra["color"]]
@@ -46,18 +49,41 @@ def load_motd(self, data: ServerInfo):
4649
if extra.get("underline") or extra.get("underlined"):
4750
self.tag_configure("_", underline=True)
4851
if extra.get("bold"):
49-
tag_font.config(family="宋体", weight="bold")
52+
self.font.config(weight="bold")
5053
elif extra.get("italic"):
51-
tag_font.config(slant="italic")
54+
self.font.config(slant="italic")
5255
elif extra.get("strikethrough"):
53-
tag_font.config(overstrike=True)
56+
self.font.config(overstrike=True)
5457

55-
self.tag_configure("_", font=tag_font, justify=LEFT)
58+
self.tag_configure("_", font=self.font, justify=LEFT)
5659
self.insert(END, extra["text"], "_")
5760
except TimeoutError as e:
5861
print("MOTD Data Extra Error:", extra, e)
5962
self.configure(state=DISABLED)
6063

64+
@staticmethod
65+
def return_font():
66+
"""
67+
根据设置界面返回实例化字体
68+
69+
Returns:
70+
根据设置界面得到的实例化后的字体
71+
Notes:
72+
有概率会引发 RuntimeError, 原因未知
73+
"""
74+
if Vars.user_settings_loader.configs['use_legacy_font']:
75+
if "Unifont" not in font.families():
76+
custom_font = Font(file="assets/Unifont.otf", family="Unifont")
77+
else:
78+
custom_font = font.Font(family="Unifont")
79+
else:
80+
if "Minecraft AE" not in font.families():
81+
custom_font = Font(file="assets/MinecraftFont.ttf", family="Minecraft AE")
82+
else:
83+
custom_font = font.Font(family="Minecraft AE")
84+
85+
return custom_font
86+
6187

6288
class EntryScaleFrame(Frame):
6389
def __init__(self, master: Misc, _min: Any, _max: Any, value: Any, text: str, fmt: Any):

Libs/Vars.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ def __init__(self):
197197

198198
@staticmethod
199199
def defaults() -> Dict:
200-
return {'if_version_name_shown_as_label': False, 'theme_name': "darkly", 'ping_before_scan': True}
200+
return {'if_version_name_shown_as_label': False, 'theme_name': "darkly", 'ping_before_scan': True,
201+
'use_legacy_font': False, "font": "微软雅黑", "max_thread_number": 256}
201202

202203

203204
class UserSettingsSaver:

Libs/WinLib.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ def override_msg_window_buttons(left: str, right: str, timeout: float = 1.2):
66
"""
77
覆写按钮文字
88
9-
@param left: 左侧按钮目标文字
10-
@param right: 右侧按钮目标文字
11-
@param timeout: 超时时间 (s)
9+
Args:
10+
left: 左侧按钮目标文字
11+
right : 右侧按钮目标文字
12+
timeout: 超时时间 (s)
1213
"""
1314
def callback(hwnd: int, _):
1415
if GetWindowText(hwnd) == "是(&Y)":

0 commit comments

Comments
 (0)