def get_uri(self): # Make sure we extract everything from html in case we are running # from an egg environ.get_resource_filename('stoq', 'html') if locale.getlocale()[0] == 'pt_BR' or platform.system() == 'Windows': content = environ.get_resource_filename('stoq', 'html', 'welcome-pt_BR.html') else: content = environ.get_resource_filename('stoq', 'html', 'welcome.html') if api.sysparam.get_bool('DEMO_MODE'): content += '?demo-mode' return 'file:///' + content
def get_uri(self): # Make sure we extract everything from html in case we are running # from an egg environ.get_resource_filename('stoq', 'html') if locale.getlocale()[0] == 'pt_BR' or platform.system() == 'Windows': content = environ.get_resource_filename('stoq', 'html', 'welcome-pt_BR.html') else: content = environ.get_resource_filename('stoq', 'html', 'welcome.html') if api.sysparam.get_bool('DEMO_MODE'): content += '?demo-mode' return 'file:///' + content
def add_delegate(self, delegate, attr): from kiwi.environ import environ from kiwi.ui.builderloader import BuilderWidgetTree import gtk if not delegate.gladefile: return f = environ.get_resource_filename('stoq', 'glade', delegate.gladefile) tree = BuilderWidgetTree(delegate, f, None) t = '' t += 'import kiwi\n' t += 'class %s(object):\n' % (attr, ) for widget in sorted(tree.get_widgets()): try: name = gtk.Buildable.get_name(widget) except TypeError: continue t += ' %s = %s.%s()\n' % (name, widget.__module__, widget.__class__.__name__) print t real_node = self.module[attr] self.module.body.remove(real_node) print vars(self.module) nodes = self.builder.string_build(t) for key, value in nodes.items(): self.module.locals[key] = [value] self.module.body.append(value) new_node = self.module.locals[attr][0] for key, value in real_node.locals.items(): print key new_node[key] = [value]
def __init__(self, **kwargs): # Informações gerais self.especie_documento = "" self.instrucoes = [] # Cedente (empresa - dados do banco) self.agencia = "" self.carteira = "" self.cedente = "" self.conta = "" # Sacado (cliente) self.sacado_nome = "" self.sacado_cidade = "" self.sacado_uf = "" self.sacado_endereco = "" self.sacado_bairro = "" self.sacado_cep = "" # Pagamento self.data_documento = "" self.data_processamento = datetime.date.today() self.data_vencimento = "" self.demonstrativo = [] if (not 'numero_documento' in kwargs and 'nosso_numero' in kwargs): kwargs['numero_documento'] = kwargs['nosso_numero'] for key, value in kwargs.items(): setattr(self, key, value) self.logo_image_path = "" if self.logo: self.logo_image_path = environ.get_resource_filename( 'stoq', 'pixmaps', self.logo)
def register(): from gi.repository import Gtk from kiwi.environ import environ theme = Gtk.IconTheme.get_default() path = environ.get_resource_filename('stoq', 'pixmaps') theme.prepend_search_path(path)
def register(): from gi.repository import Gtk from kiwi.environ import environ theme = Gtk.IconTheme.get_default() path = environ.get_resource_filename('stoq', 'pixmaps') theme.prepend_search_path(path)
def add_delegate(self, delegate, attr): from kiwi.environ import environ from kiwi.ui.builderloader import BuilderWidgetTree import gtk if not delegate.gladefile: return f = environ.get_resource_filename('stoq', 'glade', delegate.gladefile) tree = BuilderWidgetTree(delegate, f, None) t = '' t += 'import kiwi\n' t += 'class %s(object):\n' % (attr, ) for widget in sorted(tree.get_widgets()): try: name = gtk.Buildable.get_name(widget) except TypeError: continue t += ' %s = %s.%s()\n' % (name, widget.__module__, widget.__class__.__name__) print t real_node = self.module[attr] self.module.body.remove(real_node) print vars(self.module) nodes = self.builder.string_build(t) for key, value in nodes.items(): self.module.locals[key] = [value] self.module.body.append(value) new_node = self.module.locals[attr][0] for key, value in real_node.locals.items(): print key new_node[key] = [value]
def __init__(self, **kwargs): # Informações gerais self.especie_documento = "" self.instrucoes = [] # Cedente (empresa - dados do banco) self.agencia = "" self.carteira = "" self.cedente = "" self.conta = "" # Sacado (cliente) self.sacado_nome = "" self.sacado_cidade = "" self.sacado_uf = "" self.sacado_endereco = "" self.sacado_bairro = "" self.sacado_cep = "" # Pagamento self.data_documento = "" self.data_processamento = datetime.date.today() self.data_vencimento = "" self.demonstrativo = [] if (not 'numero_documento' in kwargs and 'nosso_numero' in kwargs): kwargs['numero_documento'] = kwargs['nosso_numero'] for key, value in kwargs.items(): setattr(self, key, value) self.logo_image_path = "" if self.logo: self.logo_image_path = environ.get_resource_filename( 'stoq', 'pixmaps', self.logo)
def render(self, stylesheet=None): template_dir = environ.get_resource_filename("stoq", "template") if platform.system() == "Windows": # FIXME: Figure out why this is breaking # On windows, weasyprint is eating the last directory of the path template_dir = os.path.join(template_dir, "foobar") html = weasyprint.HTML(string=self.get_html(), base_url=template_dir) return html.render(stylesheets=[weasyprint.CSS(string=stylesheet)])
def _get_latest_schema(): schema_pattern = "schema-??.sql" schemas = [] resource = environ.get_resource_filename('stoq', 'sql') for filename in glob.glob(os.path.join(resource, schema_pattern)): schemas.append(filename) assert schemas schemas.sort() return schemas[-1]
def _get_latest_schema(): schema_pattern = "schema-??.sql" schemas = [] resource = environ.get_resource_filename('stoq', 'sql') for filename in glob.glob(os.path.join(resource, schema_pattern)): schemas.append(filename) assert schemas schemas.sort() return schemas[-1]
def render(self, stylesheet=None): template_dir = environ.get_resource_filename('stoq', 'template') if platform.system() == 'Windows': # FIXME: Figure out why this is breaking # On windows, weasyprint is eating the last directory of the path template_dir = os.path.join(template_dir, 'foobar') html = weasyprint.HTML(string=self.get_html(), base_url=template_dir) return html.render(stylesheets=[weasyprint.CSS(string=stylesheet)])
def populate_initial_data(store): from stoqlib.domain.system import SystemTable generation = store.find(SystemTable).max(SystemTable.generation) if generation < 4: # FIXME: Initial data can (and needs to) only be sourced on schemas # greater or equal than 4. Remove this in the future. return log.info('Populating initial data') initial_data = environ.get_resource_filename('stoq', 'sql', 'initial.sql') if db_settings.execute_sql(initial_data) != 0: error(u'Failed to populate initial data')
def populate_initial_data(store): from stoqlib.domain.system import SystemTable generation = store.find(SystemTable).max(SystemTable.generation) if generation < 4: # FIXME: Initial data can (and needs to) only be sourced on schemas # greater or equal than 4. Remove this in the future. return log.info('Populating initial data') initial_data = environ.get_resource_filename('stoq', 'sql', 'initial.sql') if db_settings.execute_sql(initial_data) != 0: error(u'Failed to populate initial data')
def render_template(filename, **ns): """Renders a template giving a filename and a keyword dictionary @filename: a template filename to render @kwargs: keyword arguments to send to the template @return: the rendered template """ directories = environ.get_resource_filename('stoq', 'template') lookup = TemplateLookup(directories=directories, output_encoding='utf8', input_encoding='utf8', default_filters=['h']) tmpl = lookup.get_template(filename) return tmpl.render(**ns)
def _get_patches(self): patches = [] for filename in environ.get_resource_names('stoq', self.patch_resource): for pattern in self.patch_patterns: if not fnmatch.fnmatch(filename, pattern): continue if not self._patchname_is_valid(filename): print "Invalid patch name: %s" % filename continue filename = environ.get_resource_filename('stoq', self.patch_resource, filename) patches.append(Patch(filename, self)) return sorted(patches)
def _open_glade(view, gladefile, domain, translation_domain): if not gladefile: raise ValueError("A gladefile wasn't provided.") elif not isinstance(gladefile, str): raise TypeError( "gladefile should be a string, found %s" % type(gladefile)) if gladefile.endswith('.ui'): directory = os.path.dirname(namedAny(view.__module__).__file__) gladefile = os.path.join(directory, gladefile) else: for ext in ['.glade', '.ui']: if environ.get_resource_exists(domain, 'glade', gladefile + ext): gladefile = environ.get_resource_filename(domain, 'glade', gladefile + ext) break else: raise EnvironmentError( "Glade resource %s was not found on domain %s" % ( gladefile, domain)) # XXX: Opening this not in binary mode was raising an weird error on win32 fp = open(gladefile, 'rb') sniff = fp.read(200).decode() fp.close() if '<interface' in sniff: WidgetTree = _get_builder() loader_name = 'builder' # glade-2: <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> # glade-3: <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> elif 'glade-2.0.dtd' in sniff: WidgetTree = _get_libglade() loader_name = 'libglade' elif 'gaxml-0.1.dtd' in sniff: WidgetTree = _get_gaxml() loader_name = 'gaxml' else: log.warning("Could not determine type/dtd of gladefile %s" % gladefile) # Defaulting to builder WidgetTree = _get_builder() loader_name = 'builder' # None means, failed to import if WidgetTree is None: raise RuntimeError( "Could not find %s, it needs to be installed to " "load the gladefile %r" % (loader_name, gladefile)) return WidgetTree(view, gladefile, translation_domain)
def __init__(self, payment): self.payment = payment self.payer = payment.group.payer self.branch = payment.branch self.bank = payment.method.destination_account.bank self.data_processamento = localtoday() props = self.get_properties(payment) for key, value in props.items(): setattr(self, key, value) self.logo_image_path = "" if self.logo: self.logo_image_path = environ.get_resource_filename( 'stoq', 'pixmaps', self.logo)
def __init__(self, payment): self.payment = payment self.payer = payment.group.payer self.branch = payment.branch self.bank = payment.method.destination_account.bank self.data_processamento = localtoday() props = self.get_properties(payment) for key, value in props.items(): setattr(self, key, value) self.logo_image_path = "" if self.logo: self.logo_image_path = environ.get_resource_filename( 'stoq', 'pixmaps', self.logo)
def _get_patches(self): patches = [] for filename in environ.get_resource_names(self.patch_resource_domain, self.patch_resource): for pattern in self.patch_patterns: if not fnmatch.fnmatch(filename, pattern): continue if not self._patchname_is_valid(filename): print("Invalid patch name: %s" % filename) continue filename = environ.get_resource_filename( self.patch_resource_domain, self.patch_resource, filename) patches.append(Patch(filename, self)) return sorted(patches)
def get_banks(self): configfile = self.__module__.split('.')[-2] + '.ini' config = ConfigParser() filename = environ.get_resource_filename('stoqdrivers', 'conf', configfile) if not config.read(filename): return None for section in config.sections(): # With this, we'll have a dictionary in this format: # CONFIG_NAME: "Y,X" items = dict(config.items(section)) try: bank = self._parse_bank(items) except ConfigError, errmsg: raise ConfigError("In section `%s' of `%s': %s" % (section, filename, errmsg)) self._banks[int(section)] = bank
def get_banks(self): configfile = self.__module__.split('.')[-2] + '.ini' config = ConfigParser() filename = environ.get_resource_filename('stoqdrivers', 'conf', configfile) if not config.read(filename): return None for section in config.sections(): # With this, we'll have a dictionary in this format: # CONFIG_NAME: "Y,X" items = dict(config.items(section)) try: bank = self._parse_bank(items) except ConfigError, errmsg: raise ConfigError("In section `%s' of `%s': %s" % (section, filename, errmsg)) self._banks[int(section)] = bank
def load_taxes_csv(): """ Load the fields of IBPT table. - Fields: - ncm: Nomenclatura Comum do Sul. - ex: Exceção fiscal da NCM. - tipo: Código que pertence a uma NCM. - descricao: Nome do produto. - nacionalfederal: Carga tributária para os produtos nacionais. - importadosfederal: Carga tributária para os produtos importados. - estadual: Carga tributária estadual - municipal: Carga tributária municipal - vigenciainicio: Data de início da vigência desta alíquota. - vigenciafim: Data de fim da vigência desta alíquota. - chave: Chave que associa a Tabela IBPT baixada com a empresa. - versao: Versão das alíquotas usadas para cálculo. - Fonte: Fonte """ # Avoid load taxes more than once. if taxes_data: return store = new_store() branch = get_current_branch(store) address = branch.person.get_main_address() state = address.city_location.state # Change the version according to the updates of IBPT tables. version = '16.1.A' filename = environ.get_resource_filename( 'stoq', 'csv', 'ibpt_tables', 'TabelaIBPTax%s%s.csv' % (state, version)) csv_file = (csv.reader(open(filename, "r"), delimiter=';')) for (ncm, ex, tipo, descricao, nacionalfederal, importadosfederal, estadual, municipal, vigenciainicio, vigenciafim, chave, versao, fonte) in csv_file: # Ignore service codes (NBS - Nomenclatura Brasileira de Serviços) if tipo == '1': continue tax_dict = taxes_data.setdefault(ncm, {}) tax_dict[ex] = TaxInfo(nacionalfederal, importadosfederal, estadual, fonte, chave)
def load_taxes_csv(): """ Load the fields of IBPT table. - Fields: - ncm: Nomenclatura Comum do Sul. - ex: Exceção fiscal da NCM. - tipo: Código que pertence a uma NCM. - descricao: Nome do produto. - nacionalfederal: Carga tributária para os produtos nacionais. - importadosfederal: Carga tributária para os produtos importados. - estadual: Carga tributária estadual - municipal: Carga tributária municipal - vigenciainicio: Data de início da vigência desta alíquota. - vigenciafim: Data de fim da vigência desta alíquota. - chave: Chave que associa a Tabela IBPT baixada com a empresa. - versao: Versão das alíquotas usadas para cálculo. - Fonte: Fonte """ # Avoid load taxes more than once. if taxes_data: return store = new_store() branch = get_current_branch(store) address = branch.person.get_main_address() state = address.city_location.state # Change the version according to the updates of IBPT tables. version = '16.1.A' filename = environ.get_resource_filename('stoq', 'csv', 'ibpt_tables', 'TabelaIBPTax%s%s.csv' % (state, version)) csv_file = (csv.reader(open(filename, "r"), delimiter=';')) for (ncm, ex, tipo, descricao, nacionalfederal, importadosfederal, estadual, municipal, vigenciainicio, vigenciafim, chave, versao, fonte) in csv_file: # Ignore service codes (NBS - Nomenclatura Brasileira de Serviços) if tipo == '1': continue tax_dict = taxes_data.setdefault(ncm, {}) tax_dict[ex] = TaxInfo(nacionalfederal, importadosfederal, estadual, fonte, chave)
def _update_schema(self): """Check the current version of database and update the schema if it's needed """ log.info("Updating schema") if self.check_uptodate(): log.info("Schema is already up to date") return patches = self._get_patches() latest_available = patches[-1].get_version() current_version = self.get_current_version() last_level = None if current_version != latest_available: patches_to_apply = [] for patch in patches: if patch.get_version() <= current_version: continue patches_to_apply.append(patch) functions = environ.get_resource_filename('stoq', 'sql', 'functions.sql') if db_settings.execute_sql(functions) != 0: error('Failed to create functions') log.info("Applying %d patches" % (len(patches_to_apply), )) create_log.info("PATCHES:%d" % (len(patches_to_apply), )) for patch in patches_to_apply: create_log.info("PATCH:%d.%d" % (patch.generation, patch.level)) patch.apply(self.default_store) assert patches_to_apply log.info("All patches (%s) applied." % (', '.join(str(p.level) for p in patches_to_apply))) last_level = patches_to_apply[-1].get_version() self.after_update() return current_version, last_level
def _update_schema(self): """Check the current version of database and update the schema if it's needed """ log.info("Updating schema") if self.check_uptodate(): log.info("Schema is already up to date") return patches = self._get_patches() latest_available = patches[-1].get_version() current_version = self.get_current_version() last_level = None if current_version != latest_available: patches_to_apply = [] for patch in patches: if patch.get_version() <= current_version: continue patches_to_apply.append(patch) functions = environ.get_resource_filename('stoq', 'sql', 'functions.sql') if db_settings.execute_sql(functions) != 0: error('Failed to create functions') log.info("Applying %d patches" % (len(patches_to_apply), )) create_log.info("PATCHES:%d" % (len(patches_to_apply), )) for patch in patches_to_apply: create_log.info("PATCH:%d.%d" % (patch.generation, patch.level)) patch.apply(self.default_store) assert patches_to_apply log.info("All patches (%s) applied." % ( ', '.join(str(p.level) for p in patches_to_apply))) last_level = patches_to_apply[-1].get_version() self.after_update() return current_version, last_level
def add_button(self, label, stock=None, image=None): """Adds a button in the bottom of the dialog. :param label: the text that will be displayed by the button. :param stock: the gtk stock id to be used in the button. :param image: the image filename. """ button = gtk.Button(label=label) if image: image_widget = gtk.Image() image_widget.set_from_file( environ.get_resource_filename('stoq', 'pixmaps', image)) image_widget.show() button.set_image(image_widget) elif stock: button_set_image_with_label(button, stock, label) self.action_area.set_layout(gtk.BUTTONBOX_END) self.action_area.pack_start(button, False, False, 6) self.action_area.set_child_secondary(button, True) return button
def add_button(self, label, stock=None, image=None): """Adds a button in the bottom of the dialog. :param label: the text that will be displayed by the button. :param stock: the gtk stock id to be used in the button. :param image: the image filename. """ button = gtk.Button(label=label) if image: image_widget = gtk.Image() image_widget.set_from_file( environ.get_resource_filename('stoq', 'pixmaps', image)) image_widget.show() button.set_image(image_widget) elif stock: button_set_image_with_label(button, stock, label) self.action_area.set_layout(gtk.BUTTONBOX_END) self.action_area.pack_start(button, False, False, 6) self.action_area.set_child_secondary(button, True) return button
def load_taxes_csv(state): """ Load the fields of IBPT table. - Fields: - ncm: Nomenclatura Comum do Sul. - ex: Exceção fiscal da NCM. - tipo: Código que pertence a uma NCM. - descricao: Nome do produto. - nacionalfederal: Carga tributária para os produtos nacionais. - importadosfederal: Carga tributária para os produtos importados. - estadual: Carga tributária estadual - municipal: Carga tributária municipal - vigenciainicio: Data de início da vigência desta alíquota. - vigenciafim: Data de fim da vigência desta alíquota. - chave: Chave que associa a Tabela IBPT baixada com a empresa. - versao: Versão das alíquotas usadas para cálculo. - Fonte: Fonte """ if state in taxes_data: return filename = environ.get_resource_filename('stoq', 'csv', 'ibpt_tables', 'TabelaIBPTax%s.csv' % state) csv_file = (csv.reader(open(filename, "r", encoding='latin1'), delimiter=';')) state_taxes_data = {} for (ncm, ex, tipo, descricao, nacionalfederal, importadosfederal, estadual, municipal, vigenciainicio, vigenciafim, chave, versao, fonte) in csv_file: # Ignore service codes (NBS - Nomenclatura Brasileira de Serviços) if tipo == '1': continue tax_dict = state_taxes_data.setdefault(ncm, {}) tax_dict[ex] = TaxInfo(nacionalfederal, importadosfederal, estadual, fonte, chave) taxes_data[state] = state_taxes_data
def _import_one(klass, filename): imp = klass() imp.feed_file(environ.get_resource_filename('stoq', 'csv', filename)) imp.process()
def __init__(self): Resource.__init__(self) path = environ.get_resource_filename('stoq', 'html') self.putChild('static', File(path)) self.putChild('calendar-events.json', CalendarEvents())
def write_app_logo(sheet): filename = environ.get_resource_filename('stoq', 'pixmaps', 'stoq_logo.bmp') sheet.insert_bitmap(filename, 0, 3, x=0, y=0, scale_x=0.75, scale_y=0.25)
def _install_invoice_templates(): log.info("Installing invoice templates") importer = InvoiceImporter() importer.feed_file( environ.get_resource_filename('stoq', 'csv', 'invoices.csv')) importer.process()
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # """User interface: Framework and Widget support""" try: import gi # This will raise ValueError if the required version was not found gi.require_version('Gtk', '3.0') except (ImportError, ValueError) as e: raise SystemExit("GTK+ 3.0.0 or higher is required by kiwi.ui\n" "Error was: {}".format(e)) from gi.repository import Gtk, Gdk from kiwi.environ import environ style_provider = Gtk.CssProvider() style_provider.load_from_path( environ.get_resource_filename('kiwi', 'css', 'kiwi.css')) screen = Gdk.Screen.get_default() if screen is not None: Gtk.StyleContext.add_provider_for_screen( screen, style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
## 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., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <*****@*****.**> ## import http.server import os import urllib.parse from kiwi.environ import environ from stoqlib.net.calendarevents import CalendarEvents _static = environ.get_resource_filename('stoq', 'html') resources = { '/calendar-events': CalendarEvents(), } class _RequestHandler(http.server.SimpleHTTPRequestHandler): def do_GET(self): path = urllib.parse.urlparse(self.path) realpath = path.path args = urllib.parse.parse_qs(path.query) if realpath.startswith('/static'): # This will call translate_path bellow return http.server.SimpleHTTPRequestHandler.do_GET(self)
def _install_invoice_templates(): log.info("Installing invoice templates") importer = InvoiceImporter() importer.feed_file(environ.get_resource_filename('stoq', 'csv', 'invoices.csv')) importer.process()
def get_ncm_cest_map(): """Returns a dictionary that maps an NCM to its corresponding CEST(s) This function will loop trough `data/csv/cest/ncm_cest_map.csv` and build a dictionary that maps a NCM to its corresponding CEST(s), returning a structure like: { `<ncm>`: [ `<cest>` [... other possible CESTs] ], [... other NCMs] } :returns: A dictionary mapping a given NCM to its corresponding CEST(s) """ global _ncm_cest_map if _ncm_cest_map is not None: # CEST table already loaded, just return it. return _ncm_cest_map # CEST table not loaded, load it and return it # # CEST table come in a format like: # # <cest>,<ncm> # # But some rows may contain only: # # <nothing>,<ncm> # # This means the NCM is related to the CEST that is listed above it, so # we'll need to always know what was the last seen CEST _ncm_cest_map = {} filename = environ.get_resource_filename('stoq', 'csv', 'cest', 'ncm_cest_map.csv') with open(filename) as csvfile: last_filled_row = None for row in csv.reader(csvfile): # Unpack the fields we are interested in cest, ncm = row[:2] if not ncm.isdigit(): # Some rows may be headers or empty, on these cases, we check # to see if the NCM is actually an integer - if it is not, we # ignore it continue if cest: # If it has a CEST, this means it is a common row, with # everything we would expect in it. last_filled_row = row else: # If it does not have a CEST, we'll use the last filled row for # the CEST, the NCM remains the same. cest, _ = last_filled_row[:2] # Add the CEST and the NCM key _ncm_cest_map.setdefault(ncm, []) _ncm_cest_map[ncm].append(str(cest)) return _ncm_cest_map
def render(self, stylesheet=None): template_dir = environ.get_resource_filename('stoq', 'template') html = weasyprint.HTML(string=self.get_html(), base_url=template_dir) return html.render(stylesheets=[weasyprint.CSS(string=stylesheet)])
def __init__(self): Resource.__init__(self) path = environ.get_resource_filename('stoq', 'html') self.putChild('static', File(path)) self.putChild('calendar-events.json', CalendarEvents())
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # """User interface: Framework and Widget support""" try: import gi # This will raise ValueError if the required version was not found gi.require_version('Gtk', '3.0') except (ImportError, ValueError) as e: raise SystemExit( "GTK+ 3.0.0 or higher is required by kiwi.ui\n" "Error was: {}".format(e)) from gi.repository import Gtk, Gdk from kiwi.environ import environ style_provider = Gtk.CssProvider() style_provider.load_from_path( environ.get_resource_filename('kiwi', 'css', 'kiwi.css')) screen = Gdk.Screen.get_default() if screen is not None: Gtk.StyleContext.add_provider_for_screen( screen, style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
def write_app_logo(sheet): filename = environ.get_resource_filename('stoq', 'pixmaps', 'stoq_logo.bmp') sheet.insert_bitmap(filename, 0, 3, x=0, y=0, scale_x=0.75, scale_y=0.25)
## 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., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <*****@*****.**> ## import http.server import os import urllib.parse from kiwi.environ import environ from stoqlib.net.calendarevents import CalendarEvents _static = environ.get_resource_filename('stoq', 'html') resources = { '/calendar-events': CalendarEvents(), } class _RequestHandler(http.server.SimpleHTTPRequestHandler): def do_GET(self): path = urllib.parse.urlparse(self.path) realpath = path.path args = urllib.parse.parse_qs(path.query) if realpath.startswith('/static'): # This will call translate_path bellow return http.server.SimpleHTTPRequestHandler.do_GET(self)