No announcement yet.

[Python] Compiled EXE output different from .pyw script

  • Filter
  • Time
  • Show
Clear All
new posts

  • [Python] Compiled EXE output different from .pyw script

    Hi all.

    Trying to write a really basic program in Python for compiling to exe.

    Basically, when the script is compiled to a 32-bit exe, it does't render properly (see left, right is the correct one). But when compiled to a 64-bit exe, the resulting program renders perfectly.

    Both compiled using py2exe in python 3.4 and python 3.4-64 respectively. Code is at bottom of thread. Seemingly the 32-bit exe is ignoring the app.geometry command?

    I've tried other compilers such as cx_Freeze, none of them spit out a functional exe.


    from tkinter import *
    from tkinter.messagebox import *
    from tkinter import ttk
    import subprocess
    from subprocess import *
    import os
    import sys
    app = Tk()
    app.geometry ("180x190")
    app.iconbitmap(r'x:\program files\macrium\py.ico')
    app.wm_title("Power Options")
    app.update_idletasks()x = (app.winfo_screenwidth() - app.winfo_reqwidth()) / 2
    y = (app.winfo_screenheight() - app.winfo_reqheight()) / 2
    app.geometry("+%d+%d" % (x, y))
    def shutdown():
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW'cmd /c "x:\\program files\\macrium\\wpeshutdown.bat\"', startupinfo=si)
    def reboot():
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW'cmd /c "x:\\program files\\macrium\\wpereboot.bat\"', startupinfo=si)
    def reopen():
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW'cmd /c "x:\\program files\\macrium\\fileexplorer.bat\"', startupinfo=si)
    photo=PhotoImage (file="x:\program files\macrium\power.gif")
    label = Label(image=photo)
    label.image = photo
    Button(text='Shut down', font = "Arial 9 bold",fg='black', bg='sky blue', command=shutdown).pack(padx=10,pady=3,ipadx=39.5)
    Button(text='Reboot', font = "Arial 9 bold",fg='black', bg='sky blue', command=reboot).pack(padx=10,pady=3,ipadx=49.5)
    Button(text='Reopen File Explorer', font = "Arial 9 bold",fg='black', bg='sky blue', command=reopen).pack(padx=10,pady=3,ipadx=12)
    Last edited by spleenharvester; 14-07-16, 17:35.
    Dell Vostro 3560 | Intel Core i5-3380M | 8GB RAM | HD4000 graphics | Sandisk SSDPlus 120GB | Windows 10 Pro

  • #2
    Nevermind, finally got cx_Freeze to work, the exe produced by that is working fine.
    Dell Vostro 3560 | Intel Core i5-3380M | 8GB RAM | HD4000 graphics | Sandisk SSDPlus 120GB | Windows 10 Pro


    • #3
      You may run into all sorts of weird edge cases with different Python compilers since they'll all have subtly different compatibility. If you need a portable EXE produced, then Python might not be the best language to code in.