当前位置:网站首页>Ftxui basic notes (checkbox component)
Ftxui basic notes (checkbox component)
2022-07-21 19:43:00 【zhangrelay】
Check box ( Check box 、 Check the box 、 Check the box ) Is a graphical widget that allows users to make binary selections , That is, choose between two possible mutually exclusive options . for example , Users may have to simply / No answer the question “ yes ”( Choose ) or “ no ”( Not selected ).
A checkbox (check box, tickbox, tick box) is a graphical widget that permits the user to make a binary choice, i.e. a choice between one of two possible mutually exclusive options. For example, the user may have to answer 'yes' (checked) or 'no' (not checked) on a simple yes/no question.
There are two main effects :
#include <memory> // for allocator, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
int main(int argc, const char* argv[]) {
using namespace ftxui;
Component input_list = Container::Vertical({});
std::vector<std::string> items(100, "");
for (int i = 0; i < items.size(); ++i) {
input_list->Add(Input(&(items[i]), "placeholder " + std::to_string(i)));
}
auto renderer = Renderer(input_list, [&] {
return input_list->Render() | vscroll_indicator | frame | border |
size(HEIGHT, LESS_THAN, 10);
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
// Copyright 2021 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
Essential header file :
#include <memory> // for allocator, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
100 A check box
Component input_list = Container::Vertical({});
std::vector<std::string> items(100, "");
for (int i = 0; i < items.size(); ++i) {
input_list->Add(Input(&(items[i]), "placeholder " + std::to_string(i)));
}
Terminal display effect :
auto renderer = Renderer(input_list, [&] {
return input_list->Render() | vscroll_indicator | frame | border |
size(HEIGHT, LESS_THAN, 10);
});
An example with a small box is as follows :
#include <array> // for array
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
using namespace ftxui;
int main(int argc, const char* argv[]) {
std::array<bool, 30> states;
auto container = Container::Vertical({});
for (int i = 0; i < 30; ++i) {
states[i] = false;
container->Add(Checkbox("Checkbox" + std::to_string(i), &states[i]));
}
auto renderer = Renderer(container, [&] {
return container->Render() | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 10) | border;
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(renderer);
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
Only the display effect , There is no actual function .
std::array<bool, 30> states;
states[i] = false; Not selected
There is an interesting app recommendation :
Checkbox It is a flexible test automation software . It is Ubuntu The main tools used in the certification program .
With HTML Format exported test report
You can use the check box without making any changes to check whether your system is working properly , Or you can develop your own set of tests to check your requirements . For more information , See the checkbox tutorial .
Checkbox You can choose to generate different formats (JSON、HTML etc. ) The test report of , It can be used to easily share the results of test sessions .
First , We installed some “ Provider ” package . The purpose of the provider is to encapsulate the test description and its related tools and data . Provider with Debian Packages are provided in the form of packages , This allows us to express dependencies to ensure that the required external packages are installed , We can also separate these dependencies ; for example , The provider for server testing does not actually contain server specific test definitions ( We try to keep all test definitions in Checkbox In the provider ), But it does depend on all the packages needed for server testing . Most users will want resources and... That contain many prefabricated tests Checkbox Provider , But the organization allows delivery of tiny cores and fully customized providers , Without additional dependencies .
The provider is described in the configuration file ( Stored in /usr/share/plainbox-providers-1 in ). This file describes where you can find all the files for the provider . This file is usually automatically managed ( It will be described in detail later ). The provider can send jobs 、 Binary 、 Data and test plan .
The assignment or test is Checkbox The smallest unit or description known . It describes a single test ( Historically, they have been called homework ). The simplest job is :
id: Work
plug-in unit : Manual
_description: Make sure your computer is turned on . Is the computer turned on ?
Jobs are provided in the provider's job directory . This super simple example contains three fields :id、plugin and description. ( A real job should also include a _summary Field .)id Identification work ( Of course ),_description Provide a plain text description of the work . In this case , The description is displayed to the user , Because the plug-in type is manual , Users must respond . Plug in types include ( But not limited to, ):Manual – Tests that require users to perform certain actions and report results .
shell—— Automated testing without user interaction ; Whether the test passes or fails depends on the return value of the script or command .
resource – Jobs that identify resources owned by the system . ( For example, independence GPU、Wi-Fi modular ). This information can later be used by other jobs to control the execution of other jobs . ( for example , without Wi-Fi chip , Then skip Wi-Fi test ).
user-interact – A test that requires the user to perform certain actions before executing the test . then , The test will automatically pass or fail according to the output of the test . An example is the key / Media control , It runs a tool to detect keys , Ask the user to press the volume key , Then exit automatically after pressing the last key or the user clicks the skip button in the tool .
user-interact-verify – This type of test is similar to user-interact test , Only the output of the test is displayed to the user , Then the user must decide whether it passes or fails . One example is usb/disk_detect test , It requires the user to insert USB secret key , Click the test button , Then manually verify that USB secret key .
user-verify – Tests performed manually or automatically by the user , Require the user to verify whether the result passes or fails . An example of this is the graph maximum resolution test , It detects the system to determine the maximum resolution supported , Then ask the user to confirm whether the resolution is correct .
边栏推荐
猜你喜欢
DOM 事件流(事件捕获和事件冒泡)
Electromagnetic field and electromagnetic wave experiment three familiar with the application of Mathematica software in the field of electromagnetic field
解决报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)
26. GD32F103C8T6入门教程--正交编码器的使用
OSPF Foundation
Internal implementation principle of sort
蚓激酶白蛋白纳米粒/红细胞膜定向包裹血红蛋白-白蛋白纳米粒的研究制备
机器学习 sklearn数据集
常用功能测试的检查点与用例设计思路
笔试强训第18天
随机推荐
mysql安装提示应用程序无法正常启动(0xc000007b,如何解决?
Aardio - function execution failed retry test
蓝灯绿灯按时明灭,编程古鲁的密语
LeetCode:1260. Two dimensional mesh migration [one dimensional expansion + splicing]
如何去除百度广告
攻防世界----favorite_number
别学了!这 5 种即将消亡的编程语言
载二氢丹参酮Ⅰ白蛋白纳米粒/去甲斑蝥素白蛋白纳米粒/伏立康唑白蛋白纳米粒的制备研究
Content with element type "resultmap" must match "(constructor?, id*, result*, association*, collection*, discriminato?) “
45、记录训练OrienMask过程和部署运适科技深度相机过程
常用功能测试的检查点与用例设计思路
The ability to detect movement in vivo and build a safe and reliable payment level "face brushing" experience
紫杉醇联合2-甲氧基雌二醇的白蛋白纳米粒/荜茇酰胺白蛋白纳米粒的研究制备
22张图带你深入剖析前缀、中缀、后缀表达式以及表达式求值
Find a single dog -- repeat the number twice to find a single number
Model模态框点击其他除了模态框区域不消失
Loop structure: while and do while structures
NFS share
45. Record the training process of orienmask and the process of deploying Yunshi technology depth camera
【transformer】ViT