Nodes/ComfyUI-QG-Tools/布尔开关
ComfyUI Node

布尔开关

QG_BoolToggle

By live1617·Created 15 days ago·Updated a day ago· 3
布尔开关
    • boolean
    ◄booleanfalse►
    ◄label►

    Every workflow grows the same wart eventually: five or six things should flip together. The upscaler and its save node. The detailer pass. The second LoRA row you only turn on for close-ups. So you drop a PrimitiveBoolean, wire it to each node's boolean input - after right-clicking each of those widgets and converting them to inputs, one by one - and then you stare at a canvas where the switch that controls everything is a 12-pixel checkbox labeled value.

    QG_BoolToggle is that checkbox with a body job. The node is the switch: a big 开/关 readout on one side, a clickable pill on the other, and one BOOLEAN output you can fan out as far as you like.

    What it actually is

    Underneath, this is embarrassingly ordinary. The node declares two inputs - boolean, a BOOLEAN defaulting to false, and label, a STRING - and a single BOOLEAN output named boolean. The execute() method does roughly what you'd guess:

    def execute(self, boolean=False, label=""):
        return (bool(boolean),)
    

    label never touches the output. It's there purely so the front end has somewhere to keep the name you typed, because that name has to survive save, undo, copy-paste and API export like any other widget value. The real checkbox is still on the node too - just hidden behind the painted card. That's the whole trick, and it's the right one: no custom serialization, no shadow state, no "my switch reset itself when I reloaded the graph" bug.

    This is the same pattern the plumbing layer runs on everywhere: a value gets pulled out of a widget and turned into a socket so the graph can fan it out. The core PrimitiveBoolean does that with a checkbox; this does it with something you can find on a canvas at 40% zoom.

    Why you'd reach for it over a primitive

    Two reasons, both about reading a graph rather than doing anything new.

    The first is labelling. Double-click the card (or right-click → rename label) and an inline field floats over the text - type "美颜", hit enter, done. Leave it blank and it falls back to 开/关. If you keep four of these in a row for a character workflow, that naming is the difference between a switch panel and four identical pills you have to hover to identify.

    The second is that "on" is visible from across the room. The border goes cyan, the pill slides right and goes green, the label brightens. You don't have to trace a wire to know whether the detailer was enabled for the run you're looking at.

    Inputs, outputs, and what to wire where

    • boolean - the state itself. You flip it by clicking the pill on the card, or via the node's right-click menu if you're hunting a tiny hit target at low zoom.
    • label - the name shown on the card. Empty means 开/关.
    • output boolean - a strict Python bool, so it lands on any BOOLEAN input: the pack's own string switch and if-else nodes, PrimitiveBoolean-style inputs elsewhere, and any boolean widget you've converted to a socket.

    One thing to know before you wire it: a boolean that lives as a widget on a downstream node (a "Randomize" toggle, an "Enabled" checkbox) isn't magically reachable. Right-click that widget → Convert widget to input, then connect. That's an engine rule, not a limitation of this node.

    Installing it

    It ships in ComfyUI-QG-tools, which as of this writing has no pip dependencies at all - the pack's requirements.txt is deliberately comments-only, which is ComfyUI Manager's signal to skip pip install entirely.

    cd ComfyUI/custom_nodes
    git clone https://github.com/live1617/ComfyUI-QG-tools
    

    Then restart ComfyUI fully - not just refresh the browser tab. The console should print a banner naming v0.9.4 and 32 nodes loaded. The node appears under QG-tools/逻辑, and since the display name is Chinese, you can also just search boolean or toggle - the pack registers English search aliases for exactly that reason.

    Manager install works too (search ComfyUI-QG-Tools), provided the pack is listed on the registry; if it doesn't show up, the git clone above is the reliable path.

    Where it bites

    • It renders in Nodes 2.0. Packs that paint their own UI on the canvas had a rough 2025: the Vue renderer stopped calling onDrawForeground, and nodes that drew themselves simply vanished - the famous casualty being rgthree, whose author declined to port. This pack went the other way and moved its painted nodes to DOM so they behave the same in both render modes. If you're the type to flip Nodes 2.0 off on principle, note this one was built for both.
    • A BOOLEAN output isn't a condition by itself. It drives any node that takes a boolean; it doesn't evaluate on its own. To trigger "if width > 1024" you need something that produces the boolean - the pack's math node does that from a comparison expression.
    • Don't expect it in the API prompt beyond its value. It's a plain node with a bool; that's all it is. That's the point.
    CategoryQG-tools/逻辑

    Inputs (2)

    NameTypeDefaultDescription
    booleanBOOLEANfalse开关状态。点节点上的胶囊切换;输出接到下游的布尔条件上。
    labelSTRING卡片上显示的名字,比如「美颜」。留空则显示「开 / 关」。双击卡片可改。

    Outputs (1)

    NameTypeDescription
    booleanBOOLEAN—