python写小软件

发布时间:2024-12-02 17:52

学习Python获取软件开发证书 #生活技巧# #工作学习技巧# #技能证书学习#

#!/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("209x472+1500+150")

self.createWidgets()

def createWidgets(self):

self.top = self.winfo_toplevel()

self.style = Style()

self.Command1Var = StringVar(value='python')

self.style.configure('TCommand1.TButton', font=('宋体',9))

self.Command1 = Button(self.top, text='Command1', textvariable=self.Command1Var, command=self.Command1_Cmd, style='TCommand1.TButton')

self.Command1.setText = lambda x: self.Command1Var.set(x)

self.Command1.text = lambda : self.Command1Var.get()

self.Command1.place(relx=0.096, rely=0.085, relwidth=0.818, relheight=0.108)

self.Command2Var = StringVar(value='auto.js')

self.style.configure('TCommand2.TButton', font=('宋体',9))

self.Command2 = Button(self.top, text='Command2', textvariable=self.Command2Var, command=self.Command2_Cmd, style='TCommand2.TButton')

self.Command2.setText = lambda x: self.Command2Var.set(x)

self.Command2.text = lambda : self.Command2Var.get()

self.Command2.place(relx=0.096, rely=0.233, relwidth=0.818, relheight=0.15)

self.Command3Var = StringVar(value='下载总位置')

self.style.configure('TCommand3.TButton', font=('宋体',9))

self.Command3 = Button(self.top, text='Command3', textvariable=self.Command3Var, command=self.Command3_Cmd, style='TCommand3.TButton')

self.Command3.setText = lambda x: self.Command3Var.set(x)

self.Command3.text = lambda : self.Command3Var.get()

self.Command3.place(relx=0.096, rely=0.445, relwidth=0.77, relheight=0.15)

self.Command4Var = StringVar(value='源码收集')

self.style.configure('TCommand4.TButton', font=('宋体',9))

self.Command4 = Button(self.top, text='Command4', textvariable=self.Command4Var, command=self.Command4_Cmd, style='TCommand4.TButton')

self.Command4.setText = lambda x: self.Command4Var.set(x)

self.Command4.text = lambda : self.Command4Var.get()

self.Command4.place(relx=0.096, rely=0.657, relwidth=0.77, relheight=0.108)

self.Command5Var = StringVar(value='工作区')

self.style.configure('TCommand5.TButton', font=('宋体',9))

self.Command5 = Button(self.top, text='Command5', textvariable=self.Command5Var, command=self.Command5_Cmd, style='TCommand5.TButton')

self.Command5.setText = lambda x: self.Command5Var.set(x)

self.Command5.text = lambda : self.Command5Var.get()

self.Command5.place(relx=0.096, rely=0.826, relwidth=0.77, relheight=0.108)

class Application(Application_ui):

#这个类实现具体的事件处理回调函数。界面生成代码在Application_ui中。

def __init__(self, master=None):

Application_ui.__init__(self, master)

def Command1_Cmd(self, event=None):

os.startfile("F:\源码收集\python")

self.quit()

def Command2_Cmd(self, event=None):

os.startfile("F:\源码收集\\aotu.js")

self.quit()

def Command3_Cmd(self, event=None):

os.startfile("D:\下载总位置")

self.quit()

def Command4_Cmd(self, event=None):

os.startfile("F:\源码收集")

self.quit()

def Command5_Cmd(self, event=None):

os.startfile("G:")

self.quit()

if __name__ == "__main__":

top = Tk()

Application(top).mainloop()

网址:python写小软件 https://www.yuejiaxmz.com/news/view/349931

相关内容

最受欢迎的11个Python编程软件,工作效率直接起飞!
Tkinter小项目:用Python写一个地址收藏管理工具,迅速提高你的工作效率
Python实战:使用tkinter来编写一个激活码输入程序
全面盘点:支持脚本编写的热门手机软件及应用场景解析
Python的生活小技巧
python
用Python发送邮件,需要这样三步
5款软件压力测试工具分享,上海专业的软件测评中心安利
python如何改变日常生活
Python制作生活工具

随便看看