發表文章

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

鄒於萱python time.sleep()自建函數畫線段

圖片
from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 from time import * #劉任昌輸入time函數庫,取代import time 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 * 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*cos(i*self.u)) self.y.append(self.cy + self.cr*sin(i*self.u)) def draw(self): #類別的方法 for i in range( int(self.s * 1.5) - self.t): canvas.create_line(self.x[i], self.y[i], self.x[i + self.t], self.y[i + self.t], fill = self.c, width = self.w) sleep(0.5) tk.update() def show(): #畫圖 define自訂函數...

鄒於萱微軟ACCESS查詢SQL語法ASC上升DESC下降

圖片
影片說明

鄒於萱python自訂函數built-in內建函數math程式庫

圖片
 #import math  #鄒於萱輸入math函式庫 from math import * #從數學函式庫math輸入所有函式 from tkinter import * #從tkinter視窗函式庫輸入所有函式 def f(r):   #定義函數def 函數名(參數):   print("圓周率"+str(pi))#字串 + str(數字)   print("圓面積  "+str(pi*r*r))   print("圓周長  "+str(pi*r*2))   print("球表面積"+str(pi*r*r*4))   print("球體積  "+str(pi*r*r*4/3)) def g(angle):   print("正弦sin "+str(sin(angle)))   print("餘弦cos "+str(cos(angle))) def h(x,y): #最常利用在模組化   f(x)      #呼叫計算面積與體積的函式   g(y)      #呼叫計算三角函數的函式 print("鄒於萱自訂h呼叫f,g呼叫內建函數") print("數學pi, sin, cos以下式主程式\n") h(1,pi/6) #30度=pi/6, 180度=pi window = Tk()  #建構視窗 window.title("鄒於萱建構tkinter套件視窗") can = Canvas(window,width=600,height=400).pack() lab1 = Label(window, text="輸入半徑",font=('標楷體',30)).pack(side=LEFT) window.mainloop() window.mainloop()

鄒於萱ACCESS建立資料庫關聯圖

圖片

鄒於萱Python類別class函數function

圖片
VS Code多邊形編輯 VS Code程式碼 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 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 * 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*cos(i*self.u)) self.y.append(self.cy + self.cr*sin(i*self.u)) def draw(self): #類別的方法 for i in range( int(self.s * 1.5) - self.t): canvas.create_line(self.x[i], self.y[i], self.x[i + self.t], self.y[i + self.t], fill = self.c, width = self.w) def show(): #畫圖 define自訂函數 poly = Regular(cx.get(), cy.get(), cr.get(), s.get(), t.get(), c.g...

鄒於萱Python視窗GUI自訂方法canvas.delete('all') 5月 01, 2023

圖片
  #原來240單元程式碼如下 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 t = (3,4,5,6,7,8,9,10,11,12,16,20)#宣告一元組tuple(...) tk = Tk() tk.title("鄒於萱視窗使用者介面GUI") canvas = Canvas(tk, width=800, height=500) canvas.pack() def show(event): #定義由事件event(按鈕選單)呼叫的函數show cx, cy, cr = 160, 210, 150 #宣告圓中心座標cx, cy半徑cr x, y =[],[] #宣告二陣列[...] k = s.get() #取得 ge t按鈕選單的選擇變數 u = 2 * pi / k #使用模組 math 圓周率 pi for i in range(k): x.append(cx + cr*cos(i*u)) #加入陣列的元素 y.append(cy + cr*sin(i*u)) #使用模組 math 三角函數cos, sin for i in range(k-1): canvas.create_line(x[i], y[i], x[i+1], y[i+1], width=3, fill='purple') canvas.create_line(x[k-1], y[k-1], x[0], y[0], width=3, fill='purple') #可考慮增加width寬度,fill顏色 def diagonal(): cx, cy, cr = 510, 210, 200 #宣告圓中心座標cx, cy半徑cr x, y =[],[] ...