def __init__(self, action_entries=[], horizontal=False): gtk.Window.__init__(self) self.create_actions(action_entries) rc.init_rc(self) self.box = VBox(self) if horizontal: self.box = HBox(self) self.build() self.add(self.box) self.connect(gconst.EVENT_DELETE, self._event_close)
def __init__(self, master, doc, txt, cmd=None, icon_id=None): self.doc = doc self.cmd = cmd HBox.__init__(self, master) self.pack_end(DBTabButton(self, cmd=self.close_cmd), False, False, 2) if icon_id: self.pack_start(Image(self, icon_id), False, False, 2) self.label = gtk.Label('') self.pack_start(self.label, False, False, 2) self.set_caption(txt) self.show_all()
class MainWindow(gtk.Window): accelgroup = None actiongroup = None actions = {} def __init__(self, action_entries=[], horizontal=False): gtk.Window.__init__(self) self.create_actions(action_entries) rc.init_rc(self) self.box = VBox(self) if horizontal: self.box = HBox(self) self.build() self.add(self.box) self.connect(gconst.EVENT_DELETE, self._event_close) def set_icon(self, image_id): gtk.Window.set_icon(self, rc.get_pixbuf(image_id)) def build(self):pass def _event_close(self, *args): return self.event_close() def event_close(self): self.exit() return False def run(self): self.show_all() gtk.main() def exit(self):gtk.main_quit();sys.exit() def pack(self, child, expand=False, fill=False, padding=0, end=False): self.box.pack(child, expand, fill, padding, end) def pack_all(self, childs, expand=False, fill=False, padding=0, end=False): self.box.pack_all(childs, expand, fill, padding, end) def center(self): self.set_position(gtk.WIN_POS_CENTER) def set_title(self, title): gtk.Window.set_title(self, title) def set_size(self, w, h): gtk.Window.set_default_size(self, w, h) def get_size(self): return tuple(gtk.Window.get_size(self)) def set_min_size(self, w, h): self.set_size_request(w, h) def maximize(self): gtk.Window.maximize(self) def is_maximized(self): return self.window.get_state() == gtk.gdk.WINDOW_STATE_MAXIMIZED def create_actions(self, entries): if not entries: return self.accelgroup = gtk.AccelGroup() self.actiongroup = gtk.ActionGroup('MW_Actions') self.modegroup = None self.actions = {} for entry in entries: action_id = entry[0] if action_id < 100: action = AppRadioAction(*entry) elif action_id < 1000: action = AppAction(*entry) else: action = AppToggleAction(*entry) self.actions[entry[0]] = action if action_id < 100: if self.modegroup is None: self.modegroup = action else: action.set_group(self.modegroup) if not action.shortcut is None: self.actiongroup.add_action_with_accel(action, action.shortcut) action.set_accel_group(self.accelgroup) else: self.actiongroup.add_action(action) self.add_accel_group(self.accelgroup)
class MainWindow(gtk.Window): accelgroup = None actiongroup = None actions = {} def __init__(self, action_entries=[], horizontal=False): gtk.Window.__init__(self) self.create_actions(action_entries) rc.init_rc(self) self.box = VBox(self) if horizontal: self.box = HBox(self) self.build() self.add(self.box) self.connect(gconst.EVENT_DELETE, self._event_close) def set_icon(self, image_id): gtk.Window.set_icon(self, rc.get_pixbuf(image_id)) def build(self): pass def _event_close(self, *args): return self.event_close() def event_close(self): self.exit() return False def run(self): self.show_all() gtk.main() def exit(self): gtk.main_quit() sys.exit() def pack(self, child, expand=False, fill=False, padding=0, end=False): self.box.pack(child, expand, fill, padding, end) def pack_all(self, childs, expand=False, fill=False, padding=0, end=False): self.box.pack_all(childs, expand, fill, padding, end) def center(self): self.set_position(gtk.WIN_POS_CENTER) def set_title(self, title): gtk.Window.set_title(self, title) def set_size(self, w, h): gtk.Window.set_default_size(self, w, h) def get_size(self): return tuple(gtk.Window.get_size(self)) def set_min_size(self, w, h): self.set_size_request(w, h) def maximize(self): gtk.Window.maximize(self) def is_maximized(self): return self.window.get_state() == gtk.gdk.WINDOW_STATE_MAXIMIZED def create_actions(self, entries): if not entries: return self.accelgroup = gtk.AccelGroup() self.actiongroup = gtk.ActionGroup('MW_Actions') self.modegroup = None self.actions = {} for entry in entries: action_id = entry[0] if action_id < 100: action = AppRadioAction(*entry) elif action_id < 1000: action = AppAction(*entry) else: action = AppToggleAction(*entry) self.actions[entry[0]] = action if action_id < 100: if self.modegroup is None: self.modegroup = action else: action.set_group(self.modegroup) if not action.shortcut is None: self.actiongroup.add_action_with_accel(action, action.shortcut) action.set_accel_group(self.accelgroup) else: self.actiongroup.add_action(action) self.add_accel_group(self.accelgroup)