1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Rep Power

    [Python 3.x + Tkinter] How do i Change the Basic-Menu Color ?, Help Needed!

    Hey Python Programmers...

    I try to change the foreground and background color of my basic-menu, but it don't works...
    This is my script, writted in python 3.x, on Windows 10 at my computer:
    # Import Tkinter to my Script
    from tkinter import *
    # Make an Main App
    def main():
        # Setup App
        root = Tk()
        root.title('Menubar Test')
        root.config(background = 'black')
        # Print (File Menu - Tools)
        def PrintNew():
            print('Command : New')
        def PrintOpen():
            print('Command : Open')
        def PrintSave():
            print('Command : Save')
        def PrintSaveAs():
            print('Command : SaveAs')
        def PrintImport():
            print('Command : Import')
        def PrintExport():
            print('Command : Export')
        # Edit (Edit Menu - Tools)
        def EditText():
            print('Edit : Text')
        def EditNodes():
            print('Edit : Nodes')
        def EditData():
            print('Edit : Data')
        def EditPrefs():
            print('Edit : Preference')
        def EditSets():
            print('Edit : Settings')
        # Make an Basic-Menubar for all Menu's
        menu = Menu(root, foreground = 'white', background = 'blue', relief = SUNKEN)
        root.config(menu = menu)
        # Make an File-Menu (First Command called before my First Seperator for my File Menu)
        file = Menu(menu, foreground = 'white', background = 'blue', activeforeground = 'gray', activebackground = 'cyan', tearoff = False)
        file.add_command(label = 'New', command = PrintNew)
        # Make an File-Menu (Second, Third and Fourth Command are before my seccond seperator)
        file.add_command(label = 'Open', command = PrintOpen)
        file.add_command(label = 'Save', command = PrintSave)
        file.add_command(label = 'Save As', command = PrintSaveAs)
        # Make an File-Menu (Fifth and Sixth Command are the last commands before my File Cascade to the basic menu (the basic for all Menu's))
        file.add_command(label = 'Import', command = PrintImport)
        file.add_command(label = 'Export', command = PrintExport)
        menu.add_cascade(label = 'File', menu = file)
        # Make an Edit-Menu (First, Second and Thirth Command are before my First Separator for my Edit Menu)
        edit = Menu(menu, foreground = 'white', background = 'blue', activeforeground = 'gray', activebackground = 'cyan', tearoff = False)
        edit.add_command(label = 'Text', command = EditText)
        edit.add_command(label = 'Nodes', command = EditNodes)
        edit.add_command(label = 'Data', command = EditData)
        # Make an Edit-Menu (Fourth and Fifth Command are before my Edit Cascade to the basic menu (the basic menu for all Menu's))
        edit.add_command(label = 'User Preferences', command = EditPrefs)
        edit.add_command(label = 'Settings', command = EditSets)
        menu.add_cascade(label = 'Edit', menu = edit)
        # App Mainloop
    # Check of __name__ __main__ is and start my app if it __main__ is the name
    if __name__ == '__main__':
    Just i get called the "foreground = 'white, background = 'blue'" function on the basic menubar,
    but if i run my script and my app starts, you will see thad my basic menubar (the menubar
    for all menu's (called for "File" and "Edit"), or reather with the variable "menu"), looks just
    an "black" foreground and an "white" background, but it must be looks the same like my
    partal menus: File and Edit...

    Can anyone help me to fix this problem, pleace... ?... and sorry for my font..., all menu's
    in apps get an font like as in this app, just like word, blender, paint, etc... they menu's like
    looks the same font (text format for the menubars), like as my menubar...

    So this is only an menubar with the current font format like in the most menubars in apps...
    But further at my problem... pleace...

    So can you help me to fix this problem thad i get with my colors for the basic-menu, pleace,
    Thanks for help... Jamie.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2009
    Rep Power
    It works fine on my Slackware box. If you are running this program from some funky IDE, run it from the command line instead and see if it works.
    Last edited by dwblas; March 25th, 2018 at 10:29 PM.

IMN logo majestic logo threadwatch logo seochat tools logo