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

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

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

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框有响应

这是一个VB6的IDE插件(Addin),使用VB6的IDE直接设计Python的界面。 Python和VB都是能让人快乐的编程语言,我使用了Python之后,很多自己使用的工具都使用Python开发或改写了,因为最终实现的Python代码实在太短了(相比VB),有时候Python一行代码就可以实现VB一个函数的功能。 Python就是这种让人越用越开心的语言。 不过说实在,使用Python开发GUI界面还是麻烦了一些了,自带的标准库Tkinter使用起来非常简单,不过对于习惯了VB拖放控件完成界面设计的偶来说,还是不够人性化。TK也有一个工具叫GUI Builder,不过它使用Layout布局,不够直观,而且用起来很不爽。。 至于PyQt/wxPython等GUI库,尽管有可视化设计工具,但总感觉做一般的轻量级应用是杀鸡用牛刀, 而且不够环保,不够低碳,要带一个很大的库,需要目标机器上夜同样安装了PyQt/wxPython,做不了绿色软件。 所以最终的结果是我更喜欢Tkinter,用起来很简单,绿色环保,真正的跨平台,一个py文件到处运行(担心泄密就编译成pyc)。 很多人都认为TK的界面不够美观,不过我经过多次实验后发现导入Python自带的标准TTK主题库,界面非常Native,不输PyQt/wxPython。 此Addin默认启用TTK支持,也可选择关闭。 总而言之,轻量级GUI,TK+TTK足够。 使用此Addin,你可以不用写一句代码就可以生成一个完整可运行的Python的GUI界面,支持2.X和3.X。 安装方法:将压缩包解压到你希望的目录,然后执行Setup.exe完成注册插件过程,打开VB6就可以用了。 在VB窗体上设计完成界面后(你可以大胆的设置各控件的属性,Addin尽量将其翻译为tkinter的控件属性),点工具栏上的VisualTkinter(图标为一片羽毛),再点'生成代码'按钮,即可生成可运行的Python代码,可以拷贝至剪贴板或保存至文件。 一般情况下你可以不用再改变tkinter的控件属性,但是如果你熟悉tkinter,需要更多的控制,可以一一核对各属性,并且修改,再生成代码。 当然除了用来设计界面外,此ADDIN内置的各控件属性列表可以做为编程参考,比较完整,除了极少数我认为大多数人都不用的属性外,属性定义基本上是我从官方的tkinter文档直接翻译的。 如果还没有VB6,网上找一个VB6精简版即可,不到20M,小巧玲珑。 代码已经在Github上托管,更新的版本可以在这上面找到,需求也可以在上面提: https://github.com/cdhigh/Visual-Tkinter-for-Python
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值