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

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

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/868435.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存