Pysimplegui: [Request] Background color for titlebar and menubar

Created on 21 Dec 2018  ·  10Comments  ·  Source: PySimpleGUI/PySimpleGUI

screenshot

import turtle as t
import PySimpleGUI as sg

menu_def = [
    ['File',['Open', ['Hello', ['U', ['Mum', ['lasagna']]]]]],
    ['Melon'],
]

sg.SetOptions(text_color="#e4e4e4", font='opensans 11')

layout = [
    [sg.Menu(menu_def)],
    [sg.Text("Welkom Gebruiker", background_color="#343434", font='sfprodisplay 25 bold')],
    [sg.Text("Lijn Grootte", background_color="#343434"), sg.Input(45)],
    [sg.Text("Aantal Vakjes", background_color="#343434"), sg.Input(10)],
    [sg.Text("Skip Turtle Animatie", background_color="#343434", font='opensans 11'), sg.Radio('Yes', "radio1", default=False, background_color="#343434"), sg.Radio('No', 'radio1', background_color="#343434")],
    [sg.Button(image_filename=r"D:\User\Desktop\Apple\Pictures\begin.png", border_width=0)]
]

window = sg.Window("User Turtle", background_color="#343434", icon=r"D:\User\Desktop\Apple\Pictures\myicon.ico")
event, entered = window.Layout(layout).Read()


if entered[2]:
    # Stopt refresh zodat bord instant is.
    t.tracer(0, 0)
    # Zet Turtle op hoogste snelheid/
    t.speed(0)

elif entered[3]:
    pass
Done - Download from GitHub

Most helpful comment

Whew! Done!

ButtonMenus for tkinter is done and checked into Master Branch.

buttonmenu

This menu was created using this code:

import PySimpleGUI as sg
# import PySimpleGUIQt as sg

sg.ChangeLookAndFeel('Black')

menu_def = ['&File', ['&Open', '!&Save', 'E&xit', 'Properties']]
edit_def = ['Edit', ['&Edit', '&Menu', 'Items', 'Properties']]

layout = [
            [sg.ButtonMenu('File', menu_def, button_color=('white', 'black'), key='_FILE_'),
             sg.ButtonMenu('Edit', menu_def,  button_color=('white', 'black'), key='_EDIT_'),
             sg.Stretch()],
            [sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_')],
            [sg.Input(do_not_clear=True, key='_IN_')],
            [sg.Button('Show'), sg.Button('Exit')]
         ]

window = sg.Window('Window Title',
                   no_titlebar=True,
                   border_depth=0,
                   grab_anywhere=True,
                   ).Layout(layout)

while True:             # Event Loop
    event, values = window.Read()
    if event in  (None, 'Exit'):
        break
    print(event, values)
    if event == '_FILE_':               # if a File menu item chosen
        if values[event] == 'Exit':    # test which item chosen
            break
    if event == 'Show':
        window.Element('_EDIT_').Update(edit_def)   # change the edit menu definition

window.Close()

They work exactly the same way as PySimpleGUIQt ButtonMenus work.

If you change the import statement at the top to Qt, the code works in an identical manner.

Hopefully this gets you closer to what you're looking for. At least you can now have cascading menus that match your background color.

While you cannot use shortcut keys to access the top-level menu buttons, you can use shortcuts once the menu is open.

I'm glad to have this one now off the list.

All 10 comments

Is it even possible to change title screen to another color?

You cannot change the titlebar color.

You can, however, remove the title bar and draw your own. You will have to implement all the buttons yourself.

I'm checking to see how to change the menubar colors.

Not a good sign for menu bar colors.

I checked for tkinter, Qt and WxPython. Everyone says that is can't be done unless you make windows systems calls.

Here's one attempt using WxPython
http://code.activestate.com/recipes/440507-changing-the-background-color-of-the-menu-bar-in-a/

You could potentially make a series of ButtonMenus across the top, but I've only implemented those on PySimpleGUIQt so far. They won't behave exactly like normal menus however.

I'm kinda shocked that I'm unable to create windows that have a particular color for all parts of the window. That tells me that applications that do this are working at a very low level within Windows or Linux, perhaps making Windows system calls directly.

Really sorry about this. I'll see how it looks to make several ButtonMenus across the top.

I'm trying to scramble and implement the ButtonMenu Element for tkinter.

Here's what it looks like when using Qt:

image

Not good with those down arrows.

Also, you won't be able to invoke the menu using the Alt-keys.

tkinter could be a bit better.

Here's the same code running on tkinter:
image

No arrows.

I don't yet have the menuing system hooked up to it yet, but those are real tkinter "Menubutton" items. Why Qt calls them ButtonMenus and tkinter calls them MenuButtons beats me. I'm calling them ButtonMenus in PySimpleGUI code so that the SDK remains consistent.

I hope to have the feature done today, if I can finish hooking up real menus to the buttons. I've been wanting to finish this element on tkinter so this is a good time to do it. I just dread working with my recursive menu code.... gets me every time.

Whew! Done!

ButtonMenus for tkinter is done and checked into Master Branch.

buttonmenu

This menu was created using this code:

import PySimpleGUI as sg
# import PySimpleGUIQt as sg

sg.ChangeLookAndFeel('Black')

menu_def = ['&File', ['&Open', '!&Save', 'E&xit', 'Properties']]
edit_def = ['Edit', ['&Edit', '&Menu', 'Items', 'Properties']]

layout = [
            [sg.ButtonMenu('File', menu_def, button_color=('white', 'black'), key='_FILE_'),
             sg.ButtonMenu('Edit', menu_def,  button_color=('white', 'black'), key='_EDIT_'),
             sg.Stretch()],
            [sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_')],
            [sg.Input(do_not_clear=True, key='_IN_')],
            [sg.Button('Show'), sg.Button('Exit')]
         ]

window = sg.Window('Window Title',
                   no_titlebar=True,
                   border_depth=0,
                   grab_anywhere=True,
                   ).Layout(layout)

while True:             # Event Loop
    event, values = window.Read()
    if event in  (None, 'Exit'):
        break
    print(event, values)
    if event == '_FILE_':               # if a File menu item chosen
        if values[event] == 'Exit':    # test which item chosen
            break
    if event == 'Show':
        window.Element('_EDIT_').Update(edit_def)   # change the edit menu definition

window.Close()

They work exactly the same way as PySimpleGUIQt ButtonMenus work.

If you change the import statement at the top to Qt, the code works in an identical manner.

Hopefully this gets you closer to what you're looking for. At least you can now have cascading menus that match your background color.

While you cannot use shortcut keys to access the top-level menu buttons, you can use shortcuts once the menu is open.

I'm glad to have this one now off the list.

You are an angle <3

Op vr 21 dec. 2018 17:09 schreef MikeTheWatchGuy <[email protected]:

Whew! Done!

ButtonMenus for tkinter is done and checked into Master Branch.

[image: buttonmenu]
https://user-images.githubusercontent.com/13696193/50351561-95a8e400-0510-11e9-9e9e-0cbc30fe3c06.gif

This menu was created using this code:

import PySimpleGUI as sg# import PySimpleGUIQt as sg

sg.ChangeLookAndFeel('Black')

menu_def = ['&File', ['&Open', '!&Save', 'E&xit', 'Properties']]
edit_def = ['Edit', ['&Edit', '&Menu', 'Items', 'Properties']]

layout = [
[sg.ButtonMenu('File', menu_def, button_color=('white', 'black'), key='_FILE_'),
sg.ButtonMenu('Edit', menu_def, button_color=('white', 'black'), key='_EDIT_'),
sg.Stretch()],
[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_')],
[sg.Input(do_not_clear=True, key='_IN_')],
[sg.Button('Show'), sg.Button('Exit')]
]

window = sg.Window('Window Title',
no_titlebar=True,
border_depth=0,
grab_anywhere=True,
).Layout(layout)
while True: # Event Loop
event, values = window.Read()
if event in (None, 'Exit'):
break
print(event, values)
if event == '_FILE_': # if a File menu item chosen
if values[event] == 'Exit': # test which item chosen
break
if event == 'Show':
window.Element('_EDIT_').Update(edit_def) # change the edit menu definition

window.Close()

They work exactly the same way as PySimpleGUIQt ButtonMenus work.

If you change the import statement at the top to Qt, the code works in an
identical manner.

Hopefully this gets you closer to what you're looking for. At least you
can now have cascading menus that match your background color.

While you cannot use shortcut keys to access the top-level menu buttons,
you can use shortcuts once the menu is open.

I'm glad to have this one now off the list.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/961#issuecomment-449428991,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AqiZ00NdP5HuCgZxOrb6---L3ZRLTq5Cks5u7QfUgaJpZM4Zdw4V
.

I think this one is done. Will release to PyPI soonish.

Is it possible to change the pop-uped menu_def's background color? means when clicked 'File' or 'Edit' small popup window...

There's no option for color of menu now. Anyway, here workaround available

image

import PySimpleGUI as sg

sg.ChangeLookAndFeel('DarkGrey')

menu_def = ['&File', ['&Open', '!&Save', 'E&xit', 'Properties']]
edit_def = ['Edit',  ['&Edit', '&Menu',  'Items', 'Properties']]

layout = [
            [sg.ButtonMenu('File', menu_def, key='_FILE_'),
             sg.ButtonMenu('Edit', edit_def, key='_EDIT_'),
             sg.Stretch()],
            [sg.Multiline("", size=(50, 5))],
            [sg.Button('Exit')],
         ]

window = sg.Window('Window Title', layout, no_titlebar=True, border_depth=0,
    grab_anywhere=True, finalize=True)

# Set color here for Menu, not ButtonMenu.
window['_FILE_'].TKMenu.configure(fg='white', bg='blue')

while True:

    event, values = window.read()
    if event in  (sg.WINDOW_CLOSED, 'Exit'):
        break

window.Close()

I think this can be closed. Menu and ButtonMenu color capabilities were released to PyPI in 4.31.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scmanjarrez picture scmanjarrez  ·  5Comments

MikeTheWatchGuy picture MikeTheWatchGuy  ·  6Comments

MikeTheWatchGuy picture MikeTheWatchGuy  ·  3Comments

DKatarakis picture DKatarakis  ·  6Comments

yogesh-aggarwal picture yogesh-aggarwal  ·  3Comments