本文目录一览:
Python UI 开发用哪个好
首选Tkinter, tk本身就是为了快速GUI开发而生,且经过多年发展,已经十分成熟,而且Tkiner是python内置的事实上的标准GUI库。
其次推荐GTK+3的python绑定PyGobject。
为什么python是用tcl/tk做UI界面的
python是解释性语言,所以也要选一个解释性的界面语言,tk工具包是唯一的选择。
tk工具包比较小巧,只关注界面,不像qt或wx一样还包含很多python已有的内容。
尽可能少的bug。
python如何调用ui文件
ui文件是Qt生成xml格式的文件,python要使用就得用pyside 或pyqt这其中一个库才能将ui文件转化为py文件,安装pyside库后,在命令行打这一句 : pyside-uic XXX.ui -o XXX_ui.py
如何用python做ui界面tkinter
import time
import tkinter as tk
class Window:
def __init__(self, title='nms', width=300, height=120, staFunc=bool, stoFunc=bool):
self.w = width
self.h = height
self.stat = True
self.staFunc = staFunc
self.stoFunc = stoFunc
self.staIco = None
self.stoIco = None
self.root = tk.Tk(className=title)
def center(self):
ws = self.root.winfo_screenwidth()
hs = self.root.winfo_screenheight()
x = int( (ws/2) - (self.w/2) )
y = int( (hs/2) - (self.h/2) )
self.root.geometry('{}x{}+{}+{}'.format(self.w, self.h, x, y))
def packBtn(self):
self.btnSer = tk.Button(self.root, command=self.event, width=15, height=3)
self.btnSer.pack(padx=20, side='left')
btnQuit = tk.Button(self.root, text='关闭窗口', command=self.root.quit, width=15, height=3)
btnQuit.pack(padx=20, side='right')
def event(self):
self.btnSer['state'] = 'disabled'
if self.stat:
if self.stoFunc():
self.btnSer['text'] = '启动服务'
self.stat = False
self.root.iconbitmap(self.stoIco)
else:
if self.staFunc():
self.btnSer['text'] = '停止服务'
self.stat = True
self.root.iconbitmap(self.staIco)
self.btnSer['state'] = 'active'
def loop(self):
self.root.resizable(False, False) #禁止修改窗口大小
self.packBtn()
self.center() #窗口居中
self.event()
self.root.mainloop()