A custom titlebar that replaces the OS provided titlebar, thus giving you control the is not possible using the OS provided titlebar such as the color. NOTE LINUX USERS - at the moment the minimize function is not yet working. Windows users should have no problem and it should fun
(title='', icon=None, text_color=None, background_color=None, font=None, key=None, k=None)
| 13257 | |
| 13258 | |
| 13259 | def Titlebar(title='', icon=None, text_color=None, background_color=None, font=None, key=None, k=None): |
| 13260 | """ |
| 13261 | A custom titlebar that replaces the OS provided titlebar, thus giving you control |
| 13262 | the is not possible using the OS provided titlebar such as the color. |
| 13263 | |
| 13264 | NOTE LINUX USERS - at the moment the minimize function is not yet working. Windows users |
| 13265 | should have no problem and it should function as a normal window would. |
| 13266 | |
| 13267 | This titlebar is created from a row of elements that is then encapsulated into a |
| 13268 | one Column element which is what this Titlebar function returns to you. |
| 13269 | |
| 13270 | A custom titlebar removes the margins from your window. If you want the remainder |
| 13271 | of your Window to have margins, place the layout after the Titlebar into a Column and |
| 13272 | set the pad of that Column to the dimensions you would like your margins to have. |
| 13273 | |
| 13274 | The Titlebar is a COLUMN element. You can thus call the update method for the column and |
| 13275 | perform operations such as making the column visible/invisible |
| 13276 | |
| 13277 | :param icon: Can be either a filename or Base64 byte string of a PNG or GIF. This is used in an Image element to create the titlebar |
| 13278 | :type icon: str or bytes or None |
| 13279 | :param title: The "title" to show in the titlebar |
| 13280 | :type title: str |
| 13281 | :param text_color: Text color for titlebar |
| 13282 | :type text_color: str | None |
| 13283 | :param background_color: Background color for titlebar |
| 13284 | :type background_color: str | None |
| 13285 | :param font: Font to be used for the text and the symbols |
| 13286 | :type font: (str or (str, int[, str]) or None) |
| 13287 | :param key: Identifies an Element. Should be UNIQUE to this window. |
| 13288 | :type key: str | int | tuple | object | None |
| 13289 | :param k: Exactly the same as key. Choose one of them to use |
| 13290 | :type k: str | int | tuple | object | None |
| 13291 | :return: A single Column element that has eveything in 1 element |
| 13292 | :rtype: Column |
| 13293 | """ |
| 13294 | bc = background_color or CUSTOM_TITLEBAR_BACKGROUND_COLOR or theme_button_color()[1] |
| 13295 | tc = text_color or CUSTOM_TITLEBAR_TEXT_COLOR or theme_button_color()[0] |
| 13296 | font = font or CUSTOM_TITLEBAR_FONT or ('Helvetica', 12) |
| 13297 | key = k or key |
| 13298 | if key is None: |
| 13299 | key = TITLEBAR_KEY |
| 13300 | if isinstance(icon, bytes): |
| 13301 | icon_and_text_portion = [Image(data=icon, background_color=bc, key=TITLEBAR_IMAGE_KEY)] |
| 13302 | elif icon == TITLEBAR_DO_NOT_USE_AN_ICON: |
| 13303 | icon_and_text_portion = [] |
| 13304 | elif icon is not None: |
| 13305 | icon_and_text_portion = [Image(filename=icon, background_color=bc, key=TITLEBAR_IMAGE_KEY)] |
| 13306 | elif CUSTOM_TITLEBAR_ICON is not None: |
| 13307 | if isinstance(CUSTOM_TITLEBAR_ICON, bytes): |
| 13308 | icon_and_text_portion = [Image(data=CUSTOM_TITLEBAR_ICON, background_color=bc, key=TITLEBAR_IMAGE_KEY)] |
| 13309 | else: |
| 13310 | icon_and_text_portion = [Image(filename=CUSTOM_TITLEBAR_ICON, background_color=bc, key=TITLEBAR_IMAGE_KEY)] |
| 13311 | else: |
| 13312 | icon_and_text_portion = [Image(data=DEFAULT_BASE64_ICON_16_BY_16, background_color=bc, key=TITLEBAR_IMAGE_KEY)] |
| 13313 | |
| 13314 | icon_and_text_portion += [T(title, text_color=tc, background_color=bc, font=font, grab=True, key=TITLEBAR_TEXT_KEY)] |
| 13315 | |
| 13316 | return Column([[Column([icon_and_text_portion], pad=(0, 0), background_color=bc), |
no test coverage detected