def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Export to %s') % 'HTML') ## parent=None FIXME #self.set_has_separator(False) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('Month Range'))) combo = gtk.ComboBoxText() for t in ('Current Month', 'Whole Current Year', 'Custom'): combo.append_text(_(t)) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) self.combo = combo ### hbox2 = gtk.HBox(spacing=2) pack(hbox2, gtk.Label(_('from month'))) self.ymBox0 = YearMonthButton() pack(hbox2, self.ymBox0) pack(hbox2, gtk.Label(''), 1, 1) pack(hbox2, gtk.Label(_('to month'))) self.ymBox1 = YearMonthButton() pack(hbox2, self.ymBox1) pack(hbox, hbox2, 1, 1) self.hbox2 = hbox2 combo.set_active(0) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) pack(self.vbox, self.fcw, 1, 1) self.vbox.set_focus_child(self.fcw) ## FIXME self.vbox.show_all() combo.connect('changed', self.comboChanged) ## dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete) dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save) ## self.connect('delete-event', self.onDelete) try: self.fcw.set_current_folder(core.deskDir) except AttributeError: ## PyGTK < 2.4 pass
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Export to %s')%'HTML') ## parent=None FIXME #self.set_has_separator(False) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('Month Range'))) combo = gtk.ComboBoxText() for t in ('Current Month', 'Whole Current Year', 'Custom'): combo.append_text(_(t)) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) self.combo = combo ### hbox2 = gtk.HBox(spacing=2) pack(hbox2, gtk.Label(_('from month'))) self.ymBox0 = YearMonthButton() pack(hbox2, self.ymBox0) pack(hbox2, gtk.Label(''), 1, 1) pack(hbox2, gtk.Label(_('to month'))) self.ymBox1 = YearMonthButton() pack(hbox2, self.ymBox1) pack(hbox, hbox2, 1, 1) self.hbox2 = hbox2 combo.set_active(0) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) pack(self.vbox, self.fcw, 1, 1) self.vbox.set_focus_child(self.fcw)## FIXME self.vbox.show_all() combo.connect('changed', self.comboChanged) ## dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete) dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save) ## self.connect('delete-event', self.onDelete) try: self.fcw.set_current_folder(core.deskDir) except AttributeError:## PyGTK < 2.4 pass
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_("Export to %s") % "HTML") # parent=None FIXME #self.set_has_separator(False) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_("Month Range"))) combo = gtk.ComboBoxText() for t in ("Current Month", "Whole Current Year", "Custom"): combo.append_text(_(t)) pack(hbox, combo) pack(hbox, gtk.Label(""), 1, 1) self.combo = combo ### hbox2 = gtk.HBox(spacing=2) pack(hbox2, gtk.Label(_("from month"))) self.ymBox0 = YearMonthButton() pack(hbox2, self.ymBox0) pack(hbox2, gtk.Label(""), 1, 1) pack(hbox2, gtk.Label(_("to month"))) self.ymBox1 = YearMonthButton() pack(hbox2, self.ymBox1) pack(hbox, hbox2, 1, 1) self.hbox2 = hbox2 combo.set_active(0) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) pack(self.vbox, self.fcw, 1, 1) self.vbox.set_focus_child(self.fcw)## FIXME self.vbox.show_all() combo.connect("changed", self.comboChanged) ## dialog_add_button(self, gtk.STOCK_CANCEL, _("_Cancel"), 1, self.onDelete) dialog_add_button(self, gtk.STOCK_SAVE, _("_Save"), 2, self.save) ## self.connect("delete-event", self.onDelete) self.fcw.set_current_folder(core.deskDir)
class ExportDialog(gtk.Dialog, MyDialog): def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Export to %s') % 'HTML') ## parent=None FIXME #self.set_has_separator(False) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('Month Range'))) combo = gtk.ComboBoxText() for t in ('Current Month', 'Whole Current Year', 'Custom'): combo.append_text(_(t)) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) self.combo = combo ### hbox2 = gtk.HBox(spacing=2) pack(hbox2, gtk.Label(_('from month'))) self.ymBox0 = YearMonthButton() pack(hbox2, self.ymBox0) pack(hbox2, gtk.Label(''), 1, 1) pack(hbox2, gtk.Label(_('to month'))) self.ymBox1 = YearMonthButton() pack(hbox2, self.ymBox1) pack(hbox, hbox2, 1, 1) self.hbox2 = hbox2 combo.set_active(0) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) pack(self.vbox, self.fcw, 1, 1) self.vbox.set_focus_child(self.fcw) ## FIXME self.vbox.show_all() combo.connect('changed', self.comboChanged) ## dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete) dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save) ## self.connect('delete-event', self.onDelete) try: self.fcw.set_current_folder(core.deskDir) except AttributeError: ## PyGTK < 2.4 pass def comboChanged(self, widget=None, ym=None): i = self.combo.get_active() if ym == None: ym = (ui.cell.year, ui.cell.month) if i == 0: self.fcw.set_current_name('calendar-%.4d-%.2d.html' % ym) self.hbox2.hide() elif i == 1: self.fcw.set_current_name('calendar-%.4d.html' % ym[0]) self.hbox2.hide() else: #elif i==2 self.fcw.set_current_name('calendar.html') self.hbox2.show() ## select_region(0, -4) ## FIXME def onDelete(self, widget=None, event=None): ## hide(close) File Chooser Dialog self.hide() return True def _save(self, path): comboItem = self.combo.get_active() months = [] module = calTypes.primaryModule() if comboItem == 0: s = getCurrentMonthStatus() months = [s] title = '%s %s' % (locale_man.getMonthName( calTypes.primary, s.month, s.year), _(s.year)) elif comboItem == 1: for i in range(1, 13): months.append(getMonthStatus(ui.cell.year, i)) title = '%s %s' % (_('Calendar'), _(ui.cell.year)) elif comboItem == 2: y0, m0 = self.ymBox0.get_value() y1, m1 = self.ymBox1.get_value() for ym in range(y0 * 12 + m0 - 1, y1 * 12 + m1): y, m = divmod(ym, 12) m += 1 months.append(getMonthStatus(y, m)) title = _('Calendar') exportToHtml(path, months, title) self.hide() def save(self, widget=None): while gtk.events_pending(): gtk.main_iteration_do(False) path = self.fcw.get_filename() if path in (None, ''): return print('Exporting to html file "%s"' % path) self.waitingDo( self._save, path, ) def showDialog(self, year, month): self.comboChanged(ym=(year, month)) self.ymBox0.set_value((year, month)) self.ymBox1.set_value((year, month)) self.resize(1, 1) openWindow(self) '''
class ExportDialog(gtk.Dialog, MyDialog): def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Export to %s')%'HTML') ## parent=None FIXME #self.set_has_separator(False) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('Month Range'))) combo = gtk.ComboBoxText() for t in ('Current Month', 'Whole Current Year', 'Custom'): combo.append_text(_(t)) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) self.combo = combo ### hbox2 = gtk.HBox(spacing=2) pack(hbox2, gtk.Label(_('from month'))) self.ymBox0 = YearMonthButton() pack(hbox2, self.ymBox0) pack(hbox2, gtk.Label(''), 1, 1) pack(hbox2, gtk.Label(_('to month'))) self.ymBox1 = YearMonthButton() pack(hbox2, self.ymBox1) pack(hbox, hbox2, 1, 1) self.hbox2 = hbox2 combo.set_active(0) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) pack(self.vbox, self.fcw, 1, 1) self.vbox.set_focus_child(self.fcw)## FIXME self.vbox.show_all() combo.connect('changed', self.comboChanged) ## dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete) dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save) ## self.connect('delete-event', self.onDelete) try: self.fcw.set_current_folder(core.deskDir) except AttributeError:## PyGTK < 2.4 pass def comboChanged(self, widget=None, ym=None): i = self.combo.get_active() if ym==None: ym = (ui.cell.year, ui.cell.month) if i==0: self.fcw.set_current_name('calendar-%.4d-%.2d.html'%ym) self.hbox2.hide() elif i==1: self.fcw.set_current_name('calendar-%.4d.html'%ym[0]) self.hbox2.hide() else:#elif i==2 self.fcw.set_current_name('calendar.html') self.hbox2.show() ## select_region(0, -4) ## FIXME def onDelete(self, widget=None, event=None):## hide(close) File Chooser Dialog self.hide() return True def _save(self, path): comboItem = self.combo.get_active() months = [] module = calTypes.primaryModule() if comboItem==0: s = getCurrentMonthStatus() months = [s] title = '%s %s'%(locale_man.getMonthName(calTypes.primary, s.month, s.year), _(s.year)) elif comboItem==1: for i in range(1, 13): months.append(getMonthStatus(ui.cell.year, i)) title = '%s %s'%(_('Calendar'), _(ui.cell.year)) elif comboItem==2: y0, m0 = self.ymBox0.get_value() y1, m1 = self.ymBox1.get_value() for ym in range(y0*12+m0-1, y1*12+m1): y, m = divmod(ym, 12) m += 1 months.append(getMonthStatus(y, m)) title = _('Calendar') exportToHtml(path, months, title) self.hide() def save(self, widget=None): while gtk.events_pending(): gtk.main_iteration_do(False) path = self.fcw.get_filename() if path in (None, ''): return print('Exporting to html file "%s"'%path) self.waitingDo( self._save, path, ) def showDialog(self, year, month): self.comboChanged(ym=(year, month)) self.ymBox0.set_value((year, month)) self.ymBox1.set_value((year, month)) self.resize(1, 1) openWindow(self) '''