54 |
|
|
55 |
self.init_ids() |
self.init_ids() |
56 |
|
|
57 |
#main_menu.print_menu() |
# creat the menubar from the main_menu description |
58 |
self.SetMenuBar(self.build_menu_bar(main_menu)) |
self.SetMenuBar(self.build_menu_bar(main_menu)) |
59 |
|
|
60 |
# toolbar |
# Similarly, create the toolbar from main_toolbar |
61 |
toolbar = self.CreateToolBar(wxTB_3DBUTTONS) |
toolbar = self.build_toolbar(main_toolbar) |
|
|
|
|
# set the size of the tools' bitmaps. Not needed on wxGTK, but |
|
|
# on Windows. We probably shouldn't hardwire the bitmap size |
|
|
# here |
|
|
toolbar.SetToolBitmapSize(wxSize(24, 24)) |
|
|
|
|
|
for name in ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool", |
|
|
"map_identify_tool", "map_label_tool", "map_full_extent"]: |
|
|
self.add_toolbar_command(toolbar, name) |
|
62 |
# call Realize to make sure that the tools appear. |
# call Realize to make sure that the tools appear. |
63 |
toolbar.Realize() |
toolbar.Realize() |
64 |
|
|
121 |
last = item |
last = item |
122 |
return wxmenu |
return wxmenu |
123 |
|
|
124 |
|
def build_toolbar(self, toolbardesc): |
125 |
|
"""Build and return the main toolbar window from a toolbar description |
126 |
|
|
127 |
|
The parameter should be an instance of the Menu class but it |
128 |
|
should not contain submenus. |
129 |
|
""" |
130 |
|
toolbar = self.CreateToolBar(wxTB_3DBUTTONS) |
131 |
|
|
132 |
|
# set the size of the tools' bitmaps. Not needed on wxGTK, but |
133 |
|
# on Windows, although it doesn't work very well there. It seems |
134 |
|
# that only 16x16 icons are really supported on windows. |
135 |
|
# We probably shouldn't hardwire the bitmap size here. |
136 |
|
toolbar.SetToolBitmapSize(wxSize(24, 24)) |
137 |
|
|
138 |
|
for item in toolbardesc.items: |
139 |
|
if item is None: |
140 |
|
toolbar.AddSeparator() |
141 |
|
else: |
142 |
|
# assume it's a string. |
143 |
|
self.add_toolbar_command(toolbar, item) |
144 |
|
|
145 |
|
return toolbar |
146 |
|
|
147 |
def add_menu_command(self, menu, name): |
def add_menu_command(self, menu, name): |
148 |
"""Add the command with name name to the menu menu. |
"""Add the command with name name to the menu menu. |
149 |
|
|
606 |
"layer_show_table"]), |
"layer_show_table"]), |
607 |
Menu("help", "&Help", |
Menu("help", "&Help", |
608 |
["help_about"])]) |
["help_about"])]) |
609 |
|
|
610 |
|
# the main toolbar |
611 |
|
|
612 |
|
main_toolbar = Menu("<toolbar>", "<toolbar>", |
613 |
|
["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool", |
614 |
|
"map_identify_tool", "map_label_tool", "map_full_extent"]) |