git自动拉代码 推送代码合并 exe 软件python


页面 在这里插入图片描述

在这里插入图片描述

python代码

import wx
import os, base64                        # 引入wxPython包
import win32api
import win32gui
import win32con
import time
import datetime

P_icon = 'C:\\Users\\DELL\\Desktop\\wx\\github.ico';
P_github ="C:\\Users\\DELL\\Desktop\\wx\\github.png"
P_github2 ="C:\\Users\\DELL\\Desktop\\wx\\github2.png"
# 定义主窗口类
class MainFrame(wx.Frame):

  panel =""; #全局变量
  msg = "";

  def __init__(self, p, t):        # 初始化函数
    
    # 基类的初始化函数
    wx.Frame.__init__(self, id=-1, parent=p, title=t, size=(300, 200))
    # 该panel的父亲就是该窗口, id=-1就表示任意ID
    global panel
    global msg

    msg = TestTaskbarIcon()
    panel = wx.Panel(self, -1)

    


    self.SetIcon(wx.Icon(name=P_icon,  type=wx.BITMAP_TYPE_ICO)) #设置icon 
    

    bmp = wx.Image(P_github, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    bmp2 = wx.Image(P_github2, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    self.button = wx.BitmapButton(panel, -1, bmp, pos=(20, 20))

    self.PUsh = wx.BitmapButton(panel, -1, bmp2, pos=(150, 20))
    # 绑定事件,就是指定的button被单击后调用onClick()成员函数
    self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
    self.Bind(wx.EVT_BUTTON, self.OnPUsh, self.PUsh)
    # self.button.SetDefault()

  def OnClick(self, event):
    # 一旦单击就关闭主窗口

    # self.Destroy()
    # dlg = wx.MessageDialog(None, u"消息对话框测试", u"标题信息", wx.YES_NO | wx.ICON_QUESTION)
    # dlg.ShowModal()
    # wx.MessageBox('Down Completed','Info',wx.OK|wx.ICON_INFORMATION)
    global panel
    global msg

    os.chdir("D:/phpstudy_pro/WWW/rygLife");

    multiStr = os.system("git pull origin dev");


    msg.showMsg("Git 拉取成功", "远方的猫 666 ")

    # exe = os.system("git pull origin dev");

    # wx.MessageBox('拉去成功','Info',wx.OK|wx.ICON_INFORMATION)
    # text5 = wx.StaticText(panel,wx.ID_ANY,multiStr,(50, 150))
  def OnPUsh(self, event):
    # 一旦单击就关闭主窗口

    # self.Destroy()
    # dlg = wx.MessageDialog(None, u"消息对话框测试", u"标题信息", wx.YES_NO | wx.ICON_QUESTION)
    # dlg.ShowModal()
    # wx.MessageBox('Down Completed','Info',wx.OK|wx.ICON_INFORMATION)
    global panel
    global msg

    os.chdir("D:/phpstudy_pro/WWW/rygLife");

    os.system("git add .");
    print("git push commit of description");
    # description = input();
    description = time.strftime('%Y-%m-%d',time.localtime(time.time()))
    os.system("git commit -a -m '" + description + "'");
    os.system("git push origin lj");

    msg.showMsg("PUSH成功", "老铁 666 ")

    # time.sleep(2)

    win32api.ShellExecute(0, 'open', 'git合并地址', '', '', 1)   # 打开网页 
  
class TestTaskbarIcon:
    def __init__(self):
        # 注册一个窗口类
        wc = win32gui.WNDCLASS()
        hinst = wc.hInstance = win32gui.GetModuleHandle(None)
        wc.lpszClassName = "PythonTaskbarDemo"
        wc.lpfnWndProc = {win32con.WM_DESTROY: self.OnDestroy, }
        classAtom = win32gui.RegisterClass(wc)
        style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU
        self.hwnd = win32gui.CreateWindow(classAtom, "Taskbar Demo", style,
                                          0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT,
                                          0, 0, hinst, None)
        hicon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
        nid = (self.hwnd, 0, win32gui.NIF_ICON, win32con.WM_USER + 20, hicon, "Demo")
        win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, nid)

    def showMsg(self, title, msg):
        # 原作者使用Shell_NotifyIconA方法代替包装后的Shell_NotifyIcon方法
        # 据称是不能win32gui structure, 我稀里糊涂搞出来了.
        # 具体对比原代码.
        nid = (self.hwnd,  # 句柄
               0,  # 托盘图标ID
               win32gui.NIF_INFO,  # 标识
               0,  # 回调消息ID
               0,  # 托盘图标句柄
               "TestMessage",  # 图标字符串
               msg,  # 气球提示字符串
               0,  # 提示的显示时间
               title,  # 提示标题
               win32gui.NIIF_INFO  # 提示用到的图标
               )
        win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, nid)

    def OnDestroy(self, hwnd, msg, wparam, lparam):
        nid = (self.hwnd, 0)
        win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
        win32gui.PostQuitMessage(0)  # Terminate the app.


if __name__ == "__main__":
    # 创建一个应用程序
    app = wx.App(False)
    # frame就是应用程序的主窗口
    frame = MainFrame(None, "远方的猫")

    frame.Show(True)        # 显示主窗口
    app.MainLoop()        # 开始消息循环
    # win32gui.DestroyWindow(t.hwnd)

打包成exe软件

pyinstaller -F 代码.py -w

 pyinstaller  -i "C:/Users/DELL/Desktop/live-exe/bin/icon/favicon.ico" index.py  --distpath "C:/Users/DELL/Desktop/live-exe/" --noconsole --clean
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐