当前位置:   article > 正文

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

tkinterdesigner官网

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标签页内容至你的编译文档即可执行。

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. import tkinter as tk
  4. import tkinter.font as tkFont
  5. class App:
  6. def __init__(self, root):
  7. #setting title
  8. root.title("undefined")
  9. #setting window size
  10. width=1022
  11. height=590
  12. screenwidth = root.winfo_screenwidth()
  13. screenheight = root.winfo_screenheight()
  14. alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
  15. root.geometry(alignstr)
  16. root.resizable(width=False, height=False)
  17. GLabel_431=tk.Label(root)
  18. ft = tkFont.Font(family='Times',size=10)
  19. GLabel_431["font"] = ft
  20. GLabel_431["fg"] = "#333333"
  21. GLabel_431["justify"] = "center"
  22. GLabel_431["text"] = ""
  23. GLabel_431.place(x=0,y=0,width=648,height=587)
  24. GLineEdit_451=tk.Entry(root)
  25. GLineEdit_451["bg"] = "#ffffff"
  26. GLineEdit_451["borderwidth"] = "1px"
  27. ft = tkFont.Font(family='Times',size=10)
  28. GLineEdit_451["font"] = ft
  29. GLineEdit_451["fg"] = "#333333"
  30. GLineEdit_451["justify"] = "left"
  31. GLineEdit_451["text"] = "log"
  32. GLineEdit_451["relief"] = "groove"
  33. GLineEdit_451.place(x=650,y=380,width=371,height=206)
  34. GLineEdit_758=tk.Entry(root)
  35. GLineEdit_758["bg"] = "#ffffff"
  36. GLineEdit_758["borderwidth"] = "1px"
  37. ft = tkFont.Font(family='Times',size=10)
  38. GLineEdit_758["font"] = ft
  39. GLineEdit_758["fg"] = "#333333"
  40. GLineEdit_758["justify"] = "left"
  41. GLineEdit_758["text"] = ""
  42. GLineEdit_758["relief"] = "groove"
  43. GLineEdit_758.place(x=650,y=40,width=369,height=339)
  44. GLineEdit_578=tk.Entry(root)
  45. GLineEdit_578["bg"] = "#ffffff"
  46. GLineEdit_578["borderwidth"] = "1px"
  47. ft = tkFont.Font(family='Times',size=10)
  48. GLineEdit_578["font"] = ft
  49. GLineEdit_578["fg"] = "#333333"
  50. GLineEdit_578["justify"] = "left"
  51. GLineEdit_578["text"] = ""
  52. GLineEdit_578["relief"] = "groove"
  53. GLineEdit_578.place(x=0,y=80,width=648,height=507)
  54. GLabel_654=tk.Label(root)
  55. ft = tkFont.Font(family='Times',size=16)
  56. GLabel_654["font"] = ft
  57. GLabel_654["fg"] = "#333333"
  58. GLabel_654["justify"] = "center"
  59. GLabel_654["text"] = "职位搜索小程序"
  60. GLabel_654.place(x=200,y=10,width=260,height=31)
  61. GLabel_72=tk.Label(root)
  62. ft = tkFont.Font(family='Times',size=10)
  63. GLabel_72["font"] = ft
  64. GLabel_72["fg"] = "#333333"
  65. GLabel_72["justify"] = "center"
  66. GLabel_72["text"] = "职位关键字"
  67. GLabel_72.place(x=10,y=40,width=70,height=31)
  68. GButton_674=tk.Button(root)
  69. GButton_674["anchor"] = "n"
  70. GButton_674["bg"] = "#efefef"
  71. ft = tkFont.Font(family='Times',size=10)
  72. GButton_674["font"] = ft
  73. GButton_674["fg"] = "#000000"
  74. GButton_674["justify"] = "center"
  75. GButton_674["text"] = "黑名单"
  76. GButton_674["relief"] = "groove"
  77. GButton_674.place(x=810,y=10,width=70,height=25)
  78. GButton_674["command"] = self.GButton_674_command
  79. GButton_194=tk.Button(root)
  80. GButton_194["anchor"] = "s"
  81. GButton_194["bg"] = "#efefef"
  82. ft = tkFont.Font(family='Times',size=10)
  83. GButton_194["font"] = ft
  84. GButton_194["fg"] = "#000000"
  85. GButton_194["justify"] = "center"
  86. GButton_194["text"] = "初始化"
  87. GButton_194["relief"] = "groove"
  88. GButton_194.place(x=910,y=10,width=70,height=25)
  89. GButton_194["command"] = self.GButton_194_command
  90. GButton_27=tk.Button(root)
  91. GButton_27["anchor"] = "s"
  92. GButton_27["bg"] = "#efefef"
  93. ft = tkFont.Font(family='Times',size=10)
  94. GButton_27["font"] = ft
  95. GButton_27["fg"] = "#000000"
  96. GButton_27["justify"] = "center"
  97. GButton_27["text"] = "开始查询"
  98. GButton_27["relief"] = "groove"
  99. GButton_27.place(x=700,y=10,width=70,height=25)
  100. GButton_27["command"] = self.GButton_27_command
  101. GLabel_423=tk.Label(root)
  102. ft = tkFont.Font(family='Times',size=10)
  103. GLabel_423["font"] = ft
  104. GLabel_423["fg"] = "#333333"
  105. GLabel_423["justify"] = "center"
  106. GLabel_423["text"] = "v0.2"
  107. GLabel_423.place(x=460,y=20,width=53,height=30)
  108. GLineEdit_450=tk.Entry(root)
  109. GLineEdit_450["bg"] = "#ffffff"
  110. GLineEdit_450["borderwidth"] = "1px"
  111. ft = tkFont.Font(family='Times',size=10)
  112. GLineEdit_450["font"] = ft
  113. GLineEdit_450["fg"] = "#333333"
  114. GLineEdit_450["justify"] = "left"
  115. GLineEdit_450["text"] = ""
  116. GLineEdit_450["relief"] = "groove"
  117. GLineEdit_450.place(x=90,y=40,width=558,height=38)
  118. def GButton_674_command(self):
  119. print("command")
  120. def GButton_194_command(self):
  121. print("command")
  122. def GButton_27_command(self):
  123. print("command")
  124. if __name__ == "__main__":
  125. root = tk.Tk()
  126. app = App(root)
  127. root.mainloop()

 有中文的记得加引用

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

执行你的代码

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

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

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. import tkinter as tk
  4. from tkinter import *
  5. import tkinter.font as tkFont
  6. import time
  7. LOG_LINE_NUM = 0
  8. JOB_LINE_NUM = 0
  9. BLACK_LINE_NUM = 0
  10. class App:
  11. keyPositions = 'python,程序设计,会计,财务'
  12. def __init__(self, window):
  13. self.window = window
  14. def run(self):
  15. window.title("职位搜索")
  16. #setting window size
  17. width=1022
  18. height=590
  19. screenwidth = window.winfo_screenwidth()
  20. screenheight = window.winfo_screenheight()
  21. alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
  22. window.geometry(alignstr)
  23. ft = tkFont.Font(family='Times', size=16)
  24. GLabel_title = tk.Label(window, font=ft, fg="#333333", justify="center", text="职位搜索小程序")
  25. GLabel_title.place(x=200, y=10, width=260, height=31)
  26. ft = tkFont.Font(family='Times', size=10)
  27. GLabel_ver = tk.Label(window, font=ft, fg="#333333", justify="center", text="v0.2")
  28. GLabel_ver.place(x=460, y=20, width=53, height=30)
  29. GLabel_job = tk.Label(window, font=ft, fg="#333333", justify="center", text="职位关键字")
  30. GLabel_job.place(x=10, y=40, width=70, height=31)
  31. self.GLineEdit_jobname = tk.Entry(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333", justify="left", relief="groove")
  32. self.GLineEdit_jobname.insert(0,self.keyPositions)
  33. self.GLineEdit_jobname.place(x=90, y=40, width=558, height=38)
  34. self.GLineEdit_main = tk.Text(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333", relief="groove")
  35. self.GLineEdit_main.place(x=0, y=80, width=648, height=507)
  36. self.GLineEdit_list = tk.Text(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333", relief="groove")
  37. self.GLineEdit_list.place(x=650, y=40, width=369, height=389)
  38. self.GLineEdit_log = tk.Text(window, font=ft, bg="#ffffff", borderwidth="1px", fg="#333333", relief="groove")
  39. self.GLineEdit_log.place(x=650, y=430, width=371, height=156)
  40. GButton_start = tk.Button(window, anchor="s", bg="#efefef", font=ft, fg="#000000", justify="center", text="开始查询", relief="groove")
  41. GButton_start.place(x=700, y=10, width=70, height=25)
  42. GButton_start["command"] = self.GButton_start_command
  43. GButton_list=tk.Button(window, anchor ="s", bg="#efefef", font =ft, fg="#000000", justify="center", text="黑名单", relief="groove")
  44. GButton_list.place(x=810,y=10,width=70,height=25)
  45. GButton_list["command"] = self.GButton_list_command
  46. GButton_init=tk.Button(window, anchor ="s", bg="#efefef", font =ft, fg="#000000", justify="center", text="初始化", relief="groove")
  47. GButton_init.place(x=910,y=10,width=70,height=25)
  48. GButton_init["command"] = self.GButton_init_command
  49. def GButton_list_command(self):
  50. print("GButton_list_command")
  51. self.write_log_to_Text("新加黑名单企业如下")
  52. def GButton_start_command(self):
  53. print("GButton_start_command")
  54. self.write_log_to_Text("开始职位搜索")
  55. def GButton_init_command(self):
  56. print("GButton_init_command")
  57. self.write_log_to_Text("初始化数据库")
  58. # 获取当前时间
  59. def get_current_time(self):
  60. current_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
  61. return current_time
  62. # 日志动态打印
  63. def write_log_to_Text(self, logmsg):
  64. global LOG_LINE_NUM
  65. current_time = self.get_current_time()
  66. logmsg_in = str(current_time) + " " + str(logmsg) + "\n" # 换行
  67. if LOG_LINE_NUM <= 8:
  68. self.GLineEdit_log.insert(END, logmsg_in)
  69. LOG_LINE_NUM = LOG_LINE_NUM + 1
  70. else:
  71. self.GLineEdit_log.delete(1.0, 2.0)
  72. self.GLineEdit_log.insert(END, logmsg_in)
  73. if __name__ == "__main__":
  74. window = Tk()
  75. app = App(window)
  76. app.run()
  77. window.resizable(False, False)
  78. window.mainloop() # 父窗口进入事件循环,可以理解为保持窗口运行,否则界面不展示

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

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号