Code Monkey home page Code Monkey logo

Comments (15)

dddomodossola avatar dddomodossola commented on June 24, 2024

Hello @tellts ,

Here is an example for you. In the following code the application handles the window resize to adapt the layout on different screen resolutions. To verify its behaviour just resize the browser screen and you will see the layout change.

import remi.gui as gui
from remi import start, App

class MyApp(App):
    def main(self):
        #creating a container GridBox type
        self.main_container = gui.GridBox(width='100%', height='100%', style={'margin':'0px auto'})
        
        label = gui.Label('This is a label')
        label.style['background-color'] = 'lightgreen'
        button = gui.Button('A button', height='100%')

        text = gui.TextInput()
        #defining layout matrix, have to be iterable of iterable
        self.main_container.define_grid(['ab',
                                    'ac'])
        self.main_container.append({'a':label, 'b':button, 'c':text})
        #setting sizes for rows and columns
        self.main_container.style.update({'grid-template-columns':'10% 90%', 'grid-template-rows':'10% 90%'})

        # returning the root widget
        return self.main_container
    
    def onpageshow(self, emitter, width, height):
        self.onresize(emitter, width, height)

    def onresize(self, emitter, width, height):
        #redefining grid layout
        if float(width)<float(height):
            self.main_container.define_grid(['c','a','b'])
            self.main_container.style.update({'grid-template-columns':'100%', 'grid-template-rows':'33% 33% 33%'})
        else:
            self.main_container.define_grid(['ab',
                                    'ac'])
            self.main_container.style.update({'grid-template-columns':'10% 90%', 'grid-template-rows':'10% 90%'})


if __name__ == "__main__":
    # starts the webserver
    start(MyApp, address='0.0.0.0', port=0, start_browser=True)

from remi.

tellts avatar tellts commented on June 24, 2024

Thanks you. Can you please tell me how to run this sample code on a mobile device?

from remi.

dddomodossola avatar dddomodossola commented on June 24, 2024

The easiest way to run python on Android is using the QPython app. Of course remi can be used in any python capable device.

from remi.

tellts avatar tellts commented on June 24, 2024

I have installed the Chaquopy https://chaquo.com/chaquopy/ . https://play.google.com/store/apps/details?id=com.chaquo.python.demo3 .
print(os.popen('echo "hello"').readline())
import runpy runpy.run_path("a1.py")
x = runpy.run_path("a1.py") print('x')
This is a free environment for running Python programs. Qpython does not work for me, since the tablet with Android 4.2 with a diagonal of about 10.

from remi.

tellts avatar tellts commented on June 24, 2024

These are 3 examples of how the code is run in this environment. Line breaks have been removed between commands.

from remi.

dddomodossola avatar dddomodossola commented on June 24, 2024

Does it provide the possibility to install pypi packages? If so you can install remi and run your app

from remi.

tellts avatar tellts commented on June 24, 2024

If I understand correctly, this is not the way to do it. But I can ask the support service how to install the program from the distribution.
https://chaquo.com/pypi-7.0/

https://chaquo.com/pypi/

from remi.

tellts avatar tellts commented on June 24, 2024

Hello. Could you tell me what questions to ask correctly or ask there yourself, since I myself can’t do it quite professionally?
chaquo/chaquopy#689

from remi.

dddomodossola avatar dddomodossola commented on June 24, 2024

Hello @tellts ,
I think that they understood your question.
They told you that a configuration file has to be modified inside your Android device. I suppose you should use a text editor.
After editing the configuration file, you should be able to do a pip install remi (maybe the chaquopy provides a console to write this command).

from remi.

tellts avatar tellts commented on June 24, 2024

If I am not mistaken, this must be done in the Android Studio by installing a special plugin https://chaquo.com/chaquopy/doc/current/android.html (this is written at the very bottom of the page). Another example is here https://chaquo.com/chaquopy/doc/current/faq.html#faq-mirror

from remi.

dddomodossola avatar dddomodossola commented on June 24, 2024

I think it is correct.

I suggest you to use QPython, it is easy to use and full featured.

from remi.

tellts avatar tellts commented on June 24, 2024

Qpython does not install on older tablets with Android 4.x

from remi.

dddomodossola avatar dddomodossola commented on June 24, 2024

Do you really need to run the python script on the mobile device? Consider that remi is a Web Gui, it means that you can run the App on another device (a PC for example) and you can see thr interface on other devices in the network

from remi.

tellts avatar tellts commented on June 24, 2024

Hello. Yes, I wanted to be able to make programs in Python with the GUI, but at the same time, so that they were autonomous from the Internet.

from remi.

dddomodossola avatar dddomodossola commented on June 24, 2024

Unfortunately I don't know about other solutions to run python on Android

from remi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.