def client_action(self, action): access = MODELACCESS[self.model_name] if action == 'new': if access['create']: self.new() elif action == 'delete': if access['delete']: self.remove(delete=not self.parent, force_remove=not self.parent) elif action == 'remove': if access['write'] and access['read'] and self.parent: self.remove(remove=True) elif action == 'copy': if access['create']: self.copy() elif action == 'next': self.display_next() elif action == 'previous': self.display_prev() elif action == 'close': from tryton.gui import Main Main.get_main().sig_win_close() elif action.startswith('switch'): _, view_type = action.split(None, 1) self.switch_view(view_type=view_type) elif action == 'reload': if (self.current_view.view_type in ['tree', 'graph', 'calendar'] and not self.parent): self.search_filter() elif action == 'reload menu': from tryton.gui import Main RPCContextReload(Main.get_main().sig_win_menu) elif action == 'reload context': RPCContextReload()
def create_wizard(action, data, direct_print=False, email_print=False, email=None, name=False, context=None, icon=None, window=False): from tryton.gui import Main from wizard import WizardForm, WizardDialog if window: win = WizardForm(name=name) win.icon = icon Main.get_main().win_add(win, Window.hide_current) else: win = WizardDialog(name=name) win.run(action, data, direct_print=direct_print, email_print=email_print, email=email, context=context)
def create_tabcontent(self): self.buttons = {} self.tooltips = common.Tooltips() self.accel_group = Main.get_main().accel_group self.widget = gtk.VBox(spacing=3) self.widget.show() title_box = self.make_title_bar() self.widget.pack_start(title_box, expand=False, fill=True, padding=3) self.create_info_bar() self.widget.pack_start(self.info_bar, False, True) self.toolbar = self.create_toolbar(self.get_toolbars()) # JCA : Allow to hide buttons through the context if not self.context.get('disable_main_toolbar', None): self.toolbar.show_all() self.widget.pack_start(self.toolbar, False, True) viewport = gtk.Viewport() viewport.set_shadow_type(gtk.SHADOW_NONE) viewport.add(self.widget_get()) viewport.show() self.scrolledwindow = gtk.ScrolledWindow() self.scrolledwindow.set_shadow_type(gtk.SHADOW_NONE) self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolledwindow.add(viewport) self.scrolledwindow.show() self.widget.pack_start(self.scrolledwindow)
def create(view_ids, model, res_id=False, domain=None, context=None, order=None, mode=None, name=False, limit=None, search_value=None, icon=None, tab_domain=None): from tryton.gui import Main if context is None: context = {} if model: from form import Form win = Form(model, res_id, domain, order=order, mode=mode, view_ids=(view_ids or []), context=context, name=name, limit=limit, search_value=search_value, tab_domain=tab_domain) else: from board import Board win = Board(model, view_ids and view_ids[0] or None, context=context, name=name) win.icon = icon Main.get_main().win_add(win, hide_current=Window.hide_current, allow_similar=Window.allow_similar)
def sig_win_close(self, widget): Main.get_main().sig_win_close(widget)
def end(self, callback=None): super(WizardForm, self).end(callback=callback) Main.get_main()._win_del(self.widget)
def __init__(self, goocalendar): super(Toolbar, self).__init__() self.goocalendar = goocalendar self.accel_group = Main.get_main().accel_group today_label = gtk.Label(_('Today')) today_button = gtk.ToolButton(today_label) today_button.set_homogeneous(False) today_button.connect("clicked", self.on_today_button_clicked) today_button.add_accelerator("clicked", self.accel_group, gtk.keysyms.t, gtk.gdk.MODIFIER_MASK, gtk.ACCEL_VISIBLE) self.insert(today_button, -1) arrow_left = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_NONE) go_back = gtk.ToolButton(arrow_left, "go left") go_back.set_expand(False) go_back.set_homogeneous(False) go_back.connect("clicked", self.on_go_back_clicked) self.insert(go_back, -1) self.current_page_label = gtk.Label("") self.current_page = gtk.ToggleToolButton() self.current_page.set_icon_widget(self.current_page_label) self.current_page.connect("clicked", self.on_current_page_clicked) self.insert(self.current_page, -1) gtkcal = gtk.Calendar() gtkcal.connect('day-selected', self.on_gtkcal_day_selected) gtkcal.set_display_options( gtk.CALENDAR_SHOW_HEADING | gtk.CALENDAR_SHOW_WEEK_NUMBERS | gtk.CALENDAR_SHOW_DAY_NAMES) gtkcal.set_no_show_all(True) gtkcal_item = goocanvas.Widget(widget=gtkcal) gtkcal_item.set_property('visibility', goocanvas.ITEM_INVISIBLE) goocalendar.get_root_item().add_child(gtkcal_item) self.gtkcal = gtkcal self.gtkcal_item = gtkcal_item self.goocalendar.connect('day-selected', self.on_goocalendar_day_selected) arrow_right = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE) go_forward = gtk.ToolButton(arrow_right, "go right") go_forward.set_expand(False) go_forward.set_homogeneous(False) go_forward.connect("clicked", self.on_go_forward_clicked) self.insert(go_forward, -1) arrow_left = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_NONE) previous_year = gtk.ToolButton(arrow_left, "next year") previous_year.set_expand(False) previous_year.set_homogeneous(False) previous_year.connect("clicked", self.on_previous_year_clicked) self.insert(previous_year, -1) self.current_year_label = gtk.Label("") current_year = gtk.ToolItem() current_year.add(self.current_year_label) self.insert(current_year, -1) arrow_right = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE) next_year = gtk.ToolButton(arrow_right, "next year") next_year.set_expand(False) next_year.set_homogeneous(False) next_year.connect("clicked", self.on_next_year_clicked) self.insert(next_year, -1) blank_widget = gtk.ToolItem() blank_widget.set_expand(True) self.insert(blank_widget, -1) week_button = gtk.RadioToolButton() week_button.set_label(_('Week View')) week_button.connect("clicked", self.on_week_button_clicked) week_button.add_accelerator("clicked", self.accel_group, gtk.keysyms.w, gtk.gdk.MODIFIER_MASK, gtk.ACCEL_VISIBLE) self.insert(week_button, -1) month_button = gtk.RadioToolButton(week_button) month_button.set_label(_('Month View')) month_button.connect("clicked", self.on_month_button_clicked) month_button.add_accelerator("clicked", self.accel_group, gtk.keysyms.m, gtk.gdk.MODIFIER_MASK, gtk.ACCEL_VISIBLE) month_button.set_active(True) self.insert(month_button, -1) self.update_displayed_date() self.set_style(gtk.TOOLBAR_ICONS)
def __init__(self, goocalendar): super(Toolbar, self).__init__() self.goocalendar = goocalendar self.accel_group = Main.get_main().accel_group today_button = gtk.ToolButton() today_button.set_label(_('Today')) today_button.set_homogeneous(False) today_button.connect("clicked", self.on_today_button_clicked) today_button.add_accelerator("clicked", self.accel_group, gtk.keysyms.t, gtk.gdk.MODIFIER_MASK, gtk.ACCEL_VISIBLE) self.insert(today_button, -1) arrow_left = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_NONE) go_back = gtk.ToolButton() go_back.set_icon_widget(arrow_left) go_back.set_label(_("go back")) go_back.set_expand(False) go_back.set_homogeneous(False) go_back.connect("clicked", self.on_go_back_clicked) self.insert(go_back, -1) self.current_page_label = gtk.Label("") self.current_page = gtk.ToggleToolButton() self.current_page.set_label_widget(self.current_page_label) self.current_page.connect("clicked", self.on_current_page_clicked) self.insert(self.current_page, -1) self.__cal_popup = gtk.Window(gtk.WINDOW_POPUP) self.__cal_popup.set_events(self.__cal_popup.get_events() | gtk.gdk.KEY_PRESS_MASK) self.__cal_popup.set_resizable(False) self.__cal_popup.connect('delete-event', self.on_cal_popup_closed) self.__cal_popup.connect('key-press-event', self.on_cal_popup_key_pressed) self.__cal_popup.connect('button-press-event', self.on_cal_popup_button_pressed) gtkcal = gtk.Calendar() gtkcal.connect('day-selected', self.on_gtkcal_day_selected) gtkcal.connect('day-selected-double-click', self.on_gtkcal_day_selected_double_click) gtkcal.set_display_options(gtk.CALENDAR_SHOW_HEADING | gtk.CALENDAR_SHOW_WEEK_NUMBERS | gtk.CALENDAR_SHOW_DAY_NAMES) gtkcal.set_no_show_all(True) self.__cal_popup.add(gtkcal) gtkcal.show() self.gtkcal = gtkcal self.goocalendar.connect('day-selected', self.on_goocalendar_day_selected) arrow_right = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE) go_forward = gtk.ToolButton() go_forward.set_icon_widget(arrow_right) go_forward.set_label(_("go forward")) go_forward.set_expand(False) go_forward.set_homogeneous(False) go_forward.connect("clicked", self.on_go_forward_clicked) self.insert(go_forward, -1) arrow_left = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_NONE) previous_year = gtk.ToolButton() previous_year.set_icon_widget(arrow_left) previous_year.set_label(_("previous year")) previous_year.set_expand(False) previous_year.set_homogeneous(False) previous_year.connect("clicked", self.on_previous_year_clicked) self.insert(previous_year, -1) self.current_year_label = gtk.Label("") current_year = gtk.ToolItem() current_year.add(self.current_year_label) self.insert(current_year, -1) arrow_right = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE) next_year = gtk.ToolButton() next_year.set_icon_widget(arrow_right) next_year.set_label(_("next year")) next_year.set_expand(False) next_year.set_homogeneous(False) next_year.connect("clicked", self.on_next_year_clicked) self.insert(next_year, -1) blank_widget = gtk.ToolItem() blank_widget.set_expand(True) self.insert(blank_widget, -1) week_button = gtk.RadioToolButton() week_button.set_label(_('Week View')) week_button.connect("clicked", self.on_week_button_clicked) week_button.add_accelerator("clicked", self.accel_group, gtk.keysyms.w, gtk.gdk.MODIFIER_MASK, gtk.ACCEL_VISIBLE) self.insert(week_button, -1) if hasattr(gtk.RadioToolButton, 'new_from_widget'): month_button = gtk.RadioToolButton.new_from_widget(week_button) else: month_button = gtk.RadioToolButton(week_button) month_button.set_label_widget(gtk.Label(_('Month View'))) month_button.connect("clicked", self.on_month_button_clicked) month_button.add_accelerator("clicked", self.accel_group, gtk.keysyms.m, gtk.gdk.MODIFIER_MASK, gtk.ACCEL_VISIBLE) self.insert(month_button, -1) buttons = {'month': month_button, 'week': week_button} buttons[self.goocalendar.view].set_active(True) self.update_displayed_date() self.set_style(gtk.TOOLBAR_ICONS)