Skip to main content

Make Tkinter apps in an easy way using JSON.

Project description

EasyTk

Downloads

Create Tkinter applications with help of JSON!

test = EasyTkObject()
test.create_root()
test.open_file("json/test.json")
test.reading_from_json()
test.start_root()

Installation

If you don't have tkinter installed in your environment,install it:

pip install tkintertable

then install this package.

pip install easy-tk

Usage

JSON strucuture:
{
...,
  "Frame1": {
    "layout": "grid",
    "methods": ["confirm_click","add_click","set.."],
    "master": "FrameContainer",
    "config": {"config_key":"config_value","config_key":"var:something"},
    "grid": {"sticky": "NSEW"},
    "newRow": false
  },...
}

You start with name of widget,for example: Frame1:{...},"LabelUsername":{...},"ButtonConfirm":{...},...

layout - you can use grid or pack or place "layout":"grid" or "layout:"pack"

methods - inside this list you can include names of methods that you will use,this is explained in Python part

master - to which master does this widget belong,be aware of which layout manager is used and that master exists

config - for example: "config":{"text":"TEST"} or if you imported your variables then just call "config":{"some_key":"var:something"}

grid - if you decided to use grid as layout then fill this with proper data,you don't have to include row and column,for example: "Button1":{...},Button2":{...},Button3":{..., "newRow":true },

Button1 is on row=0,column=0,Button2 is on row=0,column=1 and Button3 is on _row=1_,column=0. But you can also include row and column if you want. With that in mind,next column is from place where you /didn't/ specified column.

pack - if layout is pack then include here attributes,or leave it blank.

If you use pack then it's necessary to include it in JSON object even if you don't have any value. For example:

...,
"Canvas": {
    "master": "Frame0",
    "layout": "pack",
    "pack": {"side":"left", "fill":"both", "expand":true},
    "config": {},
    "methods": [1]
  },
"Scrollbar": {
    "master": "Frame0",
    "layout": "pack",
    "pack": {},
    "config": {"orient": "vertical"},
    "methods": [2]
},
...

Both widgets work. And same applies to grid.

newRow - if layout is grid then use boolean value.

Python
from easy_tk import EasyTkObject

This class has all methods you need for "converting" JSON to Tkinter app. EasyTkObject mainly use EasyTk methods but in different way. You can override them.

  • create_root()
  • get(name,obj=True)- getting object of one widget if obj were False then you will get EasyTkChild object
  • import_methods(methods={}) - put all your methods in dict and then just call that method in json list. ...,"methods":["on_check_btn","set_style_btns","exit_app",...]
  • import_modules(modules={}) - put all your modules here,you can include your own widgets,default is this ["Frame","Entry","Button","Label","Separator","Radiobutton","Canvas","Scrollbar"],you can extend it
  • import_variables(variables={}) - include only variables that you need for config,call them with "var:some_key"
  • open_file(file) - setting your json file EasyTk
  • reading_from_json() - adding every widget to screen,applying all config values,calling all methods you included
  • add_just_one(file,key) - adding just one widget from json(again be sure that master there exist),for example add_just_one("json/test.json","Canvas5")
  • easy_factory() - factory for EasyTk object
Other info

On github you can find helpers folder,there is shortcut for adding scrollbar in your entire window. In future I will add more of them that you can use.

Examples of usage

football-video-editor-python

Changes

1.0.7.1 added support for older version in creating master

1.0.6.4 added methods for removing widgets and for changing keys in json before displaying widgets on screen

1.0.6.3 fixed modules error while loading one widget

1.0.6.2 - fixed using variables inside json for grid/pack

1.0.6 - you don't have to specify all_widgets parameter in your methods that are connected with json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_tk-1.0.7.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

easy_tk-1.0.7.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file easy_tk-1.0.7.1.tar.gz.

File metadata

  • Download URL: easy_tk-1.0.7.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for easy_tk-1.0.7.1.tar.gz
Algorithm Hash digest
SHA256 c0ef26a7c1fe2b1556120f349418fcc3afce76f0ffea443ebcc121f56a75f0ac
MD5 e1f13492fc21334bf1c6812d0ec72cd2
BLAKE2b-256 0327c4abef77c6bd709c078218683300baa8551a511f40a26fc8b30ea7cc7d0a

See more details on using hashes here.

File details

Details for the file easy_tk-1.0.7.1-py3-none-any.whl.

File metadata

  • Download URL: easy_tk-1.0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for easy_tk-1.0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27b8aceef6f228183d8fc27aa1768fbc493ff1e5f87efa82cd239f0d2bf1e7d6
MD5 12800d7beb25a1fd761b47598cddc2c2
BLAKE2b-256 c48b0aca2a524cc198ca2015d737eb98a9702bcdf31fe6c0d3da017d68ca3df0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page