0

I created a pretty large Python project with multiple GUIs. I was thinking of creating an executable from it using py2exe, which automatically includes all packages you're using and it formats the files so that imports and everything will run fine.

However, there are lines in my code where I load the UI from a path:

self.ui = uic.loadUi('C:/peter/myfolder/stuffs/sub_ui/ManualBalanceUI.ui', self.window)

Where ManualBalanceUI.ui is the file that Qt Designer creates. I want to write it in a way that it will always open for any user. How should I change that line of code so that it will always be able to load ManualBalanceUI.ui, which is located in the sub_ui folder in the main package? Is there any way I can change the base path to something like os.getcwd(), and then do something like

self.ui = uic.loadUi(os.getcwd() + 'sub_ui/ManualBalanceUI.ui', self.window)

What would be the best way to approach this problem? Thanks

Peter Wang
  • 1,808
  • 1
  • 11
  • 28
  • Be aware of licence under which py2exe or analogues are released: when you make a solid executable or a directory-based distribution, you in fact statically link to your py-to-exe provider modules. – scrutari Jul 15 '16 at 14:23
  • What implications does that have for me? Sorry I've never used py2exe before – Peter Wang Jul 15 '16 at 14:47
  • The `py2exe` seems to be released under MIT licence which is quite good (you may use https://tldrlegal.com/ for quick reference). Problems arise when you want to use something under GPL-like licence. See this discussion for example http://programmers.stackexchange.com/questions/179084. – scrutari Jul 16 '16 at 09:04

1 Answers1

0

See this discussion How to make a Python script standalone executable to run without ANY dependency?.

Community
  • 1
  • 1
scrutari
  • 1,378
  • 2
  • 17
  • 33