Tkinter 및 Tk 리소스

16714 단어 guitkpython

선적 서류 비치


  • Tk Commands
  • TkDocs Home
  • Tkinter 8.5 reference: a GUI for Python

  • Welcome to this Tk tutorial! — Tk tutorial 2020 documentation
    Tkinter Hello, World! 많은 예제/스니펫

  • 기본 위젯



  • Tkinter Dialogs — Python 3.10.7 documentation
  • tkinter.messagebox - Tkinter message prompts - Python 3.10.5 documentation


  • 캔버스

    국경 없음

    highlightthickness=0, relief='ridge', bd=0
    


    영상

    foo = PhotoImage # foo may clear by garbage collection, can assign to class to prevent
    button.image = foo
    


    빠른 참조



    위젯 유용한 방법




    The following are some of the most useful methods: 
    
    - winfo_class: a class identifying the type of widget, e.g. TButton for a themed button
    - winfo_children: a list of widgets that are the direct children of a widget in the hierarchy
    - winfo_parent: parent of the widget in the hierarchy
    - winfo_toplevel: the toplevel window containing this widget 
    - winfo_width, winfo_height: current width and height of the widget; not accurate until appears onscreen 
    - winfo_reqwidth, winfo_reqheight: the width and height the widget requests of the geometry manager (more on this shortly) 
    - winfo_x, winfo_y: the position of the top-left corner of the widget relative to its parent 
    - winfo_rootx, winfo_rooty: the position of the top-left corner of the widget relative to the entire screen the position of the top-left corner of the widget relative to its parent 
    - winfo_rootx, winfo_rooty: the position of the top-left corner of the widget relative to the entire screen 
    - winfo_vieweable: whether the widget is displayed or hidden (all its ancestors in the hierarchy must be viewable for it to be viewable)
    



    def print_hierarchy(w, depth=0):
        print('  '*depth + w.winfo_class() + ' w=' + str(w.winfo_width()) + ' h=' + str(w.winfo_height()) + ' x=' + str(w.winfo_x()) + ' y=' + str(w.winfo_y()))
        for i in w.winfo_children():
            print_hierarchy(i, depth+1)
    print_hierarchy(root)
    


    그리드 관리


  • 4.2. Other grid management methods

  • grid_forget 및 grid_remove

  • python - Is their a grid_remember()? Reversible grid_forget()? - Stack Overflow

  • grid_slaves()
    w.grid_remove()
    destroy()
    grid_forget
    w.grid()
    
    # destroy
    for widget in frame.winfo_children():
        widget.destroy()
    


    라이프 서클 ?



    업데이트(), 업데이트_idletastks()

    python - What's the difference between "update" and "update_idletasks"? - Stack Overflow

    The important thing to remember is that update blocks until all events are processed. In effect, that means you have a mainloop nested inside a mainloop. It's never a good idea to have an infinite loop inside an infinite loop.



    이벤트



    수식어

    Control
    Mod1, M1, Command
    Alt
    Mod2, M2, Option
    Shift
    Mod3, M3
    Lock
    Mod4, M4
    Extended
    Mod5, M5
    Button1, B1
    Meta, M
    Button2, B2
    Double
    Button3, B3
    Triple
    Button4, B4
    Quadruple
    Button5, B5
    


    이벤트 유형

    Activate
    Destroy
    Map
    ButtonPress, Button
    Enter
    MapRequest
    ButtonRelease
    Expose
    Motion
    Circulate
    FocusIn
    MouseWheel
    CirculateRequest
    FocusOut
    Property
    Colormap
    Gravity
    Reparent
    Configure
    KeyPress, Key
    ResizeRequest
    ConfigureRequest
    KeyRelease
    Unmap
    Create
    Leave
    Visibility
    Deactivate
    


    몇 가지 예

    label.bind('<Button-1>', left_mouse_down) 
    label.bind('<ButtonRelease-1>', left_mouse_up)
    label.bind('<Button-3>', right_mouse_down)
    label.bind('<ButtonRelease-3>', right_mouse_up)
    label.bind('<B1-Motion>', moving_mouse)
    label.bind('<Enter>', moving_into)
    label.bind('<Leave>', moving_out)
    label.bind('<FocusIn>', focus)
    label.bind('<FocusOut>', unfocus)
    <Double-Button-1>
    <MouseWheel>
    <Button-4>
    <Button-5>
    <Control-Button-1>
    <space> # lower case
    frame.bind('<Control-Shift-S>', key)
    


    54.1. Levels of binding

    bind & bind_all
    bind_all: a certain event calls a handler no matter what widget has the focus or is under the mouse
    


    event_generate는 인수(데이터)를 보낼 수 없습니다.
    Generate Event Passing Data : Tkinter

    스타일




    경유: 5.6. Relief styles

    # Create style Object
    style = Style()
    
    style.configure('TButton', font =
                   ('calibri', 20, 'bold'),
                        borderwidth = '4')
    
    # Changes will be reflected
    # by the movement of mouse.
    style.map('TButton', foreground = [('active', '! disabled', 'green')],
                         background = [('active', 'black')])
    


    패키지/위젯



    위젯


  • Welcome to ttkwidgets’s documentation! — ttkwidgets 0.12.0 documentation

  • Combobox Autocomplete « Python recipes « ActiveState Code
    - tkinter-ttk-Treeview-Simple-Demo/ComplexTreeview.py at master · r2123b/tkinter-ttk-Treeview-Simple-Demo

  • 비디오 플레이어



  • huskeee/tkvideo: Python module for playing videos (without sound) inside tkinter Label widget using Pillow and imageio 사용 imageio/imageio: Python library for reading and writing image data

  • PaulleDemon/tkVideoPlayer: Video player for tkinter.用 av (ffmpeg4) build 不成功

  • 테이블/엑셀/DataGrid


  • ragardner/tksheet: Python 3.6+ tkinter table widget for displaying tabular data
  • dmnfarrell/tkintertable: A pure Python library for adding tables to a Tkinter application
  • nbro/tktable: Wrapper library for Python of the homonymous Tk library.
  • jazzband/prettytable: Display tabular data in a visually appealing ASCII table format

  • 스타일/테마


  • COLORS – wikiPython
  • List of ttk Themes

  • PaulleDemon/tkStyleSheet: stylesheet for Tkinter
    How to make Tkinter look modern? - How to use themes in Tkinter : Python

  • 서적


  • Modern Tkinter for Busy Python Developers: Quickly learn to create great looking user interfaces for Windows, Mac and Linux using Python's standard GUI toolkit 3, Roseman, Mark, eBook - Amazon.com
  • Python GUI Programming with Tkinter [Book]

  • 흥미로운


  • py_regular_expressions/interactive_exercises at master · learnbyexample/py_regular_expressions
  • 좋은 웹페이지 즐겨찾기