Tkinter equiv for setPalette

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Helmut Jarausch

    Tkinter equiv for setPalette

    Hi,

    I am to convert an old Perl-Tk script to Python.
    It starts by
    my $MW= new MainWindow;
    $MW->setPalette(bac kground ='AntiqueWhite1 ', foreground ='blue');

    Is there an equivalent for Tkinter? How can I set default colors for
    background and foreground for the whole application (root window and its
    children)

    Many thanks for a hint,
    Helmut.

    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
  • MASI

    #2
    Re: Tkinter equiv for setPalette

    Il Sun, 10 Feb 2008 12:03:59 +0100, Helmut Jarausch ha scritto:
    Hi,
    >
    I am to convert an old Perl-Tk script to Python.
    It starts by
    my $MW= new MainWindow;
    $MW->setPalette(bac kground ='AntiqueWhite1 ', foreground ='blue');
    >
    Is there an equivalent for Tkinter? How can I set default colors for
    background and foreground for the whole application (root window and its
    children)
    >
    Many thanks for a hint,
    Helmut.
    You have two options:
    1) put your preference in a file

    eg

    file 'tk_option':

    *foreground: blue
    *background: green
    *Entry*backgrou nd: red

    and read it

    root = Tkinter.Tk()
    root.option_rea dfile('tk_optio n')

    2) in your program whit option_add

    eg

    root = Tkinter.Tk()
    root.option_add ('*foreground', 'blue')
    root.option_add ('*background', 'green')
    root.option_add ('*Entry*backgr ound', 'red')

    Comment

    • Russell E. Owen

      #3
      Re: Tkinter equiv for setPalette

      In article <47aeda20$0$298 8$ba620e4c@news .skynet.be>,
      Helmut Jarausch <jarausch@skyne t.bewrote:
      Hi,
      >
      I am to convert an old Perl-Tk script to Python.
      It starts by
      my $MW= new MainWindow;
      $MW->setPalette(bac kground ='AntiqueWhite1 ', foreground ='blue');
      >
      Is there an equivalent for Tkinter? How can I set default colors for
      background and foreground for the whole application (root window and its
      children)
      Tkinter widgets have a tk_setPalette method so you can do this:

      root = Tkinter.Tk()
      root.tk_setPale tte(background = 'AntiqueWhite1' , foreground = 'blue')

      -- Russell

      Comment

      Working...