def build_dlg(self): root = self.top top = TFrame(root, borderwidth=2, style='FlatFrame') top.pack(side=TOP, expand=0, fill=BOTH) top2 = TFrame(top, height=3, style='FlatFrame') top2.pack(side=BOTTOM, expand=0, fill=X) button = UpdatedButton(top, text=_("Apply style"), command=self.apply_style, sensitivecb=self.can_apply, width=15) button.pack(side=BOTTOM, expand=0) self.Subscribe(SELECTION, button.Update) top2 = TFrame(top, height=3, style='FlatFrame') top2.pack(side=BOTTOM, expand=0, fill=X) button = UpdatedButton(top, text=_("Delete style"), command=self.remove_style, sensitivecb=self.can_remove, width=15) button.pack(side=BOTTOM, expand=0) top2 = TFrame(top, height=3, style='FlatFrame') top2.pack(side=BOTTOM, expand=0, fill=X) button = UpdatedButton(top, text=_("Create new style"), command=self.CreateStyleFromSelection, sensitivecb=self.main_window.document.CanCreateStyle, width=15) button.pack(side=BOTTOM, expand=0) self.Subscribe(SELECTION, button.Update) top2 = TFrame(top, height=5, style='FlatFrame') top2.pack(side=BOTTOM, expand=0, fill=X) list_frame = TFrame(top, style="RoundedFrame", borderwidth=5) list_frame.pack(side=TOP, expand=1, fill=BOTH) sb_vert = TScrollbar(list_frame, takefocus=0) sb_vert.pack(side=RIGHT, fill=Y) styles = UpdatedListbox(list_frame, bg='white', borderwidth=0, selectborderwidth=0) styles.pack(expand=1, fill=BOTH) styles.Subscribe(COMMAND, self.apply_style) sb_vert['command'] = (styles, 'yview') styles['yscrollcommand'] = (sb_vert, 'set') self.styles = styles root.resizable(width=0, height=0)
def init(self, master): PluginPanel.init(self, master) top = self.panel grid_top = TFrame(top, borderwidth=2, style='FlatFrame') grid_top.pack(side=TOP, expand=1, fill=X) var_number = DoubleVar(top) var_unit = StringVar(top) self.var_pos = LengthVar(1.0, config.preferences.default_unit, var_number, var_unit, command=self.set_pos) top1 = TFrame(top, style='FlatFrame') top1.pack(side=TOP, expand=0, fill=BOTH) list_frame = TFrame(top1, style="RoundedFrame", borderwidth=5) list_frame.pack(side=TOP, expand=1, fill=BOTH) sb_vert = TScrollbar(list_frame) sb_vert.pack(side=RIGHT, fill=Y) guides = UpdatedListbox(list_frame, bg='white', borderwidth=0, selectborderwidth=0, width=20, height=8) guides.pack(expand=1, fill=BOTH) guides.Subscribe(SELECTION, self.select_guide) sb_vert['command'] = (guides, 'yview') guides['yscrollcommand'] = (sb_vert, 'set') self.guides = guides self.selected = None pos_frame = TFrame(top1, style='FlatFrame') pos_frame.pack(side=TOP, expand=0) top2 = TFrame(pos_frame, height=15, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) self.var_label = StringVar(top) self.var_label.set('X: ') labelunit = UnitLabel(pos_frame) labelunit.pack(side=RIGHT, expand=0, anchor=W) label = TLabel(pos_frame, image='space_6', style='FlatLabel') label.pack(side=RIGHT) self.entry = TSpinbox(pos_frame, var=0, vartype=1, min=-50000, max=50000, step=.1, width=6, command=self.pos_changed) self.entry.pack(side=RIGHT, expand=0, anchor=E) label = TLabel(pos_frame, textvariable=self.var_label, style='FlatLabel') label.pack(side=RIGHT, expand=0, anchor=E) frame = TFrame(top1, style='FlatFrame') frame.pack(side=TOP, fill=X) top2 = TFrame(frame, height=15, width=120, style='FlatFrame') top2.pack(side=TOP) button = UpdatedButton(frame, text=_("Add Horizontal Guide"), command=self.add_guide, args=1) button.pack(side=TOP) top2 = TFrame(frame, height=3, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) button = UpdatedButton(frame, text=_("Add Vertical Guide"), command=self.add_guide, args=0) button.pack(side=TOP) top2 = TFrame(frame, height=3, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) button = UpdatedButton(frame, text=_("Delete Guide"), command=self.del_guide) button.pack(side=TOP) top2 = TFrame(frame, height=5, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) app.mw.docmanager.activedoc.Subscribe(GUIDE_LINES, self.init_from_doc) app.mw.Subscribe(DOCUMENT, self.init_from_doc) self.init_from_doc()
def build_window(self): root = self.application.root # the menu self.mbar = TFrame(root, name='menubar', style='MenuBarFrame', borderwidth=2) self.mbar.pack(fill=X) # the toolbar self.tbar = TFrame(root, name='toolbar', style='ToolBarFrame', borderwidth=2) self.tbar.pack(fill=X) # the context panel self.ctxpanel = ctxPanel.ContexPanel(root, self) self.ctxpanel.panel.pack(fill=X) b = ToolbarButton(self.ctxpanel.panel, self.commands.PCshowHide, image="show_side_panel") tooltips.AddDescription(b, self.commands.PCshowHide.menu_name) b.pack(side=RIGHT) # the status bar self.status_bar = TFrame(root, name='statusbar', style='FlatFrame') self.status_bar.pack(side=BOTTOM, fill=X) # the tools bar self.tframe = TFrame(root, name='tools_frame', style='FlatFrame', borderwidth=2) self.tframe.pack(side=LEFT, fill=Y) # the palette p_frame = TFrame(root, style='FlatFrame') p_frame.pack(side='right', fill=Y) palette_frame = TFrame(p_frame, style='FlatFrame') palette_frame.pack(side='right', fill=Y, pady=5, padx=3) b = TLabel(root, style='VLine2') b.pack(side=RIGHT, fill=Y) #################################### # Drawing area creating #################################### pc_frame = TFrame(root, style='FlatFrame') pc_frame.pack(side='right', fill=Y, expand=1) self.pc = PluginContainer(pc_frame, self.root, self) base_frame = TFrame(root, name='drawing_area_frame', style='FlatFrame') base_frame.pack(side=LEFT, fill=BOTH, expand=1) self.tabspanel = TabsPanel(base_frame, self) self.tabspanel.pack(side=TOP, fill=X) self.docmanager.Activate(self.tabspanel) label = TLabel(base_frame, style='DrawingAreaBottom', image='space_5') label.pack(side=BOTTOM, fill=X) label = TLabel(base_frame, style='DrawingAreaLeft', image='space_5') label.pack(side=LEFT, fill=Y, expand=1) label = TLabel(base_frame, style='DrawingAreaRight', image='space_5') label.pack(side=RIGHT, fill=Y, expand=1) #################################### frame = TFrame(base_frame, name='canvas_frame', style='FlatFrame') frame.pack(side=LEFT, fill=BOTH, expand=1) vbar = TScrollbar(frame) vbar.grid(in_=frame, column=3, row=1, sticky='ns') vbar.bind('<Button-4>', self.ScrollUpCanvas) vbar.bind('<Button-5>', self.ScrollDownCanvas) ############Pager################### pframe = TFrame(frame, style='FlatFrame') pframe.grid(in_=frame, column=2, row=2, sticky='ew') lab = Pager(pframe, self) lab.pack(side=LEFT, fill=Y) #################################### hbar = TScrollbar(pframe, orient=HORIZONTAL) hbar.pack(side=RIGHT, fill=X, expand=1) hbar.bind('<Button-4>', self.ScrollLeftCanvas) hbar.bind('<Button-5>', self.ScrollRightCanvas) #################################### hrule = tkruler.Ruler(frame, orient=tkruler.HORIZONTAL, bg=config.preferences.ruler_color, relief='flat') hrule.grid(in_=frame, column=2, row=0, sticky='nsew', columnspan=2) hrule.bind('<Double-Button-1>', self.RulerDoublePressH) #################################### vrule = tkruler.Ruler(frame, orient=tkruler.VERTICAL, bg=config.preferences.ruler_color, relief='flat') vrule.grid(in_=frame, column=1, row=1, sticky='nsew', rowspan=2) vrule.bind('<Double-Button-1>', self.RulerDoublePressV) #ruler corner b = tkruler.RulerCorner(frame, bg=config.preferences.ruler_color) tooltips.AddDescription(b, _('Change system coordinates')) b.grid(column=1, row=0, sticky='news') resolution = config.preferences.screen_resolution self.canvas = SketchCanvas(root, toplevel=root, background='white', name='canvas', width=self.root.winfo_screenwidth(), height=self.root.winfo_screenheight(), resolution=resolution, main_window=self, document=self.document) self.canvas.grid(in_=frame, column=2, row=1, sticky='news') self.canvas.focus() self.canvas.SetScrollbars(hbar, vbar) self.canvas.SetRulers(hrule, vrule) vrule.SetCanvas(self.canvas) hrule.SetCanvas(self.canvas) frame.columnconfigure(0, weight=0) frame.columnconfigure(1, weight=0) frame.columnconfigure(2, weight=1) frame.columnconfigure(3, weight=0) frame.rowconfigure(0, weight=0) frame.rowconfigure(1, weight=1) frame.rowconfigure(2, weight=0) hbar['command'] = self.canvas._w + ' xview' vbar['command'] = self.canvas._w + ' yview' # the palette pal = palette.get_default_palette() palette_trough = TFrame(palette_frame, style='FlatFrame') palette_container = TFrame(palette_trough, style='FlatFrame') self.palette = palette.PaletteWidget(palette_container) self.palette.SetPalette(pal) ScrollXUnits = self.palette.ScrollXUnits ScrollXPages = self.palette.ScrollXPages CanScrollLeft = self.palette.CanScrollLeft CanScrollRight = self.palette.CanScrollRight but1 = UpdatedTButton(palette_frame, class_='Repeater', style='Pal2TopButton', image='pal_dbl_arrow_up', command=ScrollXPages, args=-1, sensitivecb=CanScrollLeft) but1.pack(side=TOP) but2 = UpdatedTButton(palette_frame, class_='Repeater', style='PalTopButton', image='pal_arrow_up', command=ScrollXUnits, args=-1, sensitivecb=CanScrollLeft) but2.pack(side=TOP) palette_trough.pack(side=TOP, fill=Y, expand=1) b = TLabel(palette_trough, style='PalLBorder') b.pack(side=LEFT, fill=Y) palette_container.pack(side=LEFT, fill=Y, expand=1) but = UpdatedTButton(palette_container, style='PalNoColorButton', image='pal_no_color', command=self.no_pattern, args='fill') but.pack(side=TOP) but.bind('<ButtonPress-3>', self.no_pattern, 'line') tooltips.AddDescription(but, _("No color")) self.palette.pack(side=LEFT, fill=Y, expand=1) b = TLabel(palette_trough, style='PalRBorder') b.pack(side='right', fill=Y) but3 = UpdatedTButton(palette_frame, class_='Repeater', style='PalBottomButton', image='pal_arrow_down', command=ScrollXUnits, args=+1, sensitivecb=CanScrollRight) but3.pack(side=TOP) but4 = UpdatedTButton(palette_frame, class_='Repeater', style='Pal2BottomButton', image='pal_dbl_arrow_down', command=ScrollXPages, args=+1, sensitivecb=CanScrollRight) but4.pack(side=TOP) self.palette.Subscribe(COLOR1, self.canvas.FillSolid) self.palette.Subscribe(COLOR2, self.canvas.LineColor) root.protocol('WM_DELETE_WINDOW', tkext.MakeMethodCommand(self.Exit)) #Binding for mouse wheel self.palette.bind('<Button-4>', self.ScrollUpPallette) self.palette.bind('<Button-5>', self.ScrollDownPallette) self.canvas.bind('<Button-4>', self.ScrollUpCanvas) self.canvas.bind('<Button-5>', self.ScrollDownCanvas) self.canvas.bind('<Control-Button-4>', self.ScrollLeftCanvas) self.canvas.bind('<Control-Button-5>', self.ScrollRightCanvas) self.canvas.bind('<Shift-Button-4>', self.CanvasZoomingOut) self.canvas.bind('<Shift-Button-5>', self.CanvasZoomingIn)