Giter VIP home page Giter VIP logo

tkshow's Introduction

tkshow

Visualize images or image sequences together with graphics command list based overlays

Code repository here: https://codeberg.org/monilophyta/tkshow

Dependencies

Usage Examples

Initializing Tkinter environment

import tkshow as tks

def main():
    """main application code goes here"""

    # ...
    # get image from from somewhere
    img = ...

    # draw some overlays
    gcl = tks.GraphicsCmdList()
    gcl.rectangle( 20, 40, 40, 60, outline="black", fill="blue" )
    gcl.marker( [20,20,40,40], [40,60,40,60], symbol="v", size = 4, fill="red", alpha=0.3 )

    # show everything in tkshow window
    tw = tks.create_window()
    tw.set_image( img )
    tw.set_gcl( gcl )

    # do something else or wait until the window is closed:
    tks.tk_main_thread().join()


if __name__ == "__main__":
    tks.tk_init( main_func=main )

Visualize image forward iterator

import tkshow as tks

def img_iter():
    while True:
        # get image from from somewhere
        img = ...

        # draw some overlays
        gcl = tks.GraphicsCmdList()
        gcl.rectangle( ... )
        gcl.marker( ... )

        yield (img,gcl)

def main():
    """main application code goes here"""
    tks.show_sequence( img_iter )

if __name__ == "__main__":
    tks.tk_init( main_func=main )

Visualize forward/backward image callable

import tkshow as tks

def get_image(idx : int):
    
    # get image with index "idx"
    img = ...

    # draw some overlays for "idx"
    gcl = tks.GraphicsCmdList()
    gcl.rectangle( ... )
    gcl.marker( ... )

    return (img,gcl)

def main():
    """main application code goes here"""
    tks.show_sequence( get_image, max_idx=<number of images>-1 )

if __name__ == "__main__":
    tks.tk_init( main_func=main )

API

Function tk_init( main_func : callable )

Should be called in the beginning of you program before a tkshow window is required.
The main_func shall then serves as main function for your entire application. tk_init closes all tkshow windows and returns after main_func has finished.

Detailed Explanation:

Tkinter always has to run within the main thread. Therefore tk_init creates a new thread which processes the callable main_func. The main thread initializes TKinter (by calling tk_init) and enters its GUI mainloop.
When main_func quits tk_init closes TKinter and returns.

Function show_sequence( seq, max_idx = None, min_idx = 0 )

...

Class GraphicsCmdList

...

tkshow's People

Contributors

charun80 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.