發表文章

目前顯示的是 6月, 2023的文章

蔡碧桂tkinter視窗函式庫Entry工具widget

圖片
w3schools類別class class Person: #定義類別class稱為Person def __init__(self, name, age): #起始屬性函數一律稱__init__ self.name = name self.age = age def myfunc(self): print("嗐,我的\n名字是" + self.name) #字串中\n換列 print("嗐,我的") print("名字是" + self.name) p1 = Person("蔡碧桂", 36) #利用類別建構物件(實例) p1.myfunc() 多邊形類別class from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 import math #從函式庫 math 輸入所有 * 方法 from time import * from random import * class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定必然 def __init__ initiate發起 self.cx, self.cy, self.cr = cx, cy, cr #取得中心座標cx, cy, 半徑cr self.s, self.t = s, t #取得邊角數目s,t尖銳程度,取代原來的k = s.get() self.c, self.w = c, w #取得顏色c,寬度w self.u = 2 * math.pi / self.s #使用模組 math 圓周率 pi self.x, self.y = [], [] for i in range( int(self.s * 1.5)): self.x.append(self.cx + self.cr*math.cos(i*self.u)) self.y.appen...

蔡碧桂類別,必須有 兩底線init兩底線的起始initiate函數

圖片
w3schools練習class class Person: #定義類別class稱為person def __init__(self, name, age):#起始屬性函數一律稱_init_ self.name = name self.age = age def myfunc(self): print("靠!我的") print("名字是" + self.name) print("靠!我的\n名字是" + self.name) #字串中\n換列 p1 = Person("蔡碧桂", 36) p1.myfunc() print("印出p1.name: " + p1.name) w3schools練習class截圖 VS code練習class Stars from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 import math #從函式庫 math 輸入所有 * 方法 from time import * from random import * class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定必然 def __init__ initiate發起 self.cx, self.cy, self.cr = cx, cy, cr #取得中心座標cx, cy, 半徑cr self.s, self.t = s, t #取得邊角數目s,t尖銳程度,取代原來的k = s.get() self.c, self.w = c, w #取得顏色c,寬度w self.u = 2 * math.pi / self.s #使用模組 math 圓周率 pi self.x, self.y = [], [] for i in range( int(self.s * 1.5)): self.x.append(self.cx + se...