class12_pack_grid_place 放置位置
?
其中的部分運行效果圖(程序見序號1):
?
?
?
?
?
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ------------------------------------------------------------
#
# 參考資料:
# 用 python 和 tkinter 做簡單的窗口視窗 - 網易云課堂
# https://study.163.com/course/courseLearn.htm?courseId=1003216011#/learn/video?lessonId=1003650351&courseId=1003216011
#
#
# ------------------------------------------------------------
# ******************** class12_pack_grid_place 放置位置 *******************
# ******************** class12_pack_grid_place 放置位置 *******************
# =====>>>>>>內容概覽
# =====>>>>>>內容概覽
'''
# ------------------------------------------------------------
# # 1、Button 之 pack
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 2、Label 之 grid
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 3、Label 之 place 具體位置
# ------------------------------------------------------------
'''
?
# ------------------------------------------------分割線-------------------------------------------------
# ------------------------------------------------分割線-------------------------------------------------
# ------------------------------------------------分割線-------------------------------------------------
?
?
?
?
# ------------------------------------------------分割線------------------------------------------------- ''' # ------------------------------------------------------------ # # 1、Button 之 pack # ------------------------------------------------------------ ''' import tkinter as tkwindow = tk.Tk() window.title('class12_pack_grid_place 放置位置') window.geometry('400x300')tk.Button(window, text='top').pack(side='top') tk.Button(window, text='bottom').pack(side='bottom') tk.Button(window, text='left').pack(side='left') tk.Button(window, text='right').pack(side='right')window.mainloop()# ------------------------------------------------分割線------------------------------------------------- ''' # ------------------------------------------------------------ # # 2、Label 之 grid # ------------------------------------------------------------ ''' # import tkinter as tk # # window = tk.Tk() # window.title('class12_pack_grid_place 放置位置') # window.geometry('400x300') # # for x in range(4): # for y in range(3): # ''' # grid 設置 x 行, y 列 # ''' # # tk.Label(window, text=y).grid(row=x, column=y) # # # # # # Label 直接按的外部占的空間 橫:padx 縱:pady # # tk.Label(window, text=y).grid(row=x, column=y, padx=10, pady=10) # # # Label 直接按的內部占的空間 橫:ipadx 縱:ipady # tk.Label(window, text=y).grid(row=x, column=y, ipadx=10, ipady=5) # # window.mainloop()# ------------------------------------------------分割線------------------------------------------------- ''' # ------------------------------------------------------------ # # 3、Label 之 place 具體位置 # ------------------------------------------------------------ ''' # import tkinter as tk # # window = tk.Tk() # window.title('class12_pack_grid_place 放置位置') # window.geometry('400x300') # # # 設置標簽的錨點是 左上角方向,即 nw # tk.Label(window, text='place text').place(x=200, y=150, anchor='nw') # # window.mainloop()
?
?
?
?
?
?
其中的部分運行效果圖(程序見序號1):
?
轉載于:https://www.cnblogs.com/jyfootprint/p/9568162.html
總結
以上是生活随笔為你收集整理的class12_pack_grid_place 放置位置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Qt5使用QFtp,二次封装
- 下一篇: 时尚成人用品店名字,情趣用品店名大全53