For an example I have created welcomeGUI.py file with has a simple GUI as follows using Tkinter.
from Tkinter import *
import ttk
class Application():
def __init__(self, master):
frame = Create_widgets(master)
frame.pack()
class Create_widgets(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.toplabel = Label(master, text="Welcome!", font=('cambria', 20, 'bold'),
fg="white", bg="Midnight Blue")
self.toplabel.pack(fill=X, ipady=100)
statuslabel = Label(master, bg="Midnight Blue")
statuslabel.pack(fill=X)
self.midlabel = Label(master, text="Device ready,connect a flash drive to continue...",
font=('Ubuntu-L', 12), fg= "white", bg="Midnight Blue", anchor="n")
self.midlabel.pack(fill=X, ipady=5)
bottomlabel = Label(master, bg="Gainsboro")
bottomlabel.pack(side=BOTTOM, fill=X)
button1 = ttk.Button(bottomlabel, text="Close")
button1.pack(side=BOTTOM)
#**** Main ****
root = Tk()
root.title("Projector Plus")
root.configure(bg="Midnight Blue")
root.minsize(550, 550)
pro = Application(root)
root.mainloop()
Then I need to create this file that can be installed on Ubuntu(To create an executable file on Ubuntu). In Windows this is done very easily with .exe file(Using cx-Freeze). Really I have no idea about the file system of Ubuntu and shell files.
Please help me to get an idea about this problem. I don't have any idea how to enter this matter.
-
stackoverflow.com/questions/12089254/… This link could be of assistance.lpapez– lpapez2015年05月10日 09:41:56 +00:00Commented May 10, 2015 at 9:41
-
do you mean including other libs or is it just Tkinter?Padraic Cunningham– Padraic Cunningham2015年05月10日 10:18:36 +00:00Commented May 10, 2015 at 10:18
-
You can also use PyInstaller - it is crossplatformVictor– Victor2015年05月10日 10:40:22 +00:00Commented May 10, 2015 at 10:40
-
@PadraicCunningham Yep, including other libs in OpenCV? How do I bundle them in to one executable file?RYJ– RYJ2015年05月10日 10:45:59 +00:00Commented May 10, 2015 at 10:45
-
Having opencv as a dependency won't be easy, it has dependencies of it's own.Padraic Cunningham– Padraic Cunningham2015年05月10日 11:05:43 +00:00Commented May 10, 2015 at 11:05
2 Answers 2
Basically, to make a file executable in Unix systems, you just have to do one thing: allow it to be executed (very surprising ;) ). To do it, you must use the chmod command as follows: chmod +x youfile.py. The +x add the right to be executed.
Now, your system will allow you to execute the script, but for now it's just a simple text file... Ubuntu doesn't know that he must use the python command to run it, so you'll have undermined comportment. To resolve this, we use the sha-bang line (for more information, see the wikipedia page): at the first line of your script, you must write #! program_to_use, in your case it's python. Generally, we take benefit of the env variables, and use #! /usr/bin/env python, but you can also choose yourself the version of python you want, doing #! /usr/bin/pythonX.X where X.X is the version of python.
3 Comments
1 - Add on the top of your file this line:
#!/bin/env python (This may differ depending on your ENV variable)
2 - make your file executable by:
a - In Unix system, run the following command:
`chmod +x myfile.py`
b - In Windows System, you can use the utility py2exe found on http://www.py2exe.org/
more on this can be found at:
https://docs.python.org/2/faq/windows.html#how-do-i-make-an-executable-from-a-python-script
2 Comments
Explore related questions
See similar questions with these tags.