Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

38
LINES

< > BotCompany Repo | #1027027 // Qwant Image Search [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (8308L/44K).

!7

// TODO: cache URLs + images

cmodule ImageSearcher > DynImageSurface {
  S typingText;
  transient S text;
  switchable bool listen;
  
  start {
    set zoomToWindowOnSetImage;
    dm_onTopInput_q(voidfunc(S s) {
      if (listen) show(s)
    });
  }
  
  enhanceFrame { minFrameSize(f, 300, 300); }

  visualize {
    ret northCenterSouthWithMargins(dm_bigInputAndSubmit('typingText, "Visualize", rThread { show(typingText) }),
      super.visualize(),
      vstackWithSpacing(
        centeredLiveValueLabel(dm_fieldLiveValue('text)),
        dm_rightAlignedCheckBox('listen)));
  }
  
  // API
  
  void show(S query) q {
    pcall {
      setField(typingText := query);
      BufferedImage img = loadImage2(random(qwantImageSearch(query)));
      if (img == null) ret;
      setImage(img);
      setField(text := query);
    }
  }
}

Author comment

Began life as a copy of #1018870

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027027
Snippet name: Qwant Image Search [Dyn Module]
Eternal ID of this version: #1027027/3
Text MD5: 85458bcd6a3687d3611a6e663c916437
Transpilation MD5: 58ba6b1144c495f84972097db05fdc38
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-13 19:21:20
Source code size: 879 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 248 / 1191
Version history: 2 change(s)
Referenced in: [show references]