分享一个python tkinter 界面设计的在线编辑IDE网址,python简单界面设计

本文介绍了如何使用VisualTK在线工具和Tkinter库,通过拖放方式轻松设计GUI界面,无需下载安装额外软件。内容包括设置窗口大小、颜色、样式等,并展示了代码示例,创建了一个包含文本框、按钮等元素的职位搜索小程序。用户可以将生成的代码复制到本地并执行,实现功能包括按钮点击响应。此外,文章还提及了Tkinter-Designer作为另一替代工具。
摘要由CSDN通过智能技术生成

Visual TK, Visual Python Tkinter GUI CreatorWith Visual TK, you can design Tkinter Form(Window) by dragging and dropping Widgets Button, Lables, CheckBox, RadioBox, Entry, ListBox, Message, Container and Frame.https://www.visualtk.com/        可以在线定位几个核心模块的位置。复制代码到本地可以在定位的位置替换自己需要的其他模块。

        相对比 tkINTER-designer,不用安装下载,比较方便.GitHub - ParthJadhav/Tkinter-Designer: Create Beautiful Tkinter GUIs by Drag and Drop ☄️Create Beautiful Tkinter GUIs by Drag and Drop ☄️. Contribute to ParthJadhav/Tkinter-Designer development by creating an account on GitHub.https://github.com/ParthJadhav/Tkinter-Designer设置界面如下 ,简单的拖动即可,还可以设置前、背景颜色,图片,样式

 复制python标签页内容至你的编译文档即可执行。

#!/usr/bin/env python
# encoding: utf-8

import tkinter as tk
import tkinter.font as tkFont

class App:
    def __init__(self, root):
        #setting title
        root.title("undefined")
        #setting window size
        width=1022
        height=590
        screenwidth = root.winfo_screenwidth()
        screenheight = root.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        root.geometry(alignstr)
        root.resizable(width=False, height=False)

        GLabel_431=tk.Label(root)
        ft = tkFont.Font(family='Times',size=10)
        GLabel_431["font"] = ft
        GLabel_431["fg"] = "#333333"
        GLabel_431["justify"] = "center"
        GLabel_431["text"] = ""
        GLabel_431.place(x=0,y=0,width=648,height=587)

        GLineEdit_451=tk.Entry(root)
        GLineEdit_451["bg"] = "#ffffff"
        GLineEdit_451["borderwidth"] = "1px"
        ft = tkFont.Font(family='Times',size=10)
        GLineEdit_451["font"] = ft
        GLineEdit_451["fg"] = "#333333"
        GLineEdit_451["justify"] = "left"
        GLineEdit_451["text"] = "log"
        GLineEdit_451["relief"] = "groove"
        GLineEdit_451.place(x=650,y=380,width=371,height=206)

        GLineEdit_758=tk.Entry(root)
        GLineEdit_758["bg"] = "#ffffff"
        GLineEdit_758["borderwidth"] = "1px"
        ft = tkFont.Font(family='Times',size=10)
        GLineEdit_758["font"] = ft
        GLineEdit_758["fg"] = "#333333"
        GLineEdit_758["justify"] = "left"
        GLineEdit_758["text"] = ""
        GLineEdit_758["relief"] = "groove"
        GLineEdit_758.place(x=650,y=40,width=369,height=339)

        GLineEdit_578=tk.Entry(root)
        GLineEdit_578["bg"] = "#ffffff"
        GLineEdit_578["borderwidth"] = "1px"
        ft = tkFont.Font(family='Times',size=10)
        GLineEdit_578["font"] = ft
        GLineEdit_578["fg"] = "#333333"
        GLineEdit_578["justify"] = "left"
        GLineEdit_578["text"] = ""
        GLineEdit_578["relief"] = "groove"
        GLineEdit_578.place(x=0,y=80,width=648,height=507)

        GLabel_654=tk.Label(root)
        ft = tkFont.Font(family='Times',size=16)
        GLabel_654["font"] = ft
        GLabel_654["fg"] = "#333333"
        GLabel_654["justify"] = "center"
        GLabel_654["text"] = "职位搜索小程序"
        GLabel_654.place(x=200,y=10,width=260,height=31)

        GLabel_72=tk.Label(root)
        ft = tkFont.Font(family='Times',size=10)
        GLabel_72["font"] = ft
        GLabel_72["fg"] = "#333333"
        GLabel_72["justify"] = "center"
        GLabel_72["text"] = "职位关键字"
        GLabel_72.place(x=10,y=40,width=70,height=31)

        GButton_674=tk.Button(root)
        GButton_674["anchor"] = "n"
        GButton_674["bg"] = "#efefef"
        ft = tkFont.Font(family='Times',size=10)
        GButton_674["font"] = ft
        GButton_674["fg"] = "#000000"
        GButton_674["justify"] = "center"
        GButton_674["text"] = "黑名单"
        GButton_674["relief"] = "groove"
        GButton_674.place(x=810,y=10,width=70,height=25)
        GButton_674["command"] = self.GButton_674_command

        GButton_194=tk.Button(root)
        GButton_194["anchor"] = "s"
        GButton_194["bg"] = "#efefef"
        ft = tkFont.Font(family='Times',size=10)
        GButton_194["font"] = ft
        GButton_194["fg"] = "#000000"
        GButton_194["justify"] = "center"
        GButton_194["text"] = "初始化"
        GButton_194["relief"] = "groove"
        GButton_194.place(x=910,y=10,width=70,height=25)
        GButton_194["command"] = self.GButton_194_command

        GButton_27=tk.Button(root)
        GButton_27["anchor"] = "s"
        GButton_27["bg"] = "#efefef"
        ft = tkFont.Font(family='Times',size=10)
        GButton_27["font"] = ft
        GButton_27["fg"] = "#000000"
        GButton_27["justify"] = "center"
        GButton_27["text"] = "开始查询"
        GButton_27["relief"] = "groove"
        GButton_27.place(x=700,y=10,width=70,height=25)
        GButton_27["command"] = self.GButton_27_command

        GLabel_423=tk.Label(root)
        ft = tkFont.Font(family='Times',size=10)
        GLabel_423["font"] = ft
        GLabel_423["fg"] = "#333333"
        GLabel_423["justify"] = "center"
        GLabel_423["text"] = "v0.2"
        GLabel_423.place(x=460,y=20,width=53,height=30)

        GLineEdit_450=tk.Entry(root)
        GLineEdit_450["bg"] = "#ffffff"
        GLineEdit_450["borderwidth"] = "1px"
        ft = tkFont.Font(family='Times',size=10)
        GLineEdit_450["font"] = ft
        GLineEdit_450["fg"] = "#333333"
        GLineEdit_450["justify"] = "left"
        GLineEdit_450["text"] = ""
        GLineEdit_450["relief"] = "groove"
        GLineEdit_450.place(x=90,y=40,width=558,height=38)

    def GButton_674_command(self):
        print("command")


    def GButton_194_command(self):
        print("command")


    def GButton_27_command(self):
        print("command")

if __name__ == "__main__":
    root = tk.Tk()
    app = App(root)
    root.mainloop()

 有中文的记得加引用

#!/usr/bin/env python
# encoding: utf-8

执行你的代码

跟你在网页上设计的一毛一样。 点击按钮,也会有响应(打印字符command)。

下面就可可以开始你的创作了。格化一下代码,重命名模块,或者替换成其它模块 and so on 

#!/usr/bin/env python
# encoding: utf-8

import tkinter as tk
from tkinter import *
import tkinter.font as tkFont
import time
LOG_LINE_NUM = 0
JOB_LINE_NUM = 0
BLACK_LINE_NUM = 0

class App:
    keyPositions = 'python,程序设计,会计,财务'
    def __init__(self, window):
        self.window = window


    def run(self):
        window.title("职位搜索")
        #setting window size
        width=1022
        height=590
        screenwidth = window.winfo_screenwidth()
        screenheight = window.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        window.geometry(alignstr)

        ft = tkFont.Font(family='Times', size=16)
        GLabel_title = tk.Label(window, font=ft, fg="#333333", justify="center", text="职位搜索小程序")
        GLabel_title.place(x=200, y=10, width=260, height=31)

        ft = tkFont.Font(family='Times', size=10)
        GLabel_ver = tk.Label(window, font=ft, fg="#333333", justify="center", text="v0.2")
        GLabel_ver.place(x=460, y=20, width=53, height=30)

        GLabel_job = tk.Label(window, font=ft, fg="#333333", justify="center", text="职位关键字")
        GLabel_job.place(x=10, y=40, width=70, height=31)

        self.GLineEdit_jobname = tk.Entry(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333", justify="left", relief="groove")
        self.GLineEdit_jobname.insert(0,self.keyPositions)
        self.GLineEdit_jobname.place(x=90, y=40, width=558, height=38)

        self.GLineEdit_main = tk.Text(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333",  relief="groove")
        self.GLineEdit_main.place(x=0, y=80, width=648, height=507)

        self.GLineEdit_list = tk.Text(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333",  relief="groove")
        self.GLineEdit_list.place(x=650, y=40, width=369, height=389)

        self.GLineEdit_log = tk.Text(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333", relief="groove")
        self.GLineEdit_log.place(x=650, y=430, width=371, height=156)

        GButton_start = tk.Button(window, anchor="s", bg="#efefef", font=ft, fg="#000000", justify="center",  text="开始查询", relief="groove")
        GButton_start.place(x=700, y=10, width=70, height=25)
        GButton_start["command"] = self.GButton_start_command

        GButton_list=tk.Button(window, anchor ="s", bg="#efefef", font =ft, fg="#000000", justify="center", text="黑名单", relief="groove")
        GButton_list.place(x=810,y=10,width=70,height=25)
        GButton_list["command"] = self.GButton_list_command

        GButton_init=tk.Button(window, anchor ="s", bg="#efefef", font =ft, fg="#000000", justify="center", text="初始化", relief="groove")
        GButton_init.place(x=910,y=10,width=70,height=25)
        GButton_init["command"] = self.GButton_init_command

    def GButton_list_command(self):
        print("GButton_list_command")
        self.write_log_to_Text("新加黑名单企业如下")


    def GButton_start_command(self):
        print("GButton_start_command")
        self.write_log_to_Text("开始职位搜索")


    def GButton_init_command(self):
        print("GButton_init_command")
        self.write_log_to_Text("初始化数据库")

 # 获取当前时间
    def get_current_time(self):
        current_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
        return current_time

    # 日志动态打印
    def write_log_to_Text(self, logmsg):
        global LOG_LINE_NUM
        current_time = self.get_current_time()
        logmsg_in = str(current_time) + " " + str(logmsg) + "\n"  # 换行
        if LOG_LINE_NUM <= 8:
            self.GLineEdit_log.insert(END, logmsg_in)
            LOG_LINE_NUM = LOG_LINE_NUM + 1
        else:
            self.GLineEdit_log.delete(1.0, 2.0)
            self.GLineEdit_log.insert(END, logmsg_in)


if __name__ == "__main__":
    window = Tk()
    app = App(window)
    app.run()
    window.resizable(False, False)
    window.mainloop()  # 父窗口进入事件循环,可以理解为保持窗口运行,否则界面不展示

签单初始化,按钮点击LOG框有响应

好的,我可以为您提供一个简单Python Tkinter IDE程序的示例代码: ```python import tkinter as tk from tkinter import ttk from tkinter import scrolledtext from tkinter import messagebox from tkinter.filedialog import asksaveasfile, askopenfile class PyIDE: def __init__(self, master): self.master = master self.master.title("Python IDE") # 创建菜单栏 menu_bar = tk.Menu(self.master) self.master.config(menu=menu_bar) # 创建文件菜单 file_menu = tk.Menu(menu_bar, tearoff=0) file_menu.add_command(label="新建", command=self.new_file) file_menu.add_command(label="打开", command=self.open_file) file_menu.add_command(label="保存", command=self.save_file) file_menu.add_command(label="另存为", command=self.save_as_file) file_menu.add_separator() file_menu.add_command(label="退出", command=self.quit) menu_bar.add_cascade(label="文件", menu=file_menu) # 创建编辑菜单 edit_menu = tk.Menu(menu_bar, tearoff=0) edit_menu.add_command(label="剪切", command=self.cut) edit_menu.add_command(label="复制", command=self.copy) edit_menu.add_command(label="粘贴", command=self.paste) menu_bar.add_cascade(label="编辑", menu=edit_menu) # 创建帮助菜单 help_menu = tk.Menu(menu_bar, tearoff=0) help_menu.add_command(label="关于", command=self.about) menu_bar.add_cascade(label="帮助", menu=help_menu) # 创建文本框 self.text_area = scrolledtext.ScrolledText(self.master, wrap=tk.WORD, undo=True) self.text_area.pack(fill=tk.BOTH, expand=1) def new_file(self): self.text_area.delete(1.0, tk.END) self.master.title("未命名文件") def open_file(self): file = askopenfile(mode="r", filetypes=[("Python Files", "*.py")]) if file is not None: content = file.read() self.text_area.delete(1.0, tk.END) self.text_area.insert(tk.INSERT, content) self.master.title(file.name) def save_file(self): file = open(self.master.title(), "w") file.write(self.text_area.get(1.0, tk.END)) file.close() def save_as_file(self): files = [('Python Files', '*.py')] file = asksaveasfile(filetypes=files, defaultextension=files) if file is not None: content = self.text_area.get(1.0, tk.END) file.write(content) self.master.title(file.name) def cut(self): self.text_area.event_generate("<<Cut>>") def copy(self): self.text_area.event_generate("<<Copy>>") def paste(self): self.text_area.event_generate("<<Paste>>") def about(self): messagebox.showinfo("关于", "Python IDE v1.0") def quit(self): self.master.quit() if __name__ == "__main__": root = tk.Tk() ide = PyIDE(root) root.mainloop() ``` 这个IDE程序中包括了基本的文件操作和文本编辑功能。您可以自行修改和扩展这个程序来满足您的需求。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值