คือตอนที่ผม run โปรแกรมนะครับแล้วผมใช้Tkinter ทำตัว interface แต่รันแล้ว มันมีหน้าจอเหมือน DOS ดำๆ ออกมาด้วยอะครับ จะเอายังไงเหรอครับ(เคยอ่านเจอครั้งหนึ่งแต่จำไม่ได้ว่าที่ไหน ช่วยบอกทีครับ) หุหุหุ ขอบคุงครับ
คือตอนที่ผม run โปรแกรมนะครับแล้วผมใช้Tkinter ทำตัว interface แต่รันแล้ว มันมีหน้าจอเหมือน DOS ดำๆ ออกมาด้วยอะครับ จะเอายังไงเหรอครับ(เคยอ่านเจอครั้งหนึ่งแต่จำไม่ได้ว่าที่ไหน ช่วยบอกทีครับ) หุหุหุ ขอบคุงครับ
ไม่มีคนตอบเลย เอ๋หรือเราเขียนผิด จะเอาออกๆๆ >=( >=( >=(
pyInstaller
pyInstaller is the reincarnation of McMillan Installer. It can also create one-file executables.
You can get it from http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/wiki
Unzip pyInstaller in the pyinstaller_1.1 subdirectory, then do:
(You only have to do this once.)Code:python pyinstaller_1.1Configure.py
Then create the .spec file for your program:
Then pack your program:Code:python pyinstaller_1.1Makespec.py myprogram.py myprogram.spec
You program will be available in the distmyprogram subdirectory. (myprogram.exe, pythonXX.dll, MSVCR71.dll, etc.)Code:python pyinstaller_1.1Build.py myprogram.spec
You have several options, such as:
--onefile will create a single EXE file. E.g.:
Note that this EXE, when run, unpacks all files in a temporary directory, runs the unpacked program from there, then deletes all files when finished. You may or may not like this behaviour (I don't).Code:python pyinstaller_1.1Makespec.py --onfile myprogram.py myprogram.spec
--noconsole allows the creation of pure Windows executables (with no console window).
--tk is a really nice option of pyInstaller which packs all necessary files for tkinter (tcl/tk).Code:python pyinstaller_1.1Makespec.py --noconsole myprogram.py myprogram.spec
More at http://sebsauvage.net/python/snyppets/index.html
โอ้ ขอบคัณครับ ยุ่งยากเหมือนกันแหะ งึมๆ
ผมได้ฟังคำถามจากผู้ตั้งคำถาม..
ผมยังไม่ทราบชัดว่าคำตอบจะแก้ได้อย่างไร ?
แต่ความรู้ที่ผมมีอยู่คือ เคยรันโปรแกรม plone
เคยดู shortcut ของ plone พบว่าไม่ใช่ไฟล์ .exe แต่กลับเป็นสคริปต์ไพธอน
Plone เค้าใช้วิธีการเรียกโปรแกรมแบบนี้ครับ
"C:Program FilesPlone 2Pythonpythonw.exe" "C:Program FilesPlone 2XControllerwxApp.py" "C:Program FilesPlone 2Data" "C:Program FilesPlone 2Zopelibpython"
วิเคราะห์
1. แบ่งมันออกเป็นส่วน มี 4 ส่วนคือ
"C:Program FilesPlone 2Pythonpythonw.exe"
"C:Program FilesPlone 2XControllerwxApp.py"
"C:Program FilesPlone 2Data"
"C:Program FilesPlone 2Zopelibpython"
- ความรู้ที่เกิดขึ้นคือ เค้าเรียกใช้ pythonw.exe แทนที่จะใช้ python.exe ที่พวกเราเข้าใจ !!
- ส่วนไฟล์ .py ใช้เป็นอาร์กิวเมนต์ให้ pythonw.exe เท่านั้น
- ไฟล์ที่เหลือเป็นอาร์กิวเมนต์ที่จะใช้ร่วมกับ wxApp.py เราไม่ต้องสนใจ
ดังนั้น จากปัญหาของผู้ตั้งกระทู้ สามารถแก้ไขได้ดังนี้
1. ติดตั้ง python
2. ติดตั้ง wxPython
3. สร้างซอร์สโค๊ดของตัวเอง เช่น สมมติว่าบันทึกไว้ใน c:temptest.py
from wxPython.wx import *
class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL, -1, "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
4. เรียกใช้คำสั่ง (ตั้งเป็น shortcut) กำหนด target (ในช่อง property) ดังนี้
"C:devpythonpythonw.exe" "C:temptest.py"
โปรแกรมสามารถทำงานได้อย่างสมบูรณ์ ครับ !!
http://202.28.33.44
Actions : (View-Readers)
There are no names to display.