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).

1  
!7
2  
3  
// TODO: cache URLs + images
4  
5  
cmodule ImageSearcher > DynImageSurface {
6  
  S typingText;
7  
  transient S text;
8  
  switchable bool listen;
9  
  
10  
  start {
11  
    set zoomToWindowOnSetImage;
12  
    dm_onTopInput_q(voidfunc(S s) {
13  
      if (listen) show(s)
14  
    });
15  
  }
16  
  
17  
  enhanceFrame { minFrameSize(f, 300, 300); }
18  
19  
  visualize {
20  
    ret northCenterSouthWithMargins(dm_bigInputAndSubmit('typingText, "Visualize", rThread { show(typingText) }),
21  
      super.visualize(),
22  
      vstackWithSpacing(
23  
        centeredLiveValueLabel(dm_fieldLiveValue('text)),
24  
        dm_rightAlignedCheckBox('listen)));
25  
  }
26  
  
27  
  // API
28  
  
29  
  void show(S query) q {
30  
    pcall {
31  
      setField(typingText := query);
32  
      BufferedImage img = loadImage2(random(qwantImageSearch(query)));
33  
      if (img == null) ret;
34  
      setImage(img);
35  
      setField(text := query);
36  
    }
37  
  }
38  
}

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: 352 / 1313
Version history: 2 change(s)
Referenced in: [show references]