Пример #1
0
    def __init__(self, parent_window=None, message=None, window_title=None):
        Dialog.__init__(
            self,
            unicode(StringType(window_title)).encode('utf-8'), parent_window,
            0,
            (gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_YES, gtk.RESPONSE_YES))

        hbox = gtk.HBox(False, 8)

        hbox.set_border_width(8)

        self.vbox.pack_start(hbox, False, False, 0)

        stock = gtk.image_new_from_stock(gtk.STOCK_DIALOG_QUESTION,
                                         gtk.ICON_SIZE_DIALOG)

        hbox.pack_start(stock, False, False, 0)

        label = gtk.Label(unicode(StringType(message)).encode('utf-8'))

        hbox.pack_start(label, True, True, 0)

        self.show_all()

        self.response = self.run()

        self.destroy()
Пример #2
0
 def __init__(self, parent_window=None, date=None):
     Dialog.__init__(
         self,
         unicode("Calendario", "latin-1").encode("utf-8"),
         parent_window,
         0,
     )
     self.set_position(gtk.WIN_POS_MOUSE)
     hbox = gtk.HBox(False, 8)
     hbox.set_border_width(8)
     self.vbox.pack_start(hbox, 1, False, 0)
     self.date = date
     calendar = gtk.Calendar()
     calendar.connect('day_selected_double_click',
                      self.on_calendar_double_click)
     if date <> None and date <> "":
         calendar.select_day(int(date[0:2]))
         calendar.select_month(int(date[3:5]) - 1, int(date[6:10]))
     hbox.pack_start(calendar, True, True, 0)
     self.set_default_response(gtk.RESPONSE_CANCEL)
     self.show_all()
     calendar.grab_focus()
     response = self.run()
     if response == gtk.RESPONSE_OK:
         self.destroy()
         self.date = calendar.get_date()
         self.date = str(zfill(self.date[2], 2)) + "/" + str(
             zfill(self.date[1] + 1, 2)) + "/" + str(zfill(self.date[0], 4))
     else:
         self.destroy()
Пример #3
0
 def __init__(self, parent_window = None, date = None, entry=None):
     Dialog.__init__(self, "Calendario", parent_window, 0,)
     self.set_position(gtk.WIN_POS_MOUSE)
     hbox = gtk.HBox(False, 8)
     hbox.set_border_width(8)
     self.vbox.pack_start(hbox, 1, False, 0)
     self.date = date
     calendar = gtk.Calendar()
     calendar.connect('day_selected_double_click', self.on_calendar_double_click)
     if date <> None and date <> "":
         calendar.select_day(int(date[0:2]))
         calendar.select_month(int(date[3:5])-1,int(date[6:10]))
     hbox.pack_start(calendar, True, True, 0)
     self.set_default_response(gtk.RESPONSE_CANCEL)
     if entry is not None:
         self.set_decorated(False)
         rect = entry.get_allocation()
         wx, wy = entry.get_size_request()
         win = entry.get_parent_window()
         tx, ty = win.get_position()
         self.move(rect.x + tx, rect.y + ty + wy)
         parent = entry
         while not isinstance(parent, gtk.Window):
             parent = parent.get_parent()
         self.set_transient_for(parent)
     self.show_all()
     calendar.grab_focus()
     response = self.run()
     if response == gtk.RESPONSE_OK:
         self.destroy()
         self.date = calendar.get_date()
         self.date = str(zfill(self.date[2],2)) +"/"+ str(zfill(self.date[1] +1,2))+"/"+ str(zfill(self.date[0],4))
     else:
         self.destroy()
Пример #4
0
    def __init__(self, parent, icon):
        from os.path import exists, abspath, join
        from gtk.gdk import pixbuf_new_from_file
        Dialog.__init__(self, None, parent)
        AboutDialog.__init__(self)

        self.set_icon(pixbuf_new_from_file(icon))
        self.set_name("gtkpacman")
        self.set_version("2.4dev")
        self.set_copyright(_("Copyright (C)2005-2008 by Stefano Esposito.\nRights to copy, modify, and redistribute are granted under the GNU General Public License Terms"))
        self.set_comments(_("Gtk package manager based on pacman"))
        self.set_license(_("""gtkPacman is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

gtkPacman program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA"""))
        self.set_website("http://gtkpacman.berlios.de")
        self.set_authors(["Stefano Esposito <*****@*****.**>", "'Seti' <*****@*****.**>"])
        self.set_artists(["James D <*****@*****.**>"])

        path = "/usr/share/gtkpacman/"
        if not exists(path):
            path = abspath("data/")
            
        fname = join(path, "icons/pacman.png")
        logo = pixbuf_new_from_file(fname)
        self.set_logo(logo)
Пример #5
0
    def __init__(self, parent, icon):
        Dialog.__init__(
            self,
            _("Confirm makepkg as root"),
            parent,
            DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
            (STOCK_OK, RESPONSE_ACCEPT, STOCK_CANCEL, RESPONSE_REJECT),
        )

        self.add_button(_("Run as root"), 1000)

        lab = Label(
            _(
                "Running makepkg as root is a bad idea.\nSelect an alternate user or confirm that you want to run it as root"
            )
        )

        uname_frame = Frame(_("Username:"******"Password"))

        self.uname_entry = Entry()

        uname_frame.add(self.uname_entry)

        self.vbox.pack_start(lab)
        self.vbox.pack_start(uname_frame)
        self.vbox.show_all()
Пример #6
0
    def __init__(self, cnx=None, window=None):

        self.ventana = window
        self.cnx = cnx
        self.cod_empresa = None

        if cnx == None:
            dlgError(self.ventana, 'No hay una conexión activa.')
            return

        lbl = unicode("Selección de Empresa")
        Dialog.__init__(self, lbl.encode("utf-8"), window, 0,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                         gtk.RESPONSE_OK))
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, 1, False, 0)
        stock = gtk.Image()
        stock.set_from_stock(gtk.STOCK_HOME, gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(stock, False, False, 0)
        label = gtk.Label("Empresa")
        label.set_use_underline(True)
        hbox.pack_start(label, 0, 0, 0)

        try:
            r = cnx.cursor()
            r.execute(
                "select text(cod_empresa), descripcion_empresa from cc.empresa order by descripcion_empresa"
            )
            l = r.fetchall()

        except:
            dlgError(self.ventana, StringType(sys.exc_info()[1]))
            return 0

        self.modelo = gtk.ListStore(str, str)

        for i in l:
            self.modelo.append([i[0], unicode(i[1]).encode('utf-8')])

        self.combo = gtk.ComboBox(self.modelo)
        cell = gtk.CellRendererText()
        self.combo.pack_start(cell, True)
        self.combo.add_attribute(cell, 'text', 0)

        cell = gtk.CellRendererText()
        self.combo.pack_start(cell, True)
        self.combo.add_attribute(cell, 'text', 1)

        self.combo.set_active(0)
        self.cod_empresa = l[0][0]

        self.combo.set_size_request(300, 25)

        hbox.pack_start(self.combo, True, True, 0)
        label.set_mnemonic_widget(self.combo)
        self.set_default_response(gtk.RESPONSE_OK)
        self.show_all()
Пример #7
0
    def __init__(self, parent, pacs, icon):

        Dialog.__init__(self, _("Warning!"), parent,
                        DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                        (STOCK_YES, RESPONSE_YES, STOCK_NO, RESPONSE_REJECT))

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(pacs)
        self._setup_layout()
Пример #8
0
    def __init__(self, parent, icon):

        Dialog.__init__(self, _("Search for.."), parent,
                        DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                        (STOCK_OK, RESPONSE_ACCEPT,
                         STOCK_CANCEL, RESPONSE_REJECT))

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_layout()
Пример #9
0
    def __init__(self, parent, icon):

        Dialog.__init__(self, None, parent, DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT)
        self.set_icon(pixbuf_new_from_file(icon))
        
        self.close_button = self.add_button(STOCK_CLOSE, RESPONSE_CLOSE)
        self.close_button.connect("clicked", lambda _: self.destroy())
        
        self.terminal = terminal()
        self.terminal.connect("child-exited", lambda _: self.close_button.show())  
Пример #10
0
    def __init__(self, parent, to_upgrade, icon):

        Dialog.__init__(self, _("Confirm Upgrade"), parent,
                        DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                        (STOCK_OK, RESPONSE_ACCEPT,
                         STOCK_CANCEL, RESPONSE_REJECT))

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(to_upgrade)
        self._setup_layout()
Пример #11
0
 def __init__(self, name='GenDialog'):
     gtkDialog.__init__(self)
     self.set_name(name)
     self.ok_button = Button('ok', 'gtk-ok')
     self.ok_button.set_name(name)
     self.cancel_button = Button('cancel', 'gtk-cancel')
     self.cancel_button.set_name(name)
     self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0)
     self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0)
     self.ok_button.show()
     self.cancel_button.show()
     self.cancel_button.connect('clicked', lambda *x: self.destroy())
     self._buttons_ = {}
     self.show()
Пример #12
0
 def __init__(self, name='GenDialog'):
     gtkDialog.__init__(self)
     self.set_name(name)
     self.ok_button = Button('ok', 'gtk-ok')
     self.ok_button.set_name(name)
     self.cancel_button = Button('cancel', 'gtk-cancel')
     self.cancel_button.set_name(name)
     self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0)
     self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0)
     self.ok_button.show()
     self.cancel_button.show()
     self.cancel_button.connect('clicked', lambda *x : self.destroy())
     self._buttons_ = {}
     self.show()
Пример #13
0
    def __init__(self, window=None, db=None, rc=None, padre=None):

        lbl = unicode("Registro de Personal")
        Dialog.__init__(self, lbl.encode("utf-8"), window, 0,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                         gtk.RESPONSE_OK))

        if padre != None:
            self.padre = padre
        else:
            self.padre = None

        self.secciones = []
        self.coneccion = None
        self.ventana = window

        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, False, False, 0)
        stock = gtk.Image()
        stock.set_from_stock(gtk.STOCK_DIALOG_AUTHENTICATION,
                             gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(stock, False, False, 0)
        table = gtk.Table(3, 2)
        table.set_row_spacings(4)
        table.set_col_spacings(4)
        hbox.pack_start(table, True, True, 0)

        self.txtUsuario = gtk.Entry()

        label = gtk.Label("Usuario")
        label.set_use_underline(True)
        table.attach(label, 0, 1, 1, 2)

        table.attach(self.txtUsuario, 1, 2, 1, 2)
        label.set_mnemonic_widget(self.txtUsuario)
        lbl = unicode("Contraseña")
        label = gtk.Label(lbl.encode("utf-8"))
        label.set_use_underline(True)
        table.attach(label, 0, 1, 2, 3)
        self.txtPassword = gtk.Entry()
        self.txtPassword.set_visibility(0)
        self.txtPassword.set_invisible_char(unicode("*", "utf8"))
        self.txtPassword.set_text("")
        self.txtPassword.set_activates_default(1)
        table.attach(self.txtPassword, 1, 2, 2, 3)
        label.set_mnemonic_widget(self.txtPassword)
        self.set_default_response(gtk.RESPONSE_OK)
Пример #14
0
 def run(self):
     response = Dialog.run(self)
     self.destroy()
     if response == RESPONSE_ACCEPT:
         return True
     else:
         return False
Пример #15
0
 def __init__(self, parent_window = None, message = None, window_title = None):
     Dialog.__init__(self,
             window_title,
             parent_window,
             0,
             (gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_YES, gtk.RESPONSE_YES))
     hbox = gtk.HBox(False, 8)
     hbox.set_border_width(8)
     self.vbox.pack_start(hbox, False, False, 0)
     stock = gtk.image_new_from_stock(
                                     gtk.STOCK_DIALOG_QUESTION,
                                     gtk.ICON_SIZE_DIALOG)
     hbox.pack_start(stock, False, False, 0)
     label = gtk.Label(message)
     hbox.pack_start(label, True, True, 0)
     self.show_all()
     self.response = self.run()
     self.destroy()
Пример #16
0
 def run(self):
     res = Dialog.run(self)
     if res == 1000:
         return "root"
     elif res == RESPONSE_ACCEPT:
         uname = self.uname_entry.get_text()
         return uname
     else:
         self.destroy()
         return "reject"
Пример #17
0
    def __init__(self, parent_window = None, message = "", quit = None, trace = True):
        Dialog.__init__(self,
                unicode(StringType("Error")).encode('utf-8'),
                parent_window,
                0,
                (gtk.STOCK_OK, gtk.RESPONSE_OK))

        self.set_default_size(400, 150)
        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, False, False, 0)
        stock = gtk.image_new_from_stock(
                                        gtk.STOCK_DIALOG_ERROR,
                                        gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(stock, False, False, 0)
        try:
            label = gtk.Label(unicode(StringType(message)).encode('utf-8'))
        except:
            label = gtk.Label("Ha ocurrido un error.")
        hbox.pack_start(label, True, True, 0)
        if trace:
            sw = gtk.ScrolledWindow()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            textview = gtk.TextView()
            textbuffer = textview.get_buffer()
            sw.add(textview)
            sw.show()
            textview.set_editable(False)
            textview.set_cursor_visible(False)
            textview.show()
            t = StringType(sys.exc_info()[0]) + "\n"
            t += StringType(sys.exc_info()[1]) + "\n"
            t += "Traza:\n"
            for i in traceback.format_tb(sys.exc_info()[2]):
                t += i + "\n"
            textbuffer.set_text(t)
            expander = gtk.Expander("Detalles")
            expander.add(sw)
            expander.set_expanded(True)
            self.vbox.pack_start(expander, True, True)
        self.show_all()
        self.response = self.run()
        self.destroy()
Пример #18
0
 def __init__(self, parent_window=None, date=None, entry=None):
     Dialog.__init__(
         self,
         "Calendario",
         parent_window,
         0,
     )
     self.set_position(gtk.WIN_POS_MOUSE)
     hbox = gtk.HBox(False, 8)
     hbox.set_border_width(8)
     self.vbox.pack_start(hbox, 1, False, 0)
     self.date = date
     calendar = gtk.Calendar()
     calendar.connect('day_selected_double_click',
                      self.on_calendar_double_click)
     if date <> None and date <> "":
         calendar.select_day(int(date[0:2]))
         calendar.select_month(int(date[3:5]) - 1, int(date[6:10]))
     hbox.pack_start(calendar, True, True, 0)
     self.set_default_response(gtk.RESPONSE_CANCEL)
     if entry is not None:
         self.set_decorated(False)
         rect = entry.get_allocation()
         wx, wy = entry.get_size_request()
         win = entry.get_parent_window()
         tx, ty = win.get_position()
         self.move(rect.x + tx, rect.y + ty + wy)
         parent = entry
         while not isinstance(parent, gtk.Window):
             parent = parent.get_parent()
         self.set_transient_for(parent)
     self.show_all()
     calendar.grab_focus()
     response = self.run()
     if response == gtk.RESPONSE_OK:
         self.destroy()
         self.date = calendar.get_date()
         self.date = str(zfill(self.date[2], 2)) + "/" + str(
             zfill(self.date[1] + 1, 2)) + "/" + str(zfill(self.date[0], 4))
     else:
         self.destroy()
Пример #19
0
    def __init__(self, parent_window=None, message="", quit=None, trace=True):
        Dialog.__init__(self,
                        unicode(StringType("Error")).encode('utf-8'),
                        parent_window, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK))

        self.set_default_size(400, 150)
        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, False, False, 0)
        stock = gtk.image_new_from_stock(gtk.STOCK_DIALOG_ERROR,
                                         gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(stock, False, False, 0)
        try:
            label = gtk.Label(unicode(StringType(message)).encode('utf-8'))
        except:
            label = gtk.Label("Ha ocurrido un error.")
        label.set_use_markup(True)
        hbox.pack_start(label, True, True, 0)
        if trace:
            sw = gtk.ScrolledWindow()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            textview = gtk.TextView()
            textbuffer = textview.get_buffer()
            sw.add(textview)
            sw.show()
            textview.set_editable(False)
            textview.set_cursor_visible(False)
            textview.show()
            t = StringType(sys.exc_info()[0]) + "\n"
            t += StringType(sys.exc_info()[1]) + "\n"
            t += "Traza:\n"
            for i in traceback.format_tb(sys.exc_info()[2]):
                t += i + "\n"
            textbuffer.set_text(t)
            expander = gtk.Expander("Detalles")
            expander.add(sw)
            expander.set_expanded(True)
            self.vbox.pack_start(expander, True, True)
        self.show_all()
        self.response = self.run()
        self.destroy()
Пример #20
0
def input_entry_dialog(msg, default_answer="", parent=None):
    dia = Dialog(
        msg, parent, gtk.DIALOG_MODAL |gtk.DIALOG_DESTROY_WITH_PARENT,
        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                 gtk.STOCK_OK, RESPONSE_OK) )
    dia.vbox.pack_start(Label(msg))
    da_entry = Entry()
    da_entry.set_text(default_answer)
    dia.vbox.pack_end( da_entry )
    dia.show_all()
    result = dia.run()
    datext = da_entry.get_text()
    dia.destroy()
    return datext if result == RESPONSE_OK else None
Пример #21
0
    def __init__(self, modelo, selcol, texto, titulos=[]):

        self.modelo = modelo

        self.selcol = selcol

        self.search_text = texto

        Dialog.__init__(self,
                CUTF8("Búsqueda"),
                None,
                0,
                (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK,))

        self.set_default_size(700,400)

        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, 1, 1, 0)
        #self.connect('delete-event', self.hide_dialog)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, False, False, 1)
        stock = gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_DIALOG)
        vbox1.pack_start(stock, False, False, 0)

        vbox1.pack_start(
                gtk.Label(
                        CUTF8("\n\nDígite el texto a buscar \nen la entrada de filtro\n"+
                        "y presione la tecla INTRO. \n\nLuego haga doble-click \n"+
                        "sobre el ítem deseado \no seleccionelo y\n"+
                        "presione el botón ACEPTAR")), False, False, False)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, True, True, 1)

        lbl = gtk.Label('Filtro:')
        vbox1.pack_start(lbl, False, 0)

        self.txtFiltro = gtk.Entry()
        self.txtFiltro.add_events(gtk.gdk.KEY_PRESS_MASK)
        self.txtFiltro.connect('key-press-event', self.on_entry_key_press_cb)
        self.txtFiltro.connect('changed', self.on_entry_changed_cb)

        vbox1.pack_start(self.txtFiltro, 0, 0)
        s = gtk.ScrolledWindow()

        self.list = gtk.TreeView()
        self.list.set_headers_visible(False)
        n = 0
        if len(self.modelo) > 0:
            for i in self.modelo[0]:
                if titulos == []:
                    titulo = ""
                else:
                    titulo = titulos[n]
                    
                column = gtk.TreeViewColumn(titulo, gtk.CellRendererText(), text=n)
                column.connect('clicked', self.column_click,self.modelo, self.list, n,n)
                n = n + 1
    
                self.list.append_column(column)

            if self.search_text:
                self.txtFiltro.set_text(texto)
            self.list.connect("row-activated", self.on_tree_row_activated)
            selection = self.list.get_selection()
            selection.set_mode('single')
            self.list.set_model(self.modelo)
            self.list.set_headers_visible(True)
            self.list.set_headers_clickable(True)

        vbox1.pack_start(s, 1, 1)
        s.add(self.list)
        self.filter()
        self.show_all()
Пример #22
0
    def __init__(self, window = None, cnx = None, sql = None, col_filtro = None, col_retorno = None, titulos = None, texto = None, splash = None):

        if not cnx:
            raise ValueError, "No hay conección"
            return 0
        else:
            self.db_connection = cnx

        if not sql:
            raise ValueError, "No ha consulta"
            return 0
        else:
            self.query_db = sql

        if col_filtro is None:
            raise ValueError, "No hay columna a filtrar"
            return 0
        else:
            self.column_filter = col_filtro

        if col_retorno is None:
            raise ValueError, "No hay columna a retornar"
            return 0
        else:
            self.return_column = col_retorno

        if not titulos:
            raise ValueError, "No hay títulos para las columnas"
        else:
            self.column_titles = titulos


        self.len_retorno = len(titulos)
        self.splash = splash
        self.search_text = texto
        self.store = None
        self.padre = window
        Dialog.__init__(self,
                'Búsqueda',
                window,
                0,
                (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK,))

        self.set_default_size(700,400)

        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, 1, 1, 0)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, False, False, 1)
        stock = gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_DIALOG)
        vbox1.pack_start(stock, False, False, 0)

        vbox1.pack_start(
                gtk.Label(
                        """\n\nDígite el texto a buscar \nen la entrada de filtro\ny presione la tecla INTRO. \n\nLuego haga doble-click\nsobre el ítem deseado \no seleccionelo y\npresione el botón ACEPTAR"""), False, False, False)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, True, True, 1)

        lbl = gtk.Label('Filtro:')
        vbox1.pack_start(lbl, False, 0)

        self.txtFiltro = gtk.Entry()
        self.txtFiltro.add_events(gtk.gdk.KEY_PRESS_MASK)
        self.txtFiltro.connect('key-press-event', self.on_entry_key_press_cb)
        self.txtFiltro.connect('changed', self.on_entry_changed_cb)

        vbox1.pack_start(self.txtFiltro, 0, 0)
        s = gtk.ScrolledWindow()

        self.list = gtk.TreeView()

        n = 0

        for i in titulos:
            column = gtk.TreeViewColumn(i, gtk.CellRendererText(), text=n)
            n = n + 1
            self.list.append_column(column)

        if self.search_text:
            self.txtFiltro.set_text(texto)

        self.list.connect("row-activated", self.on_tree_row_activated)
        selection = self.list.get_selection()
        selection.set_mode('single')

        vbox1.pack_start(s, 1, 1)

        s.add(self.list)
        
        if self.query():
            self.filter()
            self.show_all()
Пример #23
0
    def __init__(self, parent_window=None, date=None):
        Dialog.__init__(
            self,
            unicode("Calendario", "latin-1").encode("utf-8"),
            parent_window,
            0,
        )
        #        self.window = gtk.Dialog()
        self.date = None
        self.set_size_request(300, 300)
        self.set_modal(True)
        #window.set_transient_for(self.get_toplevel())
        self.set_position(gtk.WIN_POS_MOUSE)
        self.set_title('Seleccione la Fecha y Hora')
        self.connect("destroy", self.on_destroy)
        vbox = gtk.VBox()

        self.calendar = gtk.Calendar()
        self.spinButtonOra = gtk.SpinButton(digits=0)
        self.spinButtonOra.set_numeric(True)
        self.spinButtonOra.set_wrap(True)
        self.spinButtonOra.set_range(0, 23)
        self.spinButtonOra.set_increments(1, 1)
        self.spinButtonMinuti = gtk.SpinButton(digits=0)
        self.spinButtonMinuti.set_numeric(True)
        self.spinButtonMinuti.set_wrap(True)
        self.spinButtonMinuti.set_range(0, 59)
        self.spinButtonMinuti.set_increments(1, 1)

        currentDateTime = None  #self.entry.get_text()
        if not (currentDateTime is None or currentDateTime == ''):
            try:
                d = time.strptime(currentDateTime, "%d/%m/%Y %H:%M")
                self.calendar.select_month((d[1] - 1), d[0])
                self.calendar.select_day(d[2])
                self.spinButtonOra.set_value(d[3])
                self.spinButtonMinuti.set_value(d[4])
            except Exception:
                pass

        self.calendar.connect('day-selected-double-click', self.confirmAction)
        alignment = gtk.Alignment(1, 1, 1, 1)
        alignment.set_padding(6, 2, 2, 2)
        alignment.add(self.calendar)
        self.calendar.show()
        frame = gtk.Frame('Fecha: ')
        frame.set_label_align(0, 1)
        frame.set_border_width(6)
        frame.add(alignment)
        alignment.show()

        vbox.pack_start(frame, True, True, 3)
        frame.show()
        separator = gtk.HSeparator()
        vbox.pack_start(separator, False, False, 0)

        hbox = gtk.HBox()
        label = gtk.Label(':')
        hbox.pack_start(self.spinButtonOra, False, False, 0)
        hbox.pack_start(label, False, False, 5)
        hbox.pack_start(self.spinButtonMinuti, False, False, 0)
        alignment = gtk.Alignment(1, 1, 1, 1)
        alignment.set_padding(3, 2, 2, 2)
        alignment.add(hbox)
        frame = gtk.Frame('Hora: ')
        frame.set_label_align(0, 1)
        frame.set_border_width(6)
        frame.add(alignment)
        vbox.pack_start(frame, False, False, 5)

        bbox = gtk.HButtonBox()
        buttonCorrente = gtk.Button(label='_Hoy',
                                    stock=None,
                                    use_underline=True)
        buttonCorrente.connect('clicked', self.currentAction)
        buttonOk = gtk.Button(label='_Ok', stock=None, use_underline=True)
        buttonOk.connect('clicked', self.confirmAction)
        buttonAnnulla = gtk.Button(label='_Cancelar',
                                   stock=None,
                                   use_underline=True)
        buttonAnnulla.connect('clicked', self.cancelAction)
        bbox.add(buttonCorrente)
        bbox.add(buttonOk)
        bbox.add(buttonAnnulla)
        bbox.set_layout(gtk.BUTTONBOX_SPREAD)
        vbox.pack_start(bbox, False, False, 5)

        self.vbox.add(vbox)
        vbox.show()
        self.show_all()
Пример #24
0
    def __init__(self,
                 window=None,
                 cnx=None,
                 sql=None,
                 col_filtro=None,
                 col_retorno=None,
                 titulos=None,
                 texto=None,
                 splash=None):

        if not cnx:
            raise ValueError, "No hay conección"
            return 0
        else:
            self.db_connection = cnx

        if not sql:
            raise ValueError, "No ha consulta"
            return 0
        else:
            self.query_db = sql

        if col_filtro is None:
            raise ValueError, "No hay columna a filtrar"
            return 0
        else:
            self.column_filter = col_filtro

        if col_retorno is None:
            raise ValueError, "No hay columna a retornar"
            return 0
        else:
            self.return_column = col_retorno

        if not titulos:
            raise ValueError, "No hay títulos para las columnas"
        else:
            self.column_titles = titulos

        self.len_retorno = len(titulos)
        self.splash = splash
        self.search_text = texto
        self.store = None
        self.padre = window
        Dialog.__init__(self, 'Búsqueda', window, 0, (
            gtk.STOCK_CANCEL,
            gtk.RESPONSE_CANCEL,
            gtk.STOCK_OK,
            gtk.RESPONSE_OK,
        ))

        self.set_default_size(700, 400)

        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, 1, 1, 0)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, False, False, 1)
        stock = gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_DIALOG)
        vbox1.pack_start(stock, False, False, 0)

        vbox1.pack_start(
            gtk.Label(
                """\n\nDígite el texto a buscar \nen la entrada de filtro\ny presione la tecla INTRO. \n\nLuego haga doble-click\nsobre el ítem deseado \no seleccionelo y\npresione el botón ACEPTAR"""
            ), False, False, False)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, True, True, 1)

        lbl = gtk.Label('Filtro:')
        vbox1.pack_start(lbl, False, 0)

        self.txtFiltro = gtk.Entry()
        self.txtFiltro.add_events(gtk.gdk.KEY_PRESS_MASK)
        self.txtFiltro.connect('key-press-event', self.on_entry_key_press_cb)
        self.txtFiltro.connect('changed', self.on_entry_changed_cb)

        vbox1.pack_start(self.txtFiltro, 0, 0)
        s = gtk.ScrolledWindow()

        self.list = gtk.TreeView()

        n = 0

        for i in titulos:
            column = gtk.TreeViewColumn(i, gtk.CellRendererText(), text=n)
            n = n + 1
            self.list.append_column(column)

        if self.search_text:
            self.txtFiltro.set_text(texto)

        self.list.connect("row-activated", self.on_tree_row_activated)
        selection = self.list.get_selection()
        selection.set_mode('single')

        vbox1.pack_start(s, 1, 1)

        s.add(self.list)

        if self.query():
            self.filter()
            self.show_all()
Пример #25
0
 def __on_plugin_directories_button_click(self, button):
     """Present a dialog to the user for selecting extra plugin directories
     and process the request."""
     
     dia = Dialog('Plugin Directories',
          None, DIALOG_MODAL,
          (STOCK_OK, RESPONSE_OK,
          STOCK_CANCEL, RESPONSE_CANCEL ) )
     dia.resize(500, 300)
     dia.vbox.set_spacing(8)
     
     # Setup the tree view of plugin directories.
     model = ListStore(str) # each row contains a single string
     tv = TreeView(model)
     cell = CellRendererText()
     column = TreeViewColumn('Directory', cell, text = 0)
     tv.append_column(column)
     dia.vbox.pack_start(tv)
     
     # Populate the tree view.
     plugin_directories = \
         get_plugins_directories_from_config(self.config, self.config_path)
     for plugin_directory in plugin_directories:
         row = (plugin_directory,)
         model.append(row)
     
     modify_box = HBox(spacing = 8)
     
     # Setup the remove directory button.
     remove_button = Button('Remove')
     remove_button.set_sensitive(False) # no directory selected initially
     remove_button.connect('clicked', self.__on_remove, tv)
     modify_box.pack_end(remove_button, expand = False)
     
     tv.connect('cursor-changed', self.__on_select, remove_button)
     
     # Setup the add directory button.
     add_button = Button('Add')
     add_button.connect('clicked', self.__on_add, tv)
     modify_box.pack_end(add_button, expand = False)
     
     dia.vbox.pack_start(modify_box, expand = False)
     
     # Setup the "already included directories" label.
     included_label = Label('Plugins in the PYTHONPATH are already ' +
                            'available to BoKeep.')
     # Use a horizontal box to left-justify the label.  For some reason,
     # the label's set_justification property doesn't work for me.
     label_box = HBox()
     label_box.pack_start(included_label, expand = False)
     dia.vbox.pack_start(label_box, expand = False)
     
     dia.show_all()
     dia_result = dia.run()
     
     if dia_result == RESPONSE_OK:            
         # Remove the old plugin directories from the program's path.
         plugin_directories = \
             get_plugins_directories_from_config(self.config,
                                                 self.config_path)
         for plugin_directory in plugin_directories:
             path.remove(plugin_directory)
         
         # Get the new plugin directories from the dialog.
         plugin_directories = []
         for row in model:
             plugin_directory = row[0]
             plugin_directories.append(plugin_directory)
         
         # Update the BoKeep PYTHONPATH so that new plugins can be loaded and
         # populate the list of possible new plugins.
         for plugin_directory in plugin_directories:
             path.append(plugin_directory)
         self.__populate_possible_plugins()
         
         # Save the new plugin directories in the configuration file.
         set_plugin_directories_in_config(self.config,
             self.config_path, plugin_directories)
     
     dia.destroy()
Пример #26
0
    def __init__(self, modelo, selcol, texto, titulos=[]):

        self.modelo = modelo

        self.selcol = selcol

        self.search_text = texto

        Dialog.__init__(self, CUTF8("Búsqueda"), None, 0, (
            gtk.STOCK_CANCEL,
            gtk.RESPONSE_CANCEL,
            gtk.STOCK_OK,
            gtk.RESPONSE_OK,
        ))

        self.set_default_size(700, 400)

        hbox = gtk.HBox(False, 8)
        hbox.set_border_width(8)
        self.vbox.pack_start(hbox, 1, 1, 0)
        #self.connect('delete-event', self.hide_dialog)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, False, False, 1)
        stock = gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_DIALOG)
        vbox1.pack_start(stock, False, False, 0)

        vbox1.pack_start(
            gtk.Label(
                CUTF8(
                    "\n\nDígite el texto a buscar \nen la entrada de filtro\n"
                    +
                    "y presione la tecla INTRO. \n\nLuego haga doble-click \n"
                    + "sobre el ítem deseado \no seleccionelo y\n" +
                    "presione el botón ACEPTAR")), False, False, False)

        vbox1 = gtk.VBox(False)
        vbox1.set_border_width(8)
        hbox.pack_start(vbox1, True, True, 1)

        lbl = gtk.Label('Filtro:')
        vbox1.pack_start(lbl, False, 0)

        self.txtFiltro = gtk.Entry()
        self.txtFiltro.add_events(gtk.gdk.KEY_PRESS_MASK)
        self.txtFiltro.connect('key-press-event', self.on_entry_key_press_cb)
        self.txtFiltro.connect('changed', self.on_entry_changed_cb)

        vbox1.pack_start(self.txtFiltro, 0, 0)
        s = gtk.ScrolledWindow()

        self.list = gtk.TreeView()
        self.list.set_headers_visible(False)
        n = 0
        if len(self.modelo) > 0:
            for i in self.modelo[0]:
                if titulos == []:
                    titulo = ""
                else:
                    titulo = titulos[n]

                column = gtk.TreeViewColumn(titulo,
                                            gtk.CellRendererText(),
                                            text=n)
                column.connect('clicked', self.column_click, self.modelo,
                               self.list, n, n)
                n = n + 1

                self.list.append_column(column)

            if self.search_text:
                self.txtFiltro.set_text(texto)
            self.list.connect("row-activated", self.on_tree_row_activated)
            selection = self.list.get_selection()
            selection.set_mode('single')
            self.list.set_model(self.modelo)
            self.list.set_headers_visible(True)
            self.list.set_headers_clickable(True)

        vbox1.pack_start(s, 1, 1)
        s.add(self.list)
        self.filter()
        self.show_all()