国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

使用cx_freeze把python打包exe示例

2020-02-23 05:07:30
字體:
來源:轉載
供稿:網友

需要使用到的文件wxapp.py, read_file.py, setup.py

代碼如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#file: wxapp.py

import wx
import os
import sys
import read_file


class Frame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent=None, title='Hello from cx_Freeze')
        panel = wx.Panel(self)
        closeMeButton = wx.Button(panel, -1, 'Close Me')
        wx.EVT_BUTTON(self, closeMeButton.GetId(), self.OnCloseMe)
        wx.EVT_CLOSE(self, self.OnCloseWindow)
        pushMeButton = wx.Button(panel, -1, 'Push Me')
        wx.EVT_BUTTON(self, pushMeButton.GetId(), self.OnPushMe)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(closeMeButton, flag=wx.ALL, border=20)
        sizer.Add(pushMeButton, flag=wx.ALL, border=20)
        panel.SetSizer(sizer)
        topSizer = wx.BoxSizer(wx.VERTICAL)
        topSizer.Add(panel, flag=wx.ALL | wx.EXPAND)
        topSizer.Fit(self)

    def OnCloseMe(self, event):
        obj = read_file.PrintContent()
        if getattr(sys, 'frozen', None):
            path = os.path.dirname(sys.executable)
        else:
            path = os.path.dirname(__file__)
        path = os.path.join(path, "read_file.py")
        obj.show_content(path)

    def OnPushMe(self, event):
        wx.MessageBox('I was pushed!', 'Informational message')

    def OnCloseWindow(self, event):
        self.Destroy()


class App(wx.App):
    def OnInit(self):
        frame = Frame()
        frame.Show(True)
        self.SetTopWindow(frame)
        return True


app = App(1)
app.MainLoop()

代碼如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#file: read_file.py

class PrintContent(object):
    def show_content(self, path):
        f = open(path)
        for line in f:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安徽省| 两当县| 黑河市| 永顺县| 章丘市| 兴仁县| 资源县| 兰考县| 南投县| 邻水| 日喀则市| 息烽县| 叶城县| 新疆| 龙泉市| 丰都县| 黎城县| 揭东县| 呼和浩特市| 卢龙县| 雷波县| 宁陕县| 南城县| 青田县| 晋城| 桐庐县| 鹿邑县| 临猗县| 呼玛县| 遂宁市| 榕江县| 巧家县| 合川市| 聂荣县| 永胜县| 花垣县| 兖州市| 遂溪县| 通海县| 瑞丽市| 罗甸县|