python tkinter界面可视化工具

python tkinter界面可视化工具,第1张

python tkinter界面可视化工具

@python tkinter界面可视化工具

最近在学习python之tkinter之大坑。做个简单的界面,做的真是麻烦。发现有几个可视化工具不错。

第一。 the page 。感觉软件不错,就是不会使用。正在慢慢试着。
下载地址:http://page.sourceforge.net

下面是一段用the page生成的代码。具体怎么使用慢慢摸索吧。

 #! /usr/bin/env python
 #  -*- coding: utf-8 -*-
 #
 # GUI module generated by PAGE version 6.2
 #  in conjunction with Tcl version 8.6
 #    Jan 01, 2022 04:32:47 PM CST  platform: Windows NT
 
import sys
 
try:
    import Tkinter as tk
except importError:
    import tkinter as tk
 
try:
    import ttk
    py3 = False
except importError:
    import tkinter.ttk as ttk
    py3 = True
 
import main_support
 
def vp_start_gui():
    '''Starting point when module is the main routine.'''
    global val, w, root
    root = tk.Tk()
    top = Toplevel1 (root)
    main_support.init(root, top)
    root.mainloop()
 
w = None
def create_Toplevel1(rt, *args, **kwargs):
    '''Starting point when module is imported by another module.
    Correct form of call: 'create_Toplevel1(root, *args, **kwargs)' .'''
    global w, w_win, root
    #rt = root
    root = rt
    w = tk.Toplevel (root)
    top = Toplevel1 (w)
    main_support.init(w, top, *args, **kwargs)
    return (w, top)
 
def destroy_Toplevel1():
    global w
    w.destroy()
    w = None
 
class Toplevel1:
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
        top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.configure('.',font="TkDefaultFont")
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("1024x512+397+222")
        top.minsize(116, 1)
        top.maxsize(1920, 1058)
        top.resizable(1,  1)
        top.title("New Toplevel")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab', background=
            [('selected', _compcolor), ('active',_ana2color)])
        self.TNbk1 = ttk.Notebook(top)
        self.TNbk1.place(relx=0.0, rely=0.0, relheight=0.973, relwidth=1.0)
        self.TNbk1.configure(takefocus="")
        self.TNbk1_t1 = tk.frame(self.TNbk1)
        self.TNbk1.add(self.TNbk1_t1, padding=3)
        self.TNbk1.tab(0, text="歌单选择",compound="left",underline="-1",)
        self.TNbk1_t1.configure(background="#d9d9d9")
        self.TNbk1_t1.configure(highlightbackground="#d9d9d9")
        self.TNbk1_t1.configure(highlightcolor="black")
        self.TNbk1_t2 = tk.frame(self.TNbk1)
        self.TNbk1.add(self.TNbk1_t2, padding=3)
        self.TNbk1.tab(1, text="下载任务",compound="left",underline="-1",)
        self.TNbk1_t2.configure(background="#d9d9d9")
        self.TNbk1_t2.configure(highlightbackground="#d9d9d9")
        self.TNbk1_t2.configure(highlightcolor="black")

        self.p1_top = tk.frame(self.TNbk1_t1)
        self.p1_top.place(relx=0.0, rely=0.0, relheight=0.138, relwidth=1.005)
        self.p1_top.configure(relief='groove')
        self.p1_top.configure(borderwidth="2")
        self.p1_top.configure(relief="groove")
        self.p1_top.configure(background="#d9d9d9")
        self.p1_top.configure(highlightbackground="#d9d9d9")
        self.p1_top.configure(highlightcolor="black")

        self.p1_left = tk.frame(self.TNbk1_t1)
        self.p1_left.place(relx=0.0, rely=0.128, relheight=0.862, relwidth=0.907)

        self.p1_left.configure(relief='groove')
        self.p1_left.configure(borderwidth="2")
        self.p1_left.configure(relief="groove")
        self.p1_left.configure(background="#d9d9d9")
        self.p1_left.configure(highlightbackground="#d9d9d9")
        self.p1_left.configure(highlightcolor="black")

        self.p1_right = tk.frame(self.TNbk1_t1)
        self.p1_right.place(relx=0.902, rely=0.128, relheight=0.862
                , relwidth=0.135)
        self.p1_right.configure(relief='groove')
        self.p1_right.configure(borderwidth="2")
        self.p1_right.configure(relief="groove")
        self.p1_right.configure(background="#d9d9d9")
        self.p1_right.configure(highlightbackground="#d9d9d9")
        self.p1_right.configure(highlightcolor="black")

        self.p2_left = tk.frame(self.TNbk1_t2)
        self.p2_left.place(relx=0.0, rely=0.0, relheight=1.011, relwidth=0.103)
        self.p2_left.configure(relief='groove')
        self.p2_left.configure(borderwidth="2")
        self.p2_left.configure(relief="groove")
        self.p2_left.configure(background="#d9d9d9")
        self.p2_left.configure(highlightbackground="#d9d9d9")
        self.p2_left.configure(highlightcolor="black")
        self.p2_right = tk.frame(self.TNbk1_t2)
        self.p2_right.place(relx=0.098, rely=0.0, relheight=0.989
                , relwidth=0.897)
        self.p2_right.configure(relief='groove')
        self.p2_right.configure(borderwidth="2")
        self.p2_right.configure(relief="groove")
        self.p2_right.configure(background="#d9d9d9")
        self.p2_right.configure(highlightbackground="#d9d9d9")
        self.p2_right.configure(highlightcolor="black")
if __name__ == '__main__':
    vp_start_gui()
  
  
  

第二个工具:VisualTkinter。是一个VB的插件。可以将VB的界面生成python tkinter代码。做个简单的界面用这个感觉不错。

这是一段生成一个菜单的代码。

#!/usr/bin/env python
#-*- coding:utf-8 -*-

import os, sys
from tkinter import *
from tkinter.font import Font
from tkinter.ttk import *
#Usage:showinfo/warning/error,askquestion/okcancel/yesno/retrycancel
from tkinter.messagebox import *
#Usage:f=tkFileDialog.askopenfilename(initialdir='E:/Python')
#import tkinter.filedialog as tkFileDialog
#import tkinter.simpledialog as tkSimpleDialog  #askstring()

class Application_ui(frame):
    #这个类仅实现界面生成功能,具体事件处理代码在子类Application中。
    def __init__(self, master=None):
        frame.__init__(self, master)
        self.master.title('Form1')
        self.master.geometry('1100x482')
        self.createWidgets()

    def createWidgets(self):
        self.top = self.winfo_toplevel()

        self.style = Style()

        self.MainMenu = Menu(self.top, tearoff=0)

        self.j = Menu(self.MainMenu, tearoff=0)
        self.j.add_command(label='最新', command=self.jx_Cmd)
        self.j.add_command(label='最热', command=self.hot_Cmd)
        self.MainMenu.add_cascade(menu=self.j, label='精选')

        self.zt = Menu(self.MainMenu, tearoff=0)
        self.zt.add_command(label='经典', command=self.jd_Cmd)
        self.zt.add_command(label='轻音乐', command=self.qinyy_Cmd)
        self.zt.add_command(label='怀旧', command=self.huijiu_Cmd)
        self.zt.add_command(label='抖音', command=self.dy_Cmd)
        self.zt.add_command(label='古风', command=self.gufen_Cmd)
        self.zt.add_command(label='网络', command=self.wangluo_Cmd)
        self.zt.add_command(label='游戏', command=self.youxi_Cmd)
        self.zt.add_command(label='影视', command=self.yinshi_Cmd)
        self.zt.add_command(label='佛乐', command=self.fuyv_Cmd)
        self.zt.add_command(label='网红', command=self.wanghong_Cmd)
        self.zt.add_command(label='纯音乐', command=self.congyy_Cmd)
        self.zt.add_command(label='ACG', command=self.ACG_Cmd)
        self.zt.add_command(label='3D', command=self.D3_Cmd)
        self.zt.add_command(label='KTV', command=self.ktv_Cmd)
        self.zt.add_command(label='器乐', command=self.qiyue_Cmd)
        self.zt.add_command(label='翻唱', command=self.fancang_Cmd)
        self.zt.add_command(label='喊麦', command=self.hanmai_Cmd)
        self.zt.add_command(label='店铺专用', command=self.dianpu_Cmd)
        self.MainMenu.add_cascade(menu=self.zt, label='主题')

        self.x = Menu(self.MainMenu, tearoff=0)
        self.x.add_command(label='伤感', command=self.shanggan_Cmd)
        self.x.add_command(label='放松', command=self.fangsong_Cmd)
        self.x.add_command(label='励志', command=self.lizhi_Cmd)
        self.x.add_command(label='开心', command=self.kaixing_Cmd)
        self.x.add_command(label='甜蜜', command=self.tianmi_Cmd)
        self.x.add_command(label='兴奋', command=self.xingfen_Cmd)
        self.x.add_command(label='安静', command=self.anjing_Cmd)
        self.x.add_command(label='治愈', command=self.zhiyu_Cmd)
        self.x.add_command(label='寂寞', command=self.jimo_Cmd)
        self.x.add_command(label='思念', command=self.sinian_Cmd)
        self.MainMenu.add_cascade(menu=self.x, label='心情')

        self.cj = Menu(self.MainMenu, tearoff=0)
        self.cj.add_command(label='开车', command=self.kaiche_Cmd)
        self.cj.add_command(label='运动', command=self.yundong_Cmd)
        self.cj.add_command(label='睡前', command=self.shuiqian_Cmd)
        self.cj.add_command(label='跳舞', command=self.tiaowu_Cmd)
        self.cj.add_command(label='学习', command=self.xuexi_Cmd)
        self.cj.add_command(label='清晨', command=self.qingchen_Cmd)
        self.cj.add_command(label='夜店', command=self.yandian_Cmd)
        self.cj.add_command(label='校园', command=self.xiaoyuan_Cmd)
        self.cj.add_command(label='咖啡店', command=self.kafeidian_Cmd)
        self.cj.add_command(label='旅行', command=self.lvxing_Cmd)
        self.cj.add_command(label='工作', command=self.gongzuo_Cmd)
        self.cj.add_command(label='广场舞', command=self.guangchuangwu_Cmd)
        self.MainMenu.add_cascade(menu=self.cj, label='场景')

        self.nd = Menu(self.MainMenu, tearoff=0)
        self.nd.add_command(label='70后', command=self.h70_Cmd)
        self.nd.add_command(label='80垢', command=self.h80_Cmd)
        self.nd.add_command(label='90后', command=self.h90_Cmd)
        self.nd.add_command(label='00后', command=self.h00_Cmd)
        self.nd.add_command(label='10后', command=self.h10_Cmd)
        self.MainMenu.add_cascade(menu=self.nd, label='年代')

        self.qf = Menu(self.MainMenu, tearoff=0)
        self.qf.add_command(label='流行', command=self.liuxin_Cmd)
        self.qf.add_command(label='电子', command=self.dianzi_Cmd)
        self.qf.add_command(label='摇滚', command=self.yaoguong_Cmd)
        self.qf.add_command(label='民歌', command=self.minge_Cmd)
        self.qf.add_command(label='民谣', command=self.migyao_Cmd)
        self.qf.add_command(label='古典', command=self.gudian_Cmd)
        self.qf.add_command(label='嘻哈', command=self.xiha_Cmd)
        self.qf.add_command(label='乡村', command=self.xiangcun_Cmd)
        self.qf.add_command(label='爵士', command=self.jueshi_Cmd)
        self.qf.add_command(label='R&B', command=self.rb_Cmd)
        self.MainMenu.add_cascade(menu=self.qf, label='曲风')

        self.yy = Menu(self.MainMenu, tearoff=0)
        self.yy.add_command(label='华语', command=self.huanyu_Cmd)
        self.yy.add_command(label='欧美', command=self.oumei_Cmd)
        self.yy.add_command(label='韩语', command=self.hanyv_Cmd)
        self.yy.add_command(label='粤语', command=self.yueyu_Cmd)
        self.yy.add_command(label='日语', command=self.riyv_Cmd)
        self.yy.add_command(label='小语种', command=self.xiaoyuzhong_Cmd)
        self.MainMenu.add_cascade(menu=self.yy, label='语言')

        self.aboutme = Menu(self.MainMenu, tearoff=0)
        self.aboutme.add_command(label='使用说明', command=self.abouthelp_Cmd)
        self.aboutme.add_command(label='关于', command=self.aboutver_Cmd)
        self.MainMenu.add_cascade(menu=self.aboutme, label='帮助')
        self.top['menu'] = self.MainMenu


class Application(Application_ui):
    #这个类实现具体的事件处理回调函数。界面生成代码在Application_ui中。
    def __init__(self, master=None):
        Application_ui.__init__(self, master)

    def jx_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def hot_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def jd_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def qinyy_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def huijiu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def dy_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def gufen_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def wangluo_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def youxi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def yinshi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def fuyv_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def wanghong_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def congyy_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def ACG_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def D3_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def ktv_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def qiyue_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def fancang_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def hanmai_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def dianpu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def shanggan_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def fangsong_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def lizhi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def kaixing_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def tianmi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def xingfen_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def anjing_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def zhiyu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def jimo_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def sinian_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def kaiche_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def yundong_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def shuiqian_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def tiaowu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def xuexi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def qingchen_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def yandian_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def xiaoyuan_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def kafeidian_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def lvxing_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def gongzuo_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def guangchuangwu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def h70_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def h80_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def h90_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def h00_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def h10_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def liuxin_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def dianzi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def yaoguong_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def minge_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def migyao_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def gudian_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def xiha_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def xiangcun_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def jueshi_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def rb_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def huanyu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def oumei_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def hanyv_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def yueyu_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def riyv_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def xiaoyuzhong_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def abouthelp_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

    def aboutver_Cmd(self, event=None):
        #TODO, Please finish the function here!
        pass

if __name__ == "__main__":
    top = Tk()
    Application(top).mainloop()
    try: top.destroy()
    except: pass

第三。网上还有一个用易语言做的工具,python Tkinter GUI可视化助手。如果想学习自己搜索吧。
得去学了。简单的界面使用 the page 和 VisualTkinter 这两个就够了。
再复杂的界面学习其他的模块如:wxPython/PyQt 。

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

原文地址: http://outofmemory.cn/zaji/5689315.html

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

发表评论

登录后才能评论

评论列表(0条)

保存