def __init__ (self): gtk.Window.__init__ (self) self.set_title (_("Selezione Lingua")) self.set_size_request (250, 100) utils.set_icon (self) self.connect ('delete-event', self._on_delete_event) mbox = gtk.VBox () vbox = gtk.VBox () mbox.set_border_width (4) vbox.set_border_width (4) self.it = it = gtk.RadioButton (None, _("Italiano")) self.en = en = gtk.RadioButton (it, _("Inglese")) it_icon = gtk.Image (); en_icon = gtk.Image () it_icon.set_from_file (os.path.join (utils.DPIXM_DIR, "it.xpm")) en_icon.set_from_file (os.path.join (utils.DPIXM_DIR, "en.xpm")) box = gtk.HBox () box.pack_start (it_icon, False, False, 0) box.pack_start (it) vbox.pack_start (box, False, False, 0) box = gtk.HBox () box.pack_start (en_icon, False, False, 0) box.pack_start (en) vbox.pack_start (box, False, False, 0) frm = gtk.Frame (_("Seleziona Lingua:")) frm.add (vbox) mbox.pack_start (frm) bb = gtk.HButtonBox () bb.set_layout (gtk.BUTTONBOX_END) btn = gtk.Button (stock=gtk.STOCK_CANCEL) btn.connect ('clicked', self._on_delete_event) bb.pack_start (btn) btn = gtk.Button (stock=gtk.STOCK_OK) btn.connect ('clicked', self._on_ok) bb.pack_start (btn) mbox.pack_start (bb, False, False, 0) self.add (mbox) if get("lang").lower () == "it": it.set_active (True) elif get("lang").lower () == "en": en.set_active (True) self.show_all ()
def main (): APP = 'acqua' if os.name == 'nt': DIR = os.path.join (utils.DHOME_DIR, "locale") else: DIR = os.path.join (utils.PROG_DIR, "locale") try: if impostazioni.get ("lang").lower () == "en": en = gettext.translation (APP, DIR, ["en"]) en.install () try: os.environ['LANG'] = "en_US" locale.setlocale (locale.LC_MESSAGES, "en_US") except: pass elif impostazioni.get ("lang").lower () == "fr": fr = gettext.translation (APP, DIR, ["fr"]) fr.install () try: os.environ['LANG'] = "fr_FR" locale.setlocale (locale.LC_MESSAGES, "fr_FR") except: pass else: # In teoria qui risulta inutile settare. Il linguaggio italiano e' di default senza gettext. os.environ['LANG'] = "it_IT" it = gettext.translation (APP, DIR, []) it.install () except (IOError, locale.Error), e: print "(%s): WARNING **: %s" % (APP, e) __builtins__.__dict__["_"] = gettext.gettext
def start (self): print ">> Starting", self.__name__ print ">> AgDB.. showtips :", impostazioni.get("show_tips") if impostazioni.get("dummy_nervose_mode"): print prova menu = app.App.get_plugin_menu () self.item = gtk.MenuItem ("AgDB Plugin") self.item.connect ('activate', self.on_activated) self.item.show () menu.append (self.item)
def load (self, path, name, klass): # Aggiungiamo la path old = sys.path sys.path.append (path) #print "Carico il modulo senza try/except.. fixami prima della revisione finale" try: module = __import__ (name)#, globals (), locals (), [klass]) instance = vars(module)[klass] for i in self.array: if i.__class__ == instance: return False plugin = instance () # Roba di preferenze... raccomandati di merda -.- gh for i in plugin.__preferences__: ret = impostazioni.get (i) if ret == None: impostazioni.set (i, plugin.__preferences__[i]) else: if type (ret) == type (plugin.__preferences__[i]): plugin.__preferences__[i] = ret plugin.start () self.array.append (plugin) #print _(">> Ripristino il path originale") sys.path = old return True except: print ">> Restoring path" sys.path = old print "!! %s::%s (%s)" % (klass, sys.exc_value, sys.exc_type) return False
def __init__(self): # Controlliamo l'esistenza di un'altra istanza if not TipsDialog.exist: TipsDialog.exist = True else: return gtk.Dialog.__init__(self, _("Tips of the Day"), None, gtk.DIALOG_NO_SEPARATOR, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_GO_FORWARD, gtk.RESPONSE_NONE)) self.textview = gtk.TextView() self.textview.set_wrap_mode(gtk.WRAP_WORD) self.textbuffer = self.textview.get_buffer() utils.set_icon (self) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.add(self.textview) self.vbox.pack_start(sw) self.check = gtk.CheckButton(_('Non mostrare al prossimo avvio')) if get ("show_tips"): self.check.set_active(False) else: self.check.set_active(True) self.vbox.pack_start(self.check, False, False, 0) self.connect('response', self._on_response) self._tip() self.set_size_request(400, 250) self.show_all()
def __init__(self): gtk.Window.__init__(self) self.set_title('Py-Acqua') self.set_size_request(467, 332) self.set_resizable(False) self.p_window = { "calcoli" : None, "test" : None, "popolazione" : None, "vasca" : None, "skin" : None, "plugin" : None, "lang" : None, "update" : None } utils.set_icon (self) image = gtk.Image() # Settiamo lo skin file = os.path.join (utils.SKIN_DIR, os.path.join (get ("skin"), "main.png")) if not os.path.exists (file): file = os.path.join (utils.DSKIN_DIR, os.path.join (get ("skin"), "main.png")) if os.path.exists (file): image.set_from_file(file) # Proviamo ad applicare lo stile gtk se presente path = os.path.join (get ("skin"), "gtkrc") if os.path.exists (os.path.join (utils.SKIN_DIR, path)): path = os.path.join (utils.SKIN_DIR, path) elif os.path.exists (os.path.join (utils.DSKIN_DIR, path)): path = os.path.join (utils.DSKIN_DIR, path) else: path = None if path: gtk.rc_set_default_files ([path]) gtk.rc_reparse_all_for_settings (gtk.settings_get_default (), True) # Menu self._create_menu() vbox = gtk.VBox() vbox.pack_start(self.ui.get_widget('/Menubar'), False, False, 0) vbox.pack_start(image) self.add (vbox) self.realize () self.show_all () if os.name == 'nt': self.connect ('delete_event', self.exit) else: self.connect ('destroy', self.exit) if get ("show_tips"): import tips tips.TipsDialog()
def get_backend_class(): if impostazioni.get("betype") == "sqlite": import sqlitebe return sqlitebe.sqliteBE