發表文章

蔡禕庭tkinter視窗套件Entry工具代替OptionMenu工具

圖片
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.append(self.cy + self.cr*math.sin(i*self.u)) def drawLine(self, x0, y0, x1, y1): canvas.create_line(x0, y0, x1, y1, width = self.w, fill=self.c) def draw(self): #類別的方法 secondTime = second.get() #取得輸入的second變數,當作區域變數secondTime for i in range( int(self.s * 1.5) - self.t): self.drawLine(self.x[i], se...

蔡禕庭Python視窗GUI自訂方法canvas.delete('all')

圖片
from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定 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(): #畫圖 poly = Regular(cx.get(), cy.get(), cr.get(), s.get(), t.get(), c.get(), w.get()) polyList.append(poly) polyList[len(poly...

蔡禕庭Python視窗GUI自訂方法canvas.delete('all')

圖片
#原來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 =[],[] ...

蔡禕庭期中考V.S Code編輯Python圖形使用者介面GUI

圖片
微軟V.S Code編輯Python圖形使用者介面 Python程式碼 #蔡禕庭GUI,Tkinter程式庫 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 t = (3,4,5,6,7,8,9,10,11,12,16,20,32) #宣告一元組tuple(...) tk = Tk() tk.title("蔡禕庭圖形使用者介面GUI=Graphical Unser Interface") canvas = Canvas(tk, width=500, height=500) canvas.pack() def show(event): #定義由事件event(按鈕選單)呼叫的函數show cx, cy, cr = 210, 210, 200 #宣告圓中心座標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]) canvas.create_line(x[k-1], y[k-1], x[0], y[0]) #可考慮增加width寬度,fill顏色 def diagonal(): cx, cy, cr = 210, 210, 200 #宣告圓中心座標cx, cy半徑cr外來學繼承 inher...

蔡禕庭python,print.input,字串[::-1]

圖片
w3schools學習python vs code編寫python vs code編寫python程式碼

D11117212 蔡禕庭 JavaScript執行輸入字串

圖片
網頁介面 蔡禕庭輸入字串: 程式碼 <p>蔡禕庭輸入字串:<input type="text" len="40" id="in"></p> <p><input type="button" value="執行JavaScript" onclick="f()"></p> <p id="out"></p> <script> function f(){   var a = document.getElementById("in").value;/*取得id=in的文字*/   var b = "原字串"+a+"<br>長度是:" + a.length + ",反串是: ";   var c = "";   for (var i = 0; i < a.length; i++)     c = a.slice(i,i+1) + c ;   b = b +"<front size=7>"+ c;   document.getElementById("out").innerHTML = b; } </script> Java程式設計 import java.util.Scanner; /*開啟套件package util=utility用途,Scanner掃描器*/ /*蔡禕庭utility industry=公用事業產業,電力,自來水,效用=utility */ class MyClass { public static void main(String[] args) { String a, b=""; /*定義字串a,b */ Scanner myObj = new Scanner(System.in); /*建構掃描物件*/ Sys...

蔡禕庭Java 資料型態

圖片
/*蔡禕庭2022/10/24Java變數variable資料type型態*/ public class Main { public static void main(String[] args) { int i; /*註解java, JavaScript, CSS*/ int myNum = 5; //宣告整數integer(whole number) float myFloatNum = 5.99f; //宣告浮點數floating point number, 4 bytes=32 bits,4位元組 char myLetter = '龍'; //宣告字元character, 2 bytes=16 bits,2位元組 boolean myBool = true; //宣告布林boolean, 1 bit,1位元 String myText = "蔡禕庭"; //宣告字串String i = myLetter; //整數i=字元'龍' System.out.println(myLetter + "字碼unicode 10進位" + i); System.out.println(myNum); System.out.println(myFloatNum); System.out.println(myLetter); System.out.println(myBool); System.out.println(myText); } } 挪威 w3schools.com練習 Java code截圖