”;
The “kivy.tools” module consists of some very useful scripts, command-line utilities and examples.
KV Viewer
Kivy doesn”t have any official visual GUI designer. Therefore, the layout design for a Kivy application becomes tedious, as the placement of widget as planned while creating the “kv” file doesn”t often give the desired result when loaded in the application.
This Kv-viewer utility allows you to dynamically display a “kv” file, taking its changes into account. One of the advantages of this utility is that you can load this “kv” script only when you are satisfied with this layout.
KViewer is a command-line utility that requires a “.kv” file as an argument.
python kviewer.py demo.kv
Example
The following “kv” file contains the design of a Demo app −
TabbedPanel: size_hint: .8, .8 pos_hint: {''center_x'': .5, ''center_y'': .5} do_default_tab: False TabbedPanelItem: text:"Register Tab" GridLayout: cols:2 Label: text:"Name" size_hint:(.2, .1) pos_hint:{''x'':.2, ''y'':.75} TextInput: size_hint:(.4, .1) pos_hint:{''x'':.3, ''y'':.65} Label: text:"email" size_hint:(.2, .1) pos_hint:{''x'':.2, ''y'':.55} TextInput: size_hint:(.4, .1) pos_hint:{''x'':.3, ''y'':.45} Label: text:"Password" size_hint:(.2, .1) pos_hint:{''x'':.2, ''y'':.35} TextInput: password:True size_hint:(.4, .1) pos:(400, 150) pos_hint:{''x'':.3, ''y'':.25} Button: text:''Submit'' size_hint : (.2, .1) pos_hint : {''center_x'':.5, ''center_y'':.09} TabbedPanelItem: text:''Login Tab'' GridLayout: cols:2 Label: text:"email" size_hint:(.2, .1) pos_hint:{''x'':.2, ''y'':.55} TextInput: size_hint:(.4, .1) pos_hint:{''x'':.3, ''y'':.45} Label: text:"Password" size_hint:(.2, .1) pos_hint:{''x'':.2, ''y'':.35} TextInput: password:True size_hint:(.4, .1) pos:(400, 150) pos_hint:{''x'':.3, ''y'':.25} Button: text:''Submit'' size_hint : (.2, .1) pos_hint : {''center_x'':.5, ''center_y'':.09}
Output
Let us view the design with the kviewer utility −
python kviewer.py demo.kv
It will produce the following output window −
Benchmark
This script performs and displays the results of a set of benchmarks. These provide a set of metrics mainly aimed at gauging the OpenGL performance of your system.
To run the utility, use the following command −
Python benchmark.py
You will get the following output −
GL Vendor: b''Intel'' GL Renderer: b''Intel(R) Iris(R) Xe Graphics'' GL Version: b''4.6.0 - Build 31.0.101.3959'' Benchmark --------- 1/8 Core: button creation (10000 * 10 a-z) 4.246505 2/8 Core: button creation (10000 * 10 a-z), with Clock.tick [INFO ] [GL ] NPOT texture support is available 6.612230 3/8 Core: label creation (10000 * 10 a-z) 4.543708 4/8 Core: label creation (10000 * 10 a-z), with Clock.tick 9.790683 5/8 Widget: creation (10000 Widget) 0.308506 6/8 Widget: creation (10000 Widget + 1 root) 1.734984 7/8 Widget: event dispatch (1000 on_update in 10*1000 Widget) 0.088639 8/8 Widget: empty drawing (10000 Widget + 1 root) 0.000706 Result: 27.325960 Do you want to send benchmark to gist.github.com (Y/n) : n No benchmark posted.
Generate Icons
This tool will help you to generate all the icons wanted for Google Play Store, App Store, Amazon store.
You need to give the name of the image file you want to generate the icons from, as the argument to generate-icons.py script found in the tools subdirectory.
python GPIcon.png
You will get the following output −
Generate App store high resolution: 1024x1024 Generate App store normal resolution: 512x512 Generate iPhone (iOS 7): 120x120 Generate iPhone @2 (iOS 7): 120x120 Generate iPad (iOS 7): 76x76 Generate iPad @2 (iOS 7): 152x152 Generate iPhone (iOS >= 6.1): 57x57 Generate iPhone @2 (iOS >= 6.1): 114x114 Generate iPad (iOS >= 6.1): 72x72 Generate iPad @2 (iOS >= 6.1): 114x114 Generate iTunes Artwork (ad-hoc): 512x512 Generate iTunes Artwork @2 (ad-hoc): 1024x1024 Generate Google Play icon: 512x512 Generate Launcher icon MDPI: 48x48 Generate Launcher icon HDPI: 72x72 Generate Launcher icon XHDPI: 96x96 Generate Launcher icon XXHDPI: 48x48 Generate Launcher icon XXXHDPI: 192x192 Generate Small icon: 114x114 Generate Large icon: 512x512
The icons generated by this utility are stored in the respective folders −
Report Tool
This tool is a helper for users. It generates a dump information that is useful during the debugging process.
Python report.py
Partial output is shown below −
============================================================== Options ============================================================== window = (''egl_rpi'', ''sdl2'', ''pygame'', ''sdl'', ''x11'') text = (''pil'', ''sdl2'', ''pygame'', ''sdlttf'') video = (''gstplayer'', ''ffmpeg'', ''ffpyplayer'', ''null'') audio = (''gstplayer'', ''pygame'', ''ffpyplayer'', ''sdl2'', ''avplayer'') image = (''tex'', ''imageio'', ''dds'', ''sdl2'', ''pygame'', ''pil'', ''ffpy'', ''gif'') camera = (''opencv'', ''gi'', ''avfoundation'', ''android'', ''picamera'') spelling = (''enchant'', ''osxappkit'') clipboard = (''android'', ''winctypes'', ''xsel'', ''xclip'', ''dbusklipper'', ''nspaste'', ''sdl2'', ''pygame'', ''dummy'', ''gtk3'') The report will be sent as an anonymous gist. Do you accept to send report to https://gist.github.com/ (Y/n) : n No report posted. Enter any key to leave.
”;