analitics

Pages

Thursday, March 12, 2026

Python Qt6 : schemdraw - 001.

Today, simple example with PyQt6 and schemdraw :
# -*- coding: utf-8 -*-
import sys
import schemdraw
import schemdraw.elements as elm
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QScrollArea
from PyQt6.QtGui import QPixmap
def draw_bistabil_grid(state):
    """
    state = 0 -> switch spre R3, LED1 aprins
    state = 1 -> switch spre R4, LED2 aprins
    """
    with schemdraw.Drawing(file='bistabil_grid.png', show=False) as d:
        d.config(unit=2.0)

        # Y COORDINATES
        y_led = 0.0
        y_r1  = -2.0
        y_rfb = -4.0
        y_swT = -7.0
        y_gnd = -10.0

        # X COORDINATES
        x_left   = -6.0
        x_right  = 6.0
        x_t1     = -3.0
        x_t2     = 3.0
        x_sw     = 0.0

        # COLORS
        col_T1 = 'green'
        col_T2 = 'orange'

        # LED-uri colorate în funcție de state
        led1_color = 'red' if state == 0 else 'gray'
        led2_color = 'red' if state == 1 else 'gray'

        # 1. LED1 and LED2
        led1 = d.add(elm.LED().down().at((x_left, y_led)).color(led1_color).label('LED1'))
        led2 = d.add(elm.LED().down().at((x_right, y_led)).color(led2_color).label('LED2'))

        # 2. R1 and R2
        r1 = d.add(elm.Resistor().down().at(led1.end).label('R1'))
        r2 = d.add(elm.Resistor().down().at(led2.end).label('R2'))

        n_r1 = d.add(elm.Dot().at(r1.end))
        n_r2 = d.add(elm.Dot().at(r2.end))

        # 3. R3 and R4 (feedback)
        d.add(elm.Line().at(n_r1.center).to((x_t1, y_rfb)))
        r3 = d.add(elm.Resistor().right().at((x_t1, y_rfb)).label('R3'))
        n_r3 = d.add(elm.Dot().at(r3.end))

        d.add(elm.Line().at(n_r2.center).to((x_t2, y_rfb)))
        r4 = d.add(elm.Resistor().left().at((x_t2, y_rfb)).label('R4'))
        n_r4 = d.add(elm.Dot().at(r4.end))

        # 4. Transistors
        t1 = d.add(
            elm.BjtNpn()
            .left()
            .flip()
            .at((x_t1, y_swT))
            .anchor('base')
            .label('T1')
        )

        t2 = d.add(
            elm.BjtNpn()
            .right()
            .at((x_t2, y_swT))
            .anchor('base')
            .label('T2')
        )

        # BASE CONNECTIONS
        d.add(elm.Line().at(n_r4.center).to(t1.base).color(col_T1))
        d.add(elm.Line().at(n_r3.center).to(t2.base).color(col_T2))

        # COLLECTOR CONNECTIONS
        d.add(elm.Line().at(t1.collector).to(n_r1.center).color(col_T1))
        d.add(elm.Line().at(t2.collector).to(n_r2.center).color(col_T2))

        # -------------------------------
        # 5. SWITCH SPDT DESENAT MANUAL
        # -------------------------------

        # Punctele a, b, c
        a = d.add(elm.Dot().at((x_sw - 1, y_swT)))
        b = d.add(elm.Dot().at((x_sw,     y_swT)))
        c = d.add(elm.Dot().at((x_sw + 1, y_swT)))

        # Linii FIXE către R3 și R4
        d.add(elm.Line().at(n_r3.center).to(a.center))
        d.add(elm.Line().at(n_r4.center).to(c.center))

        # Linia FIXĂ către GND
        d.add(elm.Line().at(b.center).to((b.center[0], y_gnd)))

        # Brațul mobil (UNICA linie care se mișcă)
        if state == 0:
            d.add(elm.Line().at(b.center).to(a.center))
        else:
            d.add(elm.Line().at(b.center).to(c.center))

        # 6. Ground bus
        d.add(
            elm.Line()
            .at((x_left - 2, y_gnd))
            .to((x_right + 2, y_gnd))
            .label('0V', loc='bottom')
        )
        d.add(elm.Ground().at((x_left - 2, y_gnd)))

        # EMITTERS TO GND
        d.add(elm.Line().at(t1.emitter).to((t1.emitter[0], y_gnd)).color(col_T1))
        d.add(elm.Line().at(t2.emitter).to((t2.emitter[0], y_gnd)).color(col_T2))


class BistabilGUI(QWidget):
    def __init__(self):
        super().__init__()

        self.state = 0

        self.setWindowTitle("Bistabil Animat – Schema completă")

        # Scroll area
        self.scroll = QScrollArea()
        self.label = QLabel()
        self.scroll.setWidget(self.label)
        self.scroll.setWidgetResizable(True)

        self.button = QPushButton("Comută switch-ul")
        self.button.clicked.connect(self.toggle_switch)

        layout = QVBoxLayout()
        layout.addWidget(self.scroll)
        layout.addWidget(self.button)
        self.setLayout(layout)

        self.update_image()

    def toggle_switch(self):
        self.state = 1 - self.state
        self.update_image()

    def update_image(self):
        draw_bistabil_grid(self.state)
        pix = QPixmap("bistabil_grid.png")
        self.label.setPixmap(pix)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    gui = BistabilGUI()
    gui.show()
    sys.exit(app.exec())

News : Major new features of the 3.15 series, compared to 3.14

Python 3.15 is still in development. This release, 3.15.0a7, is the seventh of eight planned alpha releases.
...The JIT compiler has been significantly upgraded, with 3-4% geometric mean performance improvement on x86-64 Linux over the standard interpreter, and 7-8% speedup on AArch64 macOS over the tail-calling interpreter

Wednesday, March 11, 2026

Saturday, March 7, 2026

Python 3.13.0 : schemdraw high-quality electrical circuit schematic.

Schemdraw is a Python package for producing high-quality electrical circuit schematic diagrams. Circuit elements are added, one at a time, similar to how you might draw them by hand, using Python methods.
This is the install step with pip tool:
pip install schemdraw
WARNING: Ignoring invalid distribution ~adquery-ocp (C:\Python313_64bit\Lib\site-packages)
Collecting schemdraw
  Downloading schemdraw-0.22-py3-none-any.whl.metadata (2.2 kB)
Downloading schemdraw-0.22-py3-none-any.whl (148 kB)
WARNING: Ignoring invalid distribution ~adquery-ocp (C:\Python313_64bit\Lib\site-packages)
Installing collected packages: schemdraw
WARNING: Ignoring invalid distribution ~adquery-ocp (C:\Python313_64bit\Lib\site-packages)
Successfully installed schemdraw-0.22

Tuesday, March 3, 2026

Python 3.13.0 : webcam Falticeni - processing HLS .m3u8 video stream.

Python can process data from an HLS (.m3u8) video stream, such as the one used on the Fălticeni webcam page (which loads the stream through index.m3u8).

Monday, March 2, 2026

Python 3.13.0 : the manim python module - part 002.

The last tutorial was on this post.
The manim packege can be install with pip tool:
pip install manim
...
Successfully installed audioop-lts-0.2.2 av-16.1.0 cloup-3.0.8 glcontext-3.0.0 isosurfaces-0.1.2 manim-0.20.1 manimpango-0.6.1 mapbox-earcut-2.0.0 moderngl-5.12.0 moderngl-window-3.1.1 pycairo-1.29.0 pydub-0.25.1 pyglet-2.1.13 pyglm-2.8.3 screeninfo-0.8.1 skia-pathops-0.9.2 srt-3.5.3
The last tutorial was on this post.

Saturday, February 28, 2026

Python 3.13.0 : simple script for update all python packages.

Simple script for update all python packages:
import subprocess
import sys
import datetime

log_file = "upgrade_log.txt"

def log(msg):
    with open(log_file, "a", encoding="utf-8") as f:
        f.write(msg + "\n")
    print(msg)

def get_installed_packages():
    result = subprocess.run(
        [sys.executable, "-m", "pip", "list", "--format=freeze"],
        capture_output=True,
        text=True
    )
    lines = result.stdout.strip().split("\n")
    packages = []
    for line in lines:
        if "@" in line:  # skip direct URL installs
            pkg = line.split("@")[0]
        else:
            pkg = line.split("==")[0]
        packages.append(pkg)
    return sorted(packages)

def upgrade_package(package):
    log(f"\n=== Updating: {package} ===")
    try:
        subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", package])
        log(f"[OK] Updated: {package}")
    except subprocess.CalledProcessError:
        log(f"[FAILED] Could not update: {package}")

def main():
    log(f"\n--- Upgrade started at {datetime.datetime.now()} ---\n")

    packages = get_installed_packages()
    log(f"Found {len(packages)} packages.\n")

    for pkg in packages:
        upgrade_package(pkg)

    log(f"\n--- Upgrade finished at {datetime.datetime.now()} ---\n")

if __name__ == "__main__":
    main()

Wednesday, February 25, 2026

Python 3.13.0 : build123d the BREP for 2D and 3D CAD.

build123d is a Python-based, parametric boundary representation (BREP) modeling framework for 2D and 3D CAD. Built on the Open Cascade geometric kernel, it provides a clean, fully Pythonic interface for creating precise models suitable for 3D printing, CNC machining, laser cutting, and other manufacturing processes.
You can find more about this project on the GitHub repo.
python -m pip install build123d
Collecting build123d
  Downloading build123d-0.10.0-py3-none-any.whl.metadata (6.7 kB)
...
Successfully installed anytree-2.13.0 asttokens-3.0.1 build123d-0.10.0 cadquery-ocp-7.8.1.1.post1 cadquery_ocp_proxy-7.9.3.1 cadquery_vtk-9.3.1 decorator-5.2.1 executing-2.2.1 ezdxf-1.4.3 ipython-9.10.0 ipython-pygments-lexers-1.1.1 lib3mf-2.5.0 matplotlib-inline-0.2.1 ocp_gordon-0.2.0 ocpsvg-0.5.0 pure-eval-0.2.3 stack_data-0.6.3 svgelements-1.9.6 svgpathtools-1.7.2 traitlets-5.14.3 trianglesolver-1.2 webcolors-24.8.0

Sunday, February 15, 2026

News : PySimpleGUI planned shutdown

The PySimpleGUI project’s planned shutdown was first announced in February 2025. At that time, we committed to supporting our Commercial customers through the end of 2025. PySimpleGUI 5 remained a very stable product throughout the year, with no significant issues reported.
Now that we’ve reached the end of that support period, the project is entering its final stage. During January 2026, the PySimpleGUI website, documentation, and PyPI servers will be taken offline as we officially close the project.
The private PyPI server will be shut down in January 2026 . If you currently install PySimpleGUI 5 using pip, you’ll need to switch to installing from a local wheel file instead.

Tools : Pickcode online I.D.E.

Pickcode is an online IDE, similar to Trinket. With a free account, you can create unlimited projects in Python, Java, and HTML/CSS/JS.
With our paid Pickcode Classroom plan, teachers can create lessons, set up classes and assignments, and view student work in real time.
Pickcode Classroom costs $500/teacher plus $10/student per year. We are considering options for adding a lower-priced plan similar to Trinket’s Code+, and will have more info about that later this year.

News : Trinket will be shutting down in early August 2026.

We are deeply grateful for your support over the years. Trinket has been used by millions of learners and educators, and it has been an honor to be part of your coding journey.
We're truly sorry for any disruption this may cause. If you have questions, please reach out to us at help@trinket.io.
If you have an annual subscription, you'll continue to have full access until the end of your current paid period. Your subscription will not renew.
Monthly subscriptions will not renew after June 30, 2026.
Trinket will be shutting down in early August 2026.
After this date, trinket.io will no longer be available, and you will not be able to access your trinkets, courses, or any content on this site. Please download anything you want to keep before the shutdown.

Saturday, February 14, 2026

Python Qt6 : using the py3Dmol .

NOTE : hacker provider ... :
Simple example with the py3Dmol:
import os
import sys

from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtCore import QUrl
import py3Dmol

SEROTONIN_SMILES = "C1=CC2=C(C=C1)C(=CN2)CCN"

def generate_html(smiles):
    view = py3Dmol.view(width=800, height=600)
    view.addModel(smiles, "smiles")
    view.setStyle({"stick": {}})
    view.zoomTo()
    return view._make_html()

class MoleculeViewer(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Structura 3D – Serotonină")

        layout = QVBoxLayout(self)
        self.browser = QWebEngineView()

        html = generate_html(SEROTONIN_SMILES)

        # IMPORTANT: QUrl, nu string!
        self.browser.setHtml(html, baseUrl=QUrl("https://localhost/"))

        layout.addWidget(self.browser)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MoleculeViewer()
    window.resize(900, 700)
    window.show()
    sys.exit(app.exec())

Wednesday, February 11, 2026

Python Qt6 : remove files by size.

After the vendor hacker changed my file sizes to 0kb and 1kb, only from the folders on my laptop and backup on the backup hdd, for the development project with the game I was working on with artificial intelligence. I created a script in Python to see if he left anything in the folders and subfolders.