gtk - Python Gtk3 executable -


i started using gtk3 python. have 1 question: how make executable windows file gtk3 python source using pyinstaller, cx_freeze or py2exe? tried lot of answers stack overflow , many other web pages, none worked. tried make pyinstaller (i think easiest way) , source code looks like:

import gi gi.require_version('gtk', '3.0') gi.repository import gtk  class buttonwindow(gtk.window):      def __init__(self):         gtk.window.__init__(self, title="button demo")         self.set_border_width(10)          hbox = gtk.box(spacing=6)         self.add(hbox)          button = gtk.button.new_with_label("click me")         button.connect("clicked", self.on_click_me_clicked)         hbox.pack_start(button, true, true, 0)          button = gtk.button.new_with_mnemonic("_open")         button.connect("clicked", self.on_open_clicked)         hbox.pack_start(button, true, true, 0)          button = gtk.button.new_with_mnemonic("_close")         button.connect("clicked", self.on_close_clicked)         hbox.pack_start(button, true, true, 0)      def on_click_me_clicked(self, button):         print("\"click me\" button clicked")      def on_open_clicked(self, button):         print("\"open\" button clicked")      def on_close_clicked(self, button):         print("closing application")         gtk.main_quit()  win = buttonwindow() win.connect("delete-event", gtk.main_quit) win.show_all() gtk.main() 

but following error:

traceback (most recent call last):   file "<string>", line 2, in <module>   file "c:\python34\lib\gi\__init__.py", line 102, in require_version     raise valueerror('namespace %s not available' % namespace) valueerror: namespace gtk not available gtk returned -1 

what shall or can please explain me how make executable in py2exe or cx_freeze? please me! thanks!

install cx_freeze

you should able pip install cx_freeze on windows. or go there official website http://cx-freeze.sourceforge.net/


create setup.py file in same folder program.

setup.py:

import cx_freeze  executables = [cx_freeze.executable("file.py")]  cx_freeze.setup(     name="whateveryouwanttonameit",     options={"build_exe": {"packages":["gi"]}},     executables = executables      ) 

open command prompt in file location of program. on windows should have shift + left-click folder , click open command window here. once opens type python setup.py build. if error stating python not in path, give full path. example, on windows, python 3.4, do:

c:/python34/python setup.py build 

if you're on mac, do:

python setup.py bdist_dmg 

once it's done come tell me if woks. if doesn't work give me errror message , i'll fix problem. luck!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -