2022年11月16日 星期三

Python GUI EX1.5 , 1.6

 # ch1_5.py

from tkinter import *


root = Tk()

w = 300     # 視窗寬

h = 160     # 視窗高

x = 400     # 視窗左上角x軸位置

y = 200     # 視窗左上角Y軸位置

root.geometry("%dx%d+%d+%d" % (w,h,x,y))

root.mainloop()




# ch1_6.py

from tkinter import *


root = Tk()

screenWidth = root.winfo_screenwidth()      # 螢幕寬度

screenHeight = root.winfo_screenheight()    # 螢幕高度

w = 300                                     # 視窗寬

h = 160                                     # 視窗高

x = (screenWidth - w) / 2                   # 視窗左上角x軸位置

y = (screenHeight - h ) / 2                 # 視窗左上角Y軸位置

root.geometry("%dx%d+%d+%d" % (w,h,x,y))

root.mainloop()





沒有留言:

張貼留言

  清除項目編譯快取 執行 flutter clean 重新取得套件依賴 執行 flutter pub get 完整重新編譯並執行 flutter run 1. 新增專案套件 (pubspec.yaml) 在 Flutter 專案根目錄下的 pubspec.yaml 中,新增 ...