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.
Possible to change menubar/header color and font for ui.view?
-
@zipit thanks for the answer, I will try using pop-over and see how it looks. I just like how the NavigationView covers the whole ui.view this way
-
Is there a way to load a pyui file for the main view without using
Main_view.present('pyui file)
this crash is really bugging me tried different options like "popover" and "panel" for NavigationView but in the end it always crashes -
This should look something like:
ui.load_view('My UI').present('sheet')
...You could also leave the
ui.load_view()
parameter blank and then make sure thatmy_script.py
andmy_script.pyui
have matching names or could post a minimal example that actually crashes so that we can debug it together.It is easier to debug Python code than it is to debug English prose.
-
@ccc thx. Gonna try your example first if it does not work. I will try to post it in a short version
-
@ccc it's not crashing anymore now thanks to you!
I also found an other issue that I could fix thanks to this
Really greatful for your help -
Is it possible to dynamically change the title bar color?
I have a ui.View derived class, where initially set the title_bar_color when I present the view. Based on user input, I would like to change the color of the title bar. Is this possible?
-
Are you presentng full screen, sheet, or panel?
-
Bjucha, I am presenting a sheet.
The code is:
if __name__ == "__main__": v = FSButtonView() v.present('sheet', title_bar_color='#334444', hide_close_button=True, orientation=['portrait'])
The FSButtonView class derives from the ui.View class.
In the code, I add an ImageView instance as a subview of the main view to show an image that covers all the screen except the title bar. I want the title bar so the cell signal strength, the time, etc. are visible at the top of my iPhone screen. I also want the background of the title bar to match the background of the image. The image background is approximately the color '#334444'.
By tapping the screen (using Morse code) I can control various functions, including removing the subview (image) from the view, and later adding it back. When it's removed, the screen becomes black (minimum battery power), and I want the title bar to become black too. When I add the image back, I want the title bar to return to the image background color, not to the view background color).
The problem now is that the title bar is always the image background color. It do not know how to change the title bar to be black, and then how to change it back to the image color if the image (sub-view) is added back to the view.
If I hide the title bar by using a key argument (I think it was "hide_title_bar") in the "present" methods, then the image covers the entire screen, and then the cell signal strength, time, etc.., are not visible. I want those to remain visible.
I'm not sure what would happen if I hid the title bar when the image was removed, and showed the title bar when the image was put back. I also don't know how to hide/show the title bar dynamically, or if that's even possible.
-
So, this is not at all robust, and could change in any pythonista version.... but here is a way to get access to the title bar, to change its color, hide it, etc.
v=ui.View() v.present('sheet') V=ObjCInstance(v) titlebarbkg= V.superview().superview().superview().subviews()[1].subviews()[0] #a more robust way might be to keep traversing up until one of subviews is a UINavigationBar, then follow that down to the UINavigationBarBackground titlebarbkg.backgroundColor=UIColor.redColor() #titlebarbkg.backgroundColor=UIColor.UIColor.colorWithHexString_('ffee22') #titlebarbkg.hidden=True
-
JonB, thank you very much! That worked. I had tried to write some code that iterated over Obective C UI items, trying to find the item that mattered and changing it's color, but I never got it to work.
Eventually, I'll try to figure out the hierarchy using your code as a guide, and match to the right names so that the code is somewhat more robust to version changes. For now, I added the following method to my ui.View-derived class, that allows me to change the title bar color dynamically.
def change_title_bar_color(self, hex_color): """ Change the title bar color to the passed color. """ vv = ObjCInstance(self) bar_bckgnd = vv.superview().superview().superview().subviews()[1].subviews()[0] bar_bckgnd.backgroundColor = UIColor.colorWithHexString_(hex_color)
-
This post is deleted!