python tkinter 总结

1.以管理员身份运行

import win32com.shell.shell as shell
ASADMIN = 'asadmin'

if sys.argv[-1] != ASADMIN:
    script = os.path.abspath(sys.argv[0])
    params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
    shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params)
    sys.exit(0)

2.窗口置顶

self.UI = Tk()
self.UI.wm_attributes('-topmost', 1)

3.设置窗口大小

self.UI = Tk()
self.UI.geometry('650x450')

4.创建按钮

self.text = tkinter.StringVar()
self.text.set("缩小")
btn1 = Button(self.UI, text='开始执行', bd='5', command=self._implementOrder)
btn2 = Button(self.UI, text='保存地址', bd='5', command=self._savePath)
self.btn3 = Button(self.UI, textvariable=self.text, bd='5', command=self._changeSize)
btn1.grid(row=1, column=1)
btn2.grid(row=2, column=1)
self.btn3.grid(row=3, column=1)

5.创建复选窗口

self.CheckVar1 = IntVar(value=self.isOpenZBBL)
self.CheckVar2 = IntVar(value=self.isCloseZBBL)
self.CheckVar3 = IntVar(value=self.isCopyFiles[0])
self.CheckVar4 = IntVar(value=self.isCopyFiles[1])
self.CheckVar5 = IntVar(value=self.isCopyFiles[2])
openZBBL = Checkbutton(self.UI, text="打开xx", variable=self.CheckVar1, onvalue=1, offvalue=0, height=5,
                       width=20, command=self._checkbutton_OpenZBBL)
closeZBBL = Checkbutton(self.UI, text="关闭xx", variable=self.CheckVar2, onvalue=1, offvalue=0, height=5,
                        width=20, command=self._checkbutton_CloseZBBL)
copyFile1 = Checkbutton(self.UI, text="拷贝此文件", variable=self.CheckVar3, onvalue=1, offvalue=0, height=5,
                        width=20, command=self._checkbutton_CopyFile1)
copyFile2 = Checkbutton(self.UI, text="拷贝此文件", variable=self.CheckVar4, onvalue=1, offvalue=0, height=5,
                        width=20, command=self._checkbutton_CopyFile2)
copyFile3 = Checkbutton(self.UI, text="拷贝此文件", variable=self.CheckVar5, onvalue=1, offvalue=0, height=5,
                        width=20, command=self._checkbutton_CopyFile3)
openZBBL.grid(row=1, column=2)
closeZBBL.grid(row=2, column=2)
copyFile1.grid(row=1, column=3)
copyFile2.grid(row=3, column=3)
copyFile3.grid(row=5, column=3)

6.创建文本框

rst = [StringVar(self.UI, value=self.GroupSource[0]),
     StringVar(self.UI, value=self.GroupSource[1]),
     StringVar(self.UI, value=self.GroupSource[2])]
dst = [StringVar(self.UI, value=self.GroupDst[0]),
     StringVar(self.UI, value=self.GroupDst[1]),
     StringVar(self.UI, value=self.GroupDst[2])]
self.rstpath = [Entry(self.UI, width=30, bd=6, textvariable=rst[0]),
              Entry(self.UI, width=30, bd=6, textvariable=rst[1]),
              Entry(self.UI, width=30, bd=6, textvariable=rst[2])]
self.dstpath = [Entry(self.UI, width=30, bd=6, textvariable=dst[0]),
              Entry(self.UI, width=30, bd=6, textvariable=dst[1]),
              Entry(self.UI, width=30, bd=6, textvariable=dst[2])]

for i in range(3):
  self.rstpath[i].grid(row=1 + i * 2, column=4)
  self.dstpath[i].grid(row=2 + i * 2, column=4)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值