TitleBar for native with frameless option #770
Closed
phoskee
started this conversation in
Ideas / Feature Requests
Replies: 2 comments 10 replies
-
There is no point in creating a titlebar if I try to remove it natively with the frameless paramenter, obviously. bar.py from nicegui import ui
import pygetwindow as gw
bgcolor = '#eef5fb'
def titlebar(bool: True) -> None:
"""Title bar
:param bool: True for MacOS theme
"""
def w_close():
windo = gw.getWindowsWithTitle('NiceGUI')[0]
windo.close()
def w_min():
windo = gw.getWindowsWithTitle('NiceGUI')[0]
windo.minimize()
def w_max():
windo = gw.getWindowsWithTitle('NiceGUI')[0]
windo.maximize()
def WindowsOS():
with ui.header().classes(f'w-full h-8 p-2 bg-[{bgcolor}] pywebview-drag-region'):
with ui.row().classes('gap-1 relative left-[1px] top-[1px] ml-auto mr-0'):
ui.icon('minimize').classes(
'text-[13px] text-black').on('click', w_min)
ui.icon('crop_square').classes(
'text-[13px] text-black').on('click', w_max)
ui.icon('close').classes(
'text-[13px] text-black').on('click', w_close)
ui.label('Test Title Bar').classes(
'text-sm text-gray-600 absolute left-1/2 top-[6px]').style('transform: translateX(-50%)')
def MacOS():
with ui.header().classes(f'w-full h-8 p-2 bg-[{bgcolor}] pywebview-drag-region'):
with ui.row().classes('gap-1 relative left-[1px] top-[1px]'):
ui.icon('circle').classes(
'text-[13px] text-red-400').on('click', w_close)
ui.icon('circle').classes(
'text-[13px] text-yellow-400').on('click', w_min)
ui.icon('circle').classes(
'text-[13px] text-green-400').on('click', w_max)
ui.label('Test Title Bar').classes(
'text-sm text-gray-600 absolute left-1/2 top-[6px]').style('transform: translateX(-50%)')
if bool == True:
return MacOS()
else:
return WindowsOS() maybe it could be an idea for the future to better customize the interface ! |
Beta Was this translation helpful? Give feedback.
5 replies
-
@phoskee could you try out my PR #917? It offers calling methods on the pywebview window via a proxy object |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Reading the documentation on nicegui.io, I was always impressed by the examples with a small window.
So I said to myself, why now that you can pass
webview
arguments, don't we make it a reality?The first difficulties I encountered with padding, thenicegui-content
css has a default padding of 16px.I tried to solve ( and not in the easiest way) with:
It only serves me for testing and I managed to get this:pywebview-drag-region
gives us the ability to move the window exclusively from the title bar.This is the result:

Another difficulty was to associate an event with the buttons:I gave it a read and realized that there is webview.destroy(), webview.minimize(), webview.maximize().
I am not an expert, and I tried to modify native_mode.py:The intention was then to create:orIn order to get them, by test, with:Of course all this doesn't work, global_windows doesn't exist etc etc, a little bit also due to my inexperienceI think though that it could be a very good idea, maybe
Beta Was this translation helpful? Give feedback.
All reactions