Giter Club home page Giter Club logo

pygubu-tcpclient-example's Introduction

pygubu-tcpclient-example

This is an example application based on the python module pygubu.

Tcpclientk is two things: a TCP client and a GUI based on python3, pygubu and Tkinter.

Previously, writing portable simple GUIs was a difficult task, now thanks to pygubu, almost everybody can do it.

Anyway, pygubu deserves more example code, this is why I've started to write this example.

Packaging this example for Windows with pyinstaller

This procedure was tested on Windows 7 and Python 3.6.1, it is still experimental but it works:

  1. In Windows, install python3

  2. Open a command shell and type:

    pip install pygubu

  3. Then, type:

    pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

  4. In the pygubu-tcpclient-example directory, type:

    pyi-makespec --onefile

    This will produce a file called onefile.spec

  5. Edit the .spec file to add some more data tuples, like this:

    datas=[('tcpclientk.png', '.'), ('tcpclientk.ui','.'), ('tcpclientk_about_dialog.ui', '.')],

    These files will be automatically copied to the bundle directory. There is some code in tcpclientk to detect if it is run from a bundle and adapt the PATH accordingly, see NOTES below

  6. Run pyinsaller onefile.spec, this will produce one single .exefile under the dist directory. This file contains all dependencies that are needed to run the example

NOTES:

  • I needed to install a development version of pyinstaller, because I have had problems with the latest release. But maybe you don't need to do that anymore since these changes have been added to the latest release?

  • Add from pygubu.builder import ttkstdwidgets to your source to avoid the error: ModuleNotFoundError: No module named 'pygubu.builder.ttkstdwidgets'

  • To detect if the code runs in a bundle or not:

import sys
FILE_PATH = None  # To be set in __main__

if getattr( sys, 'frozen', False ) :
    # running in a bundle
    bundle_dir = sys._MEIPASS
else :
    # running live in a normal Pyton environment
    bundle_dir = os.path.dirname(os.path.abspath(__file__))

FILE_PATH = bundle_dir

# Then refer to all files from datas like this from your code:
os.path.join(FILE_PATH, "tcpclientk.ui"), etc...

pygubu-tcpclient-example's People

Contributors

fabricecoulon avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.