Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Background color for titlebar and menubar #961

Closed
thedonutbee opened this issue Dec 21, 2018 · 10 comments
Closed

[Request] Background color for titlebar and menubar #961

thedonutbee opened this issue Dec 21, 2018 · 10 comments
Labels
Done - Install Dev Build (see docs for how) See https://docs.pysimplegui.com/en/latest/documentation/installing_licensing/upgrading/

Comments

@thedonutbee
Copy link

thedonutbee commented Dec 21, 2018

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
@thedonutbee
Copy link
Author

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

@MikeTheWatchGuy
Copy link
Collaborator

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.

@MikeTheWatchGuy
Copy link
Collaborator

MikeTheWatchGuy commented Dec 21, 2018

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.

@MikeTheWatchGuy
Copy link
Collaborator

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.

@MikeTheWatchGuy
Copy link
Collaborator

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.

@thedonutbee
Copy link
Author

thedonutbee commented Dec 22, 2018 via email

@MikeTheWatchGuy
Copy link
Collaborator

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

@MikeTheWatchGuy MikeTheWatchGuy added the Done - Install Dev Build (see docs for how) See https://docs.pysimplegui.com/en/latest/documentation/installing_licensing/upgrading/ label Dec 22, 2018
@MikeTheWatchGuy MikeTheWatchGuy changed the title Background_color menu does not work. (Windows) [Request] Background color for titlebar and menubar Dec 22, 2018
@dalpei
Copy link

dalpei commented Oct 14, 2020

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

@jason990420
Copy link
Collaborator

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()

@PySimpleGUI
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Done - Install Dev Build (see docs for how) See https://docs.pysimplegui.com/en/latest/documentation/installing_licensing/upgrading/
Projects
None yet
Development

No branches or pull requests

5 participants