骷髅PYTHON特别版2.0:用PYTHON做一个类似VisualStudioCode的PYTHON编辑器

博主小骷髅SKELETY介绍了如何用Python制作一个类似Visual Studio Code的Python编辑器——LazyPyConsole。该项目支持Python脚本,未来计划更新支持Java,并提供UI设计更新。文章提供了所需环境(Python3.0和Java16)及代码示例,邀请读者一同探索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

大家好,我是小骷髅SKELETY。

本期给大家带来的特别版本2.0系列第一集为:

用PYTHON做一个类似VSCODE的PYTHON编辑器

这个文章十分的

  • 版本号:1.0
  • 脚本语言:Python
  • 支持脚本语言:Python

更新预告:
将更新LazyPyConsole的1.1版本

更新日志:

  • LazyPyConsole 1.0: 支持Python
  • LazyConsole 1.1 支持Java、Python,UI设计更新,需要启动器启动。

需要准备:

  • Python3.0 (lpc1.0, 1.1, 1.2)
  • Java16 (lpc1.1, 1.2)
  • Windows/Mac/Linux 电脑1台

文件分布:
LazyPyConsole

  • LazyPyConsole.py
    • Libs
      • assets
        • lang
          • lang.py
        • Major
          • Settings.py
      • lpcLibs
        • .md

好啦 废话不多说 我们 来看代码吧!

(LazyPyConsole.py)

#Import the model that we need
import os
import time
import codeop
from Libs.assets.lang import lang
from Libs.assets.Major import Settings
from tkinter.filedialog import *
from tkinter.messagebox import *
from subprocess import *
from tkinter import *
t = Tk()

#Default FileName
filename = ""

#Read Language File
title = lang.suggest.get("title")
save = lang.suggest.get("file_save")
read = lang.suggest.get("file_read")
filed = lang.suggest.get("file_OP")
helpd = lang.suggest.get("help_OP")
author = lang.suggest.get("help_author")
quits = lang.suggest.get("help_quits")
bkg = Settings.suggest.get("background")
ftg = Settings.suggest.get("fontground")
ibg = Settings.suggest.get("insertbackground")

#Set the default settings
t.title(title)
t.geometry("1500x800")

#The callables that we used
def runscript(getfunc):
    os.system("python "+filename)

def saveFile():
    global filename
    filename = asksaveasfilename()
    try:
        agree_file = open(filename,"w")
        agree_file.write(tps.get(1.0,"end"))
        agree_file.close()
        t.title(title +"-("+ filename +")")
        showinfo(title, "FileSave Task Completed.")
    except FileNotFoundError:
        showerror(title, "SaveError. You can't already to save a file and then close this windows gui!")

def readFile():
    global filename
    filename = askopenfilename()
    try:
        agree_file = open(filename)
        chars = agree_file.read()
        t.title(title +"-("+ filename +")")
        tps.insert("end",chars)
    except FileNotFoundError:
        showerror(title, "OpenError. You can't already to save a file and then close this windows gui!")

def author():
    print("Watch Author and Infos on File: Libs\lpcLibs\.md")

def quitme():
    t.quit()
    quit("LazyPyConsole.py")

#Type String
tps = Text(t, font=("Consolas",16), background=bkg, fg=ftg, insertbackground=ibg)
tps.pack()

#MenuLabel
file = Menu(t, tearoff=0)
file.add_command(label=save,command=saveFile)
file.add_command(label=read,command=readFile)

help = Menu(t, tearoff=0)
help.add_command(label=author,command=author)
help.add_command(label=quits,command=quitme)

op = Menu(t)
op.add_cascade(label=filed,menu=file)
op.add_cascade(label=helpd,menu=help)
t.config(menu=op)

#KeyListener Button Bind Main
t.bind("<Control-F5>",runscript)

#MainLoop The Windows
t.mainloop()

模块:

(lang.py)
#PS: 这是文字, 你可以修改语言, 比如汉化SaveFile就把SaveFile改成你想修改的比如(保存文件)

suggest = {
    "title": "LazyPyConsole[Operator]",
    "file_save": "SaveFile",
    "file_read": "ReadFile",
    "file_OP": "file",
    "help_OP": "help",
    "help_author": "Author",
    "help_quits": "Quit"
}

(Settings.py)

suggest = {
    "background": "black",
    "fontground": "white",
    "insertbackground": "white"
}

(.md)
#这就是介绍 写的模糊不清,乱七八糟的请谅解 谢谢

My Infos

Hello Guys! Welcome To My Big ProJect: LazyPyConsole. It is a copy of python’s official idle code.
I’m LvLOG. now upload videos on B Station.
I have so much account in my life.
Like “Netease YouDao Kada”, Like “Create world Together”, Like “Alpha Club”…
EnJoy It!

ProJect’s Info

This ProJect Is a Big ProJect better than before.
It can run python scripts but can’t run without terminal.

喜欢吗?
点个免费的赞吧 你可以随时改变主意

另外,骷髅祝大家我自己

暑假快乐!

再见awa!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值