def build_tab_about(self): panel = TFrame(self.root, style='FlatFrame', borderwidth=10) self.nb.add(panel, text=_('About application')) subpanel = TFrame(panel, style='FlatFrame', borderwidth=0) subpanel.pack(side=TOP, fill=Y, expand=1) subpanel = TFrame(subpanel, style='FlatFrame', borderwidth=5) subpanel.pack(side=LEFT, anchor='center') text = TLabel(subpanel, style='FlatLabel', text=_("Illustration program for prepress")) text.pack(side=TOP, anchor=W, pady=10) from time import gmtime, strftime year = strftime("%Y", gmtime()) text = TLabel(subpanel, style='FlatLabel', text="(c)2003-%s sK1 Team" % (year)) text.pack(side=TOP, anchor=W, pady=10) text = TLabel(subpanel, style='FlatLabel', text='http://sk1project.org', foreground='blue', underline=20, cursor='hand2') text.pack(side=TOP, anchor=W) text.bind('<Button-1>', self.goToSite)
class Pager(TFrame, Publisher): hidden=1 def __init__(self, parent, mainwindow): self.parent=parent self.mainwindow=mainwindow TFrame.__init__(self, self.parent, name = 'pagerPanel', style='FlatFrame', borderwidth=0) top_border=TLabel(self, style='FlatLabel', image='space_1') top_border.pack(side=TOP, fill=X) self.container=TFrame(self, style='FlatFrame', borderwidth=0) space=TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.home_but=TButton(self.container, style='PagerHome', command=self.PageHome) self.home_but.pack(side=LEFT) self.home_but=TButton(self.container, style='PagerPrevious', command=self.PagePrevious) self.home_but.pack(side=LEFT) self.text=TLabel(self.container, style='FlatLabel', text=' '+_('Page 2 of 2')+' ') self.text.pack(side=LEFT) self.home_but=TButton(self.container, style='PagerNext', command=self.PageNext) self.home_but.pack(side=LEFT) self.home_but=TButton(self.container, style='PagerEnd', command=self.PageEnd) self.home_but.pack(side=LEFT) space=TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.mainwindow.Subscribe(DOCUMENT, self.Resubscribe) self.Resubscribe() self.doc_paged() self.text.bind('<Double-Button-1>', self.GoToPage) def stub(self): pass def doc_paged(self): current_page=self.mainwindow.document.active_page+1 num_pages=len(self.mainwindow.document.pages) if self.hidden and num_pages>1: self.container.pack(side=LEFT, fill=Y) self.hidden=0 if not self.hidden and num_pages==1: self.container.forget() self.hidden=1 self.text['text']=' '+_('Page %u of %u')%(current_page,num_pages)+' ' def Resubscribe(self, *arg): self.mainwindow.document.Subscribe(PAGE, self.doc_paged) self.doc_paged() def PageHome(self): self.mainwindow.document.GoToPage(0) self.mainwindow.document.SelectNone() self.mainwindow.canvas.ForceRedraw() def PageEnd(self): self.mainwindow.document.GoToPage(len(self.mainwindow.document.pages)-1) self.mainwindow.document.SelectNone() self.mainwindow.canvas.ForceRedraw() def PagePrevious(self): self.mainwindow.PreviousPage() def PageNext(self): self.mainwindow.NextPage() def GoToPage(self, *args): self.mainwindow.GotoPage()
class Pager(TFrame, Publisher): hidden = 1 def __init__(self, parent, mainwindow): self.parent = parent self.mainwindow = mainwindow TFrame.__init__(self, self.parent, name='pagerPanel', style='FlatFrame', borderwidth=0) top_border = TLabel(self, style='FlatLabel', image='space_1') top_border.pack(side=TOP, fill=X) self.container = TFrame(self, style='FlatFrame', borderwidth=0) space = TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.home_but = TButton(self.container, style='PagerHome', command=self.PageHome) self.home_but.pack(side=LEFT) self.home_but = TButton(self.container, style='PagerPrevious', command=self.PagePrevious) self.home_but.pack(side=LEFT) self.text = TLabel(self.container, style='FlatLabel', text=' ' + _('Page 2 of 2') + ' ') self.text.pack(side=LEFT) self.home_but = TButton(self.container, style='PagerNext', command=self.PageNext) self.home_but.pack(side=LEFT) self.home_but = TButton(self.container, style='PagerEnd', command=self.PageEnd) self.home_but.pack(side=LEFT) space = TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.mainwindow.Subscribe(DOCUMENT, self.Resubscribe) self.Resubscribe() self.doc_paged() self.text.bind('<Double-Button-1>', self.GoToPage) def stub(self): pass def doc_paged(self): current_page = self.mainwindow.document.active_page + 1 num_pages = len(self.mainwindow.document.pages) if self.hidden and num_pages > 1: self.container.pack(side=LEFT, fill=Y) self.hidden = 0 if not self.hidden and num_pages == 1: self.container.forget() self.hidden = 1 self.text['text'] = ' ' + _('Page %u of %u') % (current_page, num_pages) + ' ' def Resubscribe(self, *arg): self.mainwindow.document.Subscribe(PAGE, self.doc_paged) self.doc_paged() def PageHome(self): self.mainwindow.document.GoToPage(0) self.mainwindow.document.SelectNone() self.mainwindow.canvas.ForceRedraw() def PageEnd(self): self.mainwindow.document.GoToPage( len(self.mainwindow.document.pages) - 1) self.mainwindow.document.SelectNone() self.mainwindow.canvas.ForceRedraw() def PagePrevious(self): self.mainwindow.PreviousPage() def PageNext(self): self.mainwindow.NextPage() def GoToPage(self, *args): self.mainwindow.GotoPage()
class PluginPanel(TFrame, Publisher): receivers = [(SELECTION, 'issue', SELECTION)] name = '' category = '' title = '' icon = 'strip_dialog' contents = [] category = '' category_title = '' activated = 0 collapsed = 0 visible = 0 packed = 0 fill = X expand = 0 def init(self, master): self.master = master self.mw = app.mw self.pcontainer = self.master.master self.document = self.mw.document TFrame.__init__(self, self.master, style='FlatFrame', borderwidth=0) self.top = TFrame(self, style='PWinHead', borderwidth=3) self.panel = TFrame(self, style='PWinBody', borderwidth=3) self.activated = 1 self.visible = 1 self.packed = 1 for item in self.pcontainer.loaded: if not item.collapsed: item.collapse_panel() self.pack(side=TOP, fill=self.fill, expand=self.expand, padx=1, pady=1) self.top.pack(side=TOP, fill=X) self.panel.pack(side=TOP, fill=BOTH, expand=1) self.iconlabel = TLabel(self.top, style='PWLabel', image=self.icon) self.textlabel = TLabel(self.top, style='PWLabel', text=self.title, anchor=W) if not 'bold' in self.textlabel['font'].split(): self.textlabel['font'] += ' bold' self.closebut = TButton(self.top, style='PWButton', image='close_pw', command=self.close_panel) self.collapsebut = TButton(self.top, style='PWButton', image='minimize_pw', command=self.click) self.iconlabel.pack(side=LEFT, padx=2) self.textlabel.pack(side=LEFT, fill=BOTH, expand=1, padx=3) self.closebut.pack(side=RIGHT) self.collapsebut.pack(side=RIGHT) self.textlabel.bind("<Button-1>", self.click) self.mw.Subscribe(DOCUMENT, self.doc_changed) def click(self, *args): if self.collapsed: self.decollapse_panel() else: self.collapse_panel() def close_panel(self): self.packed = 0 self.forget() self.pcontainer.remove_plugin(self) def restore_panel(self): for item in self.pcontainer.loaded: if not item.collapsed: item.collapse_panel() self.forget() self.packed = 1 self.pack(side=TOP, fill=self.fill, expand=self.expand, padx=1, pady=1) self.decollapse_panel() def decollapse_panel(self, *arg): if self.collapsed: for item in self.pcontainer.loaded: if not item.collapsed: item.collapse_panel() self.forget() self.pack(side=TOP, fill=X, padx=1, pady=1) self.panel.pack(side=TOP, fill=BOTH, expand=1) self.collapsebut['image'] = 'minimize_pw' self.collapsed = 0 self.textlabel['foreground'] = app.uimanager.currentColorTheme.foreground self.forget() self.pack(side=TOP, fill=self.fill, expand=self.expand, padx=1, pady=1) def collapse_panel(self, *arg): if not self.collapsed: self.panel.forget() self.collapsebut['image'] = 'restore_pw' self.collapsed = 1 self.textlabel['foreground'] = app.uimanager.currentColorTheme.menudisabledforeground self.forget() self.pack(side=TOP, fill=X, expand=0, padx=1, pady=1) def doc_changed(self, *arg): self.SetDocument(self.mw.document) def doc_has_selection(self): return self.document.HasSelection() def subscribe_receivers(self): pass def unsubscribe_receivers(self): pass def SetDocument(self, doc): if self.document: self.unsubscribe_receivers() self.document = doc self.init_from_doc() self.subscribe_receivers() def init_from_doc(self): # Called whenever the document changes and from __init__ pass def Update(self): # Called when the selection changes. pass def do_apply(self): # called by the `Apply' standard button to apply the settings pass def can_apply(self): return 1 def create_std_buttons(self, master): frame = TFrame(master, style='FlatFrame', borderwidth=2) button = UpdatedButton(frame, text=_("Apply"), command=self.do_apply, sensitivecb=self.can_apply) button.pack(side=TOP) return frame