omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Event keys from external keyboard?

    Pythonista
    2
    7
    2085
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MahYam
      MahYam last edited by

      I’m using external Bluetooth Keyboard.And I want to know how to use event keys.For e.g:if I press ‘L’ then the code will print Hello

      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @MahYam last edited by mikael

        @MahYam, yes. See the help for ui.View methods View.get_key_commands() to define keys to react to, and View.key_command(sender) to process key presses.

        1 Reply Last reply Reply Quote 1
        • MahYam
          MahYam last edited by

          Thank you.Ill try it now

          mikael 1 Reply Last reply Reply Quote 0
          • mikael
            mikael @MahYam last edited by

            @MahYam, you can see a simple example for the methods here, just ignore all the scene stuff.

            1 Reply Last reply Reply Quote 0
            • MahYam
              MahYam last edited by ccc

              Thanks.But can I make it work without classes and so.Can you write me a code where you click ‘a’ and the console print(”hello")

              mikael 1 Reply Last reply Reply Quote 0
              • mikael
                mikael @MahYam last edited by

                @MahYam, if you do not want a visible UI, then things get a bit more complex, see this thread.

                1 Reply Last reply Reply Quote 0
                • MahYam
                  MahYam last edited by ccc

                  Can you pls change the code .Instead of clicking a button I want to press ‘S’ key.Thank you ,you are the best

                  from ui import*
                  from sound import*
                  from os import*
                  import photos
                  from time import*
                  x,y=get_screen_size()
                  def button_tapped(sender):
                  	img=photos.capture_image(camera='front')
                  	img.show()
                  	play_effect('8ve:8ve-slide-magic')
                  	view.close()
                  
                  view=View(bg_color='slateblue')
                  view.name = 'Hello'
                  view.background_color='white'
                  button=Button(title='Selfie')
                  button.center=(view.width*0.5,view.height*0.5)
                  
                  button.flex='LRTB'
                  button_font=('Avenir Next',20)
                  button.action=button_tapped
                  view.add_subview(button)
                  view.present('sheet',hide_title_bar=True)
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors