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.


    Basic UI Question

    Pythonista
    5
    7
    6129
    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.
    • procryon
      procryon last edited by procryon

      So first of all I'd like to say hi to the community here because I'm pretty new. I understand the language enough to work with but I don't understand how to work with the GUI as I haven't seen any good documentation explaining how to program with the GUI.

      I wanted to make a simple program where I can input text in a text field and then when I click enter, what I typed appears in a label above. Every time I enter a new text and click enter, I want it to add on this text to the old one in the label above, but in a way so that every new text is on a new line. Can anybody please help me with this. Thanks in advance for your time and I'm really enjoying the app!

      1 Reply Last reply Reply Quote 0
      • TutorialDoctor
        TutorialDoctor last edited by

        I have several projects using the UI module that may help:

        https://github.com/TutorialDoctor/Pythonista-Projects

        NickAtNight 1 Reply Last reply Reply Quote 0
        • brumm
          brumm last edited by brumm

          ui-tutorial is maybe also a good start...

          import ui
          
          def button_tapped(sender):
              view['labelname'].text += 'hello\n'
          
          view = ui.View()
          view.background_color = 'white' 
          label = ui.Label()
          label.name = 'labelname'
          label.frame = (50,50,200,200)
          label.border_color = 'lightgrey'
          label.border_width = 1
          label.number_of_lines = 0    #most important line!!!
          label.corner_radius = 5
          label.text = ''
          view.add_subview(label)
          button = ui.Button(title='Add hello!')
          button.frame = (50,251,200,100)
          button.border_color = 'blue'
          button.border_width = 1
          button.corner_radius = 5
          button.action = button_tapped
          view.add_subview(button)
          view.present('fullscreen')
          
          1 Reply Last reply Reply Quote 0
          • NickAtNight
            NickAtNight @TutorialDoctor last edited by

            Wow @TutorialDoctor. Just down loaded and ran the Web Browser tutorial. Very Nice.

            1 Reply Last reply Reply Quote 0
            • TutorialDoctor
              TutorialDoctor last edited by

              @NickAtNight, that tutorial isn't mine but it is nice. Hehe. Someone named humberry.

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

                import ui
                
                w, h = ui.get_screen_size()
                    
                def textfield_action(sender):
                    sender.superview['textview'].text += sender.text.strip() + '\n'
                    sender.text = ''
                
                view = ui.View(name='Type text in the textfield and hit return...')
                view.add_subview(ui.TextView(frame=(0, 50, w, h-50), name='textview'))
                view['textview'].editable = False
                view.add_subview(ui.TextField(frame=(0, 0, w, 50), name='textfield'))
                view['textfield'].action = textfield_action
                view.present()
                
                1 Reply Last reply Reply Quote 0
                • procryon
                  procryon last edited by

                  Thanks for all the response everyone!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors