Sabtu, 09 Mei 2026
Jumat, 24 April 2026
Chinese song
https://www.youtube.com/watch?v=QHqkw2Wmb6Q&list=RDQHqkw2Wmb6Q&start_radio=1
https://www.youtube.com/watch?v=EGwq3IfRbJ8&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=2
https://www.youtube.com/watch?v=bmAd4__qiG8&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=3
https://www.youtube.com/watch?v=nOGeAPnL5N8&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=4
https://www.youtube.com/watch?v=AsifNjTXVzA&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=5
https://www.youtube.com/watch?v=WdT5k0-pj6Y&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=6
https://www.youtube.com/watch?v=RUqzxvY-viE&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=9
https://www.youtube.com/watch?v=bqJJnRie9Yc&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=10
https://www.youtube.com/watch?v=2bvb-Ql8Pb4&list=PLjS1q0CGIyvx9NYzN2Xu_IJuHDWFq9GaL&index=13
https://www.youtube.com/watch?v=4TiE7baWeLM&list=RD4TiE7baWeLM&start_radio=1
https://www.youtube.com/watch?v=Z-5XYc-sL1U&list=RDEMB7vN_Pv6Z0HEaJkz2In01g&index=4
https://www.youtube.com/watch?v=LUBSTdjthnc&list=RDEMB7vN_Pv6Z0HEaJkz2In01g&index=7
https://www.youtube.com/watch?v=JNd3l_WgTh0&list=RDEMB7vN_Pv6Z0HEaJkz2In01g&index=8
https://www.youtube.com/watch?v=ATPulcGQ2SE&list=RDEMB7vN_Pv6Z0HEaJkz2In01g&index=15
https://www.youtube.com/watch?v=Ra0o1lxekVQ&list=RDEMB7vN_Pv6Z0HEaJkz2In01g&index=23
https://www.youtube.com/watch?v=uEzMuh7cKf0&list=RDEMB7vN_Pv6Z0HEaJkz2In01g&index=37
Sabtu, 18 April 2026
Python XML 4
Python XML 3
import tkinter as tk
from tkinter import ttk, messagebox, filedialog
import xml.etree.ElementTree as ET
import os
def load_xml_data(file_path):
"""Load and parse XML file, returning headers and rows."""
try:
tree = ET.parse(file_path)
root = tree.getroot()
# Assume each child of root is a row, and its sub-elements are columns
rows = []
headers = set()
for row_elem in root:
row_data = {}
for col_elem in row_elem:
headers.add(col_elem.tag)
row_data[col_elem.tag] = col_elem.text or ""
rows.append(row_data)
headers = sorted(headers) # Keep consistent order
return headers, rows
except ET.ParseError:
messagebox.showerror("XML Error", "Invalid XML format.")
return [], []
except FileNotFoundError:
messagebox.showerror("File Error", "File not found.")
return [], []
except Exception as e:
messagebox.showerror("Error", str(e))
return [], []
def display_table(headers, rows):
"""Display data in a Tkinter Treeview table."""
# Clear old table if exists
for widget in table_frame.winfo_children():
widget.destroy()
if not headers or not rows:
tk.Label(table_frame, text="No data to display").pack()
return
# Create Treeview
tree = ttk.Treeview(table_frame, columns=headers, show="headings")
tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
# Add column headings
for header in headers:
tree.heading(header, text=header)
tree.column(header, width=120, anchor="center")
# Insert rows
for row in rows:
tree.insert("", tk.END, values=[row.get(h, "") for h in headers])
# Add scrollbar
scrollbar = ttk.Scrollbar(table_frame, orient="vertical", command=tree.yview)
tree.configure(yscroll=scrollbar.set)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
def open_file():
"""Open file dialog and load XML data."""
file_path = filedialog.askopenfilename(
title="Select XML File",
filetypes=[("XML Files", "*.xml"), ("All Files", "*.*")]
)
if file_path:
headers, rows = load_xml_data(file_path)
display_table(headers, rows)
# --- Tkinter GUI Setup ---
root = tk.Tk()
root.title("XML Data Table Viewer")
root.geometry("700x400")
# Menu
menu_bar = tk.Menu(root)
file_menu = tk.Menu(menu_bar, tearoff=0)
file_menu.add_command(label="Open XML", command=open_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=root.quit)
menu_bar.add_cascade(label="File", menu=file_menu)
root.config(menu=menu_bar)
# Table Frame
table_frame = tk.Frame(root)
table_frame.pack(fill=tk.BOTH, expand=True)
# Start GUI
root.mainloop()
Python XML 2
Python XML 1
import tkinter as tk
from tkinter import ttk, messagebox
import xml.etree.ElementTree as ET
import os
# ---------------------------
# Load XML Data Function
# ---------------------------
def load_xml_data(file_path):
"""Load and parse XML data into a list of dictionaries."""
if not os.path.exists(file_path):
messagebox.showerror("Error", f"File not found: {file_path}")
return []
try:
tree = ET.parse(file_path)
root = tree.getroot()
data_list = []
for item in root.findall("record"):
record_data = {
"ID": item.findtext("id", "").strip(),
"Name": item.findtext("name", "").strip(),
"Age": item.findtext("age", "").strip(),
"City": item.findtext("city", "").strip()
}
data_list.append(record_data)
return data_list
except ET.ParseError as e:
messagebox.showerror("XML Parse Error", str(e))
return []
# ---------------------------
# Search Function
# ---------------------------
def search_data():
"""Filter table based on search query."""
query = search_var.get().lower().strip()
table.delete(*table.get_children()) # Clear table
for row in xml_data:
if query in row["Name"].lower() or query in row["City"].lower():
table.insert("", tk.END, values=(row["ID"], row["Name"], row["Age"], row["City"]))
# ---------------------------
# Main Tkinter Window
# ---------------------------
root = tk.Tk()
root.title("XML Search & Display")
root.geometry("600x400")
# Search Input
search_var = tk.StringVar()
tk.Label(root, text="Search:").pack(pady=5)
search_entry = tk.Entry(root, textvariable=search_var, width=40)
search_entry.pack(pady=5)
tk.Button(root, text="Search", command=search_data).pack(pady=5)
# Table (Treeview)
columns = ("ID", "Name", "Age", "City")
table = ttk.Treeview(root, columns=columns, show="headings")
for col in columns:
table.heading(col, text=col)
table.column(col, width=100)
table.pack(fill=tk.BOTH, expand=True, pady=10)
# Load XML Data
xml_file = "data.xml" # Change to your XML file path
xml_data = load_xml_data(xml_file)
# Display all data initially
for row in xml_data:
table.insert("", tk.END, values=(row["ID"], row["Name"], row["Age"], row["City"]))
root.mainloop()
=========================
data.xml
<?xml version="1.0"?>
<records>
<record>
<id>1</id>
<name>John Doe</name>
<age>30</age>
<city>New York</city>
</record>
<record>
<id>2</id>
<name>Jane Smith</name>
<age>25</age>
<city>Los Angeles</city>
</record>
<record>
<id>3</id>
<name>Michael Brown</name>
<age>40</age>
<city>Chicago</city>
</record>
</records>
Python Menu 3
import tkinter as tk
class App:
def __init__(self, root):
self.root = root
self.root.geometry("600x400")
# Menu toggle button
self.btn_toggle = tk.Button(root, text="☰ Menu", command=self.toggle_menu)
self.btn_toggle.place(x=10, y=10)
# Sliding frame
self.menu_frame = tk.Frame(root, bg="#333333", width=0, height=400)
self.menu_frame.pack_propagate(False) # Allows width to change
# Menu Items
self.menu_items = [f"Menu Item {i}" for i in range(1, 8)]
for item in self.menu_items:
tk.Button(self.menu_frame, text=item, bg="#333333", fg="white",
font=("Arial", 12), relief="flat", anchor="w").pack(fill="x", pady=5, padx=10)
self.menu_visible = False
def toggle_menu(self):
if not self.menu_visible:
# Slide In
for i in range(0, 201, 20): # Width 0 to 200
self.menu_frame.place(x=0, y=50, width=i, height=350)
self.root.update()
else:
# Slide Out
for i in range(200, -1, -20): # Width 200 to 0
self.menu_frame.place(x=0, y=50, width=i, height=350)
self.root.update()
self.menu_visible = not self.menu_visible
root = tk.Tk()
app = App(root)
root.mainloop()
Python Menu 2
import tkinter as tk
class SlidingMenuApp:
def __init__(self, root):
self.root = root
self.root.title("Sliding Menu")
self.root.geometry("400x600")
# Menu configuration
self.menu_width = 200
self.menu_height = 400
self.is_open = False
# Calculate hidden starting position (below the window)
self.hidden_y = 600
self.visible_y = 200 # Height where it stops
# --- Create Menu Frame ---
self.menu_frame = tk.Frame(self.root, bg="#333333", width=self.menu_width, height=self.menu_height)
self.menu_frame.place(x=-self.menu_width, y=self.hidden_y) # Initially hidden
self.menu_frame.pack_propagate(False) # Maintain size
# --- Menu Items ---
menu_items = ["menuitem1", "menuitem2", "menuitem3", "menuitem4",
"menuitem5", "menuitem6", "menuitem7"]
for item in menu_items:
btn = tk.Button(self.menu_frame, text=item, bg="#333333", fg="white",
font=("Arial", 12), bd=0, anchor="w",
command=lambda i=item: print(f"{i} clicked"))
btn.pack(fill="x", pady=10, padx=20)
# --- Toggle Button ---
self.toggle_btn = tk.Button(self.root, text="Menu", command=self.toggle_menu,
bg="white", font=("Arial", 12))
self.toggle_btn.place(x=10, y=10)
def toggle_menu(self):
if not self.is_open:
self.slide_in(self.hidden_y)
else:
self.slide_out(self.visible_y)
def slide_in(self, y_pos):
if y_pos > self.visible_y:
y_pos -= 20 # Speed of slide
self.menu_frame.place(x=0, y=y_pos)
self.root.after(10, lambda: self.slide_in(y_pos))
else:
self.is_open = True
def slide_out(self, y_pos):
if y_pos < self.hidden_y:
y_pos += 20 # Speed of slide
self.menu_frame.place(x=0, y=y_pos)
self.root.after(10, lambda: self.slide_out(y_pos))
else:
self.menu_frame.place(x=-self.menu_width, y=self.hidden_y)
self.is_open = False
if __name__ == "__main__":
root = tk.Tk()
app = SlidingMenuApp(root)
root.mainloop()
Jumat, 17 April 2026
Python Menu
import tkinter as tk
from tkinter import messagebox
# -------------------------------
# Sliding Menu Application Class
# -------------------------------
class SlidingMenuApp:
def __init__(self, root):
self.root = root
self.root.title("Sliding Menu Example")
self.root.geometry("600x400")
self.root.config(bg="white")
# Menu state
self.menu_width = 200
self.menu_current_x = -self.menu_width
self.menu_target_x = -self.menu_width
self.menu_speed = 20 # pixels per frame
# Create menu frame (hidden initially)
self.menu_frame = tk.Frame(self.root, bg="#2c3e50", width=self.menu_width, height=400)
self.menu_frame.place(x=self.menu_current_x, y=0)
# Add menu items
self.add_menu_items()
# Create toggle button on the right side
self.toggle_btn = tk.Button(
self.root, text="☰", font=("Arial", 14, "bold"),
bg="#3498db", fg="white", command=self.toggle_menu
)
self.toggle_btn.place(relx=1.0, x=-40, y=10, anchor="ne")
# Start animation loop
self.animate()
def add_menu_items(self):
"""Add menu buttons."""
menu_items = [
("Home", lambda: self.show_message("Home")),
("Information", lambda: self.show_message("Information")),
("Activities", lambda: self.show_message("Activities")),
("Feedback", lambda: self.show_message("Feedback")),
]
for i, (text, cmd) in enumerate(menu_items):
btn = tk.Button(
self.menu_frame, text=text, font=("Arial", 12),
bg="#34495e", fg="white", relief="flat", command=cmd
)
btn.place(x=10, y=20 + i * 50, width=self.menu_width - 20, height=40)
def show_message(self, title):
"""Show a message box for menu item."""
messagebox.showinfo("Menu Clicked", f"You clicked: {title}")
def toggle_menu(self):
"""Toggle menu open/close."""
if self.menu_target_x < 0:
self.menu_target_x = 0 # open
else:
self.menu_target_x = -self.menu_width # close
def animate(self):
"""Smoothly animate menu sliding."""
if self.menu_current_x < self.menu_target_x:
self.menu_current_x += self.menu_speed
if self.menu_current_x > self.menu_target_x:
self.menu_current_x = self.menu_target_x
elif self.menu_current_x > self.menu_target_x:
self.menu_current_x -= self.menu_speed
if self.menu_current_x < self.menu_target_x:
self.menu_current_x = self.menu_target_x
# Update menu position
self.menu_frame.place(x=self.menu_current_x, y=0)
# Repeat animation
self.root.after(15, self.animate)
# -------------------------------
# Run the Application
# -------------------------------
if __name__ == "__main__":
root = tk.Tk()
app = SlidingMenuApp(root)
root.mainloop()
Sabtu, 11 April 2026
Jumat, 10 April 2026
Python Animation Wheel Of Colors
import tkinter as tk
def rotate_wheel():
global current_angle
current_angle = (current_angle + speed) % 360
# Update each sector's starting angle
for i, sector in enumerate(sectors):
start_pos = (current_angle + i * (360 / num_sectors)) % 360
canvas.itemconfig(sector, start=start_pos)
# Schedule the next update (approx 60 FPS)
root.after(16, rotate_wheel)
root = tk.Tk()
canvas = tk.Canvas(root, width=400, height=400, bg='white')
canvas.pack()
num_sectors = 8
sectors = []
colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'cyan']
current_angle = 0
speed = 5 # Degrees per frame
# Initialize the wheel sectors
for i in range(num_sectors):
angle_extent = 360 / num_sectors
arc = canvas.create_arc(50, 50, 350, 350,
start=i * angle_extent,
extent=angle_extent,
fill=colors[i % len(colors)])
sectors.append(arc)
rotate_wheel()
root.mainloop()
Kamis, 02 April 2026
Rabu, 01 April 2026
VB 6 Self Typing Demo 2
Option Explicit
Private Const FIXED_TEXT = "This is a demo of self a typing textbox effect."
Private Sub Form_Load()
Timer1.Interval = 300
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 150 * Rnd
Static i%
i = i + 1
Text1.Text = Text1.Text & Mid(FIXED_TEXT, i, 1)
If Text1.Text = FIXED_TEXT Then Timer1.Enabled = False
End Sub
VB 6 Self Typing Demo
C++ From Year 1995 Bonus
// Filename: BPROJ1.CPP
// This program displays the character for each ASCII value
#include <iostream.h>
void main()
{
// Output a heading
cout << "Value Character" << endl;
// For all the characters (missing out the first
// few unprintable characters.
for (int i = 32; i <= 255; i++)
{
// Make the value print in 3 characters
cout.width(3);
// Print the value, followed by some spaces
// followed by the character value and
// finally a new line
cout << i << " " << (char)i << endl;
}
}
=====================
// Filename: BPROJ2.CPP
// This program demonstrates the basic structure
// of a C++ program
#include <iostream.h>
void main()
{
// Declare and initialise variables
int value1 = 10;
int value2 = 20;
int value3 = 40;
// Declare a variable for working out the
// sum of the numbers
int sum;
// Declare another variable for the result
int average;
// Add three numbers into sum
sum = value1 + value2 + value3;
// divide the sum by the number of values to
// get the average
average = sum / 3;
// Output the result
cout << "The average of " << value1 << ", "
<< value2 << " and " << value3 << " is "
<< average << endl;
cout << "The sum of the numbers is " << sum;
}
=====================
// BPROJ3.CPP
// A simple review of character and numeric
// input and output.
#include <iostream.h>
void main()
{
// Declare variables
int decimals = 0;
float number;
const int descLen = 80;
char numberDesc[descLen];
cout << "Enter a floating point number: ";
cin >> number;
cin.ignore(80,'\n');
cout << "How many decimal places do you want? ";
cin >> decimals;
cin.ignore(80,'\n');
cout << "How do you want to describe the number?" << endl;
cin.getline(numberDesc,descLen);
cout << endl;
cout << numberDesc << ": ";
// Format the number as requested
cout.precision(decimals);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout << number;
}
=====================
// Filename : BPROJ4.CPP
// This project does some calculations
// and then tests them.
#include <iostream.h>
void main()
{
char burgerType = ' ';
char cheese = ' ';
char fries = ' ';
float burgerCost = 0.0F;
float friesCost = 0.0F;
float totalCost = 0.0F;
cout << "Welcome to Spencer's Burger Bar!" << endl;
cout << endl << "What sort of burger would you like?" << endl;
cout << "[s]mall, [q]uarter pounder, [b]loatburger? ";
cin >> burgerType;
if (burgerType >= 'a' && burgerType <= 'z')
burgerType += 'A' - 'a';
if (burgerType != 'S' && burgerType != 'Q'
&& burgerType != 'B')
burgerType = 'Q';
cout << "Is that with cheese?";
cin >> cheese;
if (cheese == 'Y' || cheese == 'y')
cheese = 'Y';
else
cheese = 'N';
cout << "[r]egular or [l]arge fries?";
cin >> fries;
if (fries == 'r' || fries == 'R' ||
fries == 'l' || fries == 'L')
{
if (fries == 'r' || fries == 'l')
fries += 'A' - 'a';
}
else
fries = 'R';
// Calculate cost - everything is relative
burgerCost = 1.75F;
if (burgerType == 'S')
burgerCost *= 0.60F;
if (burgerType == 'B')
burgerCost *= 1.7F;
if (cheese == 'Y')
burgerCost += 0.50F;
if (fries == 'R')
friesCost = 1.00F;
else
friesCost = 1.50F;
totalCost = burgerCost + friesCost;
if (fries == 'L' && burgerType == 'B')
{
cout << "There is a special on the Bloat & large fries!" << endl;
totalCost = totalCost * 0.9F;
}
cout << "That will be $";
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << totalCost << "." << endl;
cout << "Have a nice day!";
}
=======================
// BPROJ5.CPP
// Switching and calculations explored
#include <iostream.h>
void main()
{
int method = 1;
float f = 1.99F;
int i = 10;
float answer = 0;
// This program simply demonstrates some rounding errors
cout << "1. i * f" << endl;
cout << "2. (int)(i * f)" << endl;
cout << "3. i * (int)f" << endl;
cout << "4. (int)(i * f) * f" << endl;
cout << "5. (int)(i *f) * (int)f" << endl;
cout << "Enter method: ";
cin >> method;
switch (method)
{
case 1:
answer = i * f;
break;
case 2:
answer = (int)(i * f);
break;
case 3:
answer = i * (int)f;
break;
case 4:
answer = (int)(i * f) * f;
break;
case 5:
answer = (int)(i * f) * (int)f;
break;
default:
cout << "Invalid input";
return;
}
cout << "The answer is " << answer << endl;
}
============================
// Filename: BPROJ6.CPP
// Factors - a factor is a number that
// multiplied by another number exactly makes another number
#include <iostream.h>
void main()
{
int product = 1;
while (product)
{
cout << endl << "Enter number to test:";
cin >> product;
if (product)
{
cout << "The factors of " << product << " are:" << endl;
for (int i = 2; i < product ; i++)
{
if (product % i)
continue;
cout << i << endl;
}
}
}
}
C++ From Year 1995 Extras
// Filename: BIT1.CPP
// Demonstrate &, |, ^, and ~ on two values
#include <iostream.h>
void main()
{
int i = 5, j = 12;
int answer;
// Although this program applies the bitwise operators to
// variables, bitwise operators also work on literal values
answer = i & j;
cout << "The result of i & j is " << answer << endl;
answer = i | j;
cout << "The result of i | j is " << answer << endl;
answer = i ^ j;
cout << "The result of i ^ j is " << answer << endl;
// Notice how ~ takes only a single argument
answer = ~i;
cout << "The result of ~i is " << answer << endl;
answer = ~j;
cout << "The result of ~j is " << answer << endl;
return;
}
===========================
// Filename: BITEQUI2.CPP
// Uses bitwise operators to work with user input
#include <iostream.h>
void main()
{
int i, result;
char c;
cout << "Enter a number and I'll say if it's odd or even: ";
cin >> i;
if (i & 1)
{ cout << "The number is odd" << endl; }
else
{ cout << "The number is even" << endl; }
cout << endl << "Enter a number that you want multiplied by 32: ";
cin >> i;
result = i << 5; // Multiplies by 2 raised to the 5th power
cout << i << " times 32 is " << result << endl;
result = i >> 3;
cout << i << " divided by 8 is " << result << endl;
cout << endl << "Please enter your first initial: ";
cin >> c;
if (c & 32)
{ cout << "Always type your initial in uppercase" << endl; }
else
{ cout << "You entered the initial in uppercase, good!" << endl; }
return;
}
========================
// Filename: BITEQUIV.CPP
// Uses bitwise operators to work with user input
#include <iostream.h>
void main()
{
int i, result;
char c;
cout << "Enter a number and I'll say if it's odd or even: ";
cin >> i;
if ((i & 1) == 1)
{ cout << "The number is odd" << endl; }
else
{ cout << "The number is even" << endl; }
cout << endl << "Enter a number that you want multiplied by 32: ";
cin >> i;
result = i << 5; // Multiply by 2 raised to the fifth power
cout << i << " times 32 is " << result << endl;
cout << endl << "Please enter your first initial: ";
cin >> c;
if (c & 32)
{ cout << "Always type your initial in uppercase" << endl; }
else
{ cout << "You entered the initial in uppercase, good!" << endl; }
return;
}
=========================
// Filename: BITSHIFT.CPP
// Shows the results of several bitwise shift operations
#include <iostream.h>
void main()
{
int shiftResult;
shiftResult = 13 << 2;
cout << "13 << 2 is " << shiftResult << endl;
shiftResult = 13 >> 2;
cout << "13 >> 2 is " << shiftResult << endl;
shiftResult = -13 << 2;
cout << "-13 << 2 is " << shiftResult << endl;
shiftResult = -13 >> 2;
cout << "-13 >> 2 is " << shiftResult << endl;
return;
}
======================
// Filename: BONUSP1.CPP
// Shows how the advanced operators give
// you more control and efficiency
#include <iostream.h>
const int MAKEUPPER = 223;
void main()
{
char partCode;
int num, doubleNum;
float price;
double totalInv;
cout << "** Inventory Valuation **" << endl << endl;
cout << "What is the character part code? ";
cin >> partCode;
partCode &= MAKEUPPER; // Ensure that the part
// code is uppercase
cout << "How many parts are there? ";
cin >> num;
cout << "What is the price of each part? ";
cin >> price;
cout.precision(2);
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
totalInv = (double)num * (double)price;
cout << endl << "For part code " << partCode << ", ";
cout << "the total valuation is $" << totalInv << endl;
doubleNum = num << 1; // Compute double the current number
cout << endl << "Doubling our inventory would give us "
<< doubleNum << " new parts" << endl;
(num < 20) ? cout << endl << "We need to order more inventory!"
<< endl
:
cout << endl << "We now have enough inventory"
<< endl;
}
================
// Filename: ORANGE.CPP
// See if the user likes orange juice
#include <iostream.h>
void main()
{
const int UPMASK = 223;
char ans;
cout << "Do you like fresh squeeze orange juice (Y/N)? ";
cin >> ans;
ans &= UPMASK; // Convert to uppercase
if (ans == 'Y')
{ cout << "You'll be healthy all your life!" << endl; }
else
{ cout << "You need the vitamin C!" << endl; }
return;
}





































