学習Python -中級コース:17日、Tkinter -高速かつ簡単にGUIアプリケーションを作成する方法です.



今日、我々はGUIでGUIから始めます!
Pythonには、' tkinter 'として知られているGUI処理用の組み込みパッケージがあります.このGUIツールキットは、Windows OSと同様にMacOSを含むほとんどのUnixプラットフォームで利用可能です.

Note- Tkinter provides a powerful object-oriented interface to the Tk-GUI toolkit. GUI requires a lot of OOP stuff. OOP python is still not covered in this course, and would be subsequently covered after GUI is completed. So till that time, don't worry if OOP things are not 100% clear. While learning GUI it is important to understand how to design things rather than how they are implemented by python. Learning OOP concepts will throw light upon how they are implemented and things will start getting clearer and clearer.


But what is Tkinter?

The Tkinter package is actually an interface to the GUI toolkit, called as Tk-GUI. However, Tkinter is not the only GUI Programming toolkit for Python. It is one of the most common and easy to learn interface. It is the only framework that’s built into the Python standard library. Other notable interfaces are wxPython and JPython (Jython. wxPython is an open-source Python interface for wxWindows, while JPython is a Python port for Java. JPython boasts of giving Python scripts a seamless access to Java class libraries on the local machine. Other alternatives include- PyQt, PySide, Pygame, Pyglet, and PyGTK. You can check them out at the wiki links provided.


tkinterの名前はTkインターフェイスです.TkinterはFredrik Lundhによって書かれました.それは、Aの下でリリースされるフリーソフトウェアですPython license .
Tkinterの利点
  • Tkinter軽量で、他よりも使いやすいです.
  • Tkinterはクロスプラットフォームなので、同じコードがすべてのシステムで動作します( Windows , MacOS , Linux )
  • さらに、Tkinter要素は、ネイティブのオペレーティングシステム要素を使用して構築されているので、システムへの容易なカモフラージュ
  • Tkinterの欠点
  • Tkinterは時代遅れです.期限切れは正しい言葉かもしれない.UIは古い、またはむしろ古代に見える.あなたは良い探して光沢のあるアプリケーションを構築する場合は、Tkinterはあなたのためではありません!
  • Tkinterは、Pythonで勉強し、GUIを探索するのに理想的です.

    Tkinterが適切にインストールされているかどうかを調べます.
    Tkinterがシステムに適切にインストールされているか、どのバージョンがインストールされているかをチェックする方法を見てみましょう.
    コマンドを入力して行うことができますpython -m tkinter コマンドラインで.次のように2つのボタンの小さな箱が開きます.箱の中で、Tcl/Tkのバージョンが示されます.


    Didn't work for you? Well it didn't work for me either.


    C:\Users\aatma>python -m tkinter
    Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
    
    私のデバイスではpy キーワードはPythonを開きますpy -m tkinter 私のために働いた.

    Common mistake-- We need to type this in the command prompt, and not the python command line!


    これはうまくいきません-
    C:\Users\aatma>py
    Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> python -m tkinter
      File "<stdin>", line 1
        python -m tkinter
                  ^
    SyntaxError: invalid syntax
    
    ボタンをクリックすると、クリックMeが四角形のブラケットで囲まれて表示されます.

    それをクリックするたびに、追加のペアのペアは、ボタンをクリックしてテキストを囲む


    ボタンをクリックすると、ボックスが閉じます.
    それはすべてこの部分です.興奮?あなたも実現する前に、我々はこれをはるかに強力でエキサイティングなアプリケーションを作ることになります.だから次の部分のためにチューニングLearning Python コース.
    🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
    更新のためにGithubの上で私に続いてください...