Protein SDK

DOWNLOAD
Hello, world. I'm Vinit Jogani, the creator of the SDK, and I'm going to quickly brief you about what you can do with it. Protein SDK is the next big thing in the world of Web and Desktop applications. It is an easy to learn and adapt python software development kit for building excellent GUI applications. You can create an application using python, html, css, javascript or jquery in minutes! You can change the mode from desktop to web simply by writing the name of the mode in the mode.txt file! The SDK allows you to: - Run pure python code, on any javascript event. - Render result of python function dynamically. - Create HTML User interfaces, using standard HTML, CSS, and Javascript! The SDK is powered by: - Google Chrome apps - Cherrypy Web Framework - Beautiful Soup Do you like PHP style rendering? No problem.
    -----------------------------------------
    HTML File:
    
    <body>
        <py>
            for i in range(0,100):
                print i;
        </py>
    </body>
    -----------------------------------------
Do you like Javascript events? No problem. (Only possible in desktop mode, due to security reasons)
    -----------------------------------------
    HTML File:
    
    <body>
        <button onclick='execute("function_name", "parameter1, parameter2, parameter3")'>Click Me!</button>
    </body>    
    -----------------------------------------
Do you like ASP.NET Razor MVC's request handling? No problem.
    -----------------------------------------
    HTML File:
    
    <form action='pythonpage'>
        <input name='id' type='text'></input>
        <input type='submit'></input>
    </form>    
    -----------------------------------------
    Python Code:
    
    def pythonpage(args):
        #DoSomething
        return args['id'] #return the input id
        
    def main(tools):
        tools.addPage('pythonpage',pythonpage)        
    -----------------------------------------
Audience: The target audience for this framework are all Python developers, beginners and advanced, that are tired of tedious GUI frameworks like Tkinter etc. which require long codes and are often too difficult. This is the primary reason why most of the Python apps are limited to back-end applications or consoles and do not include very dynamic and interactive GUI. However, the HyperText Markup Language, is very easy and suitable for designing good interfaces and forms quickly. This is also for people who want to write apps one time and use it for both desktop and web applications. Therefore, you get best of Python World and HTML World, in an easy to use SDK with many different options, AND you can run the same code on both - desktop and web, AND what's more - it's open source! How it works: The way the SDK works, is a very interesting topic. The launcher.pyw file runs the server.pyc file that starts a CherryPy server (for more information about Cherrypy, you can go to the CherryPy website). The server code does the following: - Loads all the python files in the pycode directory - Finds and executes the "main" function from the loaded code. It also passes a static class to the main function, called ServerTools. - ServerTools class contains method 'addPage(page_name, page_function)' which adds the page to the server. - For desktop applications, the server enables to execute python functions on javascript events using the execute page that the sdk.js sends request to. The execute page takes in two parameters: fid and args. The fid is the function name that you want to be executed, and the args are any arguments you need to supply to the function. The execute page finds the function name from all the python files in the pycode directory and executes it. - The sdk.js file is a jquery script which sends GET requests to the server's pages, to execute functions. This acts as a link between the Python code and the HTML code. To add a new page, simply create an html page in the root directory. Your code file in pycode directory should look like this:
            def index(self):
                return file("index.html").read() #The HTML file that needs to be added. The path is relative to the root directory.
            
            def main(tools):
                tools.addPage('', index) # '' means root directory, or default page
                tools.addPage('index', index)
            
That's it! Any html code in index.html will now be displayed when you run the launcher! The server launches the chrome app module to display the localhost url. Note that the port is written in the port.txt file in the root directory. The server code checks for all open ports and runs it. Tbe ServerTools class (parameter to the main function) has following functions: - addPage(page_name, page_function) -> adds a page dynamically - url() -> returns the request url - Session(key) -> returns the session value corresponding to the key - Session(key, value) -> changes session value for the key To get parameters from query string or post requests, you can define a page like this:
            def echo(self, text):
                return "<span>" + text + "</span>" #You can add HTML code directly too!
                
            def index(self):
                return file("index.html") #The HTML file that needs to be added. The path is relative to the root directory.
            
            def main(tools):
                tools.addPage('index', index) #You can add multiple pages too!
                tools.addPage('print', echo) #Page name and the name of the function do not need to be the same
                tools.addPage('echo', echo) #A single page function can be mapped to two urls too!