def build(self): self.pack((5, 5)) vpanel = wal.VPanel(self) hpanel = wal.HPanel(vpanel) hpanel.pack(wal.Label(hpanel, _('Guide color:'))) hpanel.pack((10, 5)) self.color = self.doc.methods.get_guide_rgb_color() self.guide_color_btn = wal.ColorButton(hpanel, self.color[:3], onchange=self.on_change) hpanel.pack(self.guide_color_btn) hpanel.pack((10, 5)) hpanel.pack( CBMiniPalette(hpanel, colors=GUIDE_COLORS, onclick=self.change_color)) vpanel.pack(hpanel, fill=True, align_center=False) val = self.doc.methods.is_guide_visible() self.show_guide_check = wal.Checkbox(vpanel, _('Show guides on canvas'), val) vpanel.pack(self.show_guide_check, align_center=False, padding=5) self.pack((10, 10)) self.preview = GuidePreview(vpanel, deepcopy(self.color)) vpanel.pack(self.preview, fill=True, expand=True) self.pack(vpanel, fill=True, expand=True, padding_all=5)
def build_ui(self): self.icon = get_icon(PLUGIN_ICON) self.config = IconizerConfig() config_dir = self.app.appdata.app_config_dir config_file = os.path.join(config_dir, 'iconizer_config.xml') self.config.load(config_file) self.panel.pack((5, 5)) hpanel = wal.HPanel(self.panel) hpanel.pack(wal.Label(hpanel, _('Background:'))) self.bg_color_btn = wal.ColorButton(hpanel, self.config.bg_color, onchange=self.update, silent=False) hpanel.pack((5, 5)) hpanel.pack(self.bg_color_btn) self.panel.pack(hpanel, padding=5) self.pallete = CBMiniPalette(self.panel, COLORS, onclick=self.bg_color_btn.set_value) self.panel.pack(self.pallete) self.panel.pack((10, 10)) self.viewer = ImageViewer(self.panel, self.config.bg_color) self.panel.pack(self.viewer) self.panel.pack((10, 10)) check_panel = wal.VPanel(self.panel) self.border_check = wal.Checkbox(check_panel, _('Show image border'), value=self.config.draw_border, onclick=self.update) check_panel.pack(self.border_check, align_center=False) self.sel_check = wal.Checkbox(check_panel, _('Draw selected only'), value=self.config.draw_selected, onclick=self.update) check_panel.pack(self.sel_check, align_center=False) self.panel.pack(check_panel) self.apply_btn = wal.Button(self.panel, _('Save image'), onclick=self.apply_action) self.panel.pack(self.apply_btn, fill=True, padding_all=5) self.panel.pack((5, 5)) self.panel.pack(wal.HLine(self.panel), fill=True) events.connect(events.DOC_CHANGED, self.update) events.connect(events.SELECTION_CHANGED, self.update) events.connect(events.DOC_MODIFIED, self.update)
class PageProps(DP_Panel): name = _('Page') page_format = None desktop_bg = None page_fill = None border_flag = False def build(self): self.page_format = self.doc.methods.get_default_page_format() self.formats = [ _('Custom'), ] + uc2const.PAGE_FORMAT_NAMES self.pack((5, 10)) # --- hpanel = wal.HPanel(self) hpanel.pack((5, 5)) label = wal.Label(hpanel, _('Default page:')) hpanel.pack(label) hpanel.pack((5, 5)) self.page_combo = wal.Combolist(self, items=self.formats, onchange=self.page_combo_changed) index = 0 state = True if self.page_format[0] in uc2const.PAGE_FORMAT_NAMES: index = self.formats.index(self.page_format[0]) state = False self.page_combo.set_active(index) hpanel.pack(self.page_combo) hpanel.pack((15, 5)) self.orient_keeper = wal.HToggleKeeper(self, ORIENTS, ORIENTS_ICONS, ORIENTS_NAMES, on_change=self.orient_changed) self.orient_keeper.set_mode(self.page_format[2]) hpanel.pack(self.orient_keeper) self.pack(hpanel, fill=True) self.pack((5, 5)) # --- w, h = self.page_format[1] hpanel = wal.HPanel(self) dx = label.get_size()[0] + 10 hpanel.pack((dx, 5)) self.page_width = UnitSpin(self.app, hpanel, w, onchange=self.page_spin_changed) hpanel.pack(self.page_width) hpanel.pack(get_bmp(self, icons.CTX_W_ON_H), padding=5) self.page_height = UnitSpin(self.app, hpanel, h, onchange=self.page_spin_changed) hpanel.pack(self.page_height) hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5) self.page_width.set_enable(state) self.page_height.set_enable(state) self.pack(hpanel, fill=True) self.pack(wal.HLine(self), padding_all=5, fill=True) # --- hpanel = wal.HPanel(self) hpanel.pack((5, 5)) self.desktop_bg = self.doc.methods.get_desktop_bg() grid = wal.GridPanel(hpanel, 3, 3, 5, 5) grid.add_growable_col(2) grid.pack(wal.Label(hpanel, _('Desktop:'))) self.desktop_color_btn = wal.ColorButton(hpanel, self.desktop_bg) grid.pack(self.desktop_color_btn) grid.pack(CBMiniPalette(grid, onclick=self.desktop_color_btn.set_value)) self.page_fill = self.doc.methods.get_page_fill() if self.page_fill[0] == FILL_SOLID: color1 = self.page_fill[1] color2 = [1.0, 1.0, 1.0] else: color1 = self.page_fill[1][0] color2 = self.page_fill[1][1] grid.pack(wal.Label(hpanel, _('Page:'))) self.page_color1_btn = wal.ColorButton(hpanel, color1) grid.pack(self.page_color1_btn) grid.pack(CBMiniPalette(grid, onclick=self.page_color1_btn.set_value)) grid.pack((5, 5)) self.page_color2_btn = wal.ColorButton(hpanel, color2) grid.pack(self.page_color2_btn) self.colors2 = CBMiniPalette(grid, onclick=self.page_color2_btn.set_value) grid.pack(self.colors2) if not self.page_fill[0] == FILL_PATTERN: self.page_color2_btn.set_enable(False) self.colors2.set_enable(False) hpanel.pack(grid, fill=True) hpanel.pack((5, 5)) self.pack(hpanel, fill=True) # --- vpanel = wal.VPanel(self) if wal.IS_MSW: vpanel.pack((5, 5)) self.pattern_check = wal.Checkbox(vpanel, _('Use pattern for page fill'), self.page_fill[0] == FILL_PATTERN, onclick=self.pattern_check_changed) vpanel.pack(self.pattern_check, align_center=False) if wal.IS_MSW: vpanel.pack((5, 5)) self.border_flag = self.doc.methods.get_page_border() self.border_check = wal.Checkbox(vpanel, _('Show page border'), self.border_flag) vpanel.pack(self.border_check, align_center=False) self.pack(vpanel, fill=True, padding_all=5) def page_combo_changed(self): state = False if not self.page_combo.get_active(): state = True else: w, h = uc2const.PAGE_FORMATS[self.page_combo.get_active_value()] self.page_width.set_point_value(w) self.page_height.set_point_value(h) self.orient_keeper.set_mode(uc2const.PORTRAIT) self.page_width.set_enable(state) self.page_height.set_enable(state) def page_spin_changed(self): w = self.page_width.get_point_value() h = self.page_height.get_point_value() if w < h: mode = uc2const.PORTRAIT else: mode = uc2const.LANDSCAPE self.orient_keeper.set_mode(mode) def orient_changed(self, mode): w = self.page_width.get_point_value() h = self.page_height.get_point_value() w, h = h, w self.page_width.set_point_value(w) self.page_height.set_point_value(h) def pattern_check_changed(self): state = self.pattern_check.get_value() self.page_color2_btn.set_enable(state) self.colors2.set_enable(state) def save(self): page_format = [ self.page_combo.get_active_value(), [ self.page_width.get_point_value(), self.page_height.get_point_value(), ], self.orient_keeper.get_mode() ] if not self.page_format == page_format: self.api.set_default_page_format(page_format) desktop_bg = self.desktop_color_btn.get_value() if not self.desktop_bg == desktop_bg: self.api.set_desktop_bg(desktop_bg) color1 = self.page_color1_btn.get_value() if self.pattern_check.get_value(): color2 = self.page_color2_btn.get_value() page_fill = [FILL_PATTERN, [color1, color2]] else: page_fill = [FILL_SOLID, color1] if not self.page_fill == page_fill: self.api.set_page_fill(page_fill) border_flag = self.border_check.get_value() if not self.border_flag == border_flag: self.api.set_page_border(border_flag)
def build(self): self.page_format = self.doc.methods.get_default_page_format() self.formats = [ _('Custom'), ] + uc2const.PAGE_FORMAT_NAMES self.pack((5, 10)) # --- hpanel = wal.HPanel(self) hpanel.pack((5, 5)) label = wal.Label(hpanel, _('Default page:')) hpanel.pack(label) hpanel.pack((5, 5)) self.page_combo = wal.Combolist(self, items=self.formats, onchange=self.page_combo_changed) hpanel.pack(self.page_combo) hpanel.pack((15, 5)) self.orient_keeper = wal.HToggleKeeper(self, ORIENTS, ORIENTS_ICONS, ORIENTS_NAMES, on_change=self.orient_changed) hpanel.pack(self.orient_keeper) hpanel.pack((5, 5)) self.as_current = wal.Button(hpanel, ' %s ' % _('As current page'), onclick=self.set_as_current) hpanel.pack(self.as_current) self.pack(hpanel, fill=True) self.pack((5, 5)) # --- hpanel = wal.HPanel(self) dx = label.get_size()[0] + 10 hpanel.pack((dx, 5)) self.page_width = UnitSpin(self.app, hpanel, 0, onchange=self.page_spin_changed) hpanel.pack(self.page_width) hpanel.pack(get_bmp(self, icons.CTX_W_ON_H), padding=5) self.page_height = UnitSpin(self.app, hpanel, 0, onchange=self.page_spin_changed) hpanel.pack(self.page_height) hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5) self.pack(hpanel, fill=True) self.pack(wal.HLine(self), padding_all=5, fill=True) self.set_page_format(self.page_format) # --- COLORS hpanel = wal.HPanel(self) hpanel.pack((5, 5)) grid = wal.GridPanel(hpanel, 3, 3, 5, 5) grid.add_growable_col(2) grid.pack(wal.Label(grid, _('Desktop:'))) self.desktop_bg = self.doc.methods.get_desktop_bg() self.desktop_color_btn = wal.ColorButton(grid, self.desktop_bg) grid.pack(self.desktop_color_btn) grid.pack(CBMiniPalette(grid, onclick=self.desktop_color_btn.set_value)) self.page_fill = self.doc.methods.get_page_fill() if self.page_fill[0] == FILL_SOLID: color1 = self.page_fill[1] color2 = [1.0, 1.0, 1.0] else: color1 = self.page_fill[1][0] color2 = self.page_fill[1][1] grid.pack(wal.Label(grid, _('Page:'))) self.page_color1_btn = wal.ColorButton(grid, color1) grid.pack(self.page_color1_btn) grid.pack(CBMiniPalette(grid, onclick=self.page_color1_btn.set_value)) grid.pack((5, 5)) self.page_color2_btn = wal.ColorButton(grid, color2) grid.pack(self.page_color2_btn) self.colors2 = CBMiniPalette(grid, onclick=self.page_color2_btn.set_value) grid.pack(self.colors2) if not self.page_fill[0] == FILL_PATTERN: self.page_color2_btn.set_enable(False) self.colors2.set_enable(False) hpanel.pack(grid, fill=True) hpanel.pack((5, 5)) self.pack(hpanel, fill=True) # --- vpanel = wal.VPanel(self) if wal.IS_MSW: vpanel.pack((5, 5)) self.pattern_check = wal.Checkbox(vpanel, _('Use pattern for page fill'), self.page_fill[0] == FILL_PATTERN, onclick=self.pattern_check_changed) vpanel.pack(self.pattern_check, align_center=False) if wal.IS_MSW: vpanel.pack((5, 5)) self.border_flag = self.doc.methods.get_page_border() self.border_check = wal.Checkbox(vpanel, _('Show page border'), self.border_flag) vpanel.pack(self.border_check, align_center=False) self.pack(vpanel, fill=True, padding_all=5)
def build(self): self.page_format = self.doc.methods.get_default_page_format() self.formats = [_('Custom'), ] + uc2const.PAGE_FORMAT_NAMES self.pack((5, 10)) #--- hpanel = wal.HPanel(self) hpanel.pack((5, 5)) label = wal.Label(hpanel, _('Default page:')) hpanel.pack(label) hpanel.pack((5, 5)) self.page_combo = wal.Combolist(self, items=self.formats, onchange=self.page_combo_changed) index = 0 state = True if self.page_format[0] in uc2const.PAGE_FORMAT_NAMES: index = self.formats.index(self.page_format[0]) state = False self.page_combo.set_active(index) hpanel.pack(self.page_combo) hpanel.pack((15, 5)) self.orient_keeper = wal.HToggleKeeper(self, ORIENTS, ORIENTS_ICONS, ORIENTS_NAMES, on_change=self.orient_changed) self.orient_keeper.set_mode(self.page_format[2]) hpanel.pack(self.orient_keeper) self.pack(hpanel, fill=True) self.pack((5, 5)) #--- w, h = self.page_format[1] hpanel = wal.HPanel(self) dx = label.get_size()[0] + 10 hpanel.pack((dx, 5)) self.page_width = UnitSpin(self.app, hpanel, w, onchange=self.page_spin_changed) hpanel.pack(self.page_width) hpanel.pack(get_bmp(self, icons.CTX_W_ON_H), padding=5) self.page_height = UnitSpin(self.app, hpanel, h, onchange=self.page_spin_changed) hpanel.pack(self.page_height) hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5) self.page_width.set_enable(state) self.page_height.set_enable(state) self.pack(hpanel, fill=True) self.pack(wal.HLine(self), padding_all=5, fill=True) #--- hpanel = wal.HPanel(self) hpanel.pack((5, 5)) self.desktop_bg = self.doc.methods.get_desktop_bg() grid = wal.GridPanel(hpanel, 3, 3, 5, 5) grid.add_growable_col(2) grid.pack(wal.Label(hpanel, _('Desktop:'))) self.desktop_color_btn = wal.ColorButton(hpanel, self.desktop_bg) grid.pack(self.desktop_color_btn) grid.pack(CBMiniPalette(grid, onclick=self.desktop_color_btn.set_value)) self.page_fill = self.doc.methods.get_page_fill() if self.page_fill[0] == FILL_SOLID: color1 = self.page_fill[1] color2 = [1.0, 1.0, 1.0] else: color1 = self.page_fill[1][0] color2 = self.page_fill[1][1] grid.pack(wal.Label(hpanel, _('Page:'))) self.page_color1_btn = wal.ColorButton(hpanel, color1) grid.pack(self.page_color1_btn) grid.pack(CBMiniPalette(grid, onclick=self.page_color1_btn.set_value)) grid.pack((5, 5)) self.page_color2_btn = wal.ColorButton(hpanel, color2) grid.pack(self.page_color2_btn) self.colors2 = CBMiniPalette(grid, onclick=self.page_color2_btn.set_value) grid.pack(self.colors2) if not self.page_fill[0] == FILL_PATTERN: self.page_color2_btn.set_enable(False) self.colors2.set_enable(False) hpanel.pack(grid, fill=True) hpanel.pack((5, 5)) self.pack(hpanel, fill=True) #--- vpanel = wal.VPanel(self) if wal.is_msw(): vpanel.pack((5, 5)) self.pattern_check = wal.Checkbox(vpanel, _('Use pattern for page fill'), self.page_fill[0] == FILL_PATTERN, onclick=self.pattern_check_changed) vpanel.pack(self.pattern_check, align_center=False) if wal.is_msw(): vpanel.pack((5, 5)) self.border_flag = self.doc.methods.get_page_border() self.border_check = wal.Checkbox(vpanel, _('Show page border'), self.border_flag) vpanel.pack(self.border_check, align_center=False) self.pack(vpanel, fill=True, padding_all=5)