Пример #1
0
    def make_at_box(self):
        # The time of day setting
        hbox = g.HBox(FALSE, 0)

        self.at = g.CheckButton(_('At'))
        hbox.pack_start(self.at, FALSE, TRUE, 4)
        self.at.connect('toggled', self.at_toggled)

        at_box = g.HBox(FALSE, 0)
        self.at_box = at_box
        hbox.pack_start(at_box, FALSE, TRUE, 0)

        arrow = Arrow(g.ARROW_LEFT, self.adj_time, -60)
        at_box.pack_start(arrow, FALSE, TRUE, 0)
        arrow = Arrow(g.ARROW_RIGHT, self.adj_time, 60)
        at_box.pack_start(arrow, FALSE, TRUE, 0)

        self.time_display = g.Label(str_time(self.hour, self.min))
        self.time_display.set_padding(4, 0)
        frame = g.Frame()
        frame.add(self.time_display)
        at_box.pack_start(frame, FALSE, TRUE, 0)

        arrow = Arrow(g.ARROW_LEFT, self.adj_time, -1)
        at_box.pack_start(arrow, FALSE, TRUE, 0)
        arrow = Arrow(g.ARROW_RIGHT, self.adj_time, 1)
        at_box.pack_start(arrow, FALSE, TRUE, 0)

        return hbox
Пример #2
0
    def make_text_view(self):
        # The TextView / time of day settings
        vbox = g.VBox(FALSE, 0)
        l = g.Label(_('Message:'))
        l.set_alignment(0, 1)
        l.set_padding(0, 4)
        vbox.pack_start(l, FALSE, TRUE, 0)

        frame = g.Frame()
        vbox.pack_start(frame, TRUE, TRUE, 0)
        frame.set_shadow_type(g.SHADOW_IN)

        hbox = g.HBox(FALSE, 0)
        frame.add(hbox)

        text = g.TextView()
        hbox.pack_start(text, TRUE, TRUE, 0)
        text.set_wrap_mode(g.WRAP_WORD)

        scrollbar = g.VScrollbar()
        adj = scrollbar.get_adjustment()
        text.set_scroll_adjustments(None, adj)
        hbox.pack_start(scrollbar, FALSE, TRUE, 0)

        text.set_size_request(200, 200)

        self.text = text

        return vbox
Пример #3
0
 def __init__(self, weather, ndays):
     g.Window.__init__(self, g.WINDOW_POPUP)
     self.stick()
     self.ndays = 0
     self.weather = weather
     self.table = None
     self.box = g.Frame()
     self.add(self.box)
     self.set_ndays(ndays)
Пример #4
0
    def build_window_frame(self, add_frame=True):
        "Create the main structure of the window."
        hbox = g.HBox(False, 4)
        self.vbox.pack_start(hbox, True, True, 0)

        # scrolled window for the tree view
        sw = g.ScrolledWindow()
        sw.set_shadow_type(g.SHADOW_IN)
        sw.set_policy(g.POLICY_NEVER, g.POLICY_AUTOMATIC)
        hbox.pack_start(sw, False, True, 0)
        self.sections_swin = sw  # Used to hide it...

        # tree view
        model = g.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
        tv = g.TreeView(model)
        sel = tv.get_selection()
        sel.set_mode(g.SELECTION_BROWSE)
        tv.set_headers_visible(False)
        self.sections = model
        self.tree_view = tv
        tv.unset_flags(g.CAN_FOCUS)  # Stop irritating highlight

        # Add a column to display column 0 of the store...
        cell = g.CellRendererText()
        column = g.TreeViewColumn('Section', cell, text=0)
        tv.append_column(column)

        sw.add(tv)

        # main options area
        notebook = g.Notebook()
        notebook.set_show_tabs(False)
        notebook.set_show_border(False)
        self.notebook = notebook

        if add_frame:
            frame = g.Frame()
            frame.set_shadow_type(g.SHADOW_IN)
            hbox.pack_start(frame, True, True, 0)
            frame.add(notebook)
        else:
            hbox.pack_start(notebook, True, True, 0)

        # Flip pages
        def change_page(sel, notebook):
            selected = sel.get_selected()
            if not selected:
                return
            model, titer = selected
            page = model.get_value(titer, 1)
            notebook.set_current_page(page)

        sel.connect('changed', change_page, notebook)

        self.vbox.show_all()
Пример #5
0
    def build_frame(self, node, label):
        """<frame label='Title'>...</frame> to group options under a heading."""
        frame = g.Frame(label)
        frame.set_shadow_type(g.SHADOW_NONE)

        # Make the label bold...
        # (bug in pygtk => use set_markup)
        label_widget = frame.get_label_widget()
        label_widget.set_markup('<b>' + label + '</b>')
        #attr = pango.AttrWeight(pango.WEIGHT_BOLD)
        #attr.start_index = 0
        #attr.end_index = -1
        #list = pango.AttrList()
        #list.insert(attr)
        #label_widget.set_attributes(list)

        vbox = g.VBox(False, 4)
        vbox.set_border_width(12)
        frame.add(vbox)

        self.do_box(node, None, vbox)

        return [frame]
Пример #6
0
    def make_advanced_box(self):
        # The advanced settings
        expander = g.Expander(_('Advanced Options'))
        expandvbox = g.VBox(FALSE, 4)
        expander.add(expandvbox)

        sound_frame = g.Frame(_('Sound'))
        #sound_frame.set_shadow_type(g.SHADOW_NONE)
        label_widget = sound_frame.get_label_widget()
        label_widget.set_markup('<b>' + _('Sound') + '</b>')

        expandvbox.pack_start(sound_frame, FALSE, TRUE, 0)

        sound_box = g.HBox(FALSE, 4)
        sound_box.set_border_width(8)
        sound_frame.add(sound_box)

        sound_choice = g.combo_box_new_text()
        self.sound_choice = sound_choice
        sound_choice.append_text(_('Use default sound'))
        sound_choice.append_text(_('Use custom sound'))
        sound_choice.append_text(_('Disabled'))
        sound_choice.set_active(0)
        sound_box.pack_start(sound_choice, FALSE, FALSE, 0)

        #sound_entry = g.Entry()
        sound_entry = g.FileChooserButton('Sound File')
        self.sound_entry = sound_entry
        sound_entry.set_sensitive(False)
        sound_box.pack_start(sound_entry, TRUE, TRUE, 0)

        sound_choice.connect('changed', self.sound_choice_changed)

        # TODO: More advanced options can be added to the 'expandbox' vbox, each
        # in its own frame.

        return expander
Пример #7
0
    def __init__(self, program, purpose, version, author, website):
        g.Dialog.__init__(self)
        self.website = website

        def close(iw, event=None, data=None):
            iw.hide()

        self.connect("delete_event", close)

        hbox = g.HBox()
        self.vbox.pack_start(hbox)
        hbox.show()

        try:
            path = os.path.join(rox.app_dir, '.DirIcon')
            pixbuf = g.gdk.pixbuf_new_from_file(path)
            icon = g.Image()
            icon.set_from_pixbuf(pixbuf)
            hbox.pack_start(icon)
            icon.show()
        except:
            #rox.report_exception()
            pass

        table = g.Table(5, 2)
        hbox.pack_start(table)

        label = g.Label("Program")
        table.attach(label, 0, 1, 0, 1)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 0, 1)

        label = g.Label(program or '')
        frame.add(label)

        label = g.Label("Purpose")
        table.attach(label, 0, 1, 1, 2)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 1, 2)

        label = g.Label(purpose or '')
        frame.add(label)

        label = g.Label("Version")
        table.attach(label, 0, 1, 2, 3)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 2, 3)

        label = g.Label(version or '')
        frame.add(label)

        label = g.Label("Authors")
        table.attach(label, 0, 1, 3, 4)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 3, 4)

        label = g.Label(author or '')
        frame.add(label)

        label = g.Label("Web site")
        table.attach(label, 0, 1, 5, 6)

        if website:
            button = g.Button(website)
            table.attach(button, 1, 2, 5, 6)

            def goto_website(widget, iw):
                webbrowser.open(iw.website)

            button.connect("clicked", goto_website, self)

        else:
            frame = g.Frame()
            frame.set_shadow_type(g.SHADOW_IN)
            table.attach(frame, 1, 2, 5, 6)

        hbox = self.action_area

        button = g.Button(stock=g.STOCK_CLOSE)
        hbox.pack_start(button)

        def dismiss(widget, iw):
            iw.hide()

        button.connect("clicked", dismiss, self)
        button.show()

        self.vbox.show_all()
Пример #8
0
    def __init__(self):
        g.Dialog.__init__(self)
        self.set_title(_('All memos'))
        self.set_has_separator(FALSE)

        self.add_button(g.STOCK_CLOSE, g.RESPONSE_CANCEL)

        frame = g.Frame()
        self.vbox.pack_start(frame, TRUE, TRUE, 0)
        frame.set_shadow_type(g.SHADOW_IN)

        hbox = g.HBox(FALSE, 0)
        frame.add(hbox)

        scroll = g.VScrollbar()
        hbox.pack_end(scroll, FALSE, TRUE, 0)

        self.list = g.TreeView(memo_list)
        hbox.pack_start(self.list, TRUE, TRUE, 0)
        self.list.set_scroll_adjustments(None, scroll.get_adjustment())
        self.list.set_size_request(-1, 12)
        self.set_default_size(-1, 300)

        text = g.CellRendererText()

        toggle = g.CellRendererToggle()
        column = g.TreeViewColumn(_('Hide'), toggle, active=memos.HIDDEN)
        self.list.append_column(column)
        toggle.connect('toggled',
                       lambda t, path: memo_list.toggle_hidden(path))

        column = g.TreeViewColumn(_('Time'), text, text=memos.TIME)
        self.list.append_column(column)

        column = g.TreeViewColumn(_('Message'), text, text=memos.BRIEF)
        self.list.append_column(column)

        self.list.set_headers_visible(TRUE)

        sel = self.list.get_selection()
        sel.set_mode(g.SELECTION_MULTIPLE)

        def activate(view, path, column):
            memo = memo_list.get_memo_by_path(path)
            from EditBox import EditBox
            EditBox(memo).show()

        self.add_events(g.gdk.BUTTON_PRESS_MASK)
        self.list.connect('row-activated', activate)

        self.connect('response', self.response)

        self.set_default_response(g.RESPONSE_CANCEL)

        actions = g.HButtonBox()
        self.vbox.pack_start(actions, FALSE, TRUE, 0)
        actions.set_layout(g.BUTTONBOX_END)
        actions.set_border_width(5)
        actions.set_spacing(4)

        def new(b):
            from EditBox import EditBox
            EditBox().show()

        button = g.Button(stock=g.STOCK_NEW)
        actions.add(button)
        button.connect('clicked', new)

        def delete(b):
            sel = self.list.get_selection()
            memos = []
            for iter in memo_list:
                if sel.iter_is_selected(iter):
                    m = memo_list.get_memo_by_iter(iter)
                    memos.append(m)
            if not memos:
                rox.alert(_('You need to select some memos first!'))
                return
            l = len(memos)
            if l == 1:
                message = _("Really delete memo '%s'?") % memos[0].brief
            else:
                message = _('Really delete %d memos?') % l

            box = g.MessageDialog(None, 0, g.MESSAGE_QUESTION,
                                  g.BUTTONS_CANCEL, message)

            if rox.confirm(message, g.STOCK_DELETE):
                for m in memos:
                    memo_list.delete(m, update=0)
                memo_list.notify_changed()

        button = g.Button(stock=g.STOCK_DELETE)
        actions.add(button)
        button.connect('clicked', delete)

        def edit(b):
            sel = self.list.get_selection()
            memos = []
            for iter in memo_list:
                if sel.iter_is_selected(iter):
                    m = memo_list.get_memo_by_iter(iter)
                    memos.append(m)
            if len(memos) != 1:
                rox.alert(_('You need to select exactly one memo first!'))
                return
            from EditBox import EditBox
            EditBox(memos[0]).show()

        button = rox.ButtonMixed(g.STOCK_PROPERTIES, _('_Edit'))
        actions.add(button)
        button.connect('clicked', edit)

        self.show_all()
Пример #9
0
	def __init__(self, tb):
		g.Frame.__init__(self, _('Stack trace (innermost last)'))

		vbox = g.VBox(False, 0)
		self.add(vbox)

		inner = g.Frame()
		inner.set_shadow_type(g.SHADOW_IN)
		vbox.pack_start(inner, False, True, 0)

		self.savebox = None

		self.tb = tb
		
		self.model = g.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT,
					 gobject.TYPE_STRING, gobject.TYPE_STRING,
					 gobject.TYPE_STRING)
		tree = g.TreeView(self.model)
		inner.add(tree)

		cell = g.CellRendererText()

		column = g.TreeViewColumn('File', cell, text = ExceptionExplorer.LEAF)
		cell.set_property('xalign', 1)
		tree.append_column(column)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Line', cell, text = ExceptionExplorer.LINE)
		tree.append_column(column)
		column = g.TreeViewColumn('Func', cell, text = ExceptionExplorer.FUNC)
		tree.append_column(column)
		column = g.TreeViewColumn('Code', cell, text = ExceptionExplorer.CODE)
		tree.append_column(column)

		inner.set_border_width(5)

		frames = []
		while tb is not None:
			frames.insert(0, (tb.tb_frame, traceback.tb_lineno(tb)))
			tb = tb.tb_next
		f = self.tb.tb_frame
		if f:
			f = f.f_back	# Skip the reporting frame
		while f is not None:
			frames.append((f, f.f_lineno))
			f = f.f_back

		frames.reverse()

		new = None
		for f, lineno in frames:
			co = f.f_code
			filename = co.co_filename
			name = co.co_name
			line = linecache.getline(filename, lineno).strip()

			leafname = os.path.basename(filename)
			
			new = self.model.append()
			self.model.set(new, ExceptionExplorer.LEAF, leafname,
					    ExceptionExplorer.LINE, lineno,
					    ExceptionExplorer.FUNC, name,
					    ExceptionExplorer.CODE, line,
					    ExceptionExplorer.FILE, filename)

		def selected_frame():
			selected = sel.get_selected()
			assert selected
			model, titer = selected
			frame, = model.get_path(titer)
			return frames[frame][0]

		vars = g.ListStore(str, str)
		sel = tree.get_selection()
		sel.set_mode(g.SELECTION_BROWSE)
		def select_frame(tree):
			vars.clear()
			for n, v in selected_frame().f_locals.iteritems():
				value = `v`
				if len(value) > 500:
					value = value[:500] + ' ...'
				new = vars.append()
				vars.set(new, 0, str(n), 1, value)
		sel.connect('changed', select_frame)
		def show_source(tree, path, column):
			line = self.model[path][ExceptionExplorer.LINE]
			file = self.model[path][ExceptionExplorer.FILE]
			import launch
			launch.launch('http://rox.sourceforge.net/2005/interfaces/Edit',
					'-l%d' % line, file)
			
		tree.connect('row-activated', show_source)

		# Area to show the local variables
		tree = g.TreeView(vars)

		vbox.pack_start(g.Label(_('Local variables in selected frame:')),
				False, True, 0)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Name', cell, text = 0)
		cell.set_property('xalign', 1)
		tree.append_column(column)
		cell = g.CellRendererText()
		column = g.TreeViewColumn('Value', cell, text = 1)
		tree.append_column(column)

		inner = g.ScrolledWindow()
		inner.set_size_request(-1, 200)
		inner.set_policy(g.POLICY_AUTOMATIC, g.POLICY_ALWAYS)
		inner.set_shadow_type(g.SHADOW_IN)
		inner.add(tree)
		inner.set_border_width(5)
		vbox.pack_start(inner, True, True, 0)

		if new:
			sel.select_iter(new)

		hbox = g.HBox(False, 4)
		hbox.set_border_width(5)
		vbox.pack_start(hbox, False, True, 0)
		hbox.pack_start(g.Label('>>>'), False, True, 0)

		expr = g.Entry()
		hbox.pack_start(expr, True, True, 0)
		def activate(entry):
			expr = entry.get_text()
			frame = selected_frame()
			try:
				info(`eval(expr, frame.f_locals, frame.f_globals)`)
			except:
				extype, value = sys.exc_info()[:2]
				brief = ''.join(traceback.format_exception_only(extype, value))
				alert(brief)
			entry.grab_focus()
		expr.connect('activate', activate)

		vbox.show_all()