def __init__(self, name): super(LayerMgr, self).__init__(ID='LayerMgr', Title=name, CloseOnReq=True) self.name = name self.__layctrllist = [] self._active = None top = pymui.VGroup() self.RootObject = top self.layctrl_grp = pymui.VGroupV(Frame='Virtual', Spacing=VIRT_GROUP_SPACING) self.__space = pymui.VSpace(0) self.layctrl_grp.AddTail(self.__space) # Layer info group layerinfo = pymui.ColGroup(2) layerinfo.AddChild(pymui.Label(_T("Blending") + ':')) self.blending = pymui.Cycle(model.Layer.OPERATORS_LIST, CycleChain=True, ShortHelp=_T("Set layer's blending mode")) layerinfo.AddChild(self.blending) layerinfo.AddChild(pymui.Label(_T("Opacity") + ':')) self.opacity = pymui.Slider(Value=100, Format='%u%%', CycleChain=True, ShortHelp=_T("Set layer's opacity value")) layerinfo.AddChild(self.opacity) # Layer management buttons btn_grp = pymui.ColGroup(4) self.btn = {} for name, label in [ ('add', 'Add'), ('del', 'Del'), ('dup', 'Copy'), ('merge', 'Merge'), ('up', 'Up'), ('down', 'Down'), ('top', 'Top'), ('bottom', 'Bottom'), ]: o = self.btn[name] = pymui.SimpleButton(label) btn_grp.AddChild(o) sc_gp = pymui.Scrollgroup(Contents=self.layctrl_grp, FreeHoriz=False) self.__vertbar = sc_gp.VertBar.object top.AddChild(sc_gp) top.AddChild(pymui.HBar(0)) top.AddChild(layerinfo) top.AddChild(pymui.HBar(0)) top.AddChild(pymui.HCenter(btn_grp))
def _do_page_misc(self, reg): top = pymui.VGroup() reg.AddChild(pymui.HCenter(pymui.VCenter(top))) grp = pymui.ColGroup(2, GroupTitle=_T("Interface")) grp.AddChild(pymui.Label(_T("Windows to open at startup") + ':', )) box = pymui.ColGroup(2, Frame='Group') self._startup_win_bt = {} win_list = prefs['pymui-window-open-at-startup'] d = pymui.GetApp().startup_windows for key in sorted(d.keys(), cmp=lambda x, y: cmp(d[x].name, d[y].name)): bt = self._startup_win_bt[key] = pymui.CheckMark(key in win_list, CycleChain=True) box.AddChild(bt) box.AddChild(pymui.Label(pymui.MUIX_L + d[key].name)) grp.AddChild(box) top.AddChild(grp)
def __init__(self, name): super(BrushEditorWindow, self).__init__(name, ID='BEW', Width=320, Height=100, CloseOnReq=True) self.name = name # UI self.RootObject = topbox = pymui.VGroup() self.AddChild(topbox) # Brush preview self.bprev = BrushPreview() topbox.AddChild(self.bprev) self.namebt = pymui.String(Frame='String', CycleChain=True) topbox.AddChild(pymui.HGroup(Child=[pymui.Label(_T('Name')+':'), self.namebt ])) topbox.AddChild(pymui.HBar(2)) # Brush parameters table = pymui.ColGroup(2) topbox.AddChild(table) self.prop = {} self.prop['radius_min'] = self._add_slider(table, 'radius_min', -2, 5, 3, .1, .5, islog=True) self.prop['radius_max'] = self._add_slider(table, 'radius_max', -2, 5, 3, .1, .5, islog=True) self.prop['yratio'] = self._add_slider(table, 'yratio', 1.0, 32., 1., 0.1, 2) self.prop['angle'] = self._add_slider(table, 'angle', -180., 180.0, 0.0, 0.5, 1) self.prop['spacing'] = self._add_slider(table, 'spacing', 0.01, 4.0, 0.25, .01, 0.1) self.prop['opacity_min'] = self._add_slider(table, 'opacity_min', 0, 1, 1, 1/255., 10/255.) self.prop['opacity_max'] = self._add_slider(table, 'opacity_max', 0, 1, 1, 1/255., 10/255.) self.prop['opa_comp'] = self._add_slider(table, 'opa_comp', 0, 2, .9, 0.01, 0.1) self.prop['hardness'] = self._add_slider(table, 'hardness', 0, 1, 1, .01, 0.1) self.prop['erase'] = self._add_slider(table, 'erase', 0, 1, 1, .01, 0.1) self.prop['grain'] = self._add_slider(table, 'grain', 0, 1, 1, .01, 0.1) self.prop['motion_track'] = self._add_slider(table, 'motion_track', 0.0, 2.0, 1.0, .1, 1) self.prop['hi_speed_track'] = self._add_slider(table, 'hi_speed_track', 0.0, 2.0, 0.0, .01, 0.1) self.prop['smudge'] = self._add_slider(table, 'smudge', 0, 1, 0, .01, 0.1) self.prop['smudge_var'] = self._add_slider(table, 'smudge_var', 0, 1, 0, .01, 0.1) self.prop['color_shift_h'] = self._add_slider(table, 'color_shift_h', -.1, .1, 0, .01, 0.1) self.prop['color_shift_s'] = self._add_slider(table, 'color_shift_s', -.1, .1, 0, .01, 0.1) self.prop['color_shift_v'] = self._add_slider(table, 'color_shift_v', -.1, .1, 0, .01, 0.1) self.prop['dab_radius_jitter'] = self._add_slider(table, 'dab_radius_jitter', 0.0, 1.0, 0.0, .01, 0.1) self.prop['dab_pos_jitter'] = self._add_slider(table, 'dab_pos_jitter', 0.0, 5.0, 0.0, .01, 0.1) self.prop['direction_jitter'] = self._add_slider(table, 'direction_jitter', 0.0, 1.0, 0.0, .01, 0.1) self.prop['alpha_lock'] = self._add_slider(table, 'alpha_lock', 0.0, 1.0, 0.0, 1.0, 1.0) self.Title = 'Brush Editor' # overwritten by mediator self.on_value_changed_cb = utils.idle_cb
def get_icons(off): icons = pymui.ColGroup(4, Frame='Group') for name in sorted(contexts.ICONS.keys()): obj = pymui.Dtpic(Name=os.path.join( icons_path, name + '.png'), InputMode='RelVerify', LightenOnMouse=True) icons.AddChild(obj) obj.Notify('Pressed', self._on_popup_icon_sel, when=False, name=name, idx=idx, off=off) return icons
def _do_page_calibration(self, reg): top = pymui.VGroup() reg.AddChild(pymui.HCenter(pymui.VCenter(top))) # Contents automatically controled by the CalibrationBar object cal_result_x = pymui.String(Frame='String', Accept="0123456789.", FixWidthTxt="######", Format=pymui.MUIV_String_Format_Right, CycleChain=True) cal_result_y = pymui.String(Frame='String', Accept="0123456789.", FixWidthTxt="######", Format=pymui.MUIV_String_Format_Right, CycleChain=True) self.cal_bar_x = CalibrationBar(prefs['view-metrics-x'], cal_result_x, horiz=True, ShortHelp=_T(cal_text)) self.cal_bar_y = CalibrationBar(prefs['view-metrics-y'], cal_result_y, horiz=False, ShortHelp=_T(cal_text)) self.cal_unit = pymui.Cycle(CALIBRATION_UNITS, Active=CALIBRATION_UNITS.index( prefs['view-metrics-unit']), CycleChain=True) grp = pymui.ColGroup( 2, Frame='Group', Child=(pymui.Label(_T("Calibration unit") + ':'), self.cal_unit, pymui.Label(_T("Horizontal axis") + ':'), cal_result_x, pymui.Label(_T("Vertical axis") + ':'), cal_result_y)) top.AddChild(self.cal_bar_x) top.AddChild(pymui.HGroup(Child=(self.cal_bar_y, pymui.HCenter(grp)))) def callback(evt, wd): wd.value = evt.value.contents cal_result_x.Notify('Acknowledge', callback, self.cal_bar_x) cal_result_y.Notify('Acknowledge', callback, self.cal_bar_y)
def __init__(self, name): super(ColorHarmoniesWindow, self).__init__(ID='CHRM', Title=name, CloseOnReq=True) self.name = name self.RootObject = top = pymui.VGroup() self.widgets = {} self.colorwheel = ColorWeelHarmonies2() top.AddChild(pymui.HCenter(self.colorwheel)) self.hue = pymui.Slider(Min=0, Max=360, CycleChain=True) self.sat = pymui.Slider(Min=0, Max=100, CycleChain=True) self.value = pymui.Slider(Min=0, Max=100, CycleChain=True) self.red = pymui.Slider(Min=0, Max=255, CycleChain=True) self.green = pymui.Slider(Min=0, Max=255, CycleChain=True) self.blue = pymui.Slider(Min=0, Max=255, CycleChain=True) self.colorbox = ColorBox(Frame='Virtual', MaxWidth=16) grp = pymui.HGroup() grp.AddChild(self.colorbox) grp.AddChild(pymui.ColGroup(2, Child=(pymui.Label(_T('Red')+':'), self.red, pymui.Label(_T('Green')+':'), self.green, pymui.Label(_T('Blue')+':'), self.blue, pymui.Label(_T('Hue')+':'), self.hue, pymui.Label(_T('Saturation')+':'), self.sat, pymui.Label(_T('Value')+':'), self.value))) top.AddChild(grp) bt = pymui.SimpleButton(_T("Use as background"), CycleChain=True) top.AddChild(bt) self.widgets['AsBgBt'] = bt top.AddChild(pymui.HBar(3)) toggle_pal = pymui.Text(_T("Toggle Palette panel"), InputMode='Toggle', Frame='Button', Background='ButtonBack', Font=pymui.MUIV_Font_Button, PreParse=pymui.MUIX_C, Selected=True) top.AddChild(toggle_pal) grp = pymui.VGroup(GroupTitle=_T('Palette')) top.AddChild(grp) toggle_pal.Notify('Selected', lambda evt: grp.SetAttr('ShowMe', evt.value.value)) ld_pal = pymui.SimpleButton(_T("Load"), CycleChain=True) sv_pal = pymui.SimpleButton(_T("Save"), CycleChain=True) del_pal = pymui.SimpleButton(_T("Delete"), CycleChain=True) grp.AddChild(pymui.HGroup(Child=(ld_pal, sv_pal, del_pal))) self._predefpallister = pymui.List(SourceArray=self.palettes_list) pal_name_bt = pymui.Text(Frame='Text', CycleChain=True, ShortHelp=_T('Predefined palettes')) popup = pymui.Popobject(Object=pymui.Listview(List=self._predefpallister), String=pal_name_bt, Button=pymui.Image(Frame='ImageButton', Spec=pymui.MUII_PopUp, InputMode='RelVerify', CycleChain=True)) grp.AddChild(pymui.HGroup(Child=(pymui.Label(_T('Avails')+':'), popup))) sort_luma = pymui.SimpleButton(_T('Luminance'), CycleChain=True) sort_hue = pymui.SimpleButton(_T('Hue'), CycleChain=True) sort_sat = pymui.SimpleButton(_T('Saturation'), CycleChain=True) sort_value = pymui.SimpleButton(_T('Value'), CycleChain=True) grp.AddChild(pymui.HGroup(Child=(pymui.Label(_T('Sort by')+':'), sort_luma, sort_hue, sort_sat, sort_value))) grp.AddChild(pymui.HBar(0)) vgrp = pymui.VGroup(SameSize=True, Columns=16, Spacing=1, HorizWeight=100, Horiz=False, Background='2:00000000,00000000,00000000') grp.AddChild(pymui.HCenter(vgrp)) self._pal_bt = [] for i in xrange(256): bt = DropColorBox(12, 12) vgrp.AddChild(bt) bt.Notify('Pressed', self._on_palbt, when=False) self._pal_bt.append(bt) # Notifications self.hue.Notify('Value', lambda evt: self._set_hsv_channel(evt.value.value / 360., 0)) self.sat.Notify('Value', lambda evt: self._set_hsv_channel(evt.value.value / 100., 1)) self.value.Notify('Value', lambda evt: self._set_hsv_channel(evt.value.value / 100., 2)) self.red.Notify('Value', lambda evt: self._set_rgb_channel(evt.value.value / 255., 0)) self.green.Notify('Value', lambda evt: self._set_rgb_channel(evt.value.value / 255., 1)) self.blue.Notify('Value', lambda evt: self._set_rgb_channel(evt.value.value / 255., 2)) ld_pal.Notify('Pressed', self._on_ld_pal_pressed, when=False) sv_pal.Notify('Pressed', self._on_sv_pal_pressed, when=False) del_pal.Notify('Pressed', self._on_del_pal_pressed, when=False) self._predefpallister.Notify('DoubleClick', self._on_popup_predef_sel, popup) self._predefpallister.Notify('Active', self._on_predef_list_active, pal_name_bt, del_pal) sort_luma.Notify('Pressed', lambda evt, cmp: self.sort_palette(cmp), self._cmp_luma, when=False) sort_hue.Notify('Pressed', lambda evt, cmp: self.sort_palette(cmp), self._cmp_hue, when=False) sort_sat.Notify('Pressed', lambda evt, cmp: self.sort_palette(cmp), self._cmp_sat, when=False) sort_value.Notify('Pressed', lambda evt, cmp: self.sort_palette(cmp), self._cmp_value, when=False) # final setup self._use_palette('default') toggle_pal.Selected = False # start in no palette mode
def _do_page_toolswheel(self, reg): top = pymui.VGroup() reg.AddChild(top) colg = pymui.ColGroup(4) top.AddChild(colg) self._toolswheel_strings = [None] * 8 self._popup = [None] * 16 all_commands = sorted(contexts.ALL_COMMANDS.keys()) def new_entry(label, idx): icons_path = resolve_path(prefs['view-icons-path']) def get_icons(off): icons = pymui.ColGroup(4, Frame='Group') for name in sorted(contexts.ICONS.keys()): obj = pymui.Dtpic(Name=os.path.join( icons_path, name + '.png'), InputMode='RelVerify', LightenOnMouse=True) icons.AddChild(obj) obj.Notify('Pressed', self._on_popup_icon_sel, when=False, name=name, idx=idx, off=off) return icons colg.AddChild(pymui.Label(label + ':')) icons_names = prefs['view-icons-names'] bt = pymui.Dtpic(Name=os.path.join(icons_path, icons_names[idx] + '.png'), Frame='ImageButton', InputMode='RelVerify') popup = pymui.Popobject(Button=bt, Object=get_icons(0), Light=True) popup.name = icons_names[idx] colg.AddChild(popup) self._popup[idx] = popup bt = pymui.Dtpic(Name=os.path.join(icons_path, icons_names[8 + idx] + '.png'), Frame='ImageButton', InputMode='RelVerify') popup = pymui.Popobject(Button=bt, Object=get_icons(8), Light=True) popup.name = icons_names[8 + idx] colg.AddChild(popup) self._popup[8 + idx] = popup string = pymui.String( Frame='String', CycleChain=True, Contents=prefs['view-toolswheel-binding'][idx] or '', ShortHelp=_T("Command to execute when tool region selected")) self._toolswheel_strings[idx] = string popup = pymui.Poplist(Array=all_commands, String=string, Button=pymui.Image(Frame='ImageButton', Spec=pymui.MUII_PopUp, InputMode='RelVerify')) colg.AddChild(popup) new_entry(_T('N'), 6) new_entry(_T('NE'), 7) new_entry(_T('E'), 0) new_entry(_T('SE'), 1) new_entry(_T('S'), 2) new_entry(_T('SO'), 3) new_entry(_T('O'), 4) new_entry(_T('NO'), 5) top.AddChild(pymui.HVSpace())
def _do_page_rendering(self, reg): top = pymui.VGroup(SameWidth=True) reg.AddChild(pymui.HCenter(pymui.VCenter(top))) grp = pymui.ColGroup(2, GroupTitle=_T("Antialiasing")) grp.AddChild(pymui.Label(_T("Filter level threshold") + ':')) self._filter_threshold = pymui.Slider( Min=0, Max=viewport.DocumentViewPort.MAX_SCALE, Default=viewport.DocumentViewPort.DEFAULT_FILTER_THRESHOLD, Value=prefs['view-filter-threshold'], CycleChain=True) grp.AddChild(self._filter_threshold) top.AddChild(grp) def new_color(parent, label, color): rgb = pymui.c_ULONG.ArrayType(3)(*tuple( int(x * 255) * 0x01010101 for x in color[:3])) field = pymui.Colorfield(CycleChain=True, InputMode='RelVerify', Frame='ImageButton', FixWidth=64, RGB=rgb) cadj = pymui.Coloradjust(CycleChain=True, RGB=rgb) bt = pymui.SimpleButton(_T("Close"), CycleChain=True) grp = pymui.VGroup(Frame='Group') grp.AddChild(cadj) grp.AddChild(bt) popup = pymui.Popobject(Button=field, Object=grp) alpha = pymui.Numericbutton(CycleChain=True, Min=0, Max=100, Default=100, Value=int(color[3] * 100), Format="%lu%%", ShortHelp=_T("Transparency level")) cadj.Notify('RGB', lambda evt: field.SetAttr('RGB', evt.value)) bt.Notify('Pressed', lambda evt: popup.Close(0), when=False) parent.AddChild(pymui.Label(_T(label) + ':')) parent.AddChild(popup) parent.AddChild(alpha) return field, alpha self._colors = {} grp = pymui.ColGroup(3, GroupTitle=_T("Tools colors")) self._colors['background'] = new_color(grp, "Text background", prefs['view-color-bg']) self._colors['outlines'] = new_color(grp, "Text outlines", prefs['view-color-ol']) self._colors['text'] = new_color(grp, "Text color", prefs['view-color-text']) self._colors['handler_bg'] = new_color(grp, "Handler background", prefs['view-color-handler-bg']) self._colors['handler_ol'] = new_color(grp, "Handler outlines", prefs['view-color-handler-ol']) self._colors['wheel_bg'] = new_color(grp, "Wheel background", prefs['view-color-wheel-bg']) self._colors['wheel_ol'] = new_color(grp, "Wheel outlines", prefs['view-color-wheel-ol']) self._colors['wheel_sel'] = new_color(grp, "Wheel selection", prefs['view-color-wheel-sel']) self._colors['pp'] = new_color(grp, "PassePartout", prefs['view-color-passepartout']) top.AddChild(grp) grp = pymui.ColGroup(2, GroupTitle=_T("Rulers")) grp.AddChild(pymui.Label(_T("Background pen") + ':')) self._ruler_bg_pen = pymui.Slider(CycleChain=True, Min=0, Max=255, Default=1, Value=prefs['pymui-ruler-bg-pen']) grp.AddChild(self._ruler_bg_pen) grp.AddChild(pymui.Label(_T("Foreground pen") + ':')) self._ruler_fg_pen = pymui.Slider(CycleChain=True, Min=0, Max=255, Default=1, Value=prefs['pymui-ruler-fg-pen']) grp.AddChild(self._ruler_fg_pen) top.AddChild(grp)
def __init__(self, name): super(DocInfoWindow, self).__init__(name, ID='INFO', CloseOnReq=True) self.name = name top = pymui.VGroup() self.RootObject = top # Document name name = pymui.Text(Frame='Text') top.AddChild(name) # Dimensions dim_grp = pymui.VGroup(GroupTitle=_T("Dimensions")) use_full_bt = pymui.SimpleButton(_T("No limits"), CycleChain=True) use_cur_bt = pymui.SimpleButton(_T("Set to current size"), CycleChain=True) ori_x = pymui.String(Frame='String', Accept="-0123456789", CycleChain=True) ori_y = pymui.String(Frame='String', Accept="-0123456789", CycleChain=True) size_x = pymui.String(Frame='String', Accept="-0123456789", CycleChain=True) size_y = pymui.String(Frame='String', Accept="-0123456789", CycleChain=True) box = pymui.ColGroup(2) box.AddChild(pymui.Label(_T("X Origin") + ':')) box.AddChild(ori_x) box.AddChild(pymui.Label(_T("Y Origin") + ':')) box.AddChild(ori_y) box.AddChild(pymui.Label(_T("Width") + ':')) box.AddChild(size_x) box.AddChild(pymui.Label(_T("Height") + ':')) box.AddChild(size_y) ori_x.Notify('Acknowledge', self._modify_dim, 0) ori_y.Notify('Acknowledge', self._modify_dim, 1) size_x.Notify('Acknowledge', self._modify_dim, 2) size_y.Notify('Acknowledge', self._modify_dim, 3) pp = pymui.Text(_T("Passe-Partout"), InputMode='Toggle', Frame='Button', Background='ButtonBack', PreParse=pymui.MUIX_C, Selected=False) pp.Notify('Selected', self._toggle_pp) dim_grp.AddChild(pp) dim_grp.AddChild(pymui.HGroup(Child=(use_full_bt, use_cur_bt))) dim_grp.AddChild(box) top.AddChild(dim_grp) def callback(evt): self.__docproxy.set_metadata(dimensions=None) use_full_bt.Notify('Pressed', callback, when=False) def callback(evt): _, _, w, h = area = self.__docproxy.document.area if not (w and h): area = None self.__docproxy.set_metadata(dimensions=area) use_cur_bt.Notify('Pressed', callback, when=False) # Density dpi_grp = pymui.VGroup(GroupTitle=_T("Density")) use_calib_bt = pymui.SimpleButton(_T("Set from calibration"), CycleChain=True) dpi_x = pymui.String(Frame='String', Accept="0123456789.", CycleChain=True) dpi_y = pymui.String(Frame='String', Accept="0123456789.", CycleChain=True) box = pymui.ColGroup(2) box.AddChild(pymui.Label(_T("X") + ':')) box.AddChild(dpi_x) box.AddChild(pymui.Label(_T("Y") + ':')) box.AddChild(dpi_y) dpi_grp.AddChild(use_calib_bt) dpi_grp.AddChild(box) top.AddChild(dpi_grp) def callback(evt): dpi_x = Ruler.METRICS['in'][2] dpi_y = Ruler.METRICS['in'][3] self.__docproxy.set_metadata(densities=[dpi_x, dpi_y]) use_calib_bt.Notify('Pressed', callback, when=False) self.widgets = { 'name': name, 'dpi-x': dpi_x, 'dpi-y': dpi_y, 'dim-x': size_x, 'dim-y': size_y, 'ori-x': ori_x, 'ori-y': ori_y, }