Example #1
0
 def _on_sv_pal_pressed(self, evt):
     filename = pymui.GetApp().get_filename(_T('Select palette filename for saving'), parent=self, pat=PAL_PAT, read=False)
     if filename:
         palette = model.Palette(os.path.splitext(os.path.basename(filename))[0])
         for i, bt in enumerate(self._pal_bt):
             if bt.rgb is not None:
                 palette[i].rgb = bt.rgb
             
         try:
             palette.savetofile(filename)
         except NotImplementedError:
             pymui.DoRequest(app=pymui.GetApp(), title="Error", format="Unkown palette file type", gadgets='*_Ok')
Example #2
0
    def confirm_close(self):
        "Request user confirmation to close the window."

        return pymui.DoRequest(pymui.GetApp(),
                               gadgets=_T("_Yes|*_No"),
                               title=_T("Need confirmation"),
                               format=_T("This window contains modified"
                                         "and not yet saved work\n"
                                         "Are you sure to close it?"))
Example #3
0
 def _modify_dim(self, evt, idx):
     n = int(evt.value.contents)
     area = self.__docproxy.document.metadata['dimensions']
     if area:
         vpmd = pymui.GetApp().mediator.viewport_mediator
         vpmd.enable_passepartout(vpmd.active, True)
         area = list(area)
     else:
         area = [0] * 4
     area[idx] = n
     self.__docproxy.set_metadata(dimensions=area)
Example #4
0
    def parse(self, prefs, interface):
        avail_maps = pymui.GetApp().startup_windows
        win_list = interface.get(
            'pymui_startup_win_list',
            ','.join(prefs['pymui-window-open-at-startup']))
        win_list = tuple(
            name
            for name in map(lambda x: x.strip().lower(), win_list.split(','))
            if name in avail_maps)

        # Update prefs and MUI now
        prefs['pymui-window-open-at-startup'] = win_list
Example #5
0
 def _on_change_icon(self, evt):
     bt = evt.Source.allbt
     filename = pymui.GetApp().get_image_filename(parent=self)
     if filename:
         self._top.InitChange()
         bt.brush.icon = filename.replace('PROGDIR:', '')
         data = self._load_brush_icon_for_rawimage(bt.brush)
         bt.ri_data = data
         bt.Picture = long(data)
         if bt.bt2:
             bt = bt.bt2
             data = self._load_brush_icon_for_rawimage(bt.brush)
             bt.ri_data = data
             bt.Picture = long(data)
         self._top.ExitChange()
Example #6
0
    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)
Example #7
0
 def __init__(self, name):
     super(Splash, self).__init__(ID=0,
                                  CloseOnReq=True,
                                  Borderless=True,
                                  DragBar=False,
                                  CloseGadget=False,
                                  SizeGadget=False,
                                  DepthGadget=False,
                                  Opacity=230,
                                  Position=('centered', 'centered'))
     self.name = name
     
     # Special root group with window auto-close on any events
     root = MyRoot(Frame='None',
                   Background='2:00000000,00000000,00000000',
                   InnerSpacing=(0,)*4)
     self.RootObject = root
     
     top_bar = pymui.HGroup(
         Frame='None',
         Background='5:PROGDIR:data/internal/splash_header.png')
     self.bottom_bar = bottom_bar = pymui.VGroup(Frame='None', InnerBottom=6)
     
     top_bar.AddChild(pymui.Dtpic('PROGDIR:data/internal/app_logo.png', InnerLeft=6, InnerRight=6))
     top_bar.AddChild(pymui.HSpace(0))
     top_bar.AddChild(pymui.Text(Frame='None',
                                 HorizWeight=0,
                                 PreParse=pymui.MUIX_C+pymui.MUIX_PH,
                                 Font=pymui.MUIV_Font_Tiny,
                                 Contents='v%.1f.%d\n%s' % (main.VERSION, main.BUILD, main.STATUS)))
     
     #hg = pymui.HGroup(InnerLeft=6, InnerRight=6)
     #bottom_bar.AddChild(hg)
     
     #hg.AddChild(pymui.Text(Frame='None', InnerLeft=6,
     #                       SetMax=True, PreParse=pymui.MUIX_PH,
     #                       Contents=_T('Interaction')+':'))
     #cycle = pymui.Cycle(['User', 'Default'], HorizWeight=0)
     
     #hg.AddChild(cycle)
     #hg.AddChild(pymui.HSpace(0))
     
     recent_gp = pymui.VGroup(InnerLeft=6, InnerRight=6)
     bottom_bar.AddChild(recent_gp)
             
     self.lasts_bt = []
     if os.path.isfile(LASTS_FILENAME):
         recent_gp.AddChild(pymui.Text(Frame='None',
                            InnerLeft=6, InnerRight=6,
                            PreParse=pymui.MUIX_L+pymui.MUIX_PH,
                            Contents=_T('Recent')+':'))
         with open(LASTS_FILENAME) as fd:
             for i in xrange(5):
                 path = fd.readline()[:-1]
                 if path:
                     logo = pymui.Dtpic('SYS:Prefs/Presets/Deficons/image/default.info',
                                        Scale=32, InnerLeft=20)
                     text = pymui.Text(Frame='None',
                                       PreParse=pymui.MUIX_PH,
                                       InputMode='RelVerify',
                                       Contents=os.path.basename(path))
                     text.path = path
                     
                     hg = pymui.HGroup()
                     hg.AddChild(logo)
                     hg.AddChild(text)
                     recent_gp.AddChild(hg)
                     
                     self.lasts_bt.append(text)
                     
     bottom_bar.AddChild(pymui.HBar(1))
     
     bt = pymui.SimpleButton(_T('About'), Weight=0, InnerRight=6)
     bt.Notify('Pressed', lambda *a: pymui.GetApp().about.OpenWindow(), when=False)
     bottom_bar.AddChild(pymui.HGroup(Child=(pymui.HSpace(0), bt)))
     
     all_logos = glob.glob('data/internal/app_intro*.png')
     logo = pymui.Dtpic(random.choice(all_logos), Frame="Group")
     
     root.AddChild(top_bar)
     root.AddChild(logo)
     root.AddChild(bottom_bar)
Example #8
0
 def _on_ld_pal_pressed(self, evt):
     filename = pymui.GetApp().get_filename(_T('Select palette filename for loading'), parent=self, pat=PAL_PAT)
     if filename:
         name = self._load_palette(filename)
         self._use_palette(name)
Example #9
0
    def apply_config(self, *a):
        # Events bindings
        for page in self._ctx_pages.itervalues():
            name = page.ctx.NAME
            page.ctx.reset_bindings()
            bind_list = prefs['bindings'][name] = []
            for bind in page.bindings.itervalues():
                data = bind.data
                if data:
                    bind_list.append(data)
                    key = data['evtcl'].encode(data['key'])
                    if data['any']: key |= contexts.EVENT_TAG_ANY
                    if data['repeat']: key |= contexts.EVENT_TAG_REPEAT
                    page.ctx.BINDINGS[key] = data['action']

        # Tools wheel
        icons_names = prefs['view-icons-names']
        binds = prefs['view-toolswheel-binding']
        for i, string in enumerate(self._toolswheel_strings):
            binds[i] = string.Contents.contents
            icons_names[i] = self._popup[i].name
            icons_names[8 + i] = self._popup[8 + i].name

        # Metrics
        unit = CALIBRATION_UNITS[self.cal_unit.Active.value]
        prefs['view-metrics-unit'] = unit

        if unit == 'dpi':
            unit = 'in'
            x = self.cal_bar_x.value
            y = self.cal_bar_y.value
        else:
            x = self.cal_bar_x.calibration  # pixels per unit
            y = self.cal_bar_y.calibration  # pixels per unit

        prefs['view-metrics-x'] = x
        prefs['view-metrics-y'] = y

        def set_ruler(unit, n, off):
            if unit == 'cm':
                Ruler.METRICS['cm'][2 + off] = n
                Ruler.METRICS['in'][2 + off] = n * 2.54
            elif unit == 'in':
                Ruler.METRICS['in'][2 + off] = n
                Ruler.METRICS['cm'][2 + off] = n / 2.54
            else:
                raise NotImplementedError(
                    "Metrics unit '%s' is not supported" % unit)

        set_ruler(unit, x, 0)
        set_ruler(unit, y, 1)

        # Rendering
        prefs['view-filter-threshold'] = self._filter_threshold.Value.value

        def apply_color(field, alpha):
            col = [float(x.value) / 0xffffffff for x in field.RGB]
            col.append(alpha.Value.value / 100.)
            return tuple(col)

        for k, v in _RenderingPrefHandler.MAPS.iteritems():
            prefs[v] = apply_color(*self._colors[k])

        prefs['pymui-ruler-bg-pen'] = self._ruler_bg_pen.Value.value
        prefs['pymui-ruler-fg-pen'] = self._ruler_fg_pen.Value.value

        # Interface
        win_list = []
        for key, bt in self._startup_win_bt.iteritems():
            if bt.Selected.value:
                win_list.append(key)
        prefs['pymui-window-open-at-startup'] = win_list
        del win_list

        # Redraw all windows
        # TODO: change that for a MVC notification as prefs is a model unit
        try:
            pymui.GetApp().mediator.document_mediator.refresh_all()
        except:
            pass
Example #10
0
 def _toggle_pp(self, evt):
     vpmd = pymui.GetApp().mediator.viewport_mediator
     vpmd.enable_passepartout(vpmd.active, evt.value.value)