M
M
Maxim Britvin2016-08-26 13:28:10
Python
Maxim Britvin, 2016-08-26 13:28:10

How to compile multiple Python files?

Good day!
I am writing now a simple application on PyQt4, consisting of 3 windows.
From the main window, by pressing the corresponding button, one of the other two windows is called. The code for each window is in different .py files.
When creating an exe via cx_Freeze, only the main window is shown, clicking on the buttons to call other windows does nothing. Examples on the net describe how to make an exe from one script file, but I have 3 of them. How to write setup.py correctly so that the program works correctly?
Python: 3.4
PyQt 4.8.3
Win7 32-bit
If you need to post something else - write. I really want to solve this problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Britvin, 2016-08-30
@DarkwingDuck48

In principle, I figured out cx_freeze, as always, I needed to read the documentation a little more carefully. It was necessary to add this thing when writing setup.py:

executables = [
    Executable('win1.py'),
    Executable('win2.py'),
    Executable('win3.py')
]

and pass it to the setup() function:
setup(name="name",
      version="0.0.1",
      description="lalala",
      options={"build_exe": build_exe_options},
      executables=executables)

As a result, 3 .exe files are obtained, and from the main window, as intended, a transition is made to the other 2. Of course, there is a more elegant solution, but I have not found it yet.
UPD.
If you do not like the way of creating separate .exe files, then here is an alternative for you.
change executables from what is written at the top to:
executables = [
    Executable('win1.py', includes=['win2.py', 'win3.py'])

Now we have one wonderful exe in which everything works))))

X
xSkyFoXx, 2016-08-27
@xSkyFoXx

For a multi-window, "multi-file" application, I used PyInstaller . Carefully check all paths and namespaces, the availability of libraries in these namespaces, and try using PyInstaller.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question