官术网_书友最值得收藏!

Types of Toplevel window

Previously in this chapter, we used the following line of code:

search_toplevel.transient(root)

Let's explore what it means here. Tkinter supports the following four types of Toplevel window:

  • The main Toplevel window: This is the type we have been constructing so far.
  • The child Toplevel window: This type is independent of the root. The Toplevel child behaves independently of its root, but it gets destroyed if its parent is destroyed.
  • The transient Toplevel window: This always appears at the top of its parent, but it does not entirely grab the focus. Clicking again on the parent window allows you to interact with it. The transient window is hidden when the parent is minimized, and it is destroyed if the parent is destroyed. Compare this to what is called a modal window. A modal window grabs all the focus from the parent window and asks a user to first close the modal window before regaining access to the parent window.
  • The undecorated Toplevel window: A Toplevel window is undecorated if it does not have a window manager decoration around it. It is created by setting the overrideredirect flag to 1. An undecorated window cannot be resized or moved.

Refer to the 2.06.py code for a demonstration of all four types of Toplevel window.

This concludes our second iteration. Congratulations! We have completed coding the Select All and Find Text functionality into our program.

More importantly, you have been introduced to indexing and tagging—two very powerful concepts associated with many Tkinter widgets. You will find yourself using these two concepts all the time in your projects.

We also explored the four types of Toplevel window and the use cases for each of them.

主站蜘蛛池模板: 桂阳县| 宁波市| 开原市| 建昌县| 台湾省| 监利县| 察哈| 胶南市| 谷城县| 福海县| 长丰县| 济阳县| 耒阳市| 丹寨县| 青铜峡市| 竹溪县| 金阳县| 临汾市| 武夷山市| 田林县| 筠连县| 扎囊县| 马尔康县| 白城市| 珲春市| 太康县| 奉新县| 井冈山市| 金华市| 湖口县| 淮南市| 河曲县| 海淀区| 固原市| 古蔺县| 中牟县| 澄江县| 浦北县| 澎湖县| 大姚县| 阜宁县|