Forum Archive

How do I Change color of top bar?

MOD0

Hi, I’ve recently started pythonista for iOS.
And I don't know how i change color of top bar.
I don't know its bar name exact, so i decided to ask here.
Please look at the image
http://i.imgur.com/ru9o49j.png

I mean I want to change color that space(bar?) , can i do that?

or Please help me on how to full space when ran myself gui program.
like this example game program. http://i.imgur.com/lNExnah.png

Thank you for reading.

bennr01

@MOd0 you can pass title_bar_color to View.present().

MOD0

@bennr01 said:

title_bar_color to View.present().

Tkanks for tell that, I became capable of change default bar_color.
i pleased.

but, how can i change "title_bar_color" when running program like when change "background_color" ,(for example label,button,,,).

for example i want change "title_bar_color" like that

  1. red (when start progrum)

  1. blue ( when "button1 = sender.superview['button1']" pushed)

↓↑

  1. green ( when "button2 = sender.superview['button2']" pushed)
lachlantula

This works decently.

import time, ui

class Interface():

    @ui.in_background
    def Switch(sender):
        if Interface.bgcolour == 'red':
            Interface.bgcolour = 'blue'
            Interface.btn.title = 'Red!'
        else:
            Interface.bgcolour = 'red'
            Interface.btn.title = 'Blue!'
        Interface.v.close()
        time.sleep(1)
        Interface.v.background_color = Interface.bgcolour
        Interface.v.present('sheet', title_bar_color = Interface.bgcolour)

    btn = ui.Button()
    btn.title = 'Blue!'
    btn.x = 0
    btn.y = 0
    btn.width = 300
    btn.height = 300
    btn.action = Switch

    bgcolour = 'red'
    v = ui.View(background_color = bgcolour)
    v.add_subview(btn)
    v.width = 300
    v.height = 300

x = Interface()
x.v.present('sheet', title_bar_color = 'red')
JonB

You need to resort to objective c to do this....

https://gist.github.com/a74e256d3972192f3d70b9bc1bcbe1bc

MOD0

@lachlantula
Thanks for tell me that add subview with changing bar_color.
I learned python grammar which i didn't know until now.

@JonB
Thanks for tell me the :URL.
I achieve my objective that changing bar_color when running program without change or add subview.

for everyone who answered my asking
Thank you for answering my question, and
I thank you for reading it through.
By now, I guess you get used to my funny English writing.