Friday, February 13, 2015

Data Science Series

I am writing a series R is a programming language for statistical programming. It is very similar to Python in that it is a scripting language. I contrast it with Python data analysis with modules like numpy and pandas. I am learning R, and since I know Python, I keep on trying to compare. It is best to use Anaconda or some other scientific distribution with most of the modules included. If a module is needed that is not included in Anaconda or from the conda command line utility, it can be easily added using pip program, again from the command line. You have to use the pip program inside Anaconda. For R, after installing the base program, add RStudio and you can add more packages from inside RStudio console.

Wednesday, August 13, 2014

58. TabbedPanel

TabbedPanels provide tabs to select between different screens.

The TabbedPanel widget is used for the root. The App class is needed for any application.

We have to have a subclass of the App class.

from kivy.uix.tabbedpanel import TabbedPanel
from import App

class Ex58(TabbedPanel):

class Ex58App(App):
    def build(self):
        return Ex58()
if __name__ == '__main__':

In the kv file, the MyImage dynamic class is created and it allows for a stretchable image.

The first 2 screens are of the images p1 and p2. There will only be tabs for the Panels and their width is 199 pixels.

The next 3 screens corresponds to images p3, p4 and p5.

# ex58.kv
    keep_ratio: False
    allow_stretch: True

    do_default_tab: False
    tab_width: 199
        text: 'The Basin'
            source: 'p1.png'
        text: 'Boise Rock'
            source: 'p2.png'
        text: 'Old Forest'
            source: 'p3.png'
        text: 'Old Man of the Mountain'
            source: 'p4.png'
        text: 'Flume Gorge'
            source: 'p5.png'

In this result, we select the p1 image. The window was resized to show all tabs. For the mobile, you will have to make calculations about the tab size so they all fit in a fixed-size screen.