def __init__(self): Gtk.Window.__init__(self, title="Listagem Pessoas") self.set_border_width(10) layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(layout) self.dao = PersonDAO(make_connection()) pls = Gtk.ListStore(int, str, str, str, str) for p in self.dao.todas_pessoas(): pls.append([p.id, p.firstname, p.middlename, p.lastname, p.suffix]) ptv = Gtk.TreeView(pls) for i, col_tittle in enumerate([ 'ID', 'Primeiro Nome', 'Nome do Meio', 'Ultimo Nome', 'Suffixo']): render = Gtk.CellRendererText() col = Gtk.TreeViewColumn(col_tittle, render, text=i) ptv.append_column(col) col.set_sort_column_id(i) sclwin = Gtk.ScrolledWindow() sclwin.add(ptv) sclwin.set_min_content_height(200) sclwin.set_min_content_width(450) layout.add(sclwin) print(self.dao.todas_pessoas())
def __init__(self): Gtk.Window.__init__(self, title='Cadastro de Projetos') self.dao = ProjectDAO(make_connection()) self.set_border_width(2) self.set_default_size(400, 200) self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.layout.set_spacing(10) box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) lbl_nome = Gtk.Label("Nome do Projeto") box.pack_start(lbl_nome, True, True, 0) self.ent_nome = Gtk.Entry() box.pack_start(self.ent_nome, True, True, 0) self.btn_save = Gtk.Button("Salvar") self.btn_save.connect("clicked", self.save) box.pack_start(self.btn_save, True, False, 0) self.layout.pack_start(box, False, False, 0) self.add(self.layout) self._dao = ProjectDAO(make_connection())
def __init__(self, project): Gtk.Window.__init__( self, title=f"Listagem Citações do Projeto {project.nome}") self.set_border_width(10) layout = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) layout.set_spacing(6) self.project = project self.add(layout) self.dao = ProjectDAO(make_connection()) pls = Gtk.ListStore(int, str, str, str, int, int) for row in self.dao.project_quotes(project.id): pls.append(row) self.ptv = Gtk.TreeView(pls) for i, col_tittle in enumerate([ 'id_source', 'Título', 'Subtítulo', 'Tipo', 'Página Fim', 'Página Fim' ]): render = Gtk.CellRendererText() col = Gtk.TreeViewColumn(col_tittle, render, text=i) if i == 0: col.set_visible(False) self.ptv.append_column(col) col.set_sort_column_id(i) res = Gtk.ScrolledWindow() res.set_min_content_height(300) res.set_min_content_width(400) self.ptv.get_selection().connect("changed", self.det_quote) res.add(self.ptv) layout.add(res) # panel = Gtk.ScrolledWindow() # panel.set_border_width(6) # panel.set_min_content_width(150) panel = Gtk.Grid() panel.set_row_spacing(3) panel.set_column_spacing(3) salvar = Gtk.Button("Salvar") salvar.connect("clicked", self.salvar) panel.attach(salvar, 0, 0, 2, 1) self.pg_start = Gtk.Entry() self.pg_start.set_size_request(50, 20) self.pg_start.set_editable(False) self.pg_start.set_width_chars(3) panel.attach(self.pg_start, 0, 1, 1, 1) self.pg_end = Gtk.Entry() self.pg_end.set_size_request(50, 20) self.pg_end.set_editable(False) self.pg_end.set_width_chars(3) panel.attach(self.pg_end, 1, 1, 1, 1) layout.add(panel)
def __init__(self, id_proj=0): Gtk.Window.__init__(self, title='Cadastro de Projetos') self.set_border_width(10) self.set_default_size(400, 200) self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.layout.set_spacing(10) proj_list_store = Gtk.ListStore(int, str) self.pdao = ProjectDAO(make_connection()) for projeto in self.pdao.todos_projetos(): proj_list_store.append([projeto.id, projeto.nome]) self.projeto_combo = Gtk.ComboBox.new_with_model_and_entry( proj_list_store) self.projeto_combo.set_entry_text_column(1) self.projeto_combo.set_active(id_proj - 1) if id_proj: self.projeto_combo.set_sensitive(False) self.layout.add(self.projeto_combo) type_source_ls = Gtk.ListStore(int, str) type_source_ls.append([0, 'book']) type_source_ls.append([1, 'article']) type_source_ls.append([2, 'site']) self.type_source_combo = Gtk.ComboBox.new_with_model_and_entry( type_source_ls) self.type_source_combo.set_entry_text_column(1) self.type_source_combo.connect("changed", self.select_type_source) self.layout.add(self.type_source_combo) self.source_combo = Gtk.ComboBox() self.source_combo.set_sensitive(False) self.source_combo.set_entry_text_column(1) self.source_box = Gtk.Box() self.source_box.add(self.source_combo) self.layout.add(self.source_box) self.ent_ini = Gtk.Entry() self.ent_ini.set_placeholder_text("página inicio") self.ent_fim = Gtk.Entry() self.ent_fim.set_placeholder_text("página fim") box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) box.set_spacing(5) box.pack_start(self.ent_ini, True, True, 0) box.pack_start(self.ent_fim, True, True, 0) self.layout.add(box) self.btn_save = Gtk.Button("Salvar") self.btn_save.connect("clicked", self.save) self.layout.add(self.btn_save) self.add(self.layout)
def __init__(self): Gtk.Window.__init__(self, title="Cadastro de Pessoas") self.set_default_size(400, 200) self.set_border_width(20) self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.layout.set_spacing(20) self.box_pn_pessoa = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.box_pn_pessoa.set_spacing(10) label_pn_pessoa = Gtk.Label("Primeiro nome") label_pn_pessoa.set_justify(Gtk.Justification.LEFT) self.input_pn_pessoa = Gtk.Entry() self.box_pn_pessoa.pack_start(label_pn_pessoa, False, True, 0) self.box_pn_pessoa.pack_start(self.input_pn_pessoa, True, True, 0) self.layout.add(self.box_pn_pessoa) self.box_nm_pessoa = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.box_nm_pessoa.set_spacing(10) label_nm_pessoa = Gtk.Label("Nome do Meio") label_nm_pessoa.set_justify(Gtk.Justification.LEFT) self.input_nm_pessoa = Gtk.Entry() self.box_nm_pessoa.pack_start(label_nm_pessoa, False, True, 0) self.box_nm_pessoa.pack_start(self.input_nm_pessoa, True, True, 0) self.layout.add(self.box_nm_pessoa) self.box_un_pessoa = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.box_un_pessoa.set_spacing(10) label_un_pessoa = Gtk.Label("Ultimo Nome") label_un_pessoa.set_justify(Gtk.Justification.LEFT) self.input_un_pessoa = Gtk.Entry() self.box_un_pessoa.pack_start(label_un_pessoa, False, True, 0) self.box_un_pessoa.pack_start(self.input_un_pessoa, True, True, 0) self.layout.add(self.box_un_pessoa) self.box_sf_pessoa = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.box_sf_pessoa.set_spacing(10) label_sf_pessoa = Gtk.Label("Sufixo") label_sf_pessoa.set_justify(Gtk.Justification.LEFT) self.input_sf_pessoa = Gtk.Entry() self.box_sf_pessoa.pack_start(label_sf_pessoa, False, True, 0) self.box_sf_pessoa.pack_start(self.input_sf_pessoa, True, True, 0) self.layout.add(self.box_sf_pessoa) self.grava_btn = Gtk.Button("Concluido") self.grava_btn.connect("clicked", self.grava_pessoa) self.layout.add(self.grava_btn) self.personDAO = PersonDAO(make_connection()) self.add(self.layout)
def select_type_source(self, widget): d = [(BookDAO, BookDAO.todos_books), (ArticleDAO, ArticleDAO.todos_articles), (SiteDAO, SiteDAO.todos_sites)] source_iter = widget.get_active_iter() if source_iter is not None: model = widget.get_model() i, _ = model[source_iter] dao, func = d[i] sources = dao(make_connection()) ls = Gtk.ListStore(int, str) for s in func(sources): ls.append([s.id, s.title]) self.source_box.remove(self.source_combo) del self.source_combo self.source_combo = Gtk.ComboBox.new_with_model_and_entry(ls) self.source_combo.set_entry_text_column(1) self.source_combo.show() self.source_box.add(self.source_combo)
def __init__(self): Gtk.Window.__init__(self, title="Listagem Pessoas") self.set_border_width(10) layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(layout) self.dao = ProjectDAO(make_connection()) pls = Gtk.ListStore(str, str) for row in self.dao.quotes(): pls.append(row) ptv = Gtk.TreeView(pls) for i, col_tittle in enumerate([ 'Projeto', 'Obra']): render = Gtk.CellRendererText() col = Gtk.TreeViewColumn(col_tittle, render, text=i) ptv.append_column(col) col.set_sort_column_id(i) layout.add(ptv)
def __init__(self): Gtk.ScrolledWindow.__init__(self, title="Listagem Projetos") # self.set_border_width(2) main_menu_bar = Gtk.MenuBar() # Drop Down proj_menu = Gtk.Menu() proj_new = Gtk.MenuItem("Novo Projeto") proj_new.connect('activate', self.new) proj_new.set_submenu(proj_menu) main_menu_bar.append(proj_new) source_menu = Gtk.Menu() source_dropdow = Gtk.MenuItem("Fontes") source_new = Gtk.MenuItem("Novo") source_new.connect('activate', self.new_source) source_list = Gtk.MenuItem("Listagem") source_list.connect('activate', self.list_source) source_dropdow.set_submenu(source_menu) source_menu.append(source_new) source_menu.append(source_list) main_menu_bar.append(source_dropdow) autores_menu = Gtk.Menu() autores_dropdow = Gtk.MenuItem("Autores") autores_new = Gtk.MenuItem("Novo") autores_new.connect('activate', self.new_autor) autores_list = Gtk.MenuItem("Listagem") autores_list.connect('activate', self.list_autor) autores_dropdow.set_submenu(autores_menu) autores_menu.append(autores_new) autores_menu.append(autores_list) main_menu_bar.append(autores_dropdow) b1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) b1.add(main_menu_bar) self.layout = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.layout.set_spacing(6) scrolled = Gtk.ScrolledWindow(Gtk.Adjustment()) scrolled.set_min_content_width(300) scrolled.set_min_content_height(250) self.layout.add(scrolled) self.dao = ProjectDAO(make_connection()) pls = Gtk.ListStore(int, str) for p in self.dao.todos_projetos(): pls.append([p.id, p.nome]) self.ptv = Gtk.TreeView(pls) for i, col_tittle in enumerate(['ID', 'Nome']): render = Gtk.CellRendererText() col = Gtk.TreeViewColumn(col_tittle, render, text=i) self.ptv.append_column(col) col.set_sort_column_id(i) # self.ptv.connect("row-activated", self.det_proj) self.ptv.get_selection().connect("changed", self.det_proj) scrolled.add(self.ptv) # panel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) # panel.set_spacing(6) panel = Gtk.ScrolledWindow() panel.set_border_width(6) panel.set_min_content_width(150) # btn_det_proj = Gtk.Button("Detalhes") # btn_det_proj.connect("clicked", self.det_proj) # panel.add(btn_det_proj) self.lbl_nome = Gtk.Label() self.lbl_nome.set_visible(False) self.btn_quotes = Gtk.Button() self.btn_quotes.connect("clicked", self.show_quotes) self.btn_quotes.set_visible(False) # self.btn_new = Gtk.Button() # self.btn_new.connect("clicked", self.new) # self.btn_new.set_label("Novo Projeto") # self.btn_new.show() self.btn_quote = Gtk.Button() self.btn_quote.set_label("Cadastrar Citação") self.btn_quote.connect("clicked", self.new_quote) self.btn_quote.show() box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) box.set_spacing(6) box.add(self.lbl_nome) box.add(self.btn_quotes) # box.add(self.btn_new) box.add(self.btn_quote) self.btn_refs = Gtk.Button() self.btn_refs.set_label("Gerar Referências") self.btn_refs.connect("clicked", self.show_refs) self.btn_refs.show() box.add(self.btn_refs) panel.add(box) self.layout.add(panel) b1.add(self.layout) self.add(b1)
import api conn = api.make_connection() inqs = api.PagamentoDAO(conn) print(inqs.realiza_pagamento('1', '1', '1', False)) print(inqs.realiza_pagamento('2', '2', '2', False, True)) print(inqs.realiza_pagamento('3', '3', '3', False)) print(inqs.realiza_pagamento('3', '3', '3', False, rollback=True)) print(inqs.realiza_pagamento('4', '4', '4', False, True)) print(inqs.realiza_pagamento('5', '5', '5', False)) conn.commit()
def __init__(self): Gtk.Window.__init__(self, title='Listagem de Fontes Bibliográficas') self.set_border_width(10) self.set_default_size(400, 200) self.notebook = Gtk.Notebook() layout = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) layout.add(self.notebook) panel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) layout.add(panel) layout.set_spacing(4) self.add(layout) # self.book_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.book_page = Gtk.ScrolledWindow() self.book_page.set_min_content_height(300) self.book_page.set_min_content_width(600) self.bdao = BookDAO(make_connection()) self.books = self.bdao.todos_books() self.pls_book = Gtk.ListStore(int, str, str, str, str, str, str, str, int, int) for book in self.books: t = (book.id, book.date, book.title, book.subtitle, book.local, book.isbn, book.publisher, book.series, book.edition, book.vol) # print(t) self.pls_book.append(list(t)) self.ptv_book = Gtk.TreeView(self.pls_book) for i, col_title in enumerate([ "ID", "Data", "Título", "Subtítulo", "Local", "ISBN", "Editora", "Serie", "Edição", "Volume" ]): render = Gtk.CellRendererText() column = Gtk.TreeViewColumn(col_title, render, text=i) self.ptv_book.append_column(column) column.set_sort_column_id(i) # make columns sortable self.book_page.add(self.ptv_book) self.notebook.append_page(self.book_page, Gtk.Label('Livros')) # self.site_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.site_page = Gtk.ScrolledWindow() self.site_page.set_min_content_height(300) self.site_page.set_min_content_width(600) self.sdao = SiteDAO(make_connection()) self.sites = self.sdao.todos_sites() self.pls_site = Gtk.ListStore(int, str, str, str, str, str, str) for site in self.sites: t = (site.id, site.date, site.title, site.subtitle, site.local, site.link, site.dt_access) self.pls_site.append(list(t)) self.ptv_site = Gtk.TreeView(self.pls_site) for i, col_title in enumerate( ["ID", "Data", "Título", "Subtítulo", "Local", "Link", "Acesso"]): render = Gtk.CellRendererText() column = Gtk.TreeViewColumn(col_title, render, text=i) self.ptv_site.append_column(column) column.set_sort_column_id(i) self.site_page.add(self.ptv_site) self.notebook.append_page(self.site_page, Gtk.Label('Site')) # self.article_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.article_page = Gtk.ScrolledWindow() self.article_page.set_min_content_height(300) self.article_page.set_min_content_width(600) self.adao = ArticleDAO(make_connection()) self.articles = self.adao.todos_articles() self.pls_articles = Gtk.ListStore(int, str, str, str, str, int, str, int, str) for a in self.articles: t = (a.id, a.date, a.title, a.subtitle, a.local, a.doi, a.journal, a.vol_journal, a.fascicle) self.pls_articles.append(list(t)) self.ptv_articles = Gtk.TreeView(self.pls_articles) for i, col_title in enumerate([ "ID", "Data", "Título", "Subtítulo", "Local", "DOI", "Revista", "Vol", "Fascículo" ]): render = Gtk.CellRendererText() column = Gtk.TreeViewColumn(col_title, render, text=i) self.ptv_articles.append_column(column) column.set_sort_column_id(i) self.article_page.add(self.ptv_articles) self.notebook.append_page(self.article_page, Gtk.Label('Artigos')) btn_abnt = Gtk.Button() btn_abnt.set_label('Gerar Referências ABNT') btn_abnt.connect('clicked', self.abnt) panel.add(btn_abnt) panel.set_spacing(4)
def __init__(self, sources): Gtk.Window.__init__(self, title="Referencias") self.set_border_width(10) layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) if not isinstance(sources, list): sources = [sources] s = '' for source in sources: print('source', source, 'type:', type(source)) if isinstance(source, Book): dao = BookDAO(make_connection()) autores = dao.autores(source.id) year = re.match(r'\d{4}', source.date).group(0) if len(autores) == 0: s += f"""{source.title.upper()}{f': {source.subtitle}' if source.subtitle else ''}. {f'{source.edition}. ed.' if source.edition else str()} {source.local.capitalize()}: {source.publisher.capitalize()}, {year}""" elif len(autores) <= 3: s += f"""{'; '.join([f'{a.lastname.upper()}, {a.firstname.capitalize()}' for a in sorted(autores, key=lambda e: e.lastname)])}. <b>{source.title}</b>{f': {source.subtitle}' if source.subtitle else ''}. {f'{source.edition}. ed.' if source.edition else str()} {source.local.capitalize()}: {source.publisher.capitalize()}, {year}""" else: a = sorted(autores, key=lambda e: e.lastname)[0] s += f"""{a.lastname.upper()}, {a.firstname.capitalize()}. et al <b>{source.title}</b>{f': {source.subtitle}' if source.subtitle else ''}. {f'{source.edition}. ed.' if source.edition else str()} {source.local.capitalize()}: {source.publisher.capitalize()}, {year}""" if isinstance(source, Article): dao = ArticleDAO(make_connection()) autores = dao.autores(source.id) # year = re.match(r'\d{4}', source.date).group(0) if len(autores) == 0: s += f"""{source.title.upper()}. {source.title}. {source.journal}. {source.local}. {source.vol_journal}. {source.fascicle}. mes. ano""" elif len(autores) <= 3: s += f"""{'; '.join([f'{a.lastname.upper()}, {a.firstname.capitalize()}' for a in sorted(autores, key=lambda e: e.lastname)])}. {source.title}. {source.journal}. {source.local}. {source.vol_journal}. {source.fascicle}. mes. ano""" else: a = sorted(autores, key=lambda e: e.lastname)[0] s += f"""{a.lastname.upper()}, {a.firstname.capitalize()}. et al {source.title}. {source.journal}. {source.local}. {source.vol_journal}. {source.fascicle}. mes. ano""" if isinstance(source, Site): dao = ArticleDAO(make_connection()) autores = dao.autores(source.id) year = re.match(r'\d{4}', source.date).group(0) if len(autores) == 0: s += f"""{source.title.upper()}. {source.title}. {year}. {source.link}. {source.dt_access}""" elif len(autores) <= 3: s += f"""{'; '.join([f'{a.lastname.upper()}, {a.firstname.capitalize()}' for a in sorted(autores, key=lambda e: e.lastname)])}. {source.title.upper()}. {source.title}. {year}. {source.link}. {source.dt_access}""" else: a = sorted(autores, key=lambda e: e.lastname)[0] s += f"""{a.lastname.upper()}, {a.firstname.capitalize()}. et al {source.title.upper()}. {source.title}. {year}. {source.link}. {source.dt_access}""" s += '<br>' view = WebKit2.WebView() print('html:', s) view.load_html(s) view.show() scl = Gtk.ScrolledWindow() scl.set_min_content_height(350) scl.set_min_content_width(600) scl.add(view) self.add(scl)