ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Python - TkInter gui 기초
    Search: Python Python 2020. 9. 9. 18:01

    Tk interface, Tk GUI toolkit.
    tkinter are available on most Unix platforms, as well as on Windows systems.

     

     

    >>>
    >>> import tkinter
    >>> tk = tkinter.Tk()
    >>> btn = tkinter.Button(tk, text="kkk")
    >>> btn.pack()
    >>> #tk.mainloop() # Our script will remain in the event loop until we close the window
    

     

    import tkinter as tk
    wd = tk.Tk()
    lb = tk.Label(wd, text="Hello Tk!")
    lb.pack()
    wd.mainloop()

     

    timer ex

    import tkinter as tk
    
    def RegCnt(label):
      RegCnt.gCnt = 0
      def CntF1():
        RegCnt.gCnt += 1
        label.config(text=str(RegCnt.gCnt))
        label.after(1000, CntF1)
      CntF1()
    def CntF2(label):
            if(not hasattr(CntF2, "gCnt")): CntF2.gCnt = 0
            CntF2.gCnt += 1
            label.config(text=str(CntF2.gCnt))
            label.after(100, CntF2, label)
    
    wd = tk.Tk()
    wd.title("Wnd1")
    fr = tk.Frame(wd)
    fr.pack()
    lb1 = tk.Label(fr, fg="blue")
    lb1.pack(side = tk.LEFT, padx = 10, pady = 10)
    RegCnt(lb1)
    lb2 = tk.Label(fr, fg="green")
    lb2.pack(side = tk.LEFT)
    lb2.after(0, CntF2, lb2)
    btn = tk.Button(wd, text='Close', width=20, command=wd.destroy)
    btn.pack()
    wd.mainloop()
    

     

    'Python' 카테고리의 다른 글

    Python 저장소 악성 코드 발견  (0) 2021.03.05
    Python - Coroutine (Python 2.4)  (0) 2020.11.07
    Python - Coroutine (Python 2.2)  (0) 2020.11.07
    Python - inspect  (0) 2020.09.09
    Python - OpenCV  (0) 2020.09.09
    Python - "python-for-android" apk  (0) 2020.09.09
    Python - exe 파일 만들기  (0) 2020.09.09
    Python - itertools  (0) 2020.09.08

    댓글