Bartłomiej 'furas' Burek
furas.pl
# prywatne notatki - Python, Linux, Machine Learning, etc.

    Tkinter PandasTable Examples [GB]

    It is few examples how to use pandastable to create table in tkinter with data from pandas dataframe.

    Installation

    pip install pandastable
    

    Dependencies

    • numpy
    • pandas
    • matplotlib
    • numexpr

    Optional dependencies

    • statsmodels
    • seaborn (requires scipy)

    Doc: https://pandastable.readthedocs.io/

    Standard Examples

    In documentation you can find few examples

    Minimal Example

    It …

    [ more | więcej ]

    Tkinter Example: use Checkbutton to start and stop timer [GB]

    When you select Checkbutton then it start timer (but without displayint it).

    When you deselect Checkbutton then it stop timer and display time cumulated with previous time

    import tkinter as tk
    import time
    
    # --- functions ---
    
    def func():
        global total
        global time_start
    
        if cb_var.get():
            time_start = time.time()
        else:
            total += (time.time …
    [ more | więcej ]

    Tkinter Example: use many Checkbuttons with IntVar or StringVars [GB]

    It uses dictionary to keep many IntVar which are used with Checkbutton

    import tkinter as tk
    
    # --- functions ---
    
    def confirm():
        for key, item in all_int_vars.items():
            if item.get() == 1:
                print(key)
    
    # --- main ---
    
    items = ['pizza', 'breadsticks', 'wings', 'CocaCola', 'brownie'] 
    
    root = tk.Tk()
    
    all_int_vars = {item:tk.IntVar() for item in items}
    
    for …
    [ more | więcej ]

    Tkinter Example: use pynput keyboard listener [GB]

    In documentation you can see example for pynput Monitoring The keyboard

    with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
        listener.join()
    

    which blocks code but you can put code between lines

    with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
    
        # ... your code ...
    
        listener.join()
    

    or you can run it …

    [ more | więcej ]

    Tkinter Przykład: użycie Checkbutton do uruchomienia i zatrzymania timera

    Gdy zaznaczysz Checkbutton wtedy timer zostanie uruchomiony (bez wyświetlania czasu).

    Gdy oznaczysz Checkbutton wtedy timer zostanie zatrzymany i wyświetlony czas zsumowany z porzedmini czasmi.

    import tkinter as tk
    import time
    
    # --- functions ---
    
    def func():
        global total
        global time_start
    
        if cb_var.get():
            time_start = time.time()
        else:
            total += (time.time() - time_start)
            label['text …
    [ more | więcej ]

    Tkinter Przykład: użycie wielu Checkbutton wraz z IntVar lub StringVar

    Przykład wykorzystuje słownik (dictionary) do przechowywania wielu IntVar, które są przypisane do Checkbutton

    import tkinter as tk
    
    # --- functions ---
    
    def confirm():
        for key, item in all_int_vars.items():
            if item.get() == 1:
                print(key)
    
    # --- main ---
    
    items = ['pizza', 'breadsticks', 'wings', 'CocaCola', 'brownie'] 
    
    root = tk.Tk()
    
    all_int_vars = {item:tk.IntVar() for item in items …
    [ more | więcej ]

« Strona: 2 / 5 »

Książki: python-dla-kazdego-podstawy-programowania python-wprowadzenie python-leksykon-kieszonkowy python-receptury python-programuj-szybko-i-wydajnie python-projekty-do-wykorzystania black-hat-python-jezyk-python-dla-hackerow-i-pentesterow efektywny-python-59-sposobow-na-lepszy-kod tdd-w-praktyce-niezawodny-kod-w-jezyku-python aplikacje-internetowe-z-django-najlepsze-receptury