Early in the development of PAGE, I considered dropping completely the preference stuff derived from Virtual Tcl primarily because many of the preferences were related to functions that do not have meaning to PAGE. However, I really disliked the gray background in PAGE and wanted to change it to my favorite background color - wheat. Also, I felt that capability should be shared with the users. Having made that decision, I saw that it was then a small step to consider allowing the user to have one color scheme for running PAGE, while generating a Python GUI with a different color scheme. A similar progression of thoughts has occurred with respect to fonts; it started because the default fonts are too small for my elderly eyes. So one thing leads to another and it became a question of where to stop. In version 4.0 I am implementing color schemes consisting of foreground and background colors as well as separate fonts for PAGE and the generated GUI. I am also trying to provide reasonable highlight coloring. I try to provide helpful information in the generated code so that you will be able to see what I am trying to do and thus be able to customize your results.
In addition there is the argument for manipulating colors is that by not exploiting colors, one is not really exploiting Tk well. Not really understanding ttk styles at all well, I ask that if you find better ways or even a way of doing something which eludes me, please let me know, I will be happy to use it, and secondly, hating to try imposing my stylistic tastes, I again welcome comments. Also let me say, I have done most of my development and testing with light colors, in particular the color wheat. That means that things can be expected to work better with light colors. I have also tested and tried to make things work with a blue background and white foreground.
Let me start by clarifying what is meant by defaults and preferences here. Defaults are the values which will be used for colors, background and foreground, and font selection and sizes unless the PAGE user sets them specifically for individual GUI widgets. Defaults also include colors and fonts to be used by PAGE in displaying its windows. As I have implemented the different widgets, I have made some “default” decisions. For example, in the Scrolledtext widget, I decided it makes more sense for the wrap property to be “word” rather than “char”.
Defaults can be derived from several sources. First, if nothing else is done, then the small gray world of Tk defaults prevail. These defaults may be overridden by values in the .pagerc file which was saved from previous executions of PAGE where user preferences for the default values were made and saved. Those saved preferences can always be respecified and saved. The third source of overriding GUI defaults comes into play when the PAGE user specifies or opens an existing generated GUI ”.tcl” file. In that case the defaults for further GUI development match those in effect when the file was saved. That is, when you open up an existing GUI ”.tcl” for further development PAGE will use the GUI defaults that were in effect at the earlier time when the GUI was created, while PAGE ignores current default settings. This third way is a version 4.0 enhancement.
Confusion stems from at least two sources. First, there is really two sets of preferences, (1) those for the PAGE program, and (2) the preferences to be used for the generated GUI. Another source is that there are multiple ways of specifying preferences within the Tk environment. In the case of Ttk widgets, one must use Themes and Styles to manipulate colors and fonts and, unfortunately, there are a number of aspects which are undocumented, complementing some serious shortcomings in the implementation or design of the Ttk code. Through experimentation and googling I have found some things that work. Once again, I received tremendous help from Guilherme Polo in solving important questions in my use of ttk styles. Even now there are some disturbing artifacts in PAGE associated with my implementation. Again, suggestions welcome.
There is no doubt, that things will be easier for the user if he sticks with the defaults. But then one is stuck with a dull gray world with small print on Linux and Microsoft PC’s. (I think that the Tk default gray is #d9d9d9 also known as the X11 color gray9. (At one point the default for Tk was bisque.)
Lets start with the easy preferences. PAGE has several simple preferences such as whether on not to use automatically generated aliases or relative placement and the granularity of the grid upon which a widget is placed. Those are easy and could even be dropped as user settable options. They were included when new features were added to PAGE but now I am almost excursively sticking with the new features and rarely test whether the older stuff still works correctly. So I recommend that you stick with the initial settings.
Preferences are tougher in the case of the GUI because one is choosing default values which may not be available to the user of the generated application when the application is executed on a different operating system from the development system. The same fonts and colors might not be available on both systems. You might accept some defaults with respect to PAGE, but really want control over things like colors and fonts to be used in your application. I am doing my development work on Linux and am oriented toward that operating system.
Finally, I have the question as to which defaults I set before you have made any preferences known. Although I do not like them, I have set up PAGE to use Tk default colors and fonts. That is, PAGE uses as the default background for Ttk widgets - #d9d9d9. So select File->Preferences and make the program behave best for you.
Note that when one makes changes in the Preferences, they are committed when one selects the check mark in the upper right. At the same time they are written to the .pagerc file to be utilized the next time the user invokes PAGE. If the user wants to abandon actions taken in the Preferencs window, he selects the stylized “x” next to the check and the whole window disappears and nothing is saved. In PAGE several variables derived from the preferences are set at the initiation of the program. If you want to change preferences, I definitely recommend opening PAGE, make your changes, save them by selecting the check mark, and then exit PAGE. When you restart they should be in effect.
One further point is that you may run into problems when upgrading to version 4.0 if you do not erase the ”.pagerc” file as part of the installation.
When you go to File->Preferences in the main PAGE menu you bring up a the Preferences notebook window with three pages. The Basics page:
This page allows one to make several miscellaneous preference choices. My recommendation is that they be left the way they are. Relative placement and aliases are described elsewhere in this document.
The top section deals with colors displayed while executing PAGE. The most important is the PAGE Background Color which is the background color for all the PAGE windows. One makes a new selection by invoking the Color Dialog by selecting the “Browse colors ...” button to the right of the page. This open the Color Dialog and one can set the color as described above. To go back to the default color, select the “Default Color” button.
The next row allows the user to set the foreground color, that is necessary in case he selects a dark background such as dark blue. In that case, a light colored foreground color should be chosen.
In a similar vein, one wants a visible distinction for the widget tree highlight. That shows which widget has been chosen in the GUI under construction.
For GUI colors, it is much the same as above. I have not seen a requirement for specifying a default highlight color. If that is necessary please let me know and I will see if I can implement it in a future version. I have wanted to have the menu in the top level window be in a distinctive color band so I support that feature.
Since my eyes require large fonts like 16 point fonts, I can set the PAGE default font which catches most of the right things. For the Python Console window I want a big bold font; that is the PAGE fixed width font.
The GUI fonts are more numerous. In addition to the ones above, one can specify the text font which is used in widgets like text boxes and list boxes. Again, I allow one to specify a menu font which is different from the default.
One question I had related to the choice of fonts for text boxes. Should the font be the text font or fixed width font? If one wants to build an editor in a text box as is the case with the PAGE Python Console, then a fixed width font is desired, but if one wants to display something like a help message then a variable width font is more appropriate. What I did for PAGE was use the GUI text font for text boxes and the GUI fixed width font for list boxes. In truth, good arguments for using all three fonts for list boxes can be made.
Fonts have caused me much anguish and confusion. One may pick a fonts which works well on the system where PAGE is hosted. Then one could build a GUI which would call for specific fonts which are not available on the target system. If you know what fonts are available on the target system you can pick the fonts you like. Tk encapsulates a set of standard fonts that are always available, and of course the standard widgets use these fonts. This helps abstract away platform differences. The The predefined fonts are:
- TkDefaultFont The default for all GUI items not otherwise specified.
- TkTextFont Used for entry widgets, listboxes, etc.
- TkFixedFont A standard fixed-width font.
- TkMenuFont The font used for menu items.
- TkHeadingFont The font typically used for column headings in lists and tables.
- TkCaptionFont A font for window and dialog caption bars.
- TkSmallCaptionFont A smaller caption font for subwindows or tool dialogs
- TkIconFont A font for icon captions.
- TkTooltipFont A font for tooltips.
The following python program (Python 2.7) will display the characteristics of the default fonts:
import Tkinter import tkFont root = Tkinter.Tk() fonts = tkFont.names() for font in fonts: print "\n%s" % font config = root.tk.call("font", "configure", font) print config
It may also be the case that if a chosen font is not available on the target system then one of these fonts may be used. I can’t tell from the documentation. The preferences window allows one to specify the default fonts used in the generated GUI. To avoid too much gilding of the lily, I have allowed the user to specify the first four only. If you try different fonts for one of the defaults and then want to return to the true default such as TkFixedFont for the text widgets,specified there is a button for that. I have not provided for specifying TkMenuFont for use in text widgets for instance.
You can specify a default font to be used and still specify different non-default fonts for any individual widget. For instance, you can use TkMenuFont for a Button widget if you want or in my case a 14 point font. There seems to be another weirdness in Tk to be avoided and that is you can change the family, size, weight, etc. of the defaults fonts; at least I have not made that easy.
If you are going to be using the GUI application on the system hosting PAGE by all means select defaults that meet you requirements. But remember those fonts may not be there if the GUI executes on a different system. In which case, the Tk will pick defaults for you and that may not be what you want.
If a default font is active for a widget, it will appear in the Attribute Editor with the default name such as TkMenuFont but if you select the adjoining ellipsis key the font will be changed to a new font with the characteristics specified by family, size, weight, etc.. That may not be what you want, in which case you can replace the font name with the default font name.